Point Composer users to package-command when wp package is missing - #1111
Draft
swissspidy wants to merge 2 commits into
Draft
Point Composer users to package-command when wp package is missing#1111swissspidy wants to merge 2 commits into
wp package is missing#1111swissspidy wants to merge 2 commits into
Conversation
`wp-cli/package-command` is a dev dependency since #846, so Composer-based installations of the bundle no longer have `wp package` available. Until now those users only got a generic "'package' is not a registered wp command" error. Declare a hint via `extra.command-hints` so WP-CLI can explain why the command is missing and how to get it back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G27BNpnRNerEeSGjvefzBf
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Installs the bundle with `--no-dev`, the state Composer-based users end up in, and asserts that `wp package` fails with the hint rather than a bare "not a registered wp command". This guards against the hint metadata being dropped or misnested, and against the framework renaming the `extra` key it reads. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G27BNpnRNerEeSGjvefzBf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #846 moved
wp-cli/package-commandtorequire-dev, it still ships in the Phar but is absent from Composer-based installations of the bundle. Installing the bundle via Composer is an anti-pattern, but people do it — and today they hit a dead end:Nothing tells them the command exists, that their install method is why it is missing, or that
composer require wp-cli/package-commandbrings it back. Thesuggestentry added in #846 only surfaces at install time, long before anyone typeswp package.Changes
Declares the guidance as metadata, using the
extra.command-hintsmechanism proposed in wp-cli/wp-cli#6386:Metadata rather than code because this package has no
autoloadsection —composer.jsonis the only channel it has.composer.lock'scontent-hashis updated in the same commit, sinceextrafeeds into it and the lock would otherwise be reported as stale.Result
Composer users get:
Phar users see no change — the hint only fires when the command is genuinely unregistered, and in the Phar
wp packageis registered. The singlepackageentry also covers every subcommand, sincewp package install foofails on the top-levelpackagelookup.Testing
A
package-command-guidancejob intesting.ymlinstalls the bundle with--no-dev— the state Composer-based users end up in — and assertswp packagefails with the hint rather than a bare "not a registered wp command". Metadata that nothing reads is easy to break silently, so this guards against the entry being dropped or misnested, and against the framework renaming theextrakey.Two honest caveats:
--no-devin this repo, the bundle is the root package, and the framework reads hints from the rootcomposer.jsonas well as fromvendor/composer/installed.json. Real users hit the latter, since for them the bundle is a dependency. Covering that path properly needs the bundle installed as a dependency of a scratch project, and wp-cli-tests currently offers no step for that —Given a dependency on current wp-clihardcodeswp-cli/wp-cli, and{SRC_DIR}points at wp-cli-tests itself rather than the repo under test. An end-to-end Behat scenario here would need a wp-cli-tests change first. The installed.json path is worth covering directly in Add hints for commands that are not registered wp-cli#6386 instead.CommandHintsondev-mainyet. That is the dependency showing up honestly in CI rather than being asserted only in prose.Neither the job nor the hint text has been executed locally — the authoring environment could not complete a dependency install for this repo. The hint text itself was verified end to end against a simulated Composer project built from this
composer.json, producing the output above, andcomposer validatepasses with the regenerated lock hash.Dependency
Requires wp-cli/wp-cli#6386 for the metadata to be read. Until that lands the metadata is inert but harmless — an unrecognized
extrakey that Composer ignores.