From 6a1495fa6058524ce7cc7ead7d14679bf36659af Mon Sep 17 00:00:00 2001 From: Adam Thompson <2414030+TheSonOfThomp@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:09:21 -0400 Subject: [PATCH] CLI version flag (#1894) * add cli version flag * Create funny-bugs-camp.md --------- Co-authored-by: Brooke Scarlett Yalof --- .changeset/funny-bugs-camp.md | 5 +++++ tools/cli/package.json | 3 ++- tools/cli/src/index.ts | 4 ++++ yarn.lock | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/funny-bugs-camp.md diff --git a/.changeset/funny-bugs-camp.md b/.changeset/funny-bugs-camp.md new file mode 100644 index 0000000000..2737377caf --- /dev/null +++ b/.changeset/funny-bugs-camp.md @@ -0,0 +1,5 @@ +--- +'@lg-tools/cli': patch +--- + +Adds CLI version flag diff --git a/tools/cli/package.json b/tools/cli/package.json index e2800648dd..2474a41218 100644 --- a/tools/cli/package.json +++ b/tools/cli/package.json @@ -24,6 +24,7 @@ "@lg-tools/test": "0.2.1", "@lg-tools/update": "0.1.1", "@lg-tools/validate": "0.1.1", - "commander": "^11.0.0" + "commander": "^11.0.0", + "read-pkg-up": "7.0.1" } } diff --git a/tools/cli/src/index.ts b/tools/cli/src/index.ts index de4152e0cd..ca7d24ea8e 100644 --- a/tools/cli/src/index.ts +++ b/tools/cli/src/index.ts @@ -7,9 +7,13 @@ import { test } from '@lg-tools/test'; import { update } from '@lg-tools/update'; import { validate } from '@lg-tools/validate'; import { Command } from 'commander'; +import { sync as readPackageUpSync } from 'read-pkg-up'; + +const pkg = readPackageUpSync({ cwd: __dirname })?.packageJson; const cli = new Command('lg'); cli + .version(pkg?.version ?? '0.0.0') .description('Command line tools for the LeafyGreen UI library by MongoDB') .enablePositionalOptions(true); diff --git a/yarn.lock b/yarn.lock index 7a5e5fe382..5924a420c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13865,7 +13865,7 @@ react@^17.0.2: loose-envify "^1.1.0" object-assign "^4.1.1" -read-pkg-up@^7.0.1: +read-pkg-up@7.0.1, read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==