Skip to content

Commit 2e2edea

Browse files
luoxuanzaoQoder-AI
andcommitted
fix(release): keep package-lock.json in sync with the version bump
Release commits bumped package.json, manifest.json and versions.json but left package-lock.json carrying the previous version, so every npm install rewrote the lock's root version and showed the file as dirty in every worktree. sync-version now rewrites the lock's root entries too, the version script stages it, and release:check fails when the two disagree. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent 76cca97 commit 2e2edea

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"smoke:qoder": "node scripts/smoke-qoder-sdk.mjs",
2424
"audit:prod": "npm audit --omit=dev",
2525
"release:check": "node scripts/validate-release.mjs",
26-
"version": "node scripts/sync-version.js && git add manifest.json versions.json"
26+
"version": "node scripts/sync-version.js && git add manifest.json versions.json package-lock.json"
2727
},
2828
"keywords": [
2929
"qodercli",

‎scripts/sync-version.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const rootDir = path.join(__dirname, '..');
77
const packagePath = path.join(rootDir, 'package.json');
88
const manifestPath = path.join(rootDir, 'manifest.json');
99
const versionsPath = path.join(rootDir, 'versions.json');
10+
const lockPath = path.join(rootDir, 'package-lock.json');
1011

1112
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
1213

@@ -15,6 +16,13 @@ manifestJson.version = packageJson.version;
1516
const minAppVersion = manifestJson.minAppVersion;
1617
fs.writeFileSync(manifestPath, `${JSON.stringify(manifestJson, null, 2)}\n`);
1718

19+
const lockJson = JSON.parse(fs.readFileSync(lockPath, 'utf8'));
20+
lockJson.version = packageJson.version;
21+
if (lockJson.packages && lockJson.packages['']) {
22+
lockJson.packages[''].version = packageJson.version;
23+
}
24+
fs.writeFileSync(lockPath, `${JSON.stringify(lockJson, null, 2)}\n`);
25+
1826
const versions = JSON.parse(fs.readFileSync(versionsPath, 'utf8'));
1927
versions[packageJson.version] = minAppVersion;
2028
const sortedVersions = Object.fromEntries(
@@ -24,4 +32,4 @@ const sortedVersions = Object.fromEntries(
2432
);
2533
fs.writeFileSync(versionsPath, `${JSON.stringify(sortedVersions, null, 2)}\n`);
2634

27-
console.log(`Synced manifest.json and versions.json to ${packageJson.version}`);
35+
console.log(`Synced manifest.json, versions.json and package-lock.json to ${packageJson.version}`);

‎scripts/validate-release.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const readJson = (relativePath) =>
1111
const packageJson = readJson('package.json');
1212
const rootManifest = readJson('manifest.json');
1313
const versions = readJson('versions.json');
14+
const lock = readJson('package-lock.json');
1415
const changelog = fs.readFileSync(path.join(rootDir, 'CHANGELOG.md'), 'utf8');
1516
const errors = [];
1617

@@ -39,6 +40,10 @@ requireCondition(
3940
packageJson.version === rootManifest.version,
4041
`package.json version (${packageJson.version}) does not match manifest version (${rootManifest.version})`,
4142
);
43+
requireCondition(
44+
lock.version === packageJson.version && lock.packages?.['']?.version === packageJson.version,
45+
`package-lock.json version (${lock.version}) does not match package.json version (${packageJson.version}); run "node scripts/sync-version.js"`,
46+
);
4247
requireCondition(
4348
versions[rootManifest.version] === rootManifest.minAppVersion,
4449
`versions.json must map ${rootManifest.version} to ${rootManifest.minAppVersion}`,

0 commit comments

Comments
 (0)