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, + }, +});