Skip to content

feat(cli): refresh CLI output via commander's help API + shared status icons#4779

Open
alexander-akait wants to merge 5 commits into
mainfrom
claude/issue-4736-commander-api-lc6deb
Open

feat(cli): refresh CLI output via commander's help API + shared status icons#4779
alexander-akait wants to merge 5 commits into
mainfrom
claude/issue-4736-commander-api-lc6deb

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

An alternative take on the output redesign from #4736. Instead of a separate ~400-line ui-renderer module, this drives the help screens through commander's own configureHelp/formatHelp API and keeps a small set of private UI helpers on WebpackCLI for the non-commander screens (info, version, configtest) and the shared status icons.

The redesign adds branded headers (⬡ webpack <command>), section dividers, colorized terms, a documentation footer, and status icons (///). Everything is colors-injected, so the chrome collapses to plain text when output is piped or --no-color is set — keeping output script-friendly.

Area How it's done
--help (global / command / option) commander configureHelp + formatHelp
info / version branded frame + aligned envinfo table (requested → resolved)
configtest branded frame + status icons
build / serve / watch & all commands status icons on every webpack-cli log message

What kind of change does this PR introduce?

Feature — a refreshed, more readable CLI UI, implemented with the commander API rather than a bespoke renderer.

Notable, deliberate choices (vs. #4736)

  • Help uses commander's API. The custom formatHelp is enhanced rather than replaced by a separate renderer; helper.formatItem is ANSI-aware, so terms are colorized while staying column-aligned.
  • No breaking changes to machine-readable output. --json and info/version --output json|markdown stay byte-for-byte unchanged and unframed.
  • Errors stay on stderr. configtest validation errors keep correct stream semantics (the original PR routed them to stdout).
  • Status icons are additive. Icons sit between the preserved [webpack-cli] prefix and the unchanged message text, so tooling that greps the prefix or the message keeps working. stats.toString()/--json and [webpack-dev-server] output are untouched.
  • No blanket test-harness stripping. Snapshots store the real new output (so they show the redesign) instead of de-chroming via a normalizer.

Did you add tests for your changes?

Yes. Updated the help/CLI/configtest snapshots to the new output, added a deterministic version snapshot that captures the framed table, and updated the build/serve/help snapshots that contain webpack-cli messages (icon-only changes). All non-machine-readable paths are covered by integration snapshots.

Does this PR introduce a breaking change?

The visual output of help/version/info/configtest changes, and webpack-cli log lines gain a leading status icon. Machine-readable output (--json, --output json|markdown), the [webpack-cli]/[webpack-dev-server] prefixes, and webpack's own stats output are unchanged, so scripted/extracted output keeps working.

Related

Alternative approach to #4736.

🤖 Generated with Claude Code

https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS


Generated by Claude Code

claude added 5 commits June 17, 2026 16:00
Refresh the `--help`, command help and single-option help screens with a
branded header (⬡ webpack <command>), section dividers, colorized terms and a
clearer footer, implemented through commander's `configureHelp`/`formatHelp`
API rather than a separate renderer.

Because `helper.formatItem` pads using the visible (ANSI-stripped) width, terms
can be colorized while keeping descriptions aligned. All colors and chrome
collapse to plain text when output is piped or `--no-color` is set, so scripts
that parse the output keep working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS
Extend the branded, section-divided UI (introduced for `--help`) to the
`info` and `version` commands via a shared `#renderEnvinfo` helper and the
reused `#uiHeader`/`#uiDivider` chrome. Each envinfo section gets a hexagon
header and divider, rows are aligned, and "requested => resolved" version
pairs render with a "→" arrow.

`--output json` and `--output markdown` stay byte-for-byte machine-readable,
and section titles/labels keep their trailing colon so existing tooling that
greps for "System:", "Packages:" or "webpack:" keeps working. Colors collapse
to plain text when output is piped or `--no-color` is set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS
…add renderer snapshot tests

Add `packages/webpack-cli/src/ui.ts` — small, pure, colors-injected helpers
for the CLI's visual chrome (header, divider, section title, status lines,
footer, and the envinfo table renderer). The help screens, `info`, `version`
and `configtest` now share these helpers instead of duplicating ad-hoc logging.

- `info`/`version`/`configtest` are wrapped in a branded command frame
  (⬡ header + description + documentation footer).
- `configtest` uses status icons: ✔ success / ✖ error / ⚠ warning / ℹ info.
  Errors stay on stderr (correct stream semantics), the rest on stdout.
- `--output json|markdown` for info/version remains byte-for-byte
  machine-readable and unframed.

Testing: add `test/api/ui.test.js`, a unit snapshot test that renders fixed
input through every helper with a plain palette (so the snapshots show the
exact rendered output — the "after") plus a tagged palette proving colors are
applied to the right tokens. Update the configtest and CLI snapshots to the
new framed output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS
…e ui module)

Move the shared UI "chrome" renderers from the standalone src/ui.ts module into
private `#` methods on WebpackCLI (#uiHeader, #uiDivider, #uiSectionTitle,
#uiStatusLine, #uiCommandHeader, #uiFooter, #renderEnvinfo). They read
`this.colors` directly instead of taking a palette argument — no extra file and
nothing new on the public surface.

Since `#` methods can't be unit-tested in isolation, the styled output is now
covered by integration snapshots that exercise the real commands: help and
configtest already capture the header/divider/section-title/status-icon/footer
chrome, and a new deterministic `version` snapshot captures the framed envinfo
table. Removed test/api/ui.test.js accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS
Prefix every webpack-cli logger message with a status icon — ✔ success,
✖ error, ⚠ warning, ℹ info — so build, serve and all other commands share the
same visual language as the framed help/info/version/configtest screens.

The icon sits between the existing `[webpack-cli]` prefix and the unchanged
message text, so this is non-breaking: webpack's own `stats.toString()` /
`--json` output and webpack-dev-server's messages are untouched, the
`[webpack-cli]` prefix is preserved, and tooling that greps the prefix or the
message text keeps working. Snapshots updated to include the icons.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j95RhPtEkRKfzDM4JEhdS
@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c82457e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.92473% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.94%. Comparing base (134e62d) to head (c82457e).

Files with missing lines Patch % Lines
packages/webpack-cli/src/webpack-cli.ts 98.92% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4779      +/-   ##
==========================================
- Coverage   92.98%   92.94%   -0.05%     
==========================================
  Files          14       14              
  Lines        5219     5416     +197     
  Branches      766      776      +10     
==========================================
+ Hits         4853     5034     +181     
- Misses        364      381      +17     
+ Partials        2        1       -1     
Files with missing lines Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 96.22% <98.92%> (-0.26%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 134e62d...c82457e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ThierryRakotomanana

Copy link
Copy Markdown
Contributor

Hey @alexander-akait ,really glad to see this moving forward, and I think the commander API approach is the right call architecturally!
Since this builds on #4736 , I'd love to stay involved. Would it be possible to be credited as a co-author like here webpack/webpack-dev-server#5659 (comment), or at minimum have the contribution acknowledged beyond just a PR reference?
Also, will #4736 be closed in favor of this one? Happy to collaborate or help get this across the finish line.
Either way, happy to see the feature land 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants