generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
commit-and-tag-version.js
114 lines (114 loc) · 2.38 KB
/
commit-and-tag-version.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* eslint-disable @typescript-eslint/no-var-requires */
const { Command, Option } = require("commander");
const commitAndTagVersion = require("commit-and-tag-version");
const dedent = require("dedent");
const c = require("ansi-colors");
const program = new Command();
c.theme({
danger: c.red,
dark: c.dim.gray,
disabled: c.gray,
em: c.italic,
heading: c.bold.underline,
info: c.cyan,
muted: c.dim,
primary: c.blue,
strong: c.bold,
success: c.green.bold,
underline: c.underline,
warning: c.yellow.underline,
});
program
.description("Bump version and create a new tag")
.option("-b, --beta", "Pre-release version")
.option("--dry-run", "Dry run")
.addOption(
new Option("-r, --release-as <size>", "release type version").choices([
"major",
"minor",
"patch",
])
);
program.parse();
const opt = program.opts();
const betaMsg = opt.beta ? c.em("- Pre-release\n\t") : "";
const dryRunMsg = opt.dryRun ? c.em("- Dry run\n\t") : "";
const releaseAsMsg = opt.releaseAs
? c.em(`- Release as ${c.underline(opt.releaseAs)}`)
: "";
const msg = dedent(`
${c.heading("Options :")}
${betaMsg}${dryRunMsg}${releaseAsMsg}
`);
console.log(msg);
console.log();
if (opt.beta) {
console.log(
`${c.bold.green(">")} ${c.info.underline("Bumping beta version...")}`
);
console.log();
const bumpFiles = [
{
filename: "manifest-beta.json",
type: "json",
},
{
filename: "package.json",
type: "json",
},
{
filename: "package-lock.json",
type: "json",
},
];
commitAndTagVersion({
infile: "CHANGELOG-beta.md",
bumpFiles: bumpFiles,
prerelease: "",
dryRun: opt.dryRun,
tagPrefix: "",
})
.then(() => {
console.log("Done");
})
.catch((err) => {
console.error(err);
});
} else {
const versionBumped = opt.releaseAs
? c.info("Release as " + c.underline(opt.releaseAs))
: c.info("Release");
console.log(`${c.bold.green(">")} ${c.underline(versionBumped)}`);
console.log();
const bumpFiles = [
{
filename: "manifest-beta.json",
type: "json",
},
{
filename: "package.json",
type: "json",
},
{
filename: "package-lock.json",
type: "json",
},
{
filename: "manifest.json",
type: "json",
},
];
commitAndTagVersion({
infile: "CHANGELOG.md",
bumpFiles: bumpFiles,
dryRun: opt.dryRun,
tagPrefix: "",
releaseAs: opt.releaseAs,
})
.then(() => {
console.log("Done");
})
.catch((err) => {
console.error(err);
});
}