singularity-forge/scripts/bump-version.mjs

90 lines
2.9 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
2026-05-05 14:46:18 +02:00
import { execSync } from "node:child_process";
/**
* Bump version in package.json, then sync platform packages and pkg/package.json.
* Usage: node scripts/bump-version.mjs <new-version>
*/
2026-05-05 14:46:18 +02:00
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const __dirname = import.meta.dirname;
const root = resolve(__dirname, "..");
const newVersion = process.argv[2];
if (!newVersion || !/^\d+\.\d+\.\d+$/.test(newVersion)) {
2026-05-05 14:31:16 +02:00
console.error("Usage: node scripts/bump-version.mjs <X.Y.Z>");
process.exit(1);
}
// 1. Update root package.json
const pkgPath = resolve(root, "package.json");
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
const oldVersion = pkg.version;
pkg.version = newVersion;
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
console.log(`[bump-version] package.json: ${oldVersion}${newVersion}`);
fix(release): sync all workspace versions and harden release scripts Two bugs were causing version drift across the repo: 1. Root package.json was silently reverted from 2.74.0 → 2.73.1 during commit b03c9401c (a CI optimization rebase). Tag v2.74.0 is already published on npm, so the next release would have computed 2.73.2 — lower than what's already out — and shipped a broken version. 2. scripts/bump-version.mjs only touches pi-coding-agent + pkg + native platform shims. Other workspace packages drift independently: - @gsd-build/mcp-server: stuck at 2.52.0 (22 minor versions behind) - @gsd-build/rpc-client: stuck at 2.52.0 - @gsd/pi-ai, pi-tui, pi-agent-core: stuck at 0.57.1 - @gsd/native, @gsd-build/daemon: stuck at 0.1.0 Changes: - Bump all non-private workspace packages to 2.74.0 to match the latest release tag. Update daemon + mcp-server's internal rpc-client dep from ^2.52.0 → ^2.74.0. Regenerate root lockfile. - scripts/generate-changelog.mjs: compute newVersion from max(latest stable tag, package.json) instead of package.json alone. Prevents version regressions when package.json is accidentally clobbered by rebases or merges. - scripts/bump-version.mjs: extend to sync all eight non-private workspace packages (daemon, mcp-server, native, pi-agent-core, pi-ai, pi-coding-agent, pi-tui, rpc-client) including their internal deps on each other. Private packages (studio, web) are left alone. Studio and web remain on their own versioning (private: true, never published). The native platform shims under native/npm/* are still synced via native/scripts/sync-platform-versions.cjs from the root version as before.
2026-04-14 19:35:28 -05:00
// 2. Update all non-private workspace packages under packages/
// These share the root version to keep the repo's source of truth coherent
// with what ships. The web package is private and has its own lifecycle.
fix(release): sync all workspace versions and harden release scripts Two bugs were causing version drift across the repo: 1. Root package.json was silently reverted from 2.74.0 → 2.73.1 during commit b03c9401c (a CI optimization rebase). Tag v2.74.0 is already published on npm, so the next release would have computed 2.73.2 — lower than what's already out — and shipped a broken version. 2. scripts/bump-version.mjs only touches pi-coding-agent + pkg + native platform shims. Other workspace packages drift independently: - @gsd-build/mcp-server: stuck at 2.52.0 (22 minor versions behind) - @gsd-build/rpc-client: stuck at 2.52.0 - @gsd/pi-ai, pi-tui, pi-agent-core: stuck at 0.57.1 - @gsd/native, @gsd-build/daemon: stuck at 0.1.0 Changes: - Bump all non-private workspace packages to 2.74.0 to match the latest release tag. Update daemon + mcp-server's internal rpc-client dep from ^2.52.0 → ^2.74.0. Regenerate root lockfile. - scripts/generate-changelog.mjs: compute newVersion from max(latest stable tag, package.json) instead of package.json alone. Prevents version regressions when package.json is accidentally clobbered by rebases or merges. - scripts/bump-version.mjs: extend to sync all eight non-private workspace packages (daemon, mcp-server, native, pi-agent-core, pi-ai, pi-coding-agent, pi-tui, rpc-client) including their internal deps on each other. Private packages (studio, web) are left alone. Studio and web remain on their own versioning (private: true, never published). The native platform shims under native/npm/* are still synced via native/scripts/sync-platform-versions.cjs from the root version as before.
2026-04-14 19:35:28 -05:00
const workspacePackages = [
2026-05-05 14:31:16 +02:00
"daemon",
"native",
"pi-agent-core",
"pi-ai",
"pi-coding-agent",
"pi-tui",
"rpc-client",
fix(release): sync all workspace versions and harden release scripts Two bugs were causing version drift across the repo: 1. Root package.json was silently reverted from 2.74.0 → 2.73.1 during commit b03c9401c (a CI optimization rebase). Tag v2.74.0 is already published on npm, so the next release would have computed 2.73.2 — lower than what's already out — and shipped a broken version. 2. scripts/bump-version.mjs only touches pi-coding-agent + pkg + native platform shims. Other workspace packages drift independently: - @gsd-build/mcp-server: stuck at 2.52.0 (22 minor versions behind) - @gsd-build/rpc-client: stuck at 2.52.0 - @gsd/pi-ai, pi-tui, pi-agent-core: stuck at 0.57.1 - @gsd/native, @gsd-build/daemon: stuck at 0.1.0 Changes: - Bump all non-private workspace packages to 2.74.0 to match the latest release tag. Update daemon + mcp-server's internal rpc-client dep from ^2.52.0 → ^2.74.0. Regenerate root lockfile. - scripts/generate-changelog.mjs: compute newVersion from max(latest stable tag, package.json) instead of package.json alone. Prevents version regressions when package.json is accidentally clobbered by rebases or merges. - scripts/bump-version.mjs: extend to sync all eight non-private workspace packages (daemon, mcp-server, native, pi-agent-core, pi-ai, pi-coding-agent, pi-tui, rpc-client) including their internal deps on each other. Private packages (studio, web) are left alone. Studio and web remain on their own versioning (private: true, never published). The native platform shims under native/npm/* are still synced via native/scripts/sync-platform-versions.cjs from the root version as before.
2026-04-14 19:35:28 -05:00
];
for (const name of workspacePackages) {
2026-05-05 14:31:16 +02:00
const wsPath = resolve(root, "packages", name, "package.json");
if (!existsSync(wsPath)) continue;
const ws = JSON.parse(readFileSync(wsPath, "utf-8"));
const wsOld = ws.version;
ws.version = newVersion;
// Bump any internal @singularity-forge/* or @singularity-forge/* dep references to match.
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
if (!ws[field]) continue;
for (const dep of Object.keys(ws[field])) {
if (
workspacePackages.some(
(n) =>
dep === `@singularity-forge/${n}` ||
dep === `@singularity-forge/${n}`,
)
) {
ws[field][dep] = `^${newVersion}`;
}
}
}
writeFileSync(wsPath, JSON.stringify(ws, null, 2) + "\n");
console.log(`[bump-version] ${name}: ${wsOld}${newVersion}`);
fix(release): sync all workspace versions and harden release scripts Two bugs were causing version drift across the repo: 1. Root package.json was silently reverted from 2.74.0 → 2.73.1 during commit b03c9401c (a CI optimization rebase). Tag v2.74.0 is already published on npm, so the next release would have computed 2.73.2 — lower than what's already out — and shipped a broken version. 2. scripts/bump-version.mjs only touches pi-coding-agent + pkg + native platform shims. Other workspace packages drift independently: - @gsd-build/mcp-server: stuck at 2.52.0 (22 minor versions behind) - @gsd-build/rpc-client: stuck at 2.52.0 - @gsd/pi-ai, pi-tui, pi-agent-core: stuck at 0.57.1 - @gsd/native, @gsd-build/daemon: stuck at 0.1.0 Changes: - Bump all non-private workspace packages to 2.74.0 to match the latest release tag. Update daemon + mcp-server's internal rpc-client dep from ^2.52.0 → ^2.74.0. Regenerate root lockfile. - scripts/generate-changelog.mjs: compute newVersion from max(latest stable tag, package.json) instead of package.json alone. Prevents version regressions when package.json is accidentally clobbered by rebases or merges. - scripts/bump-version.mjs: extend to sync all eight non-private workspace packages (daemon, mcp-server, native, pi-agent-core, pi-ai, pi-coding-agent, pi-tui, rpc-client) including their internal deps on each other. Private packages (studio, web) are left alone. Studio and web remain on their own versioning (private: true, never published). The native platform shims under native/npm/* are still synced via native/scripts/sync-platform-versions.cjs from the root version as before.
2026-04-14 19:35:28 -05:00
}
// 3. Sync platform package versions (reads from root package.json)
2026-05-05 14:31:16 +02:00
execSync("node rust-engine/scripts/sync-platform-versions.cjs", {
cwd: root,
stdio: "inherit",
});
// 4. Sync pkg/package.json (reads from pi-coding-agent)
execSync("node scripts/sync-pkg-version.cjs", { cwd: root, stdio: "inherit" });
// 5. Regenerate root package-lock.json to match the new version.
// --package-lock-only updates the lockfile in-place without touching node_modules.
2026-05-05 14:31:16 +02:00
execSync("npm install --package-lock-only --ignore-scripts", {
cwd: root,
stdio: "inherit",
});
console.log(`[bump-version] package-lock.json regenerated at ${newVersion}`);
// 6. Regenerate web/package-lock.json if the web app is present.
const webDir = resolve(root, "web");
if (existsSync(webDir)) {
2026-05-05 14:31:16 +02:00
execSync("npm install --package-lock-only --ignore-scripts", {
cwd: webDir,
stdio: "inherit",
});
console.log(`[bump-version] web/package-lock.json regenerated`);
}