-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·67 lines (64 loc) · 1.68 KB
/
cli.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
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
#!/usr/bin/env node
const moment = require("moment");
const { archiveStaleRepos } = require("./src/commands/archive");
const {
enableSecurityAlerts
} = require("./src/commands/enable-security-alerts");
const {
enableSecurityFixes
} = require("./src/commands/enable-security-fixes");
const commonOpts = argv => {
return {
apply: argv.apply,
org: argv.org
};
};
require("yargs")
.scriptName("ghad")
.usage("$0 <cmd> [options]")
.options({
apply: {
type: "boolean",
describe: "Perform the action; without this, will only be a dry run"
},
org: {
describe: "Limit to repositories owned by this user/organization"
}
})
.command(
"archive",
"Archives inactive repositories.",
yargs => {
yargs.option("cutoff", {
type: "number",
default: 90,
describe: "Number of days a repository has been inactive to be archived"
});
},
argv => {
const cutoff = moment().subtract(argv.cutoff, "days");
const opts = commonOpts(argv);
archiveStaleRepos(cutoff, opts);
}
)
.command(
"enable-security-alerts",
"Enables security alerts. https://help.github.com/en/articles/about-security-alerts-for-vulnerable-dependencies",
yargs => {},
argv => {
const opts = commonOpts(argv);
enableSecurityAlerts(opts);
}
)
.command(
"enable-security-fixes",
"Enables automated security fixes. Note you'll need to enable security alerts first. https://help.github.com/en/articles/configuring-automated-security-fixes",
yargs => {},
argv => {
const opts = commonOpts(argv);
enableSecurityFixes(opts);
}
)
.demandCommand()
.strict()
.help().argv;