@rbbtsn0w/adg 0.8.0-beta.6 → 0.8.0-beta.8
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/README.md +1 -1
- package/dist/bin/adg.js +8 -4
- package/dist/src/self-update.js +65 -13
- package/docs/branching-and-release.md +31 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -485,7 +485,7 @@ it's sanitized.
|
|
|
485
485
|
|
|
486
486
|
## Contributing
|
|
487
487
|
|
|
488
|
-
All feature/fix pull requests target the **`
|
|
488
|
+
All feature/fix pull requests target the **`develop`** integration branch; `main`
|
|
489
489
|
is reserved for stable releases. See [CONTRIBUTING.md](CONTRIBUTING.md) and
|
|
490
490
|
[docs/branching-and-release.md](docs/branching-and-release.md).
|
|
491
491
|
|
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.`;
|
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
# Branching and release
|
|
2
2
|
|
|
3
|
-
ADG uses `
|
|
4
|
-
branch. Feature and fix pull requests always target `
|
|
5
|
-
request allowed to target `main` is the
|
|
3
|
+
ADG uses `develop` as the integration branch and `main` as the stable release
|
|
4
|
+
branch. Feature and fix pull requests always target `develop`; the only pull
|
|
5
|
+
request allowed to target `main` is the release promotion from `develop`.
|
|
6
6
|
|
|
7
7
|
## Contribution flow
|
|
8
8
|
|
|
9
|
-
1. Branch from the latest `
|
|
10
|
-
2. Open a pull request back to `
|
|
9
|
+
1. Branch from the latest `develop`.
|
|
10
|
+
2. Open a pull request back to `develop`.
|
|
11
11
|
3. Pass the repository checks and review.
|
|
12
|
-
4. Merge through branch protection; never push directly to `
|
|
12
|
+
4. Merge through branch protection; never push directly to `develop` or `main`.
|
|
13
13
|
|
|
14
|
-
Merges to `
|
|
15
|
-
dist-tag
|
|
16
|
-
|
|
14
|
+
Merges to `develop` are published by semantic-release under the `beta` npm
|
|
15
|
+
dist-tag (prereleases as `x.y.z-beta.N`).
|
|
16
|
+
|
|
17
|
+
## Automated Weekly Stable Release
|
|
18
|
+
|
|
19
|
+
Every Friday at 15:00 Beijing time (UTC+8 / 07:00 UTC), a scheduled automation workflow
|
|
20
|
+
(`.github/workflows/scheduled-release-pr.yml`):
|
|
21
|
+
|
|
22
|
+
1. Checks if `develop` has new commits ahead of `main`.
|
|
23
|
+
2. Automatically opens a `develop -> main` release promotion PR.
|
|
24
|
+
3. Enables native GitHub `auto-merge`.
|
|
25
|
+
4. Once all CI checks (test matrix, audits, smoke tests) pass and there are no conflicts or blockers, GitHub automatically merges the PR into `main`.
|
|
26
|
+
5. Merging to `main` triggers `semantic-release` to cut a stable release (`latest` dist-tag).
|
|
27
|
+
|
|
28
|
+
## PR Dev Preview Releases
|
|
29
|
+
|
|
30
|
+
Each pull request targeting `develop` triggers automated dev preview packaging:
|
|
31
|
+
|
|
32
|
+
- Published under the `next` dist-tag on npm and GitHub Packages.
|
|
33
|
+
- Formatted as `<BASE>-dev.pr<PR_NUM>.<SHORT_SHA>`.
|
|
34
|
+
- The CI bot posts verification instructions directly on the PR with `npx`, `adg update --tag <version>`, or `adg update --dev`.
|
|
17
35
|
|
|
18
36
|
## Back-merge after a stable release
|
|
19
37
|
|
|
20
|
-
The release commit created on `main` must be merged back into `
|
|
21
|
-
branches share the same release ancestry. The `Sync main to
|
|
22
|
-
a `main ->
|
|
38
|
+
The release commit created on `main` must be merged back into `develop` so both
|
|
39
|
+
branches share the same release ancestry. The `Sync main to develop` workflow opens
|
|
40
|
+
a `main -> develop` pull request after successful main CI:
|
|
23
41
|
|
|
24
42
|
- A conflict-free pull request is merged automatically with a merge commit.
|
|
25
43
|
- A conflicting pull request receives `manual-sync-needed` and must be resolved
|
|
26
44
|
by a maintainer before further promotion work.
|
|
27
45
|
- Resolve version and changelog conflicts in favor of the stable `main` release
|
|
28
|
-
commit while preserving subsequent integration changes from `
|
|
46
|
+
commit while preserving subsequent integration changes from `develop`.
|
|
29
47
|
|
|
30
48
|
The workflow never pushes directly to a protected branch. An open
|
|
31
49
|
`manual-sync-needed` pull request is an operational action item, not a successful
|