diff --git a/.vortex/installer/src/Prompts/Handlers/Starter.php b/.vortex/installer/src/Prompts/Handlers/Starter.php index 701f50338..5f1c6413a 100644 --- a/.vortex/installer/src/Prompts/Handlers/Starter.php +++ b/.vortex/installer/src/Prompts/Handlers/Starter.php @@ -86,6 +86,13 @@ public function discover(): null|string|bool|array { return NULL; } + /** + * {@inheritdoc} + */ + public function shouldRun(array $responses): bool { + return !$this->isInstalled(); + } + /** * {@inheritdoc} */ diff --git a/.vortex/installer/src/Prompts/PromptManager.php b/.vortex/installer/src/Prompts/PromptManager.php index e171dd66a..ee4d96382 100644 --- a/.vortex/installer/src/Prompts/PromptManager.php +++ b/.vortex/installer/src/Prompts/PromptManager.php @@ -126,7 +126,11 @@ public function runPrompts(): void { ->add(fn(array $r, $pr, $n): string => text(...$this->args(Domain::class, NULL, $r)), Domain::id()) ->intro('Drupal') - ->add(fn(array $r, $pr, $n): int|string => select(...$this->args(Starter::class, NULL, $r)), Starter::id()) + ->addIf( + fn(array $r): bool => $this->handlers[Starter::id()]->shouldRun($r), + fn(array $r, $pr, $n): int|string => select(...$this->args(Starter::class, NULL, $r)), + Starter::id() + ) ->add( fn(array $r, $pr, $n): string => $this->resolveOrPrompt(Profile::id(), $r, fn(): int|string => select(...$this->args(Profile::class))), Profile::id() @@ -233,6 +237,11 @@ public function runPrompts(): void { $responses[DatabaseDownloadSource::id()] = DatabaseDownloadSource::NONE; } + // Handle Starter when the installer is running in update mode. + if ($this->config->isVortexProject() && !isset($responses[Starter::id()])) { + $responses[Starter::id()] = Starter::LOAD_DATABASE_DEMO; + } + if ($this->config->getNoInteraction()) { Tui::output()->setVerbosity($original_verbosity); } diff --git a/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php b/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php index 2348203d6..add9b2f91 100644 --- a/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php +++ b/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php @@ -6,6 +6,7 @@ use DrevOps\VortexInstaller\Prompts\Handlers\Profile; use DrevOps\VortexInstaller\Prompts\Handlers\Starter; +use DrevOps\VortexInstaller\Utils\Config; use Laravel\Prompts\Key; use PHPUnit\Framework\Attributes\CoversClass; @@ -41,6 +42,14 @@ function (AbstractPromptManagerTestCase $test): void { // Noop. }, ], + + 'starter - installed project - skipped' => [ + [], + [Starter::id() => Starter::LOAD_DATABASE_DEMO] + static::getExpectedInstalled(), + function (AbstractPromptManagerTestCase $test, Config $config): void { + $test->stubVortexProject($config); + }, + ], ]; }