-
Notifications
You must be signed in to change notification settings - Fork 0
/
grab.js
37 lines (30 loc) · 883 Bytes
/
grab.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
const { exec } = require('child_process')
const { readJson } = require('./shared/json')
const { enquire } = require('./shared/enquire')
const { Log } = require('./shared/log')
const log = new Log()
main()
async function main() {
const defaultOutput = 'repositories_' + new Date().valueOf() + '.json'
const keys = [
'name',
'description',
'http_url_to_repo',
'ssh_url_to_repo',
].join(',')
const { token, site } = readJson('privacy.json')
const { groupId, output } = await enquire([
['groupId'],
['output', 'output file path(optional)'],
])
const command = `curl --header "PRIVATE-TOKEN:${token}" "${site}/api/v4/groups/${groupId}/projects?per_page=100&page=1" | jq "map({${keys}})" > ${
output || defaultOutput
}`
exec(command, error => {
if (error) {
log.error(error)
return
}
log.success('grab')
})
}