From f56b0e0f0465d41098c83686f033ca10b7882ae6 Mon Sep 17 00:00:00 2001 From: Facundo Farias Date: Sat, 24 Oct 2026 18:57:08 +0200 Subject: [PATCH] fix: single version source for --version and the client header src/index.ts still reported 0.2.0. VERSION now lives in client.ts and feeds both --version and X-PixelVault-Client; a test fails if it drifts from package.json. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_019sMZVurbKqZ6zsbUYCsLJn --- src/index.ts | 3 ++- src/lib/client.ts | 5 +++-- tests/lib/version.test.ts | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/lib/version.test.ts diff --git a/src/index.ts b/src/index.ts index 83550fd..a2695e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,12 @@ import { defineCommand, runMain } from "citty"; import { CliError } from "./lib/errors.js"; +import { VERSION } from "./lib/client.js"; import { stderr } from "./lib/output.js"; const main = defineCommand({ meta: { name: "pixelvault", - version: "0.2.0", + version: VERSION, description: "CLI for PixelVault — agent-first image hosting", }, subCommands: { diff --git a/src/lib/client.ts b/src/lib/client.ts index 8ec1c0f..cf4d9d5 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -16,8 +16,9 @@ interface ApiError { // Identifies the CLI to the API so signups made through it can be attributed to // this channel (server reads X-PixelVault-Client at register/device-login — see // pixelvault docs/specs/lead-attribution.md). Keep the version in sync with -// package.json on release. -const CLIENT_ID = "pixelvault-cli/0.6.0"; +// package.json on release (tests/lib/version.test.ts fails if they drift). +export const VERSION = "0.6.0"; +const CLIENT_ID = `pixelvault-cli/${VERSION}`; /** CliError carrying the API's machine-readable error details. */ export class ApiRequestError extends CliError { diff --git a/tests/lib/version.test.ts b/tests/lib/version.test.ts new file mode 100644 index 0000000..43a9dc8 --- /dev/null +++ b/tests/lib/version.test.ts @@ -0,0 +1,10 @@ +import { readFileSync } from "node:fs"; +import { describe, it, expect } from "vitest"; +import { VERSION } from "../../src/lib/client.js"; + +describe("version", () => { + it("matches package.json, so --version and the X-PixelVault-Client header never go stale", () => { + const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")); + expect(VERSION).toBe(pkg.version); + }); +});