Skip to content

Conversation

@AlexSkrypnyk
Copy link
Member

@AlexSkrypnyk AlexSkrypnyk commented Dec 5, 2025

Related to #1950

Summary by CodeRabbit

  • New Features

    • Added a --destination option to target a custom directory for build and requirement checks.
  • Improvements

    • Commands now consistently use the selected destination as the working directory, improving path resolution and process behavior.
    • Footer output spacing refined for clearer display.
  • Bug Fixes

    • Better validation and clearer error messages for non-string, non-existent, or non-directory destination inputs.
  • Tests

    • Added functional scenarios and pre-run hooks for valid/invalid destination handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Walkthrough

Adds a reusable DestinationAwareTrait and updates installer commands and tests to accept a --destination option, resolve it into a protected $cwd, replace implicit getcwd() usage with the resolved cwd, and wire the process runner to use that working directory; tests and TUI messages updated for destination validation.

Changes

Cohort / File(s) Summary
New trait
.vortex/installer/src/Command/DestinationAwareTrait.php
Adds addDestinationOption() to register --destination and getDestination(InputInterface $input) to validate/resolve the destination (ensure string, directory exists, realpath fallback, throws InvalidArgumentException on error).
Build command updates
.vortex/installer/src/Command/BuildCommand.php
Uses DestinationAwareTrait; adds protected string $cwd; calls addDestinationOption() in configure(); resolves destination into $this->cwd in execute(); replaces getcwd() usages with $this->cwd; ensures process runner uses setCwd($this->cwd); task closure no longer captures $cwd.
CheckRequirements command updates
.vortex/installer/src/Command/CheckRequirementsCommand.php
Uses DestinationAwareTrait; adds protected string $cwd; calls addDestinationOption() in configure(); resolves destination into $this->cwd before initializing the process runner; applies setCwd($this->cwd) on the process runner.
Install command adjustments
.vortex/installer/src/Command/InstallCommand.php
runBuildCommand() composes an $args array including --destination (and conditionally --profile) for the build invocation; footerBuildSucceeded() adjusted spacing/inline strings.
Functional tests updated
.vortex/installer/tests/Functional/Command/BuildCommandTest.php, .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
Tests accept optional before-hook closures to prepare filesystem inputs; data providers add cases for valid destination, destination as file, and non-existent destination; import AlexSkrypnyk\File\File; tests apply before hook to modify inputs.
TUI output constants
.vortex/installer/tests/Helpers/TuiOutput.php
Added DESTINATION_NOT_EXIST and DESTINATION_MUST_BE_STRING constants with destination-related error messages.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Attention points:
    • DestinationAwareTrait::getDestination() — type validation, directory existence checks, realpath fallback, and exception messages.
    • All replacements of getcwd() to use $this->cwd (BuildCommand, CheckRequirementsCommand): ensure no remaining implicit cwd usage.
    • Process runner initialization ordering and correct application of setCwd($this->cwd) before spawning processes.
    • Tests: new before-hook logic, added data-provider cases, and mapping to new TUI constants.
    • BuildCommandTest changes (signature and added scenarios) — these introduced more complex test fixtures and may require careful review.

Poem

🐰 I found a trait to guide the way,
Paths now steady, no stray day.
cwd set snug, commands agree,
Tests hop in, all paths free.
A tiny rabbit cheers — hooray! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a --destination option to the build and check-requirements installer commands, which is the primary focus of this changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/add-destination-installer-build-check-reqs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 324096b and fc41a66.

📒 Files selected for processing (4)
  • .vortex/installer/src/Command/BuildCommand.php (8 hunks)
  • .vortex/installer/src/Command/CheckRequirementsCommand.php (3 hunks)
  • .vortex/installer/src/Command/DestinationAwareTrait.php (1 hunks)
  • .vortex/installer/src/Command/InstallCommand.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
.vortex/installer/src/Command/BuildCommand.php (6)
.vortex/installer/src/Command/CheckRequirementsCommand.php (1)
  • getProcessRunner (343-345)
.vortex/installer/src/Command/DestinationAwareTrait.php (2)
  • addDestinationOption (18-25)
  • getDestination (39-57)
.vortex/docs/.utils/svg-term-render.js (1)
  • input (55-55)
.vortex/installer/src/Runner/ProcessRunnerAwareTrait.php (1)
  • getProcessRunner (25-27)
