Skip to content

Prompt through laranail/console, not laravel/prompts - #27

Merged
imanimanyara merged 2 commits into
mainfrom
refactor/prompts-through-console
Oct 13, 2026
Merged

imanimanyara merged 2 commits into
mainfrom
refactor/prompts-through-console

Conversation

@imanimanyara

@imanimanyara imanimanyara commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

What

laranail::env-kit.edit prompted through laravel/prompts directly (select(), text(), confirm(), and SelectPrompt::shouldFallback() for the can-prompt check from #26) without declaring the package. It now goes through laranail/console, which wraps laravel/prompts:

Was (Laravel\Prompts) Now (laranail/console)
select($label, $options) Prompter::create()->select($label, $options)->getResult()
text($label, required:, default:) Prompter::create()->text($label, default:, required:)->getResult()
confirm($label, default: false) Prompter::create()->confirm($label, default: false)->getResult()
SelectPrompt::shouldFallback() + stream_isatty(STDIN) + isInteractive() (private canPrompt()) Prompter::canPrompt($this->input) (new in console, laranail/console#83)
tests: Prompt::fallbackWhen(true) tests: InteractsWithConsole::withPromptFallback() (new in console, laranail/console#83)

Behaviour is unchanged: the same prompts and answers, and still exit 2 with the #26 message under --no-interaction or with no TTY.

Guard

tests/Unit/PromptsBoundaryTest.php: a Pest arch rule (expect('Simtabi\Laranail\EnvKit\Headless')->not->toUse('Laravel\Prompts')), plus a raw substring scan over every PHP file under src/ that asserts it read more than 100 files. Both go red when a use function Laravel\Prompts\select; import or a fully-qualified \Laravel\Prompts\info() call is added back.

Release dependency: draft until console is released

This needs Prompter::canPrompt() and withPromptFallback(), which are only in laranail/console#83, so composer.json raises the floor to laranail/console ^0.1.7. CI on this PR is red until laranail/console#83 is on console's main: PHPStan reports Call to an undefined static method Prompter::canPrompt(). CI installs fine, because with minimum-stability: dev console's dev-main (aliased 0.1.x-dev) satisfies ^0.1.7, and that resolves today's main, which does not have #83 yet. So merging #83 turns this green even before a tag. A consumer with minimum-stability: stable still needs the tagged release, so the PR stays a draft until console cuts it. If the release gets another number, the constraint and CHANGELOG line change with it.

Verified locally against the console branch through a path repository in a $TMPDIR copy (not committed): pest 543 passed (541 on main, plus the 2 new tests), phpstan clean, pint (package-tools config) passed. The repo has no rector.php, so rector was not run.

The editor imported select(), text(), confirm() and SelectPrompt from
laravel/prompts without declaring the package; it arrived only because
laranail/console requires it. Prompts now go through console's Prompter,
and the can-prompt check is console's Prompter::canPrompt(), which carries
the same rule the editor had inline. The prompts, their answers and the
exit 2 without a terminal are unchanged.

The production editor test enables the prompt fallback through console's
InteractsWithConsole::withPromptFallback() instead of Prompt directly.

PromptsBoundaryTest fails if src/ uses Laravel\Prompts again: a Pest arch
rule, and beside it a raw substring scan over every file under src/ that
asserts how many files it read.

Requires laranail/console ^0.1.7, the first release with canPrompt().
@imanimanyara
imanimanyara marked this pull request as ready for review October 13, 2026 14:58
Copilot AI balanced review requested due to automatic review settings October 13, 2026 14:58

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.

🟢 Approval recommended

The migration preserves behavior and the only identified issue is minor comment grammar.

1 open finding
What changed in this PR

Routes editor prompts through laranail/console, removing direct reliance on laravel/prompts.

Changes:

  • Migrates editor prompts and terminal checks to Prompter.
  • Adds a source-boundary architecture test.
  • Requires laranail/console ^0.1.7 and updates documentation.
File Description
src/​Console/​EditCommand.php Uses the shared prompt wrapper.
tests/​Feature/​TuiTest.php Adopts console prompt testing helpers.
tests/​Unit/​PromptsBoundaryTest.php Guards the dependency boundary.
docs/​tools/​tui.md Documents prompt routing.
composer.json Raises the console dependency floor.
CHANGELOG.md Records the migration and requirement.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/Unit/PromptsBoundaryTest.php Outdated
@imanimanyara
imanimanyara merged commit 19e86ed into main Oct 13, 2026
5 checks passed
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