-
-
Notifications
You must be signed in to change notification settings - Fork 652
chore: merge CLI into single package #4634
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR consolidates the separate @webpack-cli/configtest, @webpack-cli/info, and @webpack-cli/serve packages into the core webpack-cli package and reworks how commands/options are wired up by delegating more behavior to Commander. It also updates the CLI API surface (e.g., makeCommand/makeOption), changes version/help behavior, and removes now-redundant sub-packages and tests.
Changes:
- Inline
configtest,info, andserveintowebpack-cli’s main CLI implementation (webpack-cli.ts), with new Commander-based command/option registration and argument processing. - Simplify and refactor CLI types and bootstrap logic, remove the legacy
IWebpackCLIinterface, and adjust logging, option construction, andinfo/versionbehavior. - Remove the now-obsolete
@webpack-cli/{configtest,info,serve}packages, update the monorepo/package references accordingly, and drop legacy help/version test suites in favor of the new command wiring.
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
Removes project references to the deprecated configtest, info, and serve sub-packages, reflecting their inlining into webpack-cli. |
packages/webpack-cli/src/types.ts |
Cleans up CLI types (removing IWebpackCLI, external-command types, ParseOptions re-export), tightens WebpackCLIOptions to Commander-centric usage, and updates LogHandler and built-in option metadata (hidden flag). |
packages/webpack-cli/src/webpack-cli.ts |
Major refactor: configures Commander output/exit behavior, centralizes logger creation, unifies built-in/core options via makeOption/getBuiltInOptions, introduces processArguments, and inlines build, watch, configtest, serve, and info/version commands directly into run(). |
packages/webpack-cli/src/bootstrap.ts |
Simplifies bootstrap to construct WebpackCLI directly, updates run parameter typing, and adds a small dev-only auto-run hook for npm_lifecycle_script === "tsx". |
packages/webpack-cli/src/index.ts |
Re-exports the main CLI class and types from webpack-cli.ts, maintaining CommonJS compatibility while moving toward a default export pattern. |
packages/webpack-cli/package.json |
Drops dependencies on @webpack-cli/configtest, @webpack-cli/info, and @webpack-cli/serve now that their functionality lives in webpack-cli proper. |
packages/serve/* |
Removes the @webpack-cli/serve package (source, tsconfig, README, changelog) now superseded by the built-in serve command. |
packages/info/* |
Removes the @webpack-cli/info package (source, tsconfig, README, changelog) in favor of an integrated info/version command in webpack-cli. |
packages/configtest/* |
Removes the @webpack-cli/configtest package (source, tsconfig, README, changelog) now handled by the internal configtest command. |
packages/README.md |
Updates package list documentation to reflect removal of the separate configtest, info, and serve sub-packages. |
.cspell.json |
Switches to useGitignore: true and trims custom ignore paths, relying more on .gitignore for spell-check exclusions. |
test/version/basic.test.js |
Removes tests for version/v/--version behavior that previously aliased to info, consistent with the breaking change that -v/--version are now no-ops and version aliases info. |
test/version/additional-package.test.js |
Drops coverage around version --additional-package in favor of the new integrated info/version behavior. |
test/version/output.test.js |
Removes tests for output-formatting flags on the old version command, to be superseded by behavior on the unified info/version command. |
test/help/help.test.js & test/help/__snapshots__/help.test.js.snap.* |
Deletes a large suite of bespoke help-behavior tests/snapshots (global and per-command help, --help verbose, error cases), reflecting the migration to Commander’s built-in help handling. |
test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 |
Updates expected stderr output format for unknown command/option cases to match Commander’s new messages (e.g., (Did you mean --entry?), new color escape sequences, and reworded unknown-command text). |
test/build/basic/basic.test.js |
Adjusts assertions for unknown-command suggestions to align with the new error wording emitted by Commander-backed parsing (e.g., "Unknown command 'buil'" and (Did you mean build?)). |
test/api/__snapshots__/CLI.test.js.snap.webpack5 |
Removes the snapshot for the “custom help output” test, which is no longer valid under the new Commander-centered help implementation. |
test/api/CLI.test.js |
Reworks the CLI API tests to target the new makeCommand and makeOption signatures/behavior, including complex option shapes (configs, enums, multi-type options, negative flags), and drops the old “custom help output” test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| warn: (val, raw) => log("warn", this.colors.red(util.format(val)), raw), | ||
| info: (val, raw) => log("info", this.colors.red(util.format(val)), raw), | ||
| success: (val, raw) => log("log", this.colors.red(util.format(val)), raw), | ||
| log: (val, raw) => log("error", this.colors.red(util.format(val)), raw), |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated logger implementation now colors all message types (including warn, info, and success) in red and routes log messages through the error method, which will send them to stderr instead of stdout. This is likely unintended, regresses the previous behavior where different severities used distinct colors, and can break tooling that distinguishes normal output from errors. Please restore distinct colors for each severity and have log use a non-error channel (e.g. console.log/stdout) rather than the error path.
| warn: (val, raw) => log("warn", this.colors.red(util.format(val)), raw), | |
| info: (val, raw) => log("info", this.colors.red(util.format(val)), raw), | |
| success: (val, raw) => log("log", this.colors.red(util.format(val)), raw), | |
| log: (val, raw) => log("error", this.colors.red(util.format(val)), raw), | |
| warn: (val, raw) => log("warn", this.colors.yellow(util.format(val)), raw), | |
| info: (val, raw) => log("info", this.colors.cyan(util.format(val)), raw), | |
| success: (val, raw) => log("log", this.colors.green(util.format(val)), raw), | |
| log: (val, raw) => log("log", util.format(val), raw), |
alexander-akait
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split this work step by step, i.e. package by package, it is impossible to review
|
Also no breaking changes, all breaking changes should be in the next major release |
|
And please avoid any unnecessary changes not related to just move, all refactor works should be done separably |
|
Yes, I seem to have gotten ahead of myself. Nevertheless, I'll break this up :-) |
|
Thanks |
This PR consolidates
@webpack-cli/serveand@webpack-cli/configtestintowebpack-cli(a single package), and simplifies a lot of the logic regarding loading these packages and their options (instead relying on Commander's built-in methods, i.e.helpandaction, etc)Fixes #4619
I tried my best to limit the breaking changes (since, the less breakage the better), however, note the following:
Breaking:
-vand--versionare no no-op. Theversioncommand, however, is an alias ofinfo(has not changed).1Semi-Breaking: The format and styling of several error/help outputs has changed, as these are now handled by Commander, rather than custom logic.
Semi-Breaking: The
IWebpackCLIobject has been removed, since it began to differ from the actual implementation.1Footnotes
These breaking changes can be reverted. ↩ ↩2