From 38f3c6f2b99f098d2f4afd60f005e8ff5cd44435 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 21 Aug 2023 09:20:27 +0530 Subject: [PATCH] feat: output pnpm version with `info`/`version` command (#3906) * feat: output pnpm version with `info`/`version` command * ci: setup pnpm for tests * chore: update comment --- .github/workflows/nodejs.yml | 5 +++++ packages/webpack-cli/package.json | 2 +- packages/webpack-cli/src/webpack-cli.ts | 2 +- test/info/additional-package.test.js | 4 ++++ test/info/basic.test.js | 2 ++ test/info/output.test.js | 1 + test/version/additional-package.test.js | 4 ++++ test/version/basic.test.js | 5 +++++ test/version/output.test.js | 1 + yarn.lock | 2 +- 10 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 07b5c3bc21c..aaa74a88783 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -82,6 +82,11 @@ jobs: node-version: ${{ matrix.node-version }} cache: "yarn" + # Setup pnpm v7 for tests which is compatible with Node.js >=14 + - uses: pnpm/action-setup@v2 + with: + version: 7 + - name: Install dependencies run: yarn --frozen-lockfile --ignore-engines diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index bf3179676b8..027ff3ad6df 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -41,7 +41,7 @@ "colorette": "^2.0.14", "commander": "^10.0.1", "cross-spawn": "^7.0.3", - "envinfo": "^7.7.3", + "envinfo": "^7.10.0", "fastest-levenshtein": "^1.0.12", "import-local": "^3.0.2", "interpret": "^3.1.1", diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 65ac8550de2..4d94683c2b6 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -475,7 +475,7 @@ class WebpackCLI implements IWebpackCLI { } const defaultInformation: Information = { - Binaries: ["Node", "Yarn", "npm"], + Binaries: ["Node", "Yarn", "npm", "pnpm"], Browsers: [ "Brave Browser", "Chrome", diff --git a/test/info/additional-package.test.js b/test/info/additional-package.test.js index a990bcc0cab..2560b771191 100644 --- a/test/info/additional-package.test.js +++ b/test/info/additional-package.test.js @@ -17,6 +17,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); }); @@ -33,6 +34,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); }); @@ -51,6 +53,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); expect(stdout).toContain("eslint"); expect(stdout).toContain("eslint-config-prettier"); @@ -72,6 +75,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); expect(stdout).toContain("eslint"); expect(stdout).toContain("eslint-config-prettier"); diff --git a/test/info/basic.test.js b/test/info/basic.test.js index 2bf135d795e..cb95d46c2a2 100644 --- a/test/info/basic.test.js +++ b/test/info/basic.test.js @@ -11,6 +11,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("should work and gets more info in project root", async () => { @@ -24,6 +25,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("shows an appropriate warning on supplying unknown args", async () => { diff --git a/test/info/output.test.js b/test/info/output.test.js index 65404891648..0fb93d6819a 100644 --- a/test/info/output.test.js +++ b/test/info/output.test.js @@ -12,6 +12,7 @@ describe("'-o, --output ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("gets info as json", async () => { diff --git a/test/version/additional-package.test.js b/test/version/additional-package.test.js index 0f71229b894..8ca3dac67d6 100644 --- a/test/version/additional-package.test.js +++ b/test/version/additional-package.test.js @@ -17,6 +17,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); }); @@ -33,6 +34,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); }); @@ -51,6 +53,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); expect(stdout).toContain("eslint"); expect(stdout).toContain("eslint-config-prettier"); @@ -72,6 +75,7 @@ describe("'-a, --additional-package ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); expect(stdout).toContain("typescript"); expect(stdout).toContain("eslint"); expect(stdout).toContain("eslint-config-prettier"); diff --git a/test/version/basic.test.js b/test/version/basic.test.js index 568e85b5362..d6323073c9c 100644 --- a/test/version/basic.test.js +++ b/test/version/basic.test.js @@ -11,6 +11,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("should work with v alias", async () => { @@ -22,6 +23,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("should work with --version", async () => { @@ -33,6 +35,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("should work with -v alias", async () => { @@ -44,6 +47,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("should work and gets more info in project root", async () => { @@ -57,6 +61,7 @@ describe("basic usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("shows an appropriate warning on supplying unknown args", async () => { diff --git a/test/version/output.test.js b/test/version/output.test.js index 1c2f7f04448..c1ce24e27c2 100644 --- a/test/version/output.test.js +++ b/test/version/output.test.js @@ -12,6 +12,7 @@ describe("'-o, --output ' usage", () => { expect(stdout).toContain("Node"); expect(stdout).toContain("npm"); expect(stdout).toContain("Yarn"); + expect(stdout).toContain("pnpm"); }); it("gets info as json", async () => { diff --git a/yarn.lock b/yarn.lock index a4f3a29f45e..471e61e7c25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5134,7 +5134,7 @@ env-paths@^2.2.0: resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== -envinfo@^7.7.3, envinfo@^7.7.4: +envinfo@^7.10.0, envinfo@^7.7.4: version "7.10.0" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.10.0.tgz#55146e3909cc5fe63c22da63fb15b05aeac35b13" integrity sha512-ZtUjZO6l5mwTHvc1L9+1q5p/R3wTopcfqMW8r5t8SJSKqeVI/LtajORwRFEKpEFuekjD0VBjwu1HMxL4UalIRw==