From d21d05f3e60c4dcffaee60e88c2c9ab5a809a8e5 Mon Sep 17 00:00:00 2001 From: Sweets Sweetman Date: Wed, 25 Feb 2026 11:05:15 -0500 Subject: [PATCH 1/2] fix: read CLI version from package.json at runtime The version was hardcoded as "0.1.0" in bin.ts, so every published version reported itself as 0.1.0 regardless of the actual version. Also reorders the publish workflow to bump version before building, so the built artifact includes the correct version. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/publish.yml | 4 ++-- __tests__/bin.test.ts | 20 ++++++++++++++++++++ src/bin.ts | 7 ++++++- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 __tests__/bin.test.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bcabe1d..5779a3d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,8 +31,6 @@ jobs: - run: pnpm test - - run: pnpm build - - name: Bump patch version run: | git config user.name "github-actions[bot]" @@ -43,6 +41,8 @@ jobs: git commit -m "chore: bump version to $VERSION [skip ci]" git push + - run: pnpm build + - name: Publish to npm run: pnpm publish --no-git-checks env: diff --git a/__tests__/bin.test.ts b/__tests__/bin.test.ts new file mode 100644 index 0000000..aa1c0ea --- /dev/null +++ b/__tests__/bin.test.ts @@ -0,0 +1,20 @@ +import { describe, it, expect } from "vitest"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { execFileSync } from "node:child_process"; + +describe("CLI version", () => { + it("reports the version from package.json", () => { + const pkg = JSON.parse( + readFileSync(join(__dirname, "..", "package.json"), "utf-8"), + ); + + const output = execFileSync( + "node", + [join(__dirname, "..", "dist", "bin.cjs"), "--version"], + { encoding: "utf-8" }, + ).trim(); + + expect(output).toBe(pkg.version); + }); +}); diff --git a/src/bin.ts b/src/bin.ts index 88057fb..0312632 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -1,3 +1,5 @@ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; import { Command } from "commander"; import { whoamiCommand } from "./commands/whoami.js"; import { artistsCommand } from "./commands/artists.js"; @@ -6,12 +8,15 @@ import { sandboxesCommand } from "./commands/sandboxes.js"; import { notificationsCommand } from "./commands/notifications.js"; import { orgsCommand } from "./commands/orgs.js"; +const pkgPath = join(__dirname, "..", "package.json"); +const { version } = JSON.parse(readFileSync(pkgPath, "utf-8")); + const program = new Command(); program .name("recoup") .description("Recoup platform CLI") - .version("0.1.0"); + .version(version); program.addCommand(whoamiCommand); program.addCommand(artistsCommand); From c15c19aba1c00188ec35290bc1f44b6502cfcb15 Mon Sep 17 00:00:00 2001 From: Sweets Sweetman Date: Wed, 25 Feb 2026 11:07:04 -0500 Subject: [PATCH 2/2] fix: build before test in CI workflow The version test requires dist/bin.cjs to exist. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f62e8ca..a2df4b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,6 @@ jobs: - run: pnpm install --frozen-lockfile - - run: pnpm test - - run: pnpm build + + - run: pnpm test