-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathncu-team.js
More file actions
executable file
·99 lines (91 loc) · 2.31 KB
/
ncu-team.js
File metadata and controls
executable file
·99 lines (91 loc) · 2.31 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import Request from '../lib/request.js';
import auth from '../lib/auth.js';
import { runPromise } from '../lib/run.js';
import CLI from '../lib/cli.js';
import TeamInfo from '../lib/team_info.js';
import { setVerbosityFromEnv } from '../lib/verbosity.js';
setVerbosityFromEnv();
yargs(hideBin(process.argv))
.completion('completion')
.command({
command: 'list <team> [org]',
desc: 'Get the list of members in a team',
builder: (yargs) => {
yargs
.positional('team', {
describe: 'Name of the team',
type: 'string'
})
.positional('org', {
describe: 'Name of the organization',
type: 'string',
default: 'nodejs'
});
},
handler
})
.command({
command: 'sync <file>',
desc:
'Synchronize the <!-- ncu-team-sync.team($org/$team) --> block in a file',
builder: (yargs) => {
yargs
.positional('file', {
describe: 'Path to the file to update',
type: 'string'
});
},
handler
})
.command({
command: 'check-gpg',
desc: 'Check that all the team members have a valid GPG key',
builder: (yargs) => {
yargs
.option('org', {
describe: 'Name of the organization',
type: 'string',
default: 'nodejs'
});
yargs
.option('team', {
describe: 'Name of the team',
type: 'string',
default: 'releasers'
});
},
handler
})
.demandCommand(1, 'must provide a valid command')
.help()
.parse();
function handler(argv) {
runPromise(main(argv));
}
async function main(argv) {
const cli = new CLI();
const credentials = await auth({
github: true
});
const request = new Request(credentials);
const [command] = argv._;
switch (command) {
case 'list': {
const info = new TeamInfo(cli, request, argv.org, argv.team);
await info.listMembers();
break;
}
case 'sync':
await TeamInfo.syncFile(cli, request, argv.file);
break;
case 'check-gpg':
const info = new TeamInfo(cli, request, argv.org, argv.team);
await info.checkTeamPGPKeys();
break;
default:
throw new Error(`Unknown command ${command}`);
}
}