From 69298a4bf6c31021335d4183180c0101fe1ca2ad Mon Sep 17 00:00:00 2001 From: Kevin Stubbs Date: Thu, 13 Jun 2024 19:53:12 +0700 Subject: [PATCH 1/2] Manually handle printing the CLI version to work-around monorepo issues. --- packages/cli/src/cli/index.ts | 9 ++++++++- packages/cli/src/lib/checkUpdate.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/cli/index.ts b/packages/cli/src/cli/index.ts index f8bbbbc2..db41ba85 100755 --- a/packages/cli/src/cli/index.ts +++ b/packages/cli/src/cli/index.ts @@ -2,7 +2,7 @@ import ora from "ora"; import yargs from "yargs"; import { hideBin } from "yargs/helpers"; -import checkUpdate from "../lib/checkUpdate"; +import checkUpdate, { getPackageDetails } from "../lib/checkUpdate"; import { isProgramInstalled } from "../lib/utils"; import { printConfigurationData, @@ -59,6 +59,13 @@ yargs(hideBin(process.argv)) .middleware(configureMiddleware(checkUpdate)) .strictCommands() .demandCommand() + .version(false) + .command( + "version", + "Prints the version of this CLI", + () => void 0, + () => console.log(getPackageDetails().version), + ) .command( "init [options]", "Sets up project with required files.", diff --git a/packages/cli/src/lib/checkUpdate.ts b/packages/cli/src/lib/checkUpdate.ts index 4246efbd..38b11277 100644 --- a/packages/cli/src/lib/checkUpdate.ts +++ b/packages/cli/src/lib/checkUpdate.ts @@ -9,12 +9,17 @@ import semver from "semver"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const checkUpdate = async () => { +export function getPackageDetails() { const { name, version } = JSON.parse( fs.readFileSync(__dirname + "/../package.json").toString(), ); - const { version: latestVersion } = await pkgJson(name); + return { name, version }; +} + +const checkUpdate = async () => { + const { name, version } = getPackageDetails(); + const { version: latestVersion } = await pkgJson(name); const updateAvailable = semver.lt(version, latestVersion as string); if (updateAvailable) { const msg = { From 0c7573649ccb9dc1fb12508c65af9a798b6d337f Mon Sep 17 00:00:00 2001 From: Kevin Stubbs Date: Mon, 17 Jun 2024 23:35:28 +0700 Subject: [PATCH 2/2] Add changeset --- .changeset/brown-crabs-perform.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brown-crabs-perform.md diff --git a/.changeset/brown-crabs-perform.md b/.changeset/brown-crabs-perform.md new file mode 100644 index 00000000..0ed7c6c5 --- /dev/null +++ b/.changeset/brown-crabs-perform.md @@ -0,0 +1,5 @@ +--- +"@pantheon-systems/pcc-cli": patch +--- + +CLI replaces "--version" command with "version"