forked from tscircuit/pver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
executable file
·123 lines (117 loc) · 3.33 KB
/
Copy pathcli.ts
File metadata and controls
executable file
·123 lines (117 loc) · 3.33 KB
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
115
116
117
118
119
120
121
122
123
#!/usr/bin/env node
import yargs from "yargs"
import { hideBin } from "yargs/helpers"
import { getAppContext } from "./src/app-context"
import { analyze } from "./src/analyze"
import { release } from "./src/release"
import { stage } from "./src/stage"
interface ReleaseOptions {
git?: boolean
npm?: boolean
readme?: boolean
pyproject?: boolean
setuppy?: boolean
versionpy?: boolean
versionrb?: boolean
mdfile?: string
}
if (process.env.NPM_TOKEN && !process.env.NODE_AUTH_TOKEN) {
process.env.NODE_AUTH_TOKEN = process.env.NPM_TOKEN
}
const handleCommandError = (e: any) => {
console.error(e.stack)
console.error(e.toString())
process.exit(1)
}
yargs(hideBin(process.argv))
// Analyze Command
.command(
"analyze",
"Automatically compute the latest Pragmatic Version using the git history",
(yargs) => {
return yargs
.option("current", {
describe: "Method to compute the current version",
choices: ["auto", "package.json"],
default: "auto",
})
.option("transition", {
describe: "Method to compute next version(s) from current version",
choices: ["auto", "simplegit"],
default: "auto",
})
},
async (argv) => {
const analysis = await analyze(await getAppContext({ argv })).catch(
handleCommandError
)
console.log(analysis)
}
)
// Release Command
.command(
"release [action]",
"Automatically compute and release a new version",
(yargs) => {
return yargs
.positional("action", {
describe: "The release action to perform",
default: "auto",
choices: ["auto", "increment", "announce", "bigrelease"],
})
.option("git", {
describe: "Release as a git tag and push it",
type: "boolean",
})
.option("npm", {
describe: "Increment version in package.json",
type: "boolean",
})
.option("package-json", {
describe: "Increment version in package.json without publishing to npm",
type: "boolean",
})
.option("push-main", {
describe: "Push the main branch after releasing",
type: "boolean",
})
.option("no-push-main", {
describe: "Disable pushing to main branch (overrides --push-main)",
type: "boolean",
})
.option("readme", {
describe: "Increment version in README files",
type: "boolean",
})
// Additional options here...
},
async (argv) => {
const ctx = await getAppContext({ argv })
await release(ctx).catch(handleCommandError)
}
)
// Stage Command
.command(
"stage [action]",
"Tag the current commit and stage changes locally",
(yargs) => {
return yargs
.positional("action", {
describe: "The stage action to perform",
default: "auto",
choices: ["auto", "increment", "announce", "bigrelease"],
})
.option("git", {
describe: "Stage as a git tag",
type: "boolean",
})
.option("npm", {
describe: "Stage version in package.json",
type: "boolean",
})
},
async (argv) => {
const ctx = await getAppContext({ argv })
await stage(ctx).catch(handleCommandError)
}
).argv