From 61dfd6fa922a963484915cf39a432ee43a410689 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Sun, 12 Apr 2026 02:28:53 -0700 Subject: [PATCH] fix: keep lockfile release version in sync --- scripts/release.sh | 24 ++++++++++++++++++++++-- tests/plugin-manifest.test.js | 8 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 7e93acf4..e433ff85 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -6,6 +6,7 @@ set -euo pipefail VERSION="${1:-}" ROOT_PACKAGE_JSON="package.json" +PACKAGE_LOCK_JSON="package-lock.json" PLUGIN_JSON=".claude-plugin/plugin.json" MARKETPLACE_JSON=".claude-plugin/marketplace.json" CODEX_PLUGIN_JSON=".codex-plugin/plugin.json" @@ -45,7 +46,7 @@ if ! git diff --quiet || ! git diff --cached --quiet; then fi # Verify versioned manifests exist -for FILE in "$ROOT_PACKAGE_JSON" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$README_FILE"; do +for FILE in "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_JSON" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$README_FILE"; do if [[ ! -f "$FILE" ]]; then echo "Error: $FILE not found" exit 1 @@ -77,6 +78,24 @@ update_version() { fi } +update_package_lock_version() { + node -e ' + const fs = require("fs"); + const file = process.argv[1]; + const version = process.argv[2]; + const lock = JSON.parse(fs.readFileSync(file, "utf8")); + if (!lock || typeof lock !== "object") { + console.error(`Error: ${file} does not contain a JSON object`); + process.exit(1); + } + lock.version = version; + if (lock.packages && lock.packages[""] && typeof lock.packages[""] === "object") { + lock.packages[""].version = version; + } + fs.writeFileSync(file, `${JSON.stringify(lock, null, 2)}\n`); + ' "$PACKAGE_LOCK_JSON" "$VERSION" +} + update_readme_version_row() { node -e ' const fs = require("fs"); @@ -97,6 +116,7 @@ update_readme_version_row() { # Update all shipped package/plugin manifests update_version "$ROOT_PACKAGE_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" +update_package_lock_version update_version "$PLUGIN_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" update_version "$MARKETPLACE_JSON" "0,/\"version\": *\"[^\"]*\"/s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" update_version "$CODEX_PLUGIN_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" @@ -104,7 +124,7 @@ update_version "$OPENCODE_PACKAGE_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": update_readme_version_row # Stage, commit, tag, and push -git add "$ROOT_PACKAGE_JSON" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$README_FILE" +git add "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_JSON" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$README_FILE" git commit -m "chore: bump plugin version to $VERSION" git tag "v$VERSION" git push origin main "v$VERSION" diff --git a/tests/plugin-manifest.test.js b/tests/plugin-manifest.test.js index 1f7c3ad0..9522d193 100644 --- a/tests/plugin-manifest.test.js +++ b/tests/plugin-manifest.test.js @@ -21,6 +21,7 @@ const path = require('path'); const repoRoot = path.resolve(__dirname, '..'); const repoRootWithSep = `${repoRoot}${path.sep}`; const packageJsonPath = path.join(repoRoot, 'package.json'); +const packageLockPath = path.join(repoRoot, 'package-lock.json'); const opencodePackageJsonPath = path.join(repoRoot, '.opencode', 'package.json'); let passed = 0; @@ -67,12 +68,19 @@ function assertSafeRepoRelativePath(relativePath, label) { } const rootPackage = loadJsonObject(packageJsonPath, 'package.json'); +const packageLock = loadJsonObject(packageLockPath, 'package-lock.json'); const expectedVersion = rootPackage.version; test('package.json has version field', () => { assert.ok(expectedVersion, 'Expected package.json version field'); }); +test('package-lock.json root version matches package.json', () => { + assert.strictEqual(packageLock.version, expectedVersion); + assert.ok(packageLock.packages && packageLock.packages[''], 'Expected package-lock root package entry'); + assert.strictEqual(packageLock.packages[''].version, expectedVersion); +}); + // ── Claude plugin manifest ──────────────────────────────────────────────────── console.log('\n=== .claude-plugin/plugin.json ===\n');