Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/version.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading