Skip to content

Base the install command on package-tools' InstallCommand - #24

Merged
imanimanyara merged 1 commit into
mainfrom
refactor/install-command-package-tools-base
Oct 5, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
refactor/install-command-package-tools-base

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Moves laranail::captcha.install onto laranail/package-tools' InstallCommand base, keeping laranail/console's display API ($this->services) and managed run lifecycle by use-ing its InteractsWithConsoleServices and InteractsWithConsoleWriter traits. No new dependency direction: captcha already requires both packages, and neither of them gains a dependency on the other.

What stays the same

  • Name laranail::captcha.install, no aliases, the same description.
  • One option, --migrations (no value), no arguments.
  • Listed in php artisan list. The base hides install commands by default, so hidden: false is passed explicitly.
  • The same output lines and exit code 0, including the unknown provider fallback.
  • handle() is unchanged. The base's generic publish pipeline is not used, because it would print different steps.

How

  • InstallCommand extends the package-tools base, passes its own signature and hidden: false, and restores its description after the base writes Install laranail/captcha.
  • The base takes the Package in its constructor, which the container cannot autowire, so packageRegistered() binds the command. It stays registered by class name in hasCommands(), constructed only when Artisan resolves it, exactly as before.

Tests

  • New InstallCommandContractTest pins the name, aliases, description, visibility, options and arguments, the output with and without --migrations, the unknown-provider line, and asserts the class extends the package-tools base and uses both console traits. The behaviour pins passed against the old base before the swap; the inheritance assertion failed there, as intended.
  • Locally: 258 tests pass, PHPStan clean, Pint and Rector clean.

Moves the captcha install command onto laranail/package-tools' install
base while keeping laranail/console's display API through its two
traits, so neither package gains a dependency on the other.

Observable behaviour is unchanged: the name, the --migrations option,
the description, listing visibility (passed explicitly, since the base
hides install commands by default), the output and the exit codes. A
contract test pins all of them and passed against the previous base
before the swap. The command is bound in the container because the new
base takes the Package in its constructor, which keeps it registered by
class name and constructed only when Artisan resolves it.
Copilot AI balanced review requested due to automatic review settings October 4, 2026 23:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants