@regardio/dev 2.2.0 → 2.3.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as git, c as runScript, i as getWorkspacePackages, n as
|
|
2
|
+
import { a as git, c as runScript, i as getWorkspacePackages, n as chooseForEach, o as gitRead, s as runQualityChecks, t as branchExists } from "./utils-VktE94Vs.mjs";
|
|
3
3
|
//#region src/bin/ship/hotfix.ts
|
|
4
4
|
/**
|
|
5
5
|
* ship-hotfix: Manage hotfix branches based on production code.
|
|
@@ -65,30 +65,14 @@ function runShipHotfix(subcommand, subArgs, cwd = process.cwd()) {
|
|
|
65
65
|
console.error("No publishable workspace packages found.");
|
|
66
66
|
process.exit(1);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.error("Could not determine package to ship.");
|
|
74
|
-
process.exit(1);
|
|
68
|
+
console.log("\nSelect a version bump for each package (or skip):");
|
|
69
|
+
const bumps = chooseForEach(packages);
|
|
70
|
+
if (bumps.length === 0) {
|
|
71
|
+
console.log("\nNo packages selected for release. Aborted.");
|
|
72
|
+
process.exit(0);
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
label: "patch — bug fixes",
|
|
79
|
-
value: "patch"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
label: "minor — new features",
|
|
83
|
-
value: "minor"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: "major — breaking changes",
|
|
87
|
-
value: "major"
|
|
88
|
-
}
|
|
89
|
-
]);
|
|
90
|
-
console.log("\nBumping version and updating CHANGELOG...");
|
|
91
|
-
runScript(`--filter ${packageName} release:${bumpType}`);
|
|
74
|
+
console.log("\nBumping versions and updating CHANGELOGs...");
|
|
75
|
+
for (const { package: pkg, bump } of bumps) runScript(`--filter ${pkg.name} release:${bump}`);
|
|
92
76
|
console.log("\nFetching latest state from origin...");
|
|
93
77
|
git("fetch", "origin");
|
|
94
78
|
console.log("\nMerging hotfix into production...");
|
|
@@ -110,7 +94,8 @@ function runShipHotfix(subcommand, subArgs, cwd = process.cwd()) {
|
|
|
110
94
|
try {
|
|
111
95
|
git("push", "origin", "--delete", currentBranch);
|
|
112
96
|
} catch {}
|
|
113
|
-
|
|
97
|
+
const shipped = bumps.map((b) => b.package.name).join(", ");
|
|
98
|
+
console.log(`\n✅ Hotfix ${shipped} shipped to production → staging → main`);
|
|
114
99
|
console.log("CI will publish changed packages to npm.");
|
|
115
100
|
console.log("You are on main and ready to keep working.");
|
|
116
101
|
process.exit(0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as git, c as runScript, i as getWorkspacePackages, n as
|
|
2
|
+
import { a as git, c as runScript, i as getWorkspacePackages, n as chooseForEach, o as gitRead, r as confirm, s as runQualityChecks, t as branchExists } from "./utils-VktE94Vs.mjs";
|
|
3
3
|
//#region src/bin/ship/production.ts
|
|
4
4
|
/**
|
|
5
5
|
* ship-production: Promote main to production following the GitLab workflow.
|
|
@@ -47,15 +47,13 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
47
47
|
console.error("No publishable workspace packages found.");
|
|
48
48
|
process.exit(1);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.error("Could not determine package to ship.");
|
|
56
|
-
process.exit(1);
|
|
50
|
+
console.log("\nSelect a version bump for each package (or skip):");
|
|
51
|
+
const bumps = chooseForEach(packages);
|
|
52
|
+
if (bumps.length === 0) {
|
|
53
|
+
console.log("\nNo packages selected for release. Aborted.");
|
|
54
|
+
process.exit(0);
|
|
57
55
|
}
|
|
58
|
-
if (!confirm(
|
|
56
|
+
if (!confirm(`\nShip to production?\n${bumps.map((b) => ` ${b.package.name} → ${b.bump}`).join("\n")}\n`)) {
|
|
59
57
|
console.log("Aborted.");
|
|
60
58
|
process.exit(0);
|
|
61
59
|
}
|
|
@@ -67,22 +65,8 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
67
65
|
process.exit(1);
|
|
68
66
|
}
|
|
69
67
|
console.log("✅ Quality checks passed");
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
label: "patch — bug fixes",
|
|
73
|
-
value: "patch"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
label: "minor — new features",
|
|
77
|
-
value: "minor"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
label: "major — breaking changes",
|
|
81
|
-
value: "major"
|
|
82
|
-
}
|
|
83
|
-
]);
|
|
84
|
-
console.log("\nBumping version and updating CHANGELOG...");
|
|
85
|
-
runScript(`--filter ${packageName} release:${bumpType}`);
|
|
68
|
+
console.log("\nBumping versions and updating CHANGELOGs...");
|
|
69
|
+
for (const { package: pkg, bump } of bumps) runScript(`--filter ${pkg.name} release:${bump}`);
|
|
86
70
|
console.log("\nMerging main into production...");
|
|
87
71
|
git("checkout", "production");
|
|
88
72
|
git("pull", "--ff-only", "origin", "production");
|
|
@@ -95,7 +79,8 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
95
79
|
git("push", "origin", "staging");
|
|
96
80
|
git("checkout", "main");
|
|
97
81
|
git("push", "--follow-tags", "origin", "main");
|
|
98
|
-
|
|
82
|
+
const shipped = bumps.map((b) => b.package.name).join(", ");
|
|
83
|
+
console.log(`\n✅ Shipped ${shipped} to production. CI will publish changed packages to npm.`);
|
|
99
84
|
console.log("You are on main and ready to keep working.");
|
|
100
85
|
}
|
|
101
86
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as git, o as gitRead, s as runQualityChecks, t as branchExists } from "./utils-
|
|
2
|
+
import { a as git, o as gitRead, s as runQualityChecks, t as branchExists } from "./utils-VktE94Vs.mjs";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
//#region src/bin/ship/staging.ts
|
|
@@ -40,6 +40,35 @@ const getWorkspacePackages = (cwd = process.cwd()) => {
|
|
|
40
40
|
path
|
|
41
41
|
}));
|
|
42
42
|
};
|
|
43
|
+
const chooseForEach = (packages, ttyPath = "/dev/tty") => {
|
|
44
|
+
const bumps = [];
|
|
45
|
+
const options = [
|
|
46
|
+
{
|
|
47
|
+
label: "skip",
|
|
48
|
+
value: "skip"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "patch — bug fixes",
|
|
52
|
+
value: "patch"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "minor — new features",
|
|
56
|
+
value: "minor"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "major — breaking changes",
|
|
60
|
+
value: "major"
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
for (const pkg of packages) {
|
|
64
|
+
const answer = choose(`\n${pkg.name}:`, [...options], ttyPath);
|
|
65
|
+
if (answer !== "skip") bumps.push({
|
|
66
|
+
bump: answer,
|
|
67
|
+
package: pkg
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return bumps;
|
|
71
|
+
};
|
|
43
72
|
const branchExists = (name) => gitRead("branch", "--list", name) !== "" || gitRead("branch", "--list", "--remotes", `origin/${name}`) !== "";
|
|
44
73
|
const confirm = (prompt, ttyPath = "/dev/tty") => {
|
|
45
74
|
process.stdout.write(`${prompt} (y/N) `);
|
|
@@ -83,4 +112,4 @@ const choose = (prompt, options, ttyPath = "/dev/tty") => {
|
|
|
83
112
|
return chosen.value;
|
|
84
113
|
};
|
|
85
114
|
//#endregion
|
|
86
|
-
export { git as a, runScript as c, getWorkspacePackages as i,
|
|
115
|
+
export { git as a, runScript as c, getWorkspacePackages as i, chooseForEach as n, gitRead as o, confirm as r, runQualityChecks as s, branchExists as t };
|
|
@@ -25,14 +25,14 @@ main → staging (optional) → production
|
|
|
25
25
|
- **`staging`** — optional validation environment. No versioning happens here.
|
|
26
26
|
- **`production`** — versioned, published code only.
|
|
27
27
|
|
|
28
|
-
When `ship-production` runs, it discovers publishable workspace packages
|
|
28
|
+
When `ship-production` runs, it discovers all publishable workspace packages and asks you to assign a bump type — `skip`, `patch`, `minor`, or `major` — to each one individually. Packages you skip are left untouched. For each package with a bump, it calls `pnpm --filter <package> release:<type>`, which bumps that package's version, rewrites its `CHANGELOG.md` using commits since its last scoped tag, and commits on `main`. The branches merge once after all bumps are applied. CI on `production` publishes only the packages whose version changed.
|
|
29
29
|
|
|
30
30
|
## How It Works
|
|
31
31
|
|
|
32
32
|
### Design principles
|
|
33
33
|
|
|
34
34
|
1. **Branches mirror environments.** `staging` reflects what is deployed to the staging server (when used); `production` always reflects what is published to npm. There is never ambiguity about what is running where.
|
|
35
|
-
2. **You choose the bump at ship time.** When running `ship-production` or `ship-hotfix finish`,
|
|
35
|
+
2. **You choose the bump per package at ship time.** When running `ship-production` or `ship-hotfix finish`, every publishable package is listed and you assign it `skip`, `patch`, `minor`, or `major`. Packages you skip are untouched. The conventional commits in the log inform each choice; the decisions are always explicit.
|
|
36
36
|
3. **Version numbers are a production guarantee.** Bumps are applied only at `ship-production` time. Every version tag in git and every release on npm corresponds to code that has been validated and shipped.
|
|
37
37
|
4. **Staging is optional.** You can ship directly from `main` to `production`. Use `ship-staging` when you want to test changes in a staging environment first.
|
|
38
38
|
5. **Tests are a local gate, not a CI gate.** Quality checks (`build`, `typecheck`, `test`) run on your machine before any commit is made. Broken code cannot enter the repository.
|
|
@@ -136,14 +136,14 @@ This will:
|
|
|
136
136
|
|
|
137
137
|
1. Guard: must be on `main`, working tree clean
|
|
138
138
|
2. Fetch and verify `staging` + `production` branches exist
|
|
139
|
-
3. Show commits to be shipped
|
|
140
|
-
4.
|
|
141
|
-
5.
|
|
142
|
-
6.
|
|
143
|
-
7.
|
|
139
|
+
3. Show commits to be shipped
|
|
140
|
+
4. For each publishable package: choose `skip / patch / minor / major`
|
|
141
|
+
5. Confirm the planned bumps — abort if declined or all skipped
|
|
142
|
+
6. Run full quality suite on `main` — aborts on failure
|
|
143
|
+
7. For each non-skipped package: run `pnpm --filter <pkg> release:<type>` — bumps version, rewrites `CHANGELOG.md`, commits
|
|
144
144
|
8. Fast-forward merge `main` into `production` and push
|
|
145
145
|
9. Sync `staging` with `production`
|
|
146
|
-
10. Push `main` with `--follow-tags` to push
|
|
146
|
+
10. Push `main` with `--follow-tags` to push all new version tags
|
|
147
147
|
11. Return to `main`
|
|
148
148
|
|
|
149
149
|
CI on `production` runs `pnpm -r publish` to push changed packages to npm.
|
|
@@ -167,7 +167,7 @@ git add . && git commit -m "fix: ..."
|
|
|
167
167
|
pnpm ship:hotfix finish
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
`finish`
|
|
170
|
+
`finish` asks you to assign a bump type (`skip`, `patch`, `minor`, or `major`) to each publishable package, runs `pnpm --filter <pkg> release:<type>` for each non-skipped one to bump versions and update `CHANGELOG.md`, then merges `hotfix → production → staging → main` and deletes the hotfix branch. CI publishes from `production`.
|
|
171
171
|
|
|
172
172
|
## Adoption
|
|
173
173
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "@regardio/dev",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Regardio development presets: biome, typescript, commitlint, markdownlint, vitest, playwright, sqlfluff, husky, and GitLab-flow ship tooling",
|
|
7
7
|
"keywords": [
|