From 9283fb13cae099c4898f65f368bb605ccb0294ea Mon Sep 17 00:00:00 2001 From: Jason Galea Date: Thu, 5 Nov 2026 11:37:15 +1000 Subject: [PATCH] fix(cli): report the package version from --version The version was hardcoded as 0.1.0 in the first scaffold and never updated. Read it from package.json like the client header does. The command definition moves out of index.ts so a test can import it without running the CLI. --- .changeset/cli-version-from-package.md | 5 +++++ src/index.ts | 28 ++------------------------ src/main.test.ts | 9 +++++++++ src/main.ts | 27 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 .changeset/cli-version-from-package.md create mode 100644 src/main.test.ts create mode 100644 src/main.ts diff --git a/.changeset/cli-version-from-package.md b/.changeset/cli-version-from-package.md new file mode 100644 index 0000000..b217477 --- /dev/null +++ b/.changeset/cli-version-from-package.md @@ -0,0 +1,5 @@ +--- +"@makespdf/cli": patch +--- + +`makespdf --version` now prints the installed version. It always printed `0.1.0`. diff --git a/src/index.ts b/src/index.ts index 09a65ae..399d2cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,28 +1,4 @@ -import { defineCommand, runMain } from "citty"; -import { authCommand } from "./commands/auth.js"; -import { loginCommand } from "./commands/login.js"; -import { mdCommand } from "./commands/md.js"; -import { previewCommand } from "./commands/preview.js"; -import { renderCommand } from "./commands/render.js"; -import { skillCommand } from "./commands/skill.js"; -import { validateCommand } from "./commands/validate.js"; - -const main = defineCommand({ - meta: { - name: "makespdf", - version: "0.1.0", - description: - "Command-line interface for makesPDF — convert markdown and templates to PDF from the terminal.", - }, - subCommands: { - md: mdCommand, - preview: previewCommand, - render: renderCommand, - validate: validateCommand, - login: loginCommand, - auth: authCommand, - skill: skillCommand, - }, -}); +import { runMain } from "citty"; +import { main } from "./main.js"; runMain(main); diff --git a/src/main.test.ts b/src/main.test.ts new file mode 100644 index 0000000..4ddca87 --- /dev/null +++ b/src/main.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from "vitest"; +import pkg from "../package.json"; +import { main } from "./main.js"; + +describe("makespdf command", () => { + it("reports the package version", () => { + expect((main.meta as { version?: string }).version).toBe(pkg.version); + }); +}); diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..50fca7c --- /dev/null +++ b/src/main.ts @@ -0,0 +1,27 @@ +import { defineCommand } from "citty"; +import { CLIENT_VERSION } from "./client-info.js"; +import { authCommand } from "./commands/auth.js"; +import { loginCommand } from "./commands/login.js"; +import { mdCommand } from "./commands/md.js"; +import { previewCommand } from "./commands/preview.js"; +import { renderCommand } from "./commands/render.js"; +import { skillCommand } from "./commands/skill.js"; +import { validateCommand } from "./commands/validate.js"; + +export const main = defineCommand({ + meta: { + name: "makespdf", + version: CLIENT_VERSION, + description: + "Command-line interface for makesPDF — convert markdown and templates to PDF from the terminal.", + }, + subCommands: { + md: mdCommand, + preview: previewCommand, + render: renderCommand, + validate: validateCommand, + login: loginCommand, + auth: authCommand, + skill: skillCommand, + }, +});