From 95b51e8cb4620cac855a90dbcb8388c4d128d4a9 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 4 Nov 2024 09:48:01 +0530 Subject: [PATCH 1/3] chore: update commander.js to v12 --- packages/webpack-cli/package.json | 2 +- test/api/CLI.test.js | 4 +--- yarn.lock | 5 ----- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 86b25c2d5e3..6c406a3cfb7 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -39,7 +39,7 @@ "@webpack-cli/info": "^2.0.2", "@webpack-cli/serve": "^2.0.5", "colorette": "^2.0.14", - "commander": "^10.0.1", + "commander": "^12.1.0", "cross-spawn": "^7.0.3", "envinfo": "^7.14.0", "fastest-levenshtein": "^1.0.12", diff --git a/test/api/CLI.test.js b/test/api/CLI.test.js index a9f490a3d8f..bb4b4601505 100644 --- a/test/api/CLI.test.js +++ b/test/api/CLI.test.js @@ -1703,11 +1703,9 @@ describe("CLI API", () => { consoleSpy = jest.spyOn(global.console, "log"); exitSpy = jest.spyOn(process, "exit").mockImplementation(() => {}); - cli.program.option("--color [value]", "any color", "blue"); - await new Promise((resolve, reject) => { try { - cli.run(["help", "--color"], { from: "user" }); + cli.run(["help", "--mode"], { from: "user" }); resolve(); } catch (error) { reject(error); diff --git a/yarn.lock b/yarn.lock index 70fa3bf0311..920fcca0e6a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4142,11 +4142,6 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" -commander@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" - integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== - commander@^12.1.0, commander@~12.1.0: version "12.1.0" resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" From 3d5089caeb9e68b796056ea07b5660495d245863 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 4 Nov 2024 09:50:19 +0530 Subject: [PATCH 2/3] test: update snapshots --- test/api/__snapshots__/CLI.test.js.snap.webpack5 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/api/__snapshots__/CLI.test.js.snap.webpack5 b/test/api/__snapshots__/CLI.test.js.snap.webpack5 index 1df97468a75..40b8c08886a 100644 --- a/test/api/__snapshots__/CLI.test.js.snap.webpack5 +++ b/test/api/__snapshots__/CLI.test.js.snap.webpack5 @@ -3,13 +3,13 @@ exports[`CLI API custom help output should display help information 1`] = ` [ [ - "Usage: webpack --color [value]", + "Usage: webpack --mode ", ], [ - "Description: any color", + "Description: Enable production optimizations or development hints.", ], [ - "Default value: "blue"", + "Possible values: "development | production | none"", ], [ "", @@ -19,13 +19,13 @@ exports[`CLI API custom help output should display help information 1`] = ` ", ], [ - "Webpack documentation: https://webpack.js.org/.", + "Webpack documentation: https://webpack.js.org/.", ], [ - "CLI documentation: https://webpack.js.org/api/cli/.", + "CLI documentation: https://webpack.js.org/api/cli/.", ], [ - "Made with ♥ by the webpack team.", + "Made with ♥ by the webpack team.", ], ] `; From e5ea5d0000b9152f4791cdf4c6c1706a892cbbd1 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 4 Nov 2024 10:21:47 +0530 Subject: [PATCH 3/3] chore: migrate to helpCommand from addHelpCommand --- packages/webpack-cli/src/webpack-cli.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 2478db9cdf7..5fdb737542a 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -1668,7 +1668,8 @@ class WebpackCLI implements IWebpackCLI { process.exit(0); }; this.program.helpOption(false); - this.program.addHelpCommand(false); + // Suppress the default help command + this.program.helpCommand(false); this.program.option("-h, --help [verbose]", "Display help for commands and options."); let isInternalActionCalled = false;