.vortex/installer/src/Runner/AbstractRunner.php (1)
  • setCwd (97-102)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • setCwd (78-78)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build (1)
  • GitHub Check: build (0)
  • GitHub Check: vortex-test-workflow (3)
  • GitHub Check: vortex-test-workflow (1)
  • GitHub Check: vortex-test-workflow (4)
  • GitHub Check: vortex-test-workflow (2)
  • GitHub Check: vortex-test-workflow (0)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-installer (8.4)
  • GitHub Check: vortex-test-installer (8.3)
  • GitHub Check: vortex-test-installer (8.2)
🔇 Additional comments (3)
.vortex/installer/src/Command/InstallCommand.php (2)

597-598: Footer build-success messages look good.

The new inline “Get site info” and “Login” lines are clear, compact, and consistent with the rest of the installer messaging; no issues here.


456-462: The --destination and --profile flags are correctly wired to build. BuildCommand defines the destination option via DestinationAwareTrait (line 20 of DestinationAwareTrait.php), and CommandRunner::run() merges both $args and $inputs arrays (line 38 of CommandRunner.php) before passing them to ArrayInput, which properly recognizes associative keys as option names. No changes needed.

.vortex/installer/src/Command/CheckRequirementsCommand.php (1)

27-28: Destination-aware working directory for requirement checks is wired correctly.

Using DestinationAwareTrait, storing the resolved directory in $this->cwd, and initialising $this->processRunner with setCwd($this->cwd) ensures all process-based checks share a consistent working directory without exposing uninitialised state. Since the current checks don’t depend on CWD semantics, this is backward compatible while keeping the command ready for destination-specific logic later.

Also applies to: 69-72, 81-82, 92-93, 97-99

Comment on lines +1 to +59
<?php

declare(strict_types=1);

namespace DrevOps\VortexInstaller\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;

/**
* Provides destination directory option for commands.
*/
trait DestinationAwareTrait {

/**
* Add the destination option to the command.
*/
protected function addDestinationOption(): void {
$this->addOption(
'destination',
'd',
InputOption::VALUE_REQUIRED,
'Target directory for the operation. Defaults to current directory.'
);
}

/**
* Get the destination directory from input.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* The input interface.
*
* @return string
* The validated destination directory path.
*
* @throws \InvalidArgumentException
* If the destination directory does not exist.
*/
protected function getDestination(InputInterface $input): string {
$destination = $input->getOption('destination');

if ($destination === NULL || $destination === '') {
return getcwd() ?: '.';
}

if (!is_string($destination)) {
throw new \InvalidArgumentException('Destination must be a string.');
}

if (!is_dir($destination)) {
throw new \InvalidArgumentException(
sprintf('Destination directory does not exist: %s', $destination)
);
}

return realpath($destination) ?: $destination;
}

}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Trait cleanly encapsulates destination option and validation; minor doc tweak possible.

The trait nicely centralises --destination handling: option registration is reusable, and getDestination() provides a clear, validated, realpath-normalised directory with a sensible fallback to the current working directory. One minor polish point: the docblock currently mentions throwing when the directory does not exist, but the method can also throw if the option value is not a string. If you care about strict docs, you could broaden the @throws description to cover both cases.

🤖 Prompt for AI Agents
.vortex/installer/src/Command/DestinationAwareTrait.php lines 1-59: update the
method docblock for getDestination() to reflect both error conditions that can
throw an InvalidArgumentException (non-string option value and non-existent
destination directory) by broadening the @throws description to mention both
cases and, optionally, add a short inline note about the non-string check; keep
implementation unchanged.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.07%. Comparing base (b1e255c) to head (73176e7).

Files with missing lines Patch % Lines
.vortex/installer/src/Command/BuildCommand.php 71.42% 2 Missing ⚠️
...ex/installer/src/Command/DestinationAwareTrait.php 93.75% 1 Missing ⚠️
.vortex/installer/src/Command/InstallCommand.php 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2168      +/-   ##
===========================================
- Coverage    76.64%   76.07%   -0.58%     
===========================================
  Files          111      105       -6     
  Lines         5836     5696     -140     
  Branches        44        0      -44     
===========================================
- Hits          4473     4333     -140     
  Misses        1363     1363              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@AlexSkrypnyk AlexSkrypnyk added this to the 1.0-25.11.0 milestone Dec 5, 2025
