From 1b3c4a53baac4b2c6638332a8f868a774a903bc4 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Sun, 12 Apr 2026 02:32:37 -0700 Subject: [PATCH] fix: remove release version drift from locks and tests --- scripts/release.sh | 10 ++++++---- tests/lib/install-state.test.js | 11 +++++++---- tests/lib/resolve-ecc-root.test.js | 13 ++++++++----- tests/plugin-manifest.test.js | 8 ++++++++ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index e433ff85..4cee1c77 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -11,6 +11,7 @@ PLUGIN_JSON=".claude-plugin/plugin.json" MARKETPLACE_JSON=".claude-plugin/marketplace.json" CODEX_PLUGIN_JSON=".codex-plugin/plugin.json" OPENCODE_PACKAGE_JSON=".opencode/package.json" +OPENCODE_PACKAGE_LOCK_JSON=".opencode/package-lock.json" README_FILE="README.md" # Function to show usage @@ -46,7 +47,7 @@ if ! git diff --quiet || ! git diff --cached --quiet; then fi # Verify versioned manifests exist -for FILE in "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_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" "$OPENCODE_PACKAGE_LOCK_JSON" "$README_FILE"; do if [[ ! -f "$FILE" ]]; then echo "Error: $FILE not found" exit 1 @@ -93,7 +94,7 @@ update_package_lock_version() { lock.packages[""].version = version; } fs.writeFileSync(file, `${JSON.stringify(lock, null, 2)}\n`); - ' "$PACKAGE_LOCK_JSON" "$VERSION" + ' "$1" "$VERSION" } update_readme_version_row() { @@ -116,15 +117,16 @@ update_readme_version_row() { # Update all shipped package/plugin manifests update_version "$ROOT_PACKAGE_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" -update_package_lock_version +update_package_lock_version "$PACKAGE_LOCK_JSON" 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\"|" update_version "$OPENCODE_PACKAGE_JSON" "s|\"version\": *\"[^\"]*\"|\"version\": \"$VERSION\"|" +update_package_lock_version "$OPENCODE_PACKAGE_LOCK_JSON" update_readme_version_row # Stage, commit, tag, and push -git add "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_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" "$OPENCODE_PACKAGE_LOCK_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/lib/install-state.test.js b/tests/lib/install-state.test.js index 1e21018e..01011f6a 100644 --- a/tests/lib/install-state.test.js +++ b/tests/lib/install-state.test.js @@ -6,6 +6,9 @@ const assert = require('assert'); const fs = require('fs'); const os = require('os'); const path = require('path'); +const CURRENT_PACKAGE_VERSION = JSON.parse( + fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8') +).version; const { createInstallState, @@ -66,7 +69,7 @@ function runTests() { }, ], source: { - repoVersion: '1.10.0', + repoVersion: CURRENT_PACKAGE_VERSION, repoCommit: 'abc123', manifestVersion: 1, }, @@ -100,7 +103,7 @@ function runTests() { }, operations: [], source: { - repoVersion: '1.10.0', + repoVersion: CURRENT_PACKAGE_VERSION, repoCommit: 'abc123', manifestVersion: 1, }, @@ -154,7 +157,7 @@ function runTests() { }, operations: [operation], source: { - repoVersion: '1.10.0', + repoVersion: CURRENT_PACKAGE_VERSION, repoCommit: 'abc123', manifestVersion: 1, }, @@ -208,7 +211,7 @@ function runTests() { skippedModules: [], }, source: { - repoVersion: '1.10.0', + repoVersion: CURRENT_PACKAGE_VERSION, repoCommit: 'abc123', manifestVersion: 1, }, diff --git a/tests/lib/resolve-ecc-root.test.js b/tests/lib/resolve-ecc-root.test.js index 628e53a9..2d74b2d4 100644 --- a/tests/lib/resolve-ecc-root.test.js +++ b/tests/lib/resolve-ecc-root.test.js @@ -13,6 +13,9 @@ const assert = require('assert'); const fs = require('fs'); const os = require('os'); const path = require('path'); +const CURRENT_PACKAGE_VERSION = JSON.parse( + fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf8') +).version; const { resolveEccRoot, INLINE_RESOLVE } = require('../../scripts/lib/resolve-ecc-root'); @@ -181,7 +184,7 @@ function runTests() { const homeDir = createTempDir(); try { const expected = setupLegacyPluginInstall(homeDir, ['marketplace', 'ecc']); - setupPluginCache(homeDir, 'ecc', 'affaan-m', '1.10.0'); + setupPluginCache(homeDir, 'ecc', 'affaan-m', CURRENT_PACKAGE_VERSION); const result = resolveEccRoot({ envRoot: '', homeDir }); assert.strictEqual(result, expected); } finally { @@ -193,7 +196,7 @@ function runTests() { if (test('discovers plugin root from cache directory', () => { const homeDir = createTempDir(); try { - const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', '1.10.0'); + const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', CURRENT_PACKAGE_VERSION); const result = resolveEccRoot({ envRoot: '', homeDir }); assert.strictEqual(result, expected); } finally { @@ -205,7 +208,7 @@ function runTests() { const homeDir = createTempDir(); try { const claudeDir = setupStandardInstall(homeDir); - setupPluginCache(homeDir, 'ecc', 'affaan-m', '1.10.0'); + setupPluginCache(homeDir, 'ecc', 'affaan-m', CURRENT_PACKAGE_VERSION); const result = resolveEccRoot({ envRoot: '', homeDir }); assert.strictEqual(result, claudeDir, 'Standard install should take precedence over plugin cache'); @@ -218,7 +221,7 @@ function runTests() { const homeDir = createTempDir(); try { setupPluginCache(homeDir, 'everything-claude-code', 'legacy-org', '1.7.0'); - const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', '1.10.0'); + const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', CURRENT_PACKAGE_VERSION); const result = resolveEccRoot({ envRoot: '', homeDir }); // Should find one of them (either is valid) assert.ok( @@ -311,7 +314,7 @@ function runTests() { if (test('INLINE_RESOLVE discovers plugin cache when env var is unset', () => { const homeDir = createTempDir(); try { - const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', '1.10.0'); + const expected = setupPluginCache(homeDir, 'ecc', 'affaan-m', CURRENT_PACKAGE_VERSION); const { execFileSync } = require('child_process'); const result = execFileSync('node', [ '-e', `console.log(${INLINE_RESOLVE})`, diff --git a/tests/plugin-manifest.test.js b/tests/plugin-manifest.test.js index 9522d193..eaa85ea4 100644 --- a/tests/plugin-manifest.test.js +++ b/tests/plugin-manifest.test.js @@ -23,6 +23,7 @@ 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'); +const opencodePackageLockPath = path.join(repoRoot, '.opencode', 'package-lock.json'); let passed = 0; let failed = 0; @@ -69,6 +70,7 @@ function assertSafeRepoRelativePath(relativePath, label) { const rootPackage = loadJsonObject(packageJsonPath, 'package.json'); const packageLock = loadJsonObject(packageLockPath, 'package-lock.json'); +const opencodePackageLock = loadJsonObject(opencodePackageLockPath, '.opencode/package-lock.json'); const expectedVersion = rootPackage.version; test('package.json has version field', () => { @@ -351,6 +353,12 @@ test('.opencode/package.json version matches package.json', () => { assert.strictEqual(opencodePackage.version, expectedVersion); }); +test('.opencode/package-lock.json root version matches package.json', () => { + assert.strictEqual(opencodePackageLock.version, expectedVersion); + assert.ok(opencodePackageLock.packages && opencodePackageLock.packages[''], 'Expected .opencode/package-lock root package entry'); + assert.strictEqual(opencodePackageLock.packages[''].version, expectedVersion); +}); + test('README version row matches package.json', () => { const readme = fs.readFileSync(path.join(repoRoot, 'README.md'), 'utf8'); const match = readme.match(/^\| \*\*Version\*\* \| Plugin \| Plugin \| Reference config \| ([0-9][0-9.]*) \|$/m);