-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (42 loc) · 1.47 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(async () => {
const open = require('open')
const clipboardy = require('clipboardy')
const { writeFile } = require('fs').promises
const repos = require('./data/repos.json')
const template = require('./data/template.json')
const getRenovate = require('./lib/get-renovate-json')
console.log(`got ${repos.length} repos`)
const next = async () => {
if (repos.length > 0) {
const repo = repos.pop()
console.log(`now checking ${repo.name}`)
try {
const renovate = await getRenovate({
name: repo.full_name,
branch: repo.default_branch
})
if (renovate) {
if (JSON.stringify(renovate, null, 2) === JSON.stringify(template, null, 2)) {
console.log(`${repo.name} - renovate ok`)
await next()
} else {
console.log(`${repo.name} - renovate needs update`)
await clipboardy.write(JSON.stringify(template, null, 2))
await writeFile('data/repos.json', JSON.stringify(repos, null, 2), 'utf-8')
open(`${repo.html_url}/blob/${repo.default_branch}/renovate.json`)
process.exit()
}
} else {
console.log(`${repo.name} - no renovate`)
await next()
}
} catch (error) {
console.log(`Could not check ${repo.name} - error`)
}
} else {
console.log('Finished!')
await writeFile('data/repos.json', JSON.stringify(repos, null, 2), 'utf-8')
}
}
await next()
})()