-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
46 lines (42 loc) · 1.01 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
#!/usr/bin/env node
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { sendDeployStartMessage } from "./sendDeployStartMessage.js";
const argv = yargs(hideBin(process.argv))
.usage("Usage: $0 <command> [options]")
.command(
"notify-deploy-start",
"Sends message to Slack that deployment is starting"
)
.command(
"notify-deploy-end",
"Sends message to Slack that deployment is starting"
)
.option("slack_channel")
.option("sha1")
.option("repo_owner")
.option("repo_name")
.option("workflow_url")
.demandOption([
"slack_channel",
"repo_owner",
"repo_name",
"sha1",
"workflow_url",
])
.help("h")
.alias("h", "help").argv;
const commandString = argv._[0];
async function execute() {
if (commandString === "notify-deploy-start") {
try {
await sendDeployStartMessage(argv);
console.log("Done");
} catch (e) {
console.error(e);
}
} else if (commandString === "notify-deploy-end") {
//TODO
}
}
execute();