forked from octokit/webhooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
octokit-webhooks.mts
executable file
·72 lines (66 loc) · 1.69 KB
/
octokit-webhooks.mts
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
#!/usr/bin/env -S ts-node-transpile-only --esm
import yargs from "yargs";
import type { Options as yargsOptions, Arguments } from "yargs";
import { hideBin } from "yargs/helpers";
import { checkOrUpdateWebhooks } from "../lib/index.mjs";
interface Options {
cached: boolean;
ghe?: string;
githubAE?: boolean;
updateAll?: boolean;
}
const options: Record<string, yargsOptions> = {
cached: {
describe: "Load HTML from local cache",
type: "boolean",
default: false,
},
ghe: {
describe:
'GitHub Enterprise. To load a specific version set it the version, e.g. "2.20"',
type: "string",
},
githubAE: {
describe: "Fetch webhooks for GitHub AE",
type: "boolean",
default: false,
},
updateAll: {
describe:
"Fetch webhooks for github.com as well as all enterprise versions",
type: "boolean",
default: false,
},
};
const {
cached,
ghe,
githubAE,
updateAll,
_: [command],
} = yargs(hideBin(process.argv))
.command("update", "Update webhooks", (yargs) => {
yargs.options(options).example("$0 update --cached", "");
})
.command("check", "Check if webhooks are up-to-date", (yargs) => {
yargs.options(options).example("$0 check --cached", "");
})
.help("h")
.alias("h", ["help", "usage"])
.demandCommand(1, "")
.scriptName("bin/octokit-webhooks")
.usage("$0 <command> [--cached]").argv as Arguments<Options>;
if (!["update", "check"].includes(command.toString())) {
console.log(`"${command}" must be one of: update, check`);
process.exit(1);
}
checkOrUpdateWebhooks({
cached,
ghe,
githubAE,
updateAll,
checkOnly: command === "check",
}).catch((error: Error) => {
console.log(error.stack);
process.exit(1);
});