@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/add-destination-installer-build-check-reqs branch 2 times, most recently from 2b23a82 to 194b056 Compare December 5, 2025 02:31
@AlexSkrypnyk AlexSkrypnyk enabled auto-merge (rebase) December 5, 2025 02:35
@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/add-destination-installer-build-check-reqs branch from 194b056 to c09df9f Compare December 5, 2025 03:14
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
.vortex/installer/src/Command/DestinationAwareTrait.php (1)

27-57: Destination handling is solid; consider broadening the @throws description.

The trait cleanly centralises --destination registration and validation, and the runtime behaviour (defaulting to CWD, type-checking, directory existence, realpath() normalisation) looks correct.

The docblock, however, only mentions throwing when the directory does not exist, while getDestination() can also throw for a non-string value. You could make the @throws description slightly more accurate, for example:

-   * @throws \InvalidArgumentException
-   *   If the destination directory does not exist.
+   * @throws \InvalidArgumentException
+   *   If the destination is not a string or the directory does not exist.

Implementation can stay as-is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 194b056 and c09df9f.

📒 Files selected for processing (7)
  • .vortex/installer/src/Command/BuildCommand.php (8 hunks)
  • .vortex/installer/src/Command/CheckRequirementsCommand.php (3 hunks)
  • .vortex/installer/src/Command/DestinationAwareTrait.php (1 hunks)
  • .vortex/installer/src/Command/InstallCommand.php (2 hunks)
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php (4 hunks)
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php (4 hunks)
  • .vortex/installer/tests/Helpers/TuiOutput.php (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-13T04:14:41.765Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 2011
File: .vortex/tests/phpunit/Traits/Steps/StepAhoyTrait.php:20-23
Timestamp: 2025-09-13T04:14:41.765Z
Learning: In .vortex/tests/phpunit PHPUnit tests using cmd/cmdFail helpers, patterns in the expected output arrays support '*' markers for positive assertions (text must be present) and '!' markers for negative assertions (text must NOT be present). The '*' markers are NOT literal text matches but rather indicate expected presence.

Applied to files:

  • .vortex/installer/tests/Helpers/TuiOutput.php
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
📚 Learning: 2025-06-01T08:10:15.903Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1693
File: .vortex/installer/src/Prompts/Handlers/Internal.php:52-52
Timestamp: 2025-06-01T08:10:15.903Z
Learning: The File utility class in .vortex/installer/src/Utils/File.php extends AlexSkrypnyk\File\File, and methods like collapseRepeatedEmptyLines() are available from this external parent class dependency.

Applied to files:

  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
🧬 Code graph analysis (5)
.vortex/installer/src/Command/CheckRequirementsCommand.php (5)
.vortex/installer/src/Command/DestinationAwareTrait.php (2)
  • addDestinationOption (18-25)
  • getDestination (39-57)
.vortex/installer/src/Runner/ProcessRunnerAwareInterface.php (1)
  • getProcessRunner (18-18)
.vortex/installer/src/Runner/ProcessRunnerAwareTrait.php (1)
  • getProcessRunner (25-27)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • setCwd (78-78)
.vortex/installer/src/Runner/AbstractRunner.php (1)
  • setCwd (97-102)
.vortex/installer/src/Command/InstallCommand.php (6)
.vortex/installer/src/Utils/Config.php (1)
  • getDst (101-103)
.vortex/installer/src/Runner/CommandRunnerAwareTrait.php (1)
  • getCommandRunner (26-29)
.vortex/installer/src/Runner/ProcessRunner.php (1)
  • run (21-75)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • run (41-41)
.vortex/installer/src/Runner/CommandRunner.php (1)
  • run (34-72)
.vortex/installer/src/Utils/Git.php (1)
  • run (29-34)
.vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php (1)
.vortex/installer/tests/Helpers/TuiOutput.php (2)
  • TuiOutput (7-314)
  • present (173-175)
.vortex/installer/src/Command/BuildCommand.php (4)
.vortex/installer/src/Command/DestinationAwareTrait.php (2)
  • addDestinationOption (18-25)
  • getDestination (39-57)
.vortex/installer/src/Runner/ProcessRunnerAwareTrait.php (1)
  • getProcessRunner (25-27)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • setCwd (78-78)
.vortex/installer/src/Runner/AbstractRunner.php (1)
  • setCwd (97-102)
.vortex/installer/tests/Functional/Command/BuildCommandTest.php (1)
.vortex/installer/tests/Helpers/TuiOutput.php (2)
  • TuiOutput (7-314)
  • present (173-175)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build (1)
  • GitHub Check: build (0)
  • GitHub Check: vortex-test-workflow (3)
  • GitHub Check: vortex-test-workflow (2)
  • GitHub Check: vortex-test-workflow (4)
  • GitHub Check: vortex-test-workflow (1)
  • GitHub Check: vortex-test-workflow (0)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-installer (8.2)
  • GitHub Check: vortex-test-installer (8.3)
  • GitHub Check: vortex-test-installer (8.4)
🔇 Additional comments (4)
.vortex/installer/src/Command/InstallCommand.php (2)

496-510: runBuildCommand now correctly forwards destination and profile to build.

Passing --destination from $this->config->getDst() and conditionally adding --profile ensures the build command runs in the same target directory and mode as the installer just configured. Using a single $args array and wiring it into CommandRunner::run() is consistent and keeps this step easy to extend.


635-640: Footer alignment tweak is consistent with test helpers.

Inlining "Get site info: ahoy info" and "Login: ahoy login" keeps the messages simple while still matching the TuiOutput patterns (FOOTER_GET_SITE_INFO, FOOTER_AHOY_INFO, FOOTER_AHOY_LOGIN) used in tests.

.vortex/installer/tests/Helpers/TuiOutput.php (1)

160-163: Destination error constants align with command validation.

DESTINATION_NOT_EXIST and DESTINATION_MUST_BE_STRING mirror the DestinationAwareTrait exception messages and give tests a stable way to assert on destination-related failures without hardcoding full error lines.

.vortex/installer/src/Command/BuildCommand.php (1)

25-28: BuildCommand’s destination-aware cwd wiring is consistent and robust.

Using DestinationAwareTrait plus a typed $cwd property, then:

  • Initialising $this->cwd via getDestination($input) in execute(),
  • Setting the process runner cwd with $this->getProcessRunner()->setCwd($this->cwd) before ahoy build,
  • Deriving .env and docker-compose config from $this->cwd,

makes build properly target the chosen destination both when invoked directly and via InstallCommand. The fallback in getProjectMachineName() to basename($this->cwd) when .env is missing also keeps behaviour sensible for non-.env setups.

Also applies to: 47-51, 55-60, 70-72, 91-107, 125-136, 147-149

Comment on lines +69 to +73
/**
* The working directory for checks.
*/
protected string $cwd;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Always apply setCwd() to the process runner, even when injected.

Destination handling and $cwd initialisation look good, but this line:

$this->processRunner ??= $this->getProcessRunner()->setCwd($this->cwd);

means that when a runner is injected via setProcessRunner(), setCwd() is never called, so check-requirements will ignore --destination in that scenario.

To keep behaviour consistent with BuildCommand and ensure destination-aware checks regardless of how the runner is provided, consider:

-    $this->processRunner ??= $this->getProcessRunner()->setCwd($this->cwd);
+    $this->processRunner = $this->getProcessRunner()->setCwd($this->cwd);

This still reuses an existing runner when present, but always updates its working directory.

Also applies to: 81-82, 92-98

🤖 Prompt for AI Agents
.vortex/installer/src/Command/CheckRequirementsCommand.php around lines 69-73
(also apply same pattern at 81-82 and 92-98): the current conditional assignment
skips calling setCwd() when a ProcessRunner is injected, so --destination is
ignored; always obtain the runner (either the injected one or a newly created
one), call setCwd($this->cwd) on it, then assign it back to
$this->processRunner; apply this change in all mentioned locations so the
runner's working directory is updated regardless of whether it was injected or
created.

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/add-destination-installer-build-check-reqs branch from c09df9f to 73176e7 Compare December 5, 2025 04:06
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
.vortex/installer/src/Command/CheckRequirementsCommand.php (1)

97-99: setCwd() is skipped when a runner is injected, causing --destination to be ignored.

The null coalescing assignment (??=) means that when a ProcessRunner is injected via setProcessRunner() (e.g., in tests), setCwd($this->cwd) is never called. This causes the --destination option to be silently ignored in those scenarios.

Apply this fix to ensure setCwd() is always called:

-    $this->processRunner ??= $this->getProcessRunner()->setCwd($this->cwd);
+    $this->processRunner = $this->getProcessRunner()->setCwd($this->cwd);

This still reuses an existing runner when present (via getProcessRunner()'s internal ??=), but always updates its working directory.

.vortex/installer/src/Command/DestinationAwareTrait.php (1)

36-37: Docblock incomplete: mentions only one of two exception conditions.

The @throws annotation only documents the "directory does not exist" case, but getDestination() can also throw when the destination is not a string (line 47). Consider updating the docblock for completeness:

    * @throws \InvalidArgumentException
-   *   If the destination directory does not exist.
+   *   If the destination is not a string or the directory does not exist.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c09df9f and 73176e7.

📒 Files selected for processing (7)
  • .vortex/installer/src/Command/BuildCommand.php (8 hunks)
  • .vortex/installer/src/Command/CheckRequirementsCommand.php (3 hunks)
  • .vortex/installer/src/Command/DestinationAwareTrait.php (1 hunks)
  • .vortex/installer/src/Command/InstallCommand.php (2 hunks)
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php (4 hunks)
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php (4 hunks)
  • .vortex/installer/tests/Helpers/TuiOutput.php (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-09-13T04:14:41.765Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 2011
File: .vortex/tests/phpunit/Traits/Steps/StepAhoyTrait.php:20-23
Timestamp: 2025-09-13T04:14:41.765Z
Learning: In .vortex/tests/phpunit PHPUnit tests using cmd/cmdFail helpers, patterns in the expected output arrays support '*' markers for positive assertions (text must be present) and '!' markers for negative assertions (text must NOT be present). The '*' markers are NOT literal text matches but rather indicate expected presence.

Applied to files:

  • .vortex/installer/tests/Helpers/TuiOutput.php
  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
📚 Learning: 2025-08-08T12:02:24.652Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1896
File: .vortex/tests/bats/unit/download-db-lagoon.bats:24-25
Timestamp: 2025-08-08T12:02:24.652Z
Learning: In .vortex/tests/bats/unit Bats tests using ../_helper.bash (run_steps), prefixing a STEPS entry with "- " denotes a negative assertion (the substring must NOT appear in output). Unprefixed entries are positive assertions. Example: "- Database dump refresh requested. Will create a new dump." asserts absence; "Database dump refresh requested. Will create a new dump." asserts presence.

Applied to files:

  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
📚 Learning: 2025-06-01T08:10:15.903Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1693
File: .vortex/installer/src/Prompts/Handlers/Internal.php:52-52
Timestamp: 2025-06-01T08:10:15.903Z
Learning: The File utility class in .vortex/installer/src/Utils/File.php extends AlexSkrypnyk\File\File, and methods like collapseRepeatedEmptyLines() are available from this external parent class dependency.

Applied to files:

  • .vortex/installer/tests/Functional/Command/BuildCommandTest.php
  • .vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php
🧬 Code graph analysis (4)
.vortex/installer/src/Command/CheckRequirementsCommand.php (5)
.vortex/installer/src/Command/DestinationAwareTrait.php (2)
  • addDestinationOption (18-25)
  • getDestination (39-57)
.vortex/installer/src/Runner/ProcessRunnerAwareTrait.php (1)
  • getProcessRunner (25-27)
.vortex/installer/src/Runner/ProcessRunnerAwareInterface.php (1)
  • getProcessRunner (18-18)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • setCwd (78-78)
.vortex/installer/src/Runner/AbstractRunner.php (1)
  • setCwd (97-102)
.vortex/installer/src/Command/InstallCommand.php (5)
.vortex/installer/src/Utils/Config.php (1)
  • getDst (101-103)
.vortex/installer/src/Runner/CommandRunnerAwareTrait.php (1)
  • getCommandRunner (26-29)
.vortex/installer/src/Runner/ProcessRunner.php (1)
  • run (21-75)
.vortex/installer/src/Runner/RunnerInterface.php (1)
  • run (41-41)
.vortex/installer/src/Runner/CommandRunner.php (1)
  • run (34-72)
.vortex/installer/tests/Functional/Command/BuildCommandTest.php (2)
.vortex/installer/src/Utils/File.php (1)
  • File (10-121)
.vortex/installer/tests/Helpers/TuiOutput.php (2)
  • TuiOutput (7-314)
  • present (173-175)
.vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php (1)
.vortex/installer/tests/Helpers/TuiOutput.php (2)
  • TuiOutput (7-314)
  • present (173-175)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build (0)
  • GitHub Check: build (1)
  • GitHub Check: vortex-test-workflow (3)
  • GitHub Check: vortex-test-workflow (4)
  • GitHub Check: vortex-test-workflow (2)
  • GitHub Check: vortex-test-workflow (0)
  • GitHub Check: vortex-test-workflow (1)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-installer (8.3)
  • GitHub Check: vortex-test-installer (8.4)
  • GitHub Check: vortex-test-installer (8.2)
🔇 Additional comments (10)
.vortex/installer/src/Command/InstallCommand.php (2)

501-507: LGTM! Clean args construction for build command invocation.

The destination and profile arguments are properly constructed and passed to the build command. The logic correctly determines when to include the --profile flag based on the selected starter type.


638-639: Minor formatting improvement for output alignment.

The fixed-width inline strings improve visual alignment of the "Get site info" and "Login" instructions in the success footer.

.vortex/installer/tests/Helpers/TuiOutput.php (1)

160-163: LGTM! Test helper constants align with trait error messages.

The new constants correctly match the error messages thrown by DestinationAwareTrait::getDestination(), enabling consistent test assertions for destination validation scenarios.

.vortex/installer/src/Command/CheckRequirementsCommand.php (1)

69-72: Destination handling integration is well-structured.

The trait integration follows a clear pattern: option registration in configure(), resolution in execute(), and storage in the $cwd property. The docblock is clear and the placement is appropriate.

Also applies to: 81-81, 92-93

.vortex/installer/src/Command/DestinationAwareTrait.php (1)

1-59: Well-designed trait for reusable destination handling.

The trait cleanly encapsulates the --destination option pattern with proper validation and sensible defaults. The fallback chain (getcwd()'.') and realpath() normalization are appropriate.

.vortex/installer/tests/Functional/Command/BuildCommandTest.php (3)

38-42: Clean before-hook pattern for per-test filesystem setup.

The optional $before closure provides a flexible way to prepare test-specific filesystem state without complicating the main test harness. The pattern of receiving $command_inputs and returning modified inputs is intuitive.


453-497: Comprehensive destination validation test coverage.

The three new test cases effectively exercise:

  1. Valid directory path → success
  2. File path (not a directory) → fails with DESTINATION_NOT_EXIST
  3. Non-existent path → fails with DESTINATION_NOT_EXIST

Using uniqid() for path uniqueness prevents test collisions. The assertions correctly align with the error messages defined in DestinationAwareTrait::getDestination().


7-8: Import addition is appropriate.

The AlexSkrypnyk\File\File import supports the filesystem operations (mkdir, dump) used in the new before closures.

.vortex/installer/src/Command/BuildCommand.php (1)

27-27: LGTM! Destination integration is clean and consistent.

The DestinationAwareTrait integration is well-executed: $this->cwd is initialized early in execute() and consistently used throughout for .env resolution, project name derivation, URL inspection, and process runner configuration. Removing the closure capture (line 93) in favor of the property is cleaner and aligns with the trait pattern.

Also applies to: 47-50, 59-59, 71-71, 93-107, 126-127, 135-136, 148-149

.vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php (1)

7-7: LGTM! Test coverage for destination validation is thorough.

The before closure hook cleanly extends the test harness to support filesystem setup, and the three new test cases properly exercise the destination validation logic: valid directory (success), file instead of directory (error), and non-existent path (error). The use of uniqid() for isolation and self::$tmp for cleanup is appropriate.

Also applies to: 28-38, 87-89, 392-430

Comment on lines +46 to +48
if (!is_string($destination)) {
throw new \InvalidArgumentException('Destination must be a string.');
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Type check is likely unreachable but serves as defensive coding.

Since InputOption::VALUE_REQUIRED ensures the option is either null, empty string, or a string, the !is_string($destination) check at line 46 should never be true after the null/empty check at line 42. This is acceptable as defensive coding against future edge cases, but it may warrant a @phpstan-ignore-next-line annotation if static analysis flags it as dead code.

🤖 Prompt for AI Agents
.vortex/installer/src/Command/DestinationAwareTrait.php lines 46-48: the
defensive is_string($destination) check is flagged by static analysis as
unreachable; add a @phpstan-ignore-next-line (or equivalent PHPStan suppression)
immediately above that line to silence the dead-code warning while keeping the
runtime defensive check intact.

@AlexSkrypnyk AlexSkrypnyk disabled auto-merge December 5, 2025 05:45
@AlexSkrypnyk AlexSkrypnyk merged commit 3042e22 into develop Dec 5, 2025
33 of 35 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/add-destination-installer-build-check-reqs branch December 5, 2025 05:45
@github-project-automation github-project-automation bot moved this from BACKLOG to Release queue in Vortex Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released in 1.34.0

Development

Successfully merging this pull request may close these issues.

2 participants