@@ -6,13 +6,15 @@ const { flatten } = require('lodash')
6
6
const dbs = require ( '../lib/dbs' )
7
7
const githubQueue = require ( '../lib/github-queue' )
8
8
const { createDocs } = require ( '../lib/repository-docs' )
9
+ const GitHub = require ( '../../../lib/github' )
10
+ const getToken = require ( '../../../lib/get-token' )
9
11
10
12
module . exports = async function ( { accountId } ) {
13
+ const { installations, repositories } = await dbs ( )
11
14
const logs = dbs . getLogsDb ( )
12
- const log = Log ( { logsDb : logs , accountId : accountId , repoSlug : null , context : 'sync-repositories ' } )
15
+ const log = Log ( { logsDb : logs , accountId : accountId , repoSlug : null , context : 'sync-repos ' } )
13
16
log . info ( `started` )
14
17
15
- const { installations, repositories } = await dbs ( )
16
18
const installation = await installations . get ( String ( accountId ) )
17
19
const installationId = installation . installation
18
20
@@ -32,13 +34,15 @@ module.exports = async function ({ accountId }) {
32
34
}
33
35
34
36
try {
35
- const options = await githubQueue ( installationId ) . read ( github => github . apps . listRepos . endpoint . merge ( {
37
+ const { token } = await getToken ( installationId )
38
+ const github = GitHub ( { auth : `token ${ token } ` } )
39
+ const options = github . apps . listRepos . endpoint . merge ( {
36
40
headers : {
37
41
accept : 'application/vnd.github.machine-man-preview+json'
38
42
} ,
39
43
org : 'neighbourhoodie' ,
40
44
per_page : 100
41
- } ) )
45
+ } )
42
46
43
47
// Paginate does not actually flatten results into a single result array
44
48
// as it should, according to the docs, possibly due to these:
0 commit comments