@regardio/dev 2.3.0 → 2.4.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.
- package/dist/bin/ship/hotfix.bin.mjs +11 -2
- package/dist/bin/ship/production.bin.mjs +11 -2
- package/dist/bin/ship/staging.bin.mjs +1 -1
- package/dist/bin/ship/{utils-VktE94Vs.mjs → utils-rnvdLrkF.mjs} +21 -13
- package/dist/playwright/index.d.mts +3 -3
- package/dist/vitest/node.d.mts +3 -3
- package/dist/vitest/react.d.mts +3 -3
- package/docs/en/tools/releases.md +11 -7
- package/package.json +1 -5
- package/src/typescript/base.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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-
|
|
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-rnvdLrkF.mjs";
|
|
3
3
|
//#region src/bin/ship/hotfix.ts
|
|
4
4
|
/**
|
|
5
5
|
* ship-hotfix: Manage hotfix branches based on production code.
|
|
@@ -72,7 +72,16 @@ function runShipHotfix(subcommand, subArgs, cwd = process.cwd()) {
|
|
|
72
72
|
process.exit(0);
|
|
73
73
|
}
|
|
74
74
|
console.log("\nBumping versions and updating CHANGELOGs...");
|
|
75
|
-
for (const { package: pkg, bump } of bumps)
|
|
75
|
+
for (const { package: pkg, bump } of bumps) {
|
|
76
|
+
const originalCwd = process.cwd();
|
|
77
|
+
process.chdir(pkg.path);
|
|
78
|
+
try {
|
|
79
|
+
runScript(`--filter-root release:${bump}`);
|
|
80
|
+
} catch {
|
|
81
|
+
runScript(`commit-and-tag-version ${bump === "patch" ? "" : `--release-as ${bump}`}`);
|
|
82
|
+
}
|
|
83
|
+
process.chdir(originalCwd);
|
|
84
|
+
}
|
|
76
85
|
console.log("\nFetching latest state from origin...");
|
|
77
86
|
git("fetch", "origin");
|
|
78
87
|
console.log("\nMerging hotfix into production...");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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-
|
|
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-rnvdLrkF.mjs";
|
|
3
3
|
//#region src/bin/ship/production.ts
|
|
4
4
|
/**
|
|
5
5
|
* ship-production: Promote main to production following the GitLab workflow.
|
|
@@ -66,7 +66,16 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
66
66
|
}
|
|
67
67
|
console.log("✅ Quality checks passed");
|
|
68
68
|
console.log("\nBumping versions and updating CHANGELOGs...");
|
|
69
|
-
for (const { package: pkg, bump } of bumps)
|
|
69
|
+
for (const { package: pkg, bump } of bumps) {
|
|
70
|
+
const originalCwd = process.cwd();
|
|
71
|
+
process.chdir(pkg.path);
|
|
72
|
+
try {
|
|
73
|
+
runScript(`--filter-root release:${bump}`);
|
|
74
|
+
} catch {
|
|
75
|
+
runScript(`commit-and-tag-version ${bump === "patch" ? "" : `--release-as ${bump}`}`);
|
|
76
|
+
}
|
|
77
|
+
process.chdir(originalCwd);
|
|
78
|
+
}
|
|
70
79
|
console.log("\nMerging main into production...");
|
|
71
80
|
git("checkout", "production");
|
|
72
81
|
git("pull", "--ff-only", "origin", "production");
|
|
@@ -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-rnvdLrkF.mjs";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
//#region src/bin/ship/staging.ts
|
|
@@ -20,7 +20,7 @@ const runScript = (script) => {
|
|
|
20
20
|
execSync(`pnpm ${script}`, { stdio: "inherit" });
|
|
21
21
|
};
|
|
22
22
|
const runQualityChecks = () => {
|
|
23
|
-
runScript("
|
|
23
|
+
runScript("lint");
|
|
24
24
|
runScript("typecheck");
|
|
25
25
|
runScript("test");
|
|
26
26
|
};
|
|
@@ -44,26 +44,34 @@ const chooseForEach = (packages, ttyPath = "/dev/tty") => {
|
|
|
44
44
|
const bumps = [];
|
|
45
45
|
const options = [
|
|
46
46
|
{
|
|
47
|
-
label: "skip",
|
|
48
|
-
value: "
|
|
47
|
+
label: "0) skip",
|
|
48
|
+
value: "0"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
|
-
label: "patch — bug fixes",
|
|
52
|
-
value: "
|
|
51
|
+
label: "1) patch — bug fixes",
|
|
52
|
+
value: "1"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
label: "minor — new features",
|
|
56
|
-
value: "
|
|
55
|
+
label: "2) minor — new features",
|
|
56
|
+
value: "2"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
label: "major — breaking changes",
|
|
60
|
-
value: "
|
|
59
|
+
label: "3) major — breaking changes",
|
|
60
|
+
value: "3"
|
|
61
61
|
}
|
|
62
62
|
];
|
|
63
63
|
for (const pkg of packages) {
|
|
64
64
|
const answer = choose(`\n${pkg.name}:`, [...options], ttyPath);
|
|
65
|
-
if (answer
|
|
66
|
-
bump:
|
|
65
|
+
if (answer === "1") bumps.push({
|
|
66
|
+
bump: "patch",
|
|
67
|
+
package: pkg
|
|
68
|
+
});
|
|
69
|
+
else if (answer === "2") bumps.push({
|
|
70
|
+
bump: "minor",
|
|
71
|
+
package: pkg
|
|
72
|
+
});
|
|
73
|
+
else if (answer === "3") bumps.push({
|
|
74
|
+
bump: "major",
|
|
67
75
|
package: pkg
|
|
68
76
|
});
|
|
69
77
|
}
|
|
@@ -87,8 +95,8 @@ const confirm = (prompt, ttyPath = "/dev/tty") => {
|
|
|
87
95
|
return answer === "y" || answer === "Y";
|
|
88
96
|
};
|
|
89
97
|
const choose = (prompt, options, ttyPath = "/dev/tty") => {
|
|
90
|
-
const keys = options.map((
|
|
91
|
-
const optionList = options.map((o
|
|
98
|
+
const keys = options.map((o) => o.value);
|
|
99
|
+
const optionList = options.map((o) => ` ${o.label}`).join("\n");
|
|
92
100
|
process.stdout.write(`${prompt}\n${optionList}\nChoice [${keys.join("/")}]: `);
|
|
93
101
|
const buf = Buffer.alloc(1024);
|
|
94
102
|
let fd;
|
|
@@ -10,9 +10,9 @@ interface BuildPlaywrightBaseConfigParams {
|
|
|
10
10
|
webServerCommand: string;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* Build a base Playwright config object with Regardio defaults.
|
|
14
|
+
* Consumers should wrap with defineConfig() in their local playwright.config.ts
|
|
15
|
+
*/
|
|
16
16
|
declare function buildPlaywrightBaseConfig({
|
|
17
17
|
appUrl,
|
|
18
18
|
appPort,
|
package/dist/vitest/node.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/vitest/node.d.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Base Vitest configuration for Node.js packages.
|
|
4
|
+
* Use with defineConfig() in your vitest.config.ts
|
|
5
|
+
*/
|
|
6
6
|
declare const vitestNodeConfig: {
|
|
7
7
|
coverage: {
|
|
8
8
|
provider: "v8";
|
package/dist/vitest/react.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/vitest/react.d.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Vitest configuration for React packages with jsdom environment.
|
|
4
|
+
* Use with defineConfig() in your vitest.config.ts
|
|
5
|
+
*/
|
|
6
6
|
declare const vitestReactConfig: {
|
|
7
7
|
coverage: {
|
|
8
8
|
provider: "v8";
|
|
@@ -25,17 +25,17 @@ 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 all publishable workspace packages and asks you to assign a bump type — `skip
|
|
28
|
+
When `ship-production` runs, it discovers all publishable workspace packages and asks you to assign a bump type — `0` (skip), `1` (patch), `2` (minor), or `3` (major) — to each one individually. Packages you skip are left untouched. For each package with a bump, it first tries to run the release script from the root package.json (using `--filter-root release:<type>`), and if that fails, falls back to running `commit-and-tag-version` directly with the appropriate bump flag. This 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 per package at ship time.** When running `ship-production` or `ship-hotfix finish`, every publishable package is listed and you assign it `skip
|
|
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 `0` (skip), `1` (patch), `2` (minor), or `3` (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
|
-
5. **Tests are a local gate, not a CI gate.** Quality checks (`
|
|
38
|
+
5. **Tests are a local gate, not a CI gate.** Quality checks (`lint`, `typecheck`, `test`) run on your machine before any commit is made. Broken code cannot enter the repository.
|
|
39
39
|
6. **You always land back on `main`.** Every command returns you to `main` when it finishes.
|
|
40
40
|
|
|
41
41
|
### Full flow diagram
|
|
@@ -137,10 +137,10 @@ This will:
|
|
|
137
137
|
1. Guard: must be on `main`, working tree clean
|
|
138
138
|
2. Fetch and verify `staging` + `production` branches exist
|
|
139
139
|
3. Show commits to be shipped
|
|
140
|
-
4. For each publishable package: choose `skip / patch / minor / major`
|
|
140
|
+
4. For each publishable package: choose `0 (skip) / 1 (patch) / 2 (minor) / 3 (major)`
|
|
141
141
|
5. Confirm the planned bumps — abort if declined or all skipped
|
|
142
142
|
6. Run full quality suite on `main` — aborts on failure
|
|
143
|
-
7. For each non-skipped package: run
|
|
143
|
+
7. For each non-skipped package: run release script from root (if defined) or `commit-and-tag-version` directly — 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
146
|
10. Push `main` with `--follow-tags` to push all new version tags
|
|
@@ -167,13 +167,15 @@ git add . && git commit -m "fix: ..."
|
|
|
167
167
|
pnpm ship:hotfix finish
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
`finish` asks you to assign a bump type (`skip
|
|
170
|
+
`finish` asks you to assign a bump type (`0` (skip), `1` (patch), `2` (minor), or `3` (major)) to each publishable package, runs the release script from root (if defined) or `commit-and-tag-version` directly 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
|
|
|
174
174
|
Install `@regardio/dev` and:
|
|
175
175
|
|
|
176
|
-
1. **Add the scripts to `package.json
|
|
176
|
+
1. **Add the scripts to `package.json`** (optional, for monorepos):
|
|
177
|
+
|
|
178
|
+
In a monorepo, you can define release scripts in the root `package.json` to centralize version management. The ship scripts will use these if available, and fall back to running `commit-and-tag-version` directly if not.
|
|
177
179
|
|
|
178
180
|
```json
|
|
179
181
|
{
|
|
@@ -189,6 +191,8 @@ Install `@regardio/dev` and:
|
|
|
189
191
|
}
|
|
190
192
|
```
|
|
191
193
|
|
|
194
|
+
For single-package repos or when you prefer direct `commit-and-tag-version` usage, you can omit the release scripts — the ship commands will call `commit-and-tag-version` directly.
|
|
195
|
+
|
|
192
196
|
2. **Add a `.versionrc.json` to each publishable package** with a scoped `tagPrefix` so tags and changelogs stay isolated per package:
|
|
193
197
|
|
|
194
198
|
```bash
|
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.4.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": [
|
|
@@ -98,10 +98,6 @@
|
|
|
98
98
|
"clean": "rimraf .turbo dist",
|
|
99
99
|
"dev": "tsdown --watch",
|
|
100
100
|
"fix": "run-s fix:pkg fix:md fix:biome",
|
|
101
|
-
"release": "commit-and-tag-version",
|
|
102
|
-
"release:major": "commit-and-tag-version --release-as major",
|
|
103
|
-
"release:minor": "commit-and-tag-version --release-as minor",
|
|
104
|
-
"release:patch": "commit-and-tag-version --release-as patch",
|
|
105
101
|
"fix:biome": "biome check --write --unsafe .",
|
|
106
102
|
"fix:md": "markdownlint-cli2 --config ../../.markdownlint-cli2.jsonc --fix",
|
|
107
103
|
"fix:pkg": "sort-package-json",
|
package/src/typescript/base.json
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
"allowUnusedLabels": false,
|
|
8
8
|
"alwaysStrict": true,
|
|
9
9
|
"checkJs": false,
|
|
10
|
+
"declaration": true,
|
|
10
11
|
"esModuleInterop": true,
|
|
11
12
|
"exactOptionalPropertyTypes": false,
|
|
12
13
|
"forceConsistentCasingInFileNames": true,
|
|
13
14
|
"incremental": false,
|
|
14
15
|
"inlineSources": false,
|
|
15
|
-
"isolatedDeclarations":
|
|
16
|
+
"isolatedDeclarations": true,
|
|
16
17
|
"isolatedModules": true,
|
|
17
18
|
"module": "ESNext",
|
|
18
19
|
"moduleDetection": "force",
|