Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
fix(release): keep manifest formatting when syncing VERSION
Eren3f4ee6d888d3
diff --git a/packages/cli/test/sync-version.test.ts b/packages/cli/test/sync-version.test.tsindex e2af8eb..83b7abb 100644--- a/packages/cli/test/sync-version.test.ts+++ b/packages/cli/test/sync-version.test.ts@@ -23,6 +23,35 @@ describe("sync-version", () => {expect(syncVersion(root).changed).toEqual([]);});+ it("changes only the version string, keeping the file's formatting", async () => {+ const root = await tempDir();+ await writeFile(join(root, "VERSION"), "2.0.0\n");+ const original = `{\n "name": "x",\n "version": "0.1.0",\n "keywords": ["a", "b"]\n}\n`;+ for (const rel of TARGETS as string[]) {+ await mkdir(join(root, rel, ".."), { recursive: true });+ await writeFile(join(root, rel), original);+ }+ syncVersion(root);+ const updated = await readFile(join(root, TARGETS[0] as string), "utf8");+ expect(updated).toBe(original.replace("0.1.0", "2.0.0"));+ });++ it("writes a version into a manifest that has none", async () => {+ const root = await tempDir();+ await writeFile(join(root, "VERSION"), "2.0.0\n");+ for (const rel of TARGETS as string[]) {+ await mkdir(join(root, rel, ".."), { recursive: true });+ await writeFile(join(root, rel), '{"name":"x"}');+ }+ syncVersion(root);+ for (const rel of TARGETS as string[]) {+ expect(JSON.parse(await readFile(join(root, rel), "utf8"))).toEqual({+ name: "x",+ version: "2.0.0",+ });+ }+ });+it("leaves this repository unchanged when it is already in sync", () => {expect(run(() => {})).toEqual([]);});diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjsindex 5d55c66..76b796f 100644--- a/scripts/sync-version.mjs+++ b/scripts/sync-version.mjs@@ -12,10 +12,14 @@ export function syncVersion(root) {const changed = [];for (const rel of TARGETS) {const file = join(root, rel);- const json = JSON.parse(readFileSync(file, "utf8"));+ const text = readFileSync(file, "utf8");+ const json = JSON.parse(text);if (json.version === version) continue;- json.version = version;- writeFileSync(file, `${JSON.stringify(json, null, 2)}\n`);+ // Replace only the version string, so the file keeps the formatting the repo+ // lints. A file without one is written fresh.+ const next = text.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);+ const fallback = `${JSON.stringify({ ...json, version }, null, 2)}\n`;+ writeFileSync(file, next === text ? fallback : next);changed.push(rel);}return { version, changed };