From ddff67d9a7d9d5dc5c27477b6f352cf4f5f22632 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 20 Aug 2026 16:27:55 -0400 Subject: [PATCH] fix(publish): remove unreleased optionalDependencies and dynamically resolve version above NPM registry latest --- .github/workflows/publish.yml | 47 ++++++++++++++++++++++++----------- package-lock.json | 12 ++------- package.json | 10 +------- tests/launcher.test.ts | 16 +++--------- 4 files changed, 40 insertions(+), 45 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 58df807..2a869da 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,23 +64,42 @@ jobs: TAG_VERSION="${GITHUB_REF#refs/tags/v}" echo "Publishing tagged release: $TAG_VERSION" npm version "$TAG_VERSION" --no-git-tag-version --allow-same-version - elif [ "${{ inputs.bump }}" = "patch" ]; then - npm version patch --no-git-tag-version - elif [ "${{ inputs.bump }}" = "minor" ]; then - npm version minor --no-git-tag-version - elif [ "${{ inputs.bump }}" = "major" ]; then - npm version major --no-git-tag-version elif [ "${{ inputs.bump }}" = "none" ]; then echo "Skipping version bump as requested" else - # Auto-bump: check if current version is already on NPM - EXISTS_ON_NPM=$(npm view "@heretek-ai/agent-proof@${CURRENT_PKG}" version 2>/dev/null || echo "") - if [ -n "$EXISTS_ON_NPM" ] || [ "$CURRENT_PKG" = "$LATEST_NPM" ]; then - echo "Version $CURRENT_PKG is already published to NPM. Auto-bumping patch..." - npm version patch --no-git-tag-version - else - echo "Version $CURRENT_PKG is not yet published on NPM. Proceeding with current version." - fi + TARGET_VERSION=$(node -e ' + const currentPkg = process.argv[1]; + const latestNpm = process.argv[2] || "0.0.0"; + const bumpType = process.argv[3] || "auto"; + + function parse(v) { + return v.replace(/^v/, "").split(".").map(n => parseInt(n, 10) || 0); + } + function isGte(v1, v2) { + const [a1, a2, a3] = parse(v1); + const [b1, b2, b3] = parse(v2); + if (a1 !== b1) return a1 > b1; + if (a2 !== b2) return a2 > b2; + return a3 >= b3; + } + + let targetVersion = currentPkg; + if (latestNpm !== "0.0.0" && isGte(latestNpm, currentPkg)) { + const [major, minor, patch] = parse(latestNpm); + if (bumpType === "major") targetVersion = `${major + 1}.0.0`; + else if (bumpType === "minor") targetVersion = `${major}.${minor + 1}.0`; + else targetVersion = `${major}.${minor}.${patch + 1}`; + } else if (bumpType === "major" || bumpType === "minor" || bumpType === "patch") { + const [major, minor, patch] = parse(currentPkg); + if (bumpType === "major") targetVersion = `${major + 1}.0.0`; + else if (bumpType === "minor") targetVersion = `${major}.${minor + 1}.0`; + else targetVersion = `${major}.${minor}.${patch + 1}`; + } + console.log(targetVersion); + ' "$CURRENT_PKG" "$LATEST_NPM" "${{ inputs.bump || 'auto' }}") + + echo "Setting package version to: $TARGET_VERSION" + npm version "$TARGET_VERSION" --no-git-tag-version --allow-same-version fi FINAL_VERSION=$(node -p "require('./package.json').version") diff --git a/package-lock.json b/package-lock.json index 85c5611..0148a8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@heretek-ai/agent-proof", - "version": "1.0.0", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@heretek-ai/agent-proof", - "version": "1.0.0", + "version": "1.0.2", "license": "MIT", "bin": { "agent-gate": "bin/agent-gate.js", @@ -23,14 +23,6 @@ }, "engines": { "node": ">=18.0.0" - }, - "optionalDependencies": { - "@heretek-ai/binary-darwin-arm64": "1.0.0", - "@heretek-ai/binary-darwin-x64": "1.0.0", - "@heretek-ai/binary-linux-arm64": "1.0.0", - "@heretek-ai/binary-linux-x64": "1.0.0", - "@heretek-ai/binary-win32-arm64": "1.0.0", - "@heretek-ai/binary-win32-x64": "1.0.0" } }, "node_modules/@esbuild/aix-ppc64": { diff --git a/package.json b/package.json index 5ee322d..0c65c41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@heretek-ai/agent-proof", - "version": "1.0.0", + "version": "1.0.2", "description": "Agent-Proof Mechanical Hard-Gate CLI for deterministic AI code governance", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -40,14 +40,6 @@ "prepublishOnly": "npm run build && npm test && npm run typecheck", "release:dry-run": "npm publish --dry-run" }, - "optionalDependencies": { - "@heretek-ai/binary-darwin-arm64": "1.0.0", - "@heretek-ai/binary-darwin-x64": "1.0.0", - "@heretek-ai/binary-linux-arm64": "1.0.0", - "@heretek-ai/binary-linux-x64": "1.0.0", - "@heretek-ai/binary-win32-arm64": "1.0.0", - "@heretek-ai/binary-win32-x64": "1.0.0" - }, "devDependencies": { "@types/node": "^22.13.4", "esbuild": "^0.28.2", diff --git a/tests/launcher.test.ts b/tests/launcher.test.ts index f42eb55..bd2e9b1 100644 --- a/tests/launcher.test.ts +++ b/tests/launcher.test.ts @@ -3,13 +3,13 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { execFileSync } from 'node:child_process'; -describe('Platform-Specific Binary Packaging & Launcher', () => { +describe('Platform-Specific Packaging & Launcher', () => { const rootDir = path.resolve(__dirname, '..'); const pkgJsonPath = path.join(rootDir, 'package.json'); const binScriptPath = path.join(rootDir, 'bin', 'agent-proof.js'); const binGateScriptPath = path.join(rootDir, 'bin', 'agent-gate.js'); - it('has package.json configured with complete optionalDependencies matrix pinning', () => { + it('has package.json configured with zero runtime dependencies and valid bin entrypoints', () => { const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')); expect(pkg.name).toBe('@heretek-ai/agent-proof'); @@ -19,16 +19,8 @@ describe('Platform-Specific Binary Packaging & Launcher', () => { expect(pkg.bin['agent-gate']).toBe('./bin/agent-gate.js'); expect(pkg.bin['create-agent-gate']).toBe('./bin/agent-gate.js'); - const optDeps = pkg.optionalDependencies; - expect(optDeps).toBeDefined(); - - // Verify Darwin (macOS), Linux, and Windows matrices for both x64 and arm64 - expect(optDeps['@heretek-ai/binary-darwin-arm64']).toBeDefined(); - expect(optDeps['@heretek-ai/binary-darwin-x64']).toBeDefined(); - expect(optDeps['@heretek-ai/binary-linux-arm64']).toBeDefined(); - expect(optDeps['@heretek-ai/binary-linux-x64']).toBeDefined(); - expect(optDeps['@heretek-ai/binary-win32-arm64']).toBeDefined(); - expect(optDeps['@heretek-ai/binary-win32-x64']).toBeDefined(); + // Confirm zero runtime dependencies for lean distribution + expect(pkg.dependencies).toBeUndefined(); }); it('verifies bin/agent-proof.js and bin/agent-gate.js handle CLI options via fallback', () => {