generated from hasundue/template-deno
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcli.ts
80 lines (76 loc) · 1.89 KB
/
cli.ts
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
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts";
import { retry } from "https://deno.land/[email protected]/async/retry.ts";
import { env } from "./mod/env.ts";
import {
createCommits,
createPullRequest,
getUpdates,
VERSION,
} from "./mod.ts";
const { args, options } = await new Command()
.name("denopendabot")
.version(VERSION)
.description("Keep your Deno project up-to-date.")
.arguments("<repository:string>")
.option(
"-b --base-branch <name>",
"Branch to update.",
{ default: "main" },
)
.option(
"-w --working-branch <name>",
"Working branch.",
{ default: "denopendabot" },
)
.option(
"--root <path:file>",
"Path to the project root (not prefixed with './')",
)
.option(
"-i --include <paths:file[]>",
"Specify files to update.",
)
.option(
"-x --exclude <paths:file[]>",
"Files to exclude.",
{ separator: " " },
)
.option(
"-l --labels <names:string[]>",
"Labels for the pull request.",
{ separator: " " },
)
.option(
"-r --release <target_version:string>",
"Bump the repository version for a release.",
)
.option(
"-d --dry-run",
"Just check updates.",
)
.option(
"-t --token <token:string>",
"Access token associated with GitHub Action.",
{ default: "GITHUB_TOKEN" },
)
.option(
"-u --user-token <token:string>",
"Private access token authorized to update workflows.",
)
.parse(Deno.args);
const repo = args[0];
const updates = await retry(
() => getUpdates(repo, options),
);
if (!updates.length) {
console.info("🎉 Everything is up-to-date!");
} else if (!options.dryRun) {
await createCommits(repo, updates, options);
await createPullRequest(repo, options);
}
if (env.CI) {
await Deno.writeTextFile(env.GITHUB_OUTPUT!, "updated=true\n", {
append: true,
});
console.log(`echo "updated=true" >> $GITHUB_OUTPUT`);
}