@rbbtsn0w/adg 0.8.0-beta.6 → 0.8.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/adg.js +8 -4
- package/dist/src/self-update.js +65 -13
- package/docs/branching-and-release.md +8 -0
- package/package.json +1 -1
package/dist/bin/adg.js
CHANGED
|
@@ -82,15 +82,19 @@ function runSelfUpdate(args) {
|
|
|
82
82
|
console.log(SELF_UPDATE_USAGE);
|
|
83
83
|
return commandOutcome("success");
|
|
84
84
|
}
|
|
85
|
-
const command = selfUpdateCommand(options
|
|
85
|
+
const command = selfUpdateCommand(options);
|
|
86
|
+
if (options.dryRun) {
|
|
87
|
+
console.log(`[dry-run] would run: ${command.command} ${command.args.join(" ")}`);
|
|
88
|
+
return commandOutcome("success");
|
|
89
|
+
}
|
|
86
90
|
// npm's own inherited output is the progress indicator once it starts; this
|
|
87
91
|
// frames the silent stretch before it and states what is about to happen.
|
|
88
|
-
process.stderr.write(`${ui.meta(formatSelfUpdateStart(getVersion(), options
|
|
92
|
+
process.stderr.write(`${ui.meta(formatSelfUpdateStart(getVersion(), options))}\n`);
|
|
89
93
|
const started = Date.now();
|
|
90
94
|
const r = runSubprocessSync(command.command, command.args, selfUpdateSpawnOptions());
|
|
91
95
|
if (r.error) {
|
|
92
96
|
console.error(`${ui.err("error:")} ${r.error.message}`);
|
|
93
|
-
console.error(ui.meta(selfUpdateFailureHint(options
|
|
97
|
+
console.error(ui.meta(selfUpdateFailureHint(options)));
|
|
94
98
|
return commandOutcome("failure", "dependency");
|
|
95
99
|
}
|
|
96
100
|
const exitCode = r.status ?? 1;
|
|
@@ -100,7 +104,7 @@ function runSelfUpdate(args) {
|
|
|
100
104
|
return commandOutcome("success");
|
|
101
105
|
}
|
|
102
106
|
process.stderr.write(`${ui.err(formatSelfUpdateResult(false, elapsed))}\n`);
|
|
103
|
-
console.error(ui.meta(selfUpdateFailureHint(options
|
|
107
|
+
console.error(ui.meta(selfUpdateFailureHint(options)));
|
|
104
108
|
return { ...commandOutcome("failure", "dependency"), exitCode };
|
|
105
109
|
}
|
|
106
110
|
/**
|
package/dist/src/self-update.js
CHANGED
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { prereleaseChannel } from "./semver.js";
|
|
2
2
|
export const PACKAGE_NAME = "@rbbtsn0w/adg";
|
|
3
3
|
export function parseSelfUpdateArgs(args) {
|
|
4
|
-
const options = {
|
|
5
|
-
|
|
4
|
+
const options = {
|
|
5
|
+
beta: false,
|
|
6
|
+
dev: false,
|
|
7
|
+
tag: undefined,
|
|
8
|
+
dryRun: false,
|
|
9
|
+
help: false,
|
|
10
|
+
};
|
|
11
|
+
for (let i = 0; i < args.length; i++) {
|
|
12
|
+
const arg = args[i];
|
|
6
13
|
if (arg === "--beta" || arg === "-b") {
|
|
7
14
|
options.beta = true;
|
|
8
15
|
continue;
|
|
9
16
|
}
|
|
17
|
+
if (arg === "--dev") {
|
|
18
|
+
options.dev = true;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (arg === "--tag" || arg === "-t") {
|
|
22
|
+
const val = args[++i];
|
|
23
|
+
if (!val || val.startsWith("-")) {
|
|
24
|
+
throw new Error(`flag \`${arg}\` requires a version or dist-tag argument`);
|
|
25
|
+
}
|
|
26
|
+
options.tag = val;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (arg.startsWith("--tag=")) {
|
|
30
|
+
const val = arg.slice("--tag=".length);
|
|
31
|
+
if (!val) {
|
|
32
|
+
throw new Error(`flag \`--tag\` requires a version or dist-tag argument`);
|
|
33
|
+
}
|
|
34
|
+
options.tag = val;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (arg === "--dry-run") {
|
|
38
|
+
options.dryRun = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
10
41
|
if (arg === "--help" || arg === "-h") {
|
|
11
42
|
options.help = true;
|
|
12
43
|
continue;
|
|
@@ -17,13 +48,25 @@ export function parseSelfUpdateArgs(args) {
|
|
|
17
48
|
}
|
|
18
49
|
return options;
|
|
19
50
|
}
|
|
20
|
-
export function selfUpdateTarget(
|
|
21
|
-
|
|
51
|
+
export function selfUpdateTarget(target) {
|
|
52
|
+
if (typeof target === "boolean") {
|
|
53
|
+
return target ? "beta" : "latest";
|
|
54
|
+
}
|
|
55
|
+
if (target.tag) {
|
|
56
|
+
return target.tag;
|
|
57
|
+
}
|
|
58
|
+
if (target.dev) {
|
|
59
|
+
return "next";
|
|
60
|
+
}
|
|
61
|
+
if (target.beta) {
|
|
62
|
+
return "beta";
|
|
63
|
+
}
|
|
64
|
+
return "latest";
|
|
22
65
|
}
|
|
23
|
-
export function selfUpdateCommand(
|
|
66
|
+
export function selfUpdateCommand(target, npmBin = "npm") {
|
|
24
67
|
return {
|
|
25
68
|
command: npmBin,
|
|
26
|
-
args: ["install", "-g", `${PACKAGE_NAME}@${selfUpdateTarget(
|
|
69
|
+
args: ["install", "-g", `${PACKAGE_NAME}@${selfUpdateTarget(target)}`],
|
|
27
70
|
};
|
|
28
71
|
}
|
|
29
72
|
export function selfUpdateSpawnOptions(platform = process.platform) {
|
|
@@ -34,9 +77,9 @@ export function selfUpdateSpawnOptions(platform = process.platform) {
|
|
|
34
77
|
* seconds, so without this the command that is *named* "update" shows nothing at
|
|
35
78
|
* all until npm's summary block appears.
|
|
36
79
|
*/
|
|
37
|
-
export function formatSelfUpdateStart(currentVersion,
|
|
38
|
-
const { command, args } = selfUpdateCommand(
|
|
39
|
-
return `adg ${currentVersion} → installing ${selfUpdateTarget(
|
|
80
|
+
export function formatSelfUpdateStart(currentVersion, target) {
|
|
81
|
+
const { command, args } = selfUpdateCommand(target);
|
|
82
|
+
return `adg ${currentVersion} → installing ${selfUpdateTarget(target)} (${command} ${args.join(" ")})`;
|
|
40
83
|
}
|
|
41
84
|
/** Closing line for a self-update run. */
|
|
42
85
|
export function formatSelfUpdateResult(ok, elapsedMs) {
|
|
@@ -46,16 +89,18 @@ export function formatSelfUpdateResult(ok, elapsedMs) {
|
|
|
46
89
|
: `update failed · ${seconds}`;
|
|
47
90
|
}
|
|
48
91
|
/** Actionable next step when npm could not be launched or exited non-zero. */
|
|
49
|
-
export function selfUpdateFailureHint(
|
|
50
|
-
const { command, args } = selfUpdateCommand(
|
|
92
|
+
export function selfUpdateFailureHint(target) {
|
|
93
|
+
const { command, args } = selfUpdateCommand(target);
|
|
51
94
|
return `try running it directly: ${command} ${args.join(" ")}\nif that fails with EACCES, npm's global prefix needs write access (or install via a version manager).`;
|
|
52
95
|
}
|
|
53
96
|
export function selfUpdateHint(latestVersion) {
|
|
54
97
|
const channel = prereleaseChannel(latestVersion);
|
|
55
98
|
if (channel === "beta")
|
|
56
99
|
return "adg update --beta";
|
|
100
|
+
if (channel === "dev" || channel === "next")
|
|
101
|
+
return "adg update --dev";
|
|
57
102
|
if (channel)
|
|
58
|
-
return `
|
|
103
|
+
return `adg update --tag ${latestVersion}`;
|
|
59
104
|
return "adg update";
|
|
60
105
|
}
|
|
61
106
|
export const SELF_UPDATE_USAGE = `adg update — upgrade the ADG CLI
|
|
@@ -65,4 +110,11 @@ Usage:
|
|
|
65
110
|
Install the latest stable release with npm.
|
|
66
111
|
adg update --beta
|
|
67
112
|
adg update -b
|
|
68
|
-
Install the latest beta release with npm
|
|
113
|
+
Install the latest beta release with npm.
|
|
114
|
+
adg update --dev
|
|
115
|
+
Install the latest PR development / canary release (dist-tag: next).
|
|
116
|
+
adg update --tag <tag|version>
|
|
117
|
+
adg update -t <tag|version>
|
|
118
|
+
Install a specific version or dist-tag with npm.
|
|
119
|
+
adg update --dry-run
|
|
120
|
+
Simulate update command without running npm.`;
|
|
@@ -15,6 +15,14 @@ Merges to `beta` are published by semantic-release under the `beta` npm
|
|
|
15
15
|
dist-tag. Maintainers promote a tested release set with a `beta -> main` pull
|
|
16
16
|
request; merging that pull request publishes the stable `latest` dist-tag.
|
|
17
17
|
|
|
18
|
+
## PR Dev Preview Releases
|
|
19
|
+
|
|
20
|
+
Each pull request targeting `beta` triggers automated dev preview packaging:
|
|
21
|
+
|
|
22
|
+
- Published under the `next` dist-tag on npm and GitHub Packages.
|
|
23
|
+
- Formatted as `<BASE>-dev.pr<PR_NUM>.<SHORT_SHA>`.
|
|
24
|
+
- The CI bot posts verification instructions directly on the PR with `npx`, `adg update --tag <version>`, or `adg update --dev`.
|
|
25
|
+
|
|
18
26
|
## Back-merge after a stable release
|
|
19
27
|
|
|
20
28
|
The release commit created on `main` must be merged back into `beta` so both
|