Skip to content

feat: add shell completions - #4840

Merged
alexander-akait merged 6 commits into
mainfrom
feat/tab-completions
Aug 28, 2026
Merged

feat: add shell completions#4840
alexander-akait merged 6 commits into
mainfrom
feat/tab-completions

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

Builds on @AmirSa12's #4829 (their commit is kept as-is, first in this branch) and fixes the two things that stood between it and covering every command. Closes #1402.

  • Aliases resolved. @bomb.sh/tab registers each command under command.name() and has no alias concept, so completing after one returned only the global options: webpack b <TAB> offered 4 candidates against build's 21, webpack s <TAB> 4 against serve's 94. The alias being completed is now registered against the command it stands for. Only the requested alias is registered, so webpack <TAB> still lists the eight commands instead of all thirteen names — flip that if you would rather aliases were discoverable.
  • The parser is optional. @bomb.sh/tab moves from dependencies to an optional peer, alongside webpack-dev-server, webpack-bundle-analyzer, js-yaml, json5 and toml. It is imported only to serve a completion request. A shell runs complete -- <words> on every keypress, so a missing package is silent there (exit 0, nothing on either stream), while complete <shell> reports what to install in the usual format.

Also updates the dev-server 6 help snapshots, added after #4829 branched — without them its CI fails on every dev-server 6 job.

Not covered, and inherent rather than an oversight: third-party commands, which the CLI resolves by import(commandName) as a package, so there is no set to enumerate before one is typed.

What kind of change does this PR introduce?

feat

Did you add tests for your changes?

Yes — test/complete/complete.test.js gains three cases on top of #4829's six: an alias offers byte-identical candidates to its command, values complete through an alias (b --mode=), and aliases stay out of the command suggestions. Measured before and after across all commands:

typed before after
build / watch 21 21
b, bundle, w 4 21
serve 94 94
s, server 4 94

The missing-package paths were checked by hand (both streams empty for a resolution request; exit 2 with the install message for complete zsh) since simulating an absent package inside the suite is not worth the machinery.

Does this PR introduce a breaking change?

No — a new command, and the parser it needs is optional.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Installing completions per shell: webpack complete zsh (and bash/fish/powershell) prints the script to source, and @bomb.sh/tab has to be installed to use it.

Use of AI

Claude Code was used to review #4829 by running its CLI, which is how the alias gap was measured, to read @bomb.sh/tab's adapter and find that it keys commands by name, and to write the fix and its tests. All changes were reviewed before committing.


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67bd238

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

@socket-security

socket-security Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​bomb.sh/​tab@​0.0.2210010010099100

View full report

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (f145401).

Install it locally:

  • npm
npm i -D webpack-cli@https://pkg.pr.new/webpack-cli@f145401
  • yarn
yarn add -D webpack-cli@https://pkg.pr.new/webpack-cli@f145401
  • pnpm
pnpm add -D webpack-cli@https://pkg.pr.new/webpack-cli@f145401

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.93909% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.81%. Comparing base (7d40e4e) to head (67bd238).

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

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4840      +/-   ##
==========================================
+ Coverage   94.78%   94.81%   +0.03%     
==========================================
  Files          14       14              
  Lines        5406     5598     +192     
  Branches      799      837      +38     
==========================================
+ Hits         5124     5308     +184     
- Misses        281      289       +8     
  Partials        1        1              
Files with missing lines Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 96.70% <95.93%> (-0.05%) ⬇️

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 7d40e4e...67bd238. 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.

Completing after an alias returned only the global options, because
`@bomb.sh/tab` registers each command under `command.name()` and has no
alias concept: `webpack b <TAB>` offered 4 candidates where `webpack build
<TAB>` offers 25, and `webpack s <TAB>` 4 against `serve`'s 98. The alias
being completed is now registered against the command it stands for, so
every alias resolves. Only the requested one is registered, which keeps
`webpack <TAB>` listing the eight commands rather than all thirteen names.

Global options are registered on the root command, so nothing offered them
after a command, though they are accepted there: `webpack build --col` did
not complete `--color`, and `configtest`, `help` and `complete` offered
nothing at all, having no options of their own. Every command now carries
them.

`@bomb.sh/tab` also moves to an optional peer dependency, next to the other
packages the CLI loads on demand. It is imported only to serve a completion
request, so installing it is the user's choice: the shell runs
`complete -- <words>` on every keypress and now gets silence when the
package is absent, while `complete <shell>` says what to install.

Also updates the dev-server 6 help snapshots, which were added after this
work branched.

Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
alexander-akait and others added 4 commits August 28, 2026 11:33
Registering the requested alias made it a suggestion of its own, so
`webpack b<TAB>` offered `build` and `b` and the shell, having two
candidates, left the word at their common prefix instead of writing
`build` out. The last word is the one being typed, so only the words
before it name the command an alias has to resolve.

Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
Patch coverage reported 30 uncovered lines, most of them handler bodies
that only run while the option they belong to is being completed. Covers
`build --progress`, `version --output`, the root `--help`, and the shell
argument of `complete` itself.

Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
`@bomb.sh/tab` is optional, so the two paths that run without it carry the
behaviour a user without it sees, and both were checked by hand only. A
resolve hook now hides the package the way an install that never had it
does, pinning that a completion request prints nothing on either stream and
that asking for a script reports what to install.
Covers what completes, that `@bomb.sh/tab` has to be installed for it, and
the line to add per shell. Also lists `complete` among the commands in both
readmes, the second of which quotes `--help` and so has to match it.

Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
@alexander-akait
alexander-akait merged commit f145401 into main Aug 28, 2026
41 checks passed
@alexander-akait
alexander-akait deleted the feat/tab-completions branch August 28, 2026 13:54
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.

Feature:- AUTO TAB completion of flags

2 participants