Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update commander.js to v12 #4315

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webpack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/webpack-cli/src/webpack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions test/api/CLI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Member Author

@snitin315 snitin315 Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a duplicate option now throws an error, hence updating the test case to use an existing option.

Screenshot 2024-11-04 at 9 47 34 AM


await new Promise((resolve, reject) => {
try {
cli.run(["help", "--color"], { from: "user" });
cli.run(["help", "--mode"], { from: "user" });
resolve();
} catch (error) {
reject(error);
Expand Down
12 changes: 6 additions & 6 deletions test/api/__snapshots__/CLI.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
exports[`CLI API custom help output should display help information 1`] = `
[
[
"Usage: webpack --color [value]",
"Usage: webpack --mode <value>",
],
[
"Description: any color",
"Description: Enable production optimizations or development hints.",
],
[
"Default value: "blue"",
"Possible values: "development | production | none"",
],
[
"",
Expand All @@ -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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snitin315 Why it was changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-akait Test case was updated to use --mode instead of --color.
#4315 (comment)

],
]
`;
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading