@regardio/dev 2.1.0 → 2.1.1
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.
|
@@ -45,22 +45,21 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
45
45
|
}
|
|
46
46
|
console.log("\nCommits to be shipped to production:");
|
|
47
47
|
console.log(ahead);
|
|
48
|
-
if (!existsSync(join(cwd, ".changeset"))) {
|
|
49
|
-
console.error("\nNo .changeset/ directory found. This tooling requires Changesets.\nCopy the template from @regardio/dev/templates/changeset and run:\n pnpm changeset init");
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
const pendingChangesets = execFileSync("sh", ["-c", `ls .changeset/*.md 2>/dev/null | grep -v README.md | wc -l | tr -d ' '`], { encoding: "utf-8" }).trim();
|
|
53
|
-
if (pendingChangesets === "0") {
|
|
54
|
-
console.error("\nNo pending changesets. Run `pnpm changeset` before shipping to production.");
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
48
|
const packageJsonPath = join(cwd, "package.json");
|
|
58
49
|
if (!existsSync(packageJsonPath)) {
|
|
59
50
|
console.error("No package.json found in current directory.");
|
|
60
51
|
process.exit(1);
|
|
61
52
|
}
|
|
62
53
|
const { name: packageName } = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
63
|
-
|
|
54
|
+
const hasChangesets = existsSync(join(cwd, ".changeset"));
|
|
55
|
+
if (hasChangesets) {
|
|
56
|
+
const pendingChangesets = execFileSync("sh", ["-c", `ls .changeset/*.md 2>/dev/null | grep -v README.md | wc -l | tr -d ' '`], { encoding: "utf-8" }).trim();
|
|
57
|
+
if (pendingChangesets === "0") {
|
|
58
|
+
console.error("\nNo pending changesets. Run `pnpm changeset` before shipping to production.");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
console.log(`\n${pendingChangesets} pending changeset(s) will be consumed.`);
|
|
62
|
+
}
|
|
64
63
|
if (!confirm(`Ship ${packageName} to production?`)) {
|
|
65
64
|
console.log("Aborted.");
|
|
66
65
|
process.exit(0);
|
|
@@ -73,31 +72,33 @@ function runShipProduction(cwd = process.cwd()) {
|
|
|
73
72
|
process.exit(1);
|
|
74
73
|
}
|
|
75
74
|
console.log("✅ Quality checks passed");
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
if (hasChangesets) {
|
|
76
|
+
console.log("\nApplying changesets (bumping versions and updating CHANGELOGs)...");
|
|
77
|
+
runScript("changeset version");
|
|
78
|
+
try {
|
|
79
|
+
runScript("fix:pkg");
|
|
80
|
+
} catch {}
|
|
81
|
+
try {
|
|
82
|
+
git("add", "-A");
|
|
83
|
+
const changedFiles = gitRead("diff", "--cached", "--name-only").split("\n").filter(Boolean);
|
|
84
|
+
for (const file of changedFiles) {
|
|
85
|
+
if (file.endsWith(".json")) try {
|
|
86
|
+
execSync(`npx biome check --write ${file}`, {
|
|
87
|
+
cwd,
|
|
88
|
+
stdio: "inherit"
|
|
89
|
+
});
|
|
90
|
+
} catch {}
|
|
91
|
+
if (file.endsWith(".md")) try {
|
|
92
|
+
execSync(`npx markdownlint-cli2 --fix ${file}`, {
|
|
93
|
+
cwd,
|
|
94
|
+
stdio: "inherit"
|
|
95
|
+
});
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
98
|
+
} catch {}
|
|
82
99
|
git("add", "-A");
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (file.endsWith(".json")) try {
|
|
86
|
-
execSync(`npx biome check --write ${file}`, {
|
|
87
|
-
cwd,
|
|
88
|
-
stdio: "inherit"
|
|
89
|
-
});
|
|
90
|
-
} catch {}
|
|
91
|
-
if (file.endsWith(".md")) try {
|
|
92
|
-
execSync(`npx markdownlint-cli2 --fix ${file}`, {
|
|
93
|
-
cwd,
|
|
94
|
-
stdio: "inherit"
|
|
95
|
-
});
|
|
96
|
-
} catch {}
|
|
97
|
-
}
|
|
98
|
-
} catch {}
|
|
99
|
-
git("add", "-A");
|
|
100
|
-
git("commit", "-m", "chore(release): version packages");
|
|
100
|
+
git("commit", "-m", "chore(release): version packages");
|
|
101
|
+
}
|
|
101
102
|
console.log("\nMerging main into production...");
|
|
102
103
|
git("checkout", "production");
|
|
103
104
|
git("pull", "--ff-only", "origin", "production");
|
|
@@ -244,6 +244,56 @@ pnpm test # Must succeed
|
|
|
244
244
|
|
|
245
245
|
Packages that should never be published to npm must set `"private": true` in `package.json`. `changeset publish` skips them automatically. The git flow (`ship-staging`, `ship-production`, `ship-hotfix`) works identically for private packages — changesets, version bumps, and branch promotion all continue as normal; only the npm publish step is skipped.
|
|
246
246
|
|
|
247
|
+
## Workspace-Level Automation
|
|
248
|
+
|
|
249
|
+
The meta-workspace (`workspace/`) provides scripts that operate across all repos at once. Run these from the `workspace/` directory.
|
|
250
|
+
|
|
251
|
+
### Daily maintenance: safe-upgrade-and-ship
|
|
252
|
+
|
|
253
|
+
After a dependency upgrade cycle, ship everything to staging in one command:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
cd workspace
|
|
257
|
+
pnpm safe-upgrade-and-ship
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
What it does:
|
|
261
|
+
|
|
262
|
+
1. Runs `pnpm safe-upgrade` — upgrades all dependencies, runs build + lint + test + typecheck across the full workspace. Aborts if anything fails.
|
|
263
|
+
2. For every repo (workspace itself, commons, ensemble, system, channels/*): checks `git status`.
|
|
264
|
+
3. If only `package.json` and/or `pnpm-lock.yaml` changed: commits with `chore: upgrade dependencies`, pushes `main` to origin, fast-forward merges `main → staging`, pushes `staging`, returns to `main`.
|
|
265
|
+
4. If unexpected files are uncommitted: skips that repo and reports it.
|
|
266
|
+
|
|
267
|
+
No further interaction needed — husky pre-commit hooks run on the commit step, and the full quality suite already passed in step 1.
|
|
268
|
+
|
|
269
|
+
### Selective staging ship
|
|
270
|
+
|
|
271
|
+
If changes are already committed and ready:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
cd workspace
|
|
275
|
+
pnpm ship:staging
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Delegates to each repo's `ship:staging` (which re-runs quality checks per repo). Workspace itself is handled directly to avoid recursion.
|
|
279
|
+
|
|
280
|
+
### Production ship
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
cd workspace
|
|
284
|
+
pnpm ship:production
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Calls each sub-repo's `ship:production` in sequence, then promotes workspace itself (`main → production → staging`). For repos with Changesets (commons), this triggers the full version-bump flow. For app repos without Changesets (ensemble, system, channels), it promotes the branch without versioning.
|
|
288
|
+
|
|
289
|
+
### When to use each command
|
|
290
|
+
|
|
291
|
+
| Command | When |
|
|
292
|
+
|---------|------|
|
|
293
|
+
| `pnpm safe-upgrade-and-ship` | Daily/weekly dependency maintenance — upgrade all, verify all, ship all to staging |
|
|
294
|
+
| `pnpm ship:staging` | Changes are already committed; just push everything to staging |
|
|
295
|
+
| `pnpm ship:production` | Ready to go to production across all repos |
|
|
296
|
+
|
|
247
297
|
## Related
|
|
248
298
|
|
|
249
299
|
- [Commits](../standards/commits.md) — conventional commits and changelog generation
|
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.1.
|
|
4
|
+
"version": "2.1.1",
|
|
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": [
|