From 7d0d6274c28f58d3b8639f330717031449ee6013 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 27 Aug 2025 10:09:34 +1000 Subject: [PATCH] [#1949] Added Starter prompt and updated other prompts descriptions. --- .vortex/installer/composer.json | 8 +- .vortex/installer/composer.lock | 35 ++-- .vortex/installer/rector.php | 2 + .../installer/src/Command/InstallCommand.php | 42 +++-- .../src/Prompts/Handlers/AbstractHandler.php | 7 + .../Prompts/Handlers/AiCodeInstructions.php | 2 +- .../src/Prompts/Handlers/CiProvider.php | 4 +- .../src/Prompts/Handlers/CodeProvider.php | 9 +- .../Handlers/DatabaseDownloadSource.php | 4 +- .../Handlers/DependencyUpdatesProvider.php | 6 +- .../src/Prompts/Handlers/DeployType.php | 2 +- .../src/Prompts/Handlers/HandlerInterface.php | 7 +- .../src/Prompts/Handlers/HostingProvider.php | 2 +- .../src/Prompts/Handlers/Internal.php | 26 ++- .../Handlers/LabelMergeConflictsPr.php | 2 +- .../src/Prompts/Handlers/ModulePrefix.php | 2 +- .../installer/src/Prompts/Handlers/Name.php | 2 +- .../installer/src/Prompts/Handlers/Org.php | 2 +- .../src/Prompts/Handlers/OrgMachineName.php | 2 +- .../src/Prompts/Handlers/Profile.php | 4 +- .../src/Prompts/Handlers/ProvisionType.php | 25 ++- .../src/Prompts/Handlers/Services.php | 2 +- .../src/Prompts/Handlers/Starter.php | 114 +++++++++++++ .../installer/src/Prompts/Handlers/Theme.php | 2 +- .../src/Prompts/Handlers/Timezone.php | 2 +- .../installer/src/Prompts/Handlers/Tools.php | 2 +- .../src/Prompts/Handlers/Webroot.php | 12 +- .../installer/src/Prompts/PromptManager.php | 65 +++++--- .vortex/installer/src/Utils/Strings.php | 21 +++ .vortex/installer/src/Utils/Tui.php | 17 +- .../ciprovider_circleci/.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.github/workflows/update-dependencies.yml | 0 .../.github/workflows/update-dependencies.yml | 75 +++++++++ .../.github/workflows/update-dependencies.yml | 75 +++++++++ .../timezone_circleci/.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../.circleci/config.yml | 62 ------- .../AbstractPromptManagerTestCase.php | 9 +- .../CodeProviderPromptManagerTest.php | 6 +- ...ndencyUpdatesProviderPromptManagerTest.php | 2 +- .../Handlers/StarterPromptManagerTest.php | 38 +++++ .vortex/installer/tests/Unit/StringsTest.php | 151 ++++++++++++++++++ 50 files changed, 692 insertions(+), 840 deletions(-) create mode 100644 .vortex/installer/src/Prompts/Handlers/Starter.php rename .vortex/installer/tests/Fixtures/install/{_baseline => deps_updates_provider_ci_circleci}/.github/workflows/update-dependencies.yml (100%) create mode 100644 .vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_gha/.github/workflows/update-dependencies.yml create mode 100644 .vortex/installer/tests/Fixtures/install/deps_updates_provider_none/.github/workflows/update-dependencies.yml create mode 100644 .vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php diff --git a/.vortex/installer/composer.json b/.vortex/installer/composer.json index e9ab128b6..035fb7e7b 100644 --- a/.vortex/installer/composer.json +++ b/.vortex/installer/composer.json @@ -23,7 +23,7 @@ "composer/composer": "^2.8", "cweagans/composer-patches": "^1.7", "czproject/git-php": "^4.3", - "laravel/prompts": "^0.3.5", + "laravel/prompts": "dev-feature/add-description", "nikic/iter": "^2.4", "sebastian/diff": "*", "symfony/console": "^7.3", @@ -43,6 +43,12 @@ "rector/rector": "^2", "symfony/finder": "^7.2" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/AlexSkrypnyk/prompts.git" + } + ], "autoload": { "psr-4": { "DrevOps\\VortexInstaller\\": "src/" diff --git a/.vortex/installer/composer.lock b/.vortex/installer/composer.lock index 52eddf58a..aee3e7f9a 100644 --- a/.vortex/installer/composer.lock +++ b/.vortex/installer/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "54be44ac372765b171d1dfed26f33f30", + "content-hash": "9e29b2508215c60080be4e7175b4d85b", "packages": [ { "name": "alexskrypnyk/file", @@ -936,16 +936,16 @@ }, { "name": "laravel/prompts", - "version": "v0.3.6", + "version": "dev-feature/add-description", "source": { "type": "git", - "url": "https://github.com/laravel/prompts.git", - "reference": "86a8b692e8661d0fb308cec64f3d176821323077" + "url": "https://github.com/AlexSkrypnyk/prompts.git", + "reference": "e4cdcb467eb259a542e61e0d2d1c0a3e2741cada" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/86a8b692e8661d0fb308cec64f3d176821323077", - "reference": "86a8b692e8661d0fb308cec64f3d176821323077", + "url": "https://api.github.com/repos/AlexSkrypnyk/prompts/zipball/e4cdcb467eb259a542e61e0d2d1c0a3e2741cada", + "reference": "e4cdcb467eb259a542e61e0d2d1c0a3e2741cada", "shasum": "" }, "require": { @@ -962,8 +962,8 @@ "illuminate/collections": "^10.0|^11.0|^12.0", "mockery/mockery": "^1.5", "pestphp/pest": "^2.3|^3.4", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-mockery": "^1.1" + "phpstan/phpstan": "^1.12.28", + "phpstan/phpstan-mockery": "^1.1.3" }, "suggest": { "ext-pcntl": "Required for the spinner to be animated." @@ -975,23 +975,26 @@ } }, "autoload": { + "psr-4": { + "Laravel\\Prompts\\": "src/" + }, "files": [ "src/helpers.php" - ], + ] + }, + "autoload-dev": { "psr-4": { - "Laravel\\Prompts\\": "src/" + "Tests\\": "tests/" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { - "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.6" + "source": "https://github.com/AlexSkrypnyk/prompts/tree/feature/add-description" }, - "time": "2025-07-07T14:17:42+00:00" + "time": "2025-08-30T01:04:27+00:00" }, { "name": "marc-mabe/php-enum", @@ -5775,7 +5778,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "laravel/prompts": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/.vortex/installer/rector.php b/.vortex/installer/rector.php index fa47e3498..03ef14a55 100644 --- a/.vortex/installer/rector.php +++ b/.vortex/installer/rector.php @@ -14,6 +14,7 @@ use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; +use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; @@ -57,6 +58,7 @@ NewlineBeforeNewAssignSetRector::class, RemoveAlwaysTrueIfConditionRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, + SimplifyUselessVariableRector::class, // Dependencies. '*/vendor/*', '*/node_modules/*', diff --git a/.vortex/installer/src/Command/InstallCommand.php b/.vortex/installer/src/Command/InstallCommand.php index 3bb0ad62a..f3e80a871 100644 --- a/.vortex/installer/src/Command/InstallCommand.php +++ b/.vortex/installer/src/Command/InstallCommand.php @@ -9,6 +9,7 @@ use DrevOps\VortexInstaller\Utils\Downloader; use DrevOps\VortexInstaller\Utils\Env; use DrevOps\VortexInstaller\Utils\File; +use DrevOps\VortexInstaller\Utils\Strings; use DrevOps\VortexInstaller\Utils\Tui; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -51,6 +52,11 @@ class InstallCommand extends Command { */ protected Config $config; + /** + * The prompt manager. + */ + protected PromptManager $promptManager; + /** * {@inheritdoc} */ @@ -101,15 +107,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->resolveOptions($input->getArguments(), $input->getOptions()); Tui::init($output, !$this->config->getNoInteraction()); - $pm = new PromptManager($this->config); + $this->promptManager = new PromptManager($this->config); static::header(); - $pm->runPrompts(); + $this->promptManager->runPrompts(); - Tui::list($pm->getResponsesSummary(), 'Installation summary'); + Tui::list($this->promptManager->getResponsesSummary(), 'Installation summary'); - if (!$pm->shouldProceed()) { + if (!$this->promptManager->shouldProceed()) { Tui::info('Aborting project installation. No files were changed.'); return Command::SUCCESS; @@ -132,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int Tui::action( label: 'βš™οΈ Customizing Vortex for your project', - action: fn() => $pm->runProcessors(), + action: fn() => $this->promptManager->runProcessors(), success: 'Vortex was customized for your project', ); @@ -153,9 +159,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int action: fn(): string|array => $this->handleDemo(), success: 'Demo content prepared', ); - - // @todo Implement the demo mode. - // $this->handleDemo(); } catch (\Exception $exception) { Tui::output()->setVerbosity(OutputInterface::VERBOSITY_NORMAL); @@ -452,6 +455,8 @@ protected function header(): void { public function footer(): void { $output = ''; + $prefix = ' '; + if ($this->config->isVortexProject()) { $title = 'Finished updating Vortex πŸš€πŸš€πŸš€'; $output .= 'Please review the changes and commit the required files.'; @@ -459,29 +464,20 @@ public function footer(): void { else { $title = 'Finished installing Vortex πŸš€πŸš€πŸš€'; $output .= 'Next steps:' . PHP_EOL; - $output .= PHP_EOL; - $output .= ' Add and commit all files:' . PHP_EOL; - $output .= ' cd ' . $this->config->getDst() . PHP_EOL; - $output .= ' git add -A' . PHP_EOL; - $output .= ' git commit -m "Initial commit."' . PHP_EOL; - $output .= PHP_EOL; // Check for required tools and provide conditional instructions. $missing_tools = $this->checkRequiredTools(); if (!empty($missing_tools)) { - $output .= ' Install required tools:' . PHP_EOL; + $tools_output = 'Install required tools:' . PHP_EOL; foreach ($missing_tools as $tool => $instructions) { - $output .= sprintf(' %s: %s', $tool, $instructions) . PHP_EOL; + $tools_output .= sprintf(' %s: %s', $tool, $instructions) . PHP_EOL; } - $output .= PHP_EOL; + $tools_output .= PHP_EOL; + $output .= Strings::wrapLines($tools_output, $prefix); } - $output .= ' Build project locally:' . PHP_EOL; - $output .= ' ahoy build' . PHP_EOL; - $output .= PHP_EOL; - $output .= ' Setup integration with your CI/CD system and hosting:' . PHP_EOL; - $output .= ' See https://www.vortextemplate.com/docs/quickstart'; - $output .= PHP_EOL; + // Allow post-install handlers to add their messages. + $output .= Strings::wrapLines($this->promptManager->runPostInstall(), $prefix); } Tui::box($output, $title); diff --git a/.vortex/installer/src/Prompts/Handlers/AbstractHandler.php b/.vortex/installer/src/Prompts/Handlers/AbstractHandler.php index 77fd64dba..21f570bb9 100644 --- a/.vortex/installer/src/Prompts/Handlers/AbstractHandler.php +++ b/.vortex/installer/src/Prompts/Handlers/AbstractHandler.php @@ -163,6 +163,13 @@ public function setWebroot(string $webroot): static { return $this; } + /** + * {@inheritdoc} + */ + public function postInstall(): ?string { + return NULL; + } + /** * Check that Vortex is installed for this project. * diff --git a/.vortex/installer/src/Prompts/Handlers/AiCodeInstructions.php b/.vortex/installer/src/Prompts/Handlers/AiCodeInstructions.php index 26306f94b..edac71510 100644 --- a/.vortex/installer/src/Prompts/Handlers/AiCodeInstructions.php +++ b/.vortex/installer/src/Prompts/Handlers/AiCodeInstructions.php @@ -21,7 +21,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Helps AI coding assistants to understand the project better.'; + return 'Provides AI coding assistants with better context about the project.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/CiProvider.php b/.vortex/installer/src/Prompts/Handlers/CiProvider.php index d0b71652a..cebaf63ae 100644 --- a/.vortex/installer/src/Prompts/Handlers/CiProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/CiProvider.php @@ -25,7 +25,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Both providers support equivalent workflow.'; + return 'Use ⬆ and ⬇ to select the CI provider.'; } /** @@ -33,9 +33,9 @@ public function hint(array $responses): ?string { */ public function options(array $responses): ?array { $options = [ - self::NONE => 'None', self::GITHUB_ACTIONS => 'GitHub Actions', self::CIRCLECI => 'CircleCI', + self::NONE => 'None', ]; if (isset($responses[CodeProvider::id()]) && $responses[CodeProvider::id()] !== CodeProvider::GITHUB) { diff --git a/.vortex/installer/src/Prompts/Handlers/CodeProvider.php b/.vortex/installer/src/Prompts/Handlers/CodeProvider.php index 5ef4221d4..67b3d4a40 100644 --- a/.vortex/installer/src/Prompts/Handlers/CodeProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/CodeProvider.php @@ -22,10 +22,17 @@ public function label(): string { /** * {@inheritdoc} */ - public function hint(array $responses): ?string { + public static function description(array $responses): string { return 'Vortex offers full automation with GitHub, while support for other providers is limited.'; } + /** + * {@inheritdoc} + */ + public function hint(array $responses): ?string { + return 'Use ⬆ and ⬇ to select your code repository provider.'; + } + /** * {@inheritdoc} */ diff --git a/.vortex/installer/src/Prompts/Handlers/DatabaseDownloadSource.php b/.vortex/installer/src/Prompts/Handlers/DatabaseDownloadSource.php index 688acfe2b..c13422135 100644 --- a/.vortex/installer/src/Prompts/Handlers/DatabaseDownloadSource.php +++ b/.vortex/installer/src/Prompts/Handlers/DatabaseDownloadSource.php @@ -32,7 +32,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'The database can be downloaded as an exported dump file or pre-packaged in a container image.'; + return 'Use ⬆ and ⬇ to select the database download source.'; } /** @@ -45,7 +45,7 @@ public function options(array $responses): ?array { self::ACQUIA => 'πŸ’§ Acquia backup', self::LAGOON => '🌊 Lagoon environment', self::CONTAINER_REGISTRY => '🐳 Container registry', - self::NONE => 'πŸ™… None', + self::NONE => '🚫 None', ]; if (isset($responses[HostingProvider::id()])) { diff --git a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php index fac20a505..a6df8a998 100644 --- a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php @@ -25,7 +25,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Use a self-hosted service if you cannot install a GitHub app.'; + return 'Use ⬆ and ⬇ to select the dependency updates provider.'; } /** @@ -33,8 +33,8 @@ public function hint(array $responses): ?string { */ public function options(array $responses): ?array { return [ - self::RENOVATEBOT_CI => 'πŸ€– + πŸ”„ Renovate self-hosted in CI', self::RENOVATEBOT_APP => 'πŸ€– Renovate GitHub app', + self::RENOVATEBOT_CI => 'πŸ€– + πŸ”„ Renovate self-hosted in CI', self::NONE => '🚫 None', ]; } @@ -43,7 +43,7 @@ public function options(array $responses): ?array { * {@inheritdoc} */ public function default(array $responses): null|string|bool|array { - return self::RENOVATEBOT_CI; + return self::RENOVATEBOT_APP; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/DeployType.php b/.vortex/installer/src/Prompts/Handlers/DeployType.php index 3245a1db2..508f3d515 100644 --- a/.vortex/installer/src/Prompts/Handlers/DeployType.php +++ b/.vortex/installer/src/Prompts/Handlers/DeployType.php @@ -29,7 +29,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'You can deploy code using one or more methods.'; + return 'Use ⬆, ⬇ and Space bar to select one or more deployment types.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/HandlerInterface.php b/.vortex/installer/src/Prompts/Handlers/HandlerInterface.php index 820b0e1b2..561dff709 100644 --- a/.vortex/installer/src/Prompts/Handlers/HandlerInterface.php +++ b/.vortex/installer/src/Prompts/Handlers/HandlerInterface.php @@ -126,7 +126,7 @@ public function transform(): ?callable; * * If this returns a non-empty value, the caller should use this value * instead of prompting the user for input. This allows handlers to - * encapsulate logic for when values are discovered from environment, + * encapsulate logic for when values are discovered from the environment, * auto-selected based on other responses, or otherwise pre-determined. * * @param array $responses @@ -177,4 +177,9 @@ public function setWebroot(string $webroot): static; */ public function process(): void; + /** + * Actions to perform and messages to print after installation is complete. + */ + public function postInstall(): ?string; + } diff --git a/.vortex/installer/src/Prompts/Handlers/HostingProvider.php b/.vortex/installer/src/Prompts/Handlers/HostingProvider.php index 20a45709f..aa4bcfec8 100644 --- a/.vortex/installer/src/Prompts/Handlers/HostingProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/HostingProvider.php @@ -29,7 +29,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Select the hosting provider where the project is hosted. The web root directory will be set accordingly.'; + return 'Use ⬆, ⬇ and Space bar to select your hosting provider.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Internal.php b/.vortex/installer/src/Prompts/Handlers/Internal.php index 6800c5831..f42b4078b 100644 --- a/.vortex/installer/src/Prompts/Handlers/Internal.php +++ b/.vortex/installer/src/Prompts/Handlers/Internal.php @@ -67,7 +67,7 @@ public function process(): void { if (!$should_ignore) { $content = File::collapseRepeatedEmptyLines($content); if (in_array($file->getExtension(), ['yml', 'yaml'], TRUE)) { - $content = Yaml::collapseFirstEmptyLinesInLiteralBlock($content); + $content = Yaml::collapseFirstEmptyLinesInLiteralBlock($content); } $content = Strings::removeTrailingSpaces($content); } @@ -123,10 +123,13 @@ public function process(): void { protected function processDemoMode(array $responses, string $dir): void { $is_demo = $this->config->get(Config::IS_DEMO); - // If demo mode is not set, check if it should be enabled based on - // provision type and database download source. if (is_null($is_demo)) { - if ($responses[ProvisionType::id()] === ProvisionType::DATABASE) { + if ($responses[Starter::id()] !== Starter::DRUPAL_LOAD_DATABASE_DEMO) { + $is_demo = FALSE; + } + // Check if it should be enabled based on the provision type and database + // download source. + elseif ($responses[ProvisionType::id()] === ProvisionType::DATABASE) { $db_file_exists = file_exists(Env::get('VORTEX_DB_DIR', './.data') . DIRECTORY_SEPARATOR . Env::get('VORTEX_DB_FILE', 'db.sql')); $has_comment = File::contains($this->dstDir . '/.env', 'Override project-specific values for demonstration purposes'); @@ -165,4 +168,19 @@ protected function processDemoMode(array $responses, string $dir): void { $this->config->set(Config::IS_DEMO, $is_demo); } + public function postInstall():?string { + $output = ''; + + if (!$this->isInstalled()) { + $output .= PHP_EOL; + $output .= 'Add and commit all files:' . PHP_EOL; + $output .= ' cd ' . $this->config->getDst() . PHP_EOL; + $output .= ' git add -A' . PHP_EOL; + $output .= ' git commit -m "Initial commit."' . PHP_EOL; + $output .= PHP_EOL; + } + + return $output; + } + } diff --git a/.vortex/installer/src/Prompts/Handlers/LabelMergeConflictsPr.php b/.vortex/installer/src/Prompts/Handlers/LabelMergeConflictsPr.php index 2aca3e824..a73a6ccb9 100644 --- a/.vortex/installer/src/Prompts/Handlers/LabelMergeConflictsPr.php +++ b/.vortex/installer/src/Prompts/Handlers/LabelMergeConflictsPr.php @@ -10,7 +10,7 @@ class LabelMergeConflictsPr extends AbstractHandler { * {@inheritdoc} */ public function label(): string { - return '🎫 Auto-add a CONFLICT label to a PR when conflicts occur?'; + return '🎫 Auto-add a CONFLICT label to a PR when conflicts occur?'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/ModulePrefix.php b/.vortex/installer/src/Prompts/Handlers/ModulePrefix.php index 2c2eadf28..783b17e11 100644 --- a/.vortex/installer/src/Prompts/Handlers/ModulePrefix.php +++ b/.vortex/installer/src/Prompts/Handlers/ModulePrefix.php @@ -20,7 +20,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'We will use this name for custom modules.'; + return 'We will use this name in custom modules'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Name.php b/.vortex/installer/src/Prompts/Handlers/Name.php index 4daeef4ed..422b95390 100644 --- a/.vortex/installer/src/Prompts/Handlers/Name.php +++ b/.vortex/installer/src/Prompts/Handlers/Name.php @@ -21,7 +21,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'We will use this name in the project and in the documentation.'; + return 'We will use this name in the project and documentation.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Org.php b/.vortex/installer/src/Prompts/Handlers/Org.php index 65077a60a..63ede0d4f 100644 --- a/.vortex/installer/src/Prompts/Handlers/Org.php +++ b/.vortex/installer/src/Prompts/Handlers/Org.php @@ -21,7 +21,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'We will use this name in the project and in the documentation.'; + return 'We will use this name in the project and documentation.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/OrgMachineName.php b/.vortex/installer/src/Prompts/Handlers/OrgMachineName.php index 94ed9ef7f..09bbaac3b 100644 --- a/.vortex/installer/src/Prompts/Handlers/OrgMachineName.php +++ b/.vortex/installer/src/Prompts/Handlers/OrgMachineName.php @@ -21,7 +21,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'We will use this name for the project directory and in the code.'; + return 'We will use this name in the code.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Profile.php b/.vortex/installer/src/Prompts/Handlers/Profile.php index 8b60dc1fa..3e7fe6651 100644 --- a/.vortex/installer/src/Prompts/Handlers/Profile.php +++ b/.vortex/installer/src/Prompts/Handlers/Profile.php @@ -28,7 +28,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Select which profile to use'; + return 'Use ⬆, ⬇ and Space bar to select which Drupal profile to use.'; } /** @@ -46,7 +46,7 @@ public function options(array $responses): ?array { self::STANDARD => 'Standard', self::MINIMAL => 'Minimal', self::DEMO_UMAMI => 'Demo Umami', - self::CUSTOM => 'Custom', + self::CUSTOM => 'Custom (next prompt)', ]; } diff --git a/.vortex/installer/src/Prompts/Handlers/ProvisionType.php b/.vortex/installer/src/Prompts/Handlers/ProvisionType.php index d172aad67..304005591 100644 --- a/.vortex/installer/src/Prompts/Handlers/ProvisionType.php +++ b/.vortex/installer/src/Prompts/Handlers/ProvisionType.php @@ -6,6 +6,7 @@ use DrevOps\VortexInstaller\Utils\Env; use DrevOps\VortexInstaller\Utils\File; +use DrevOps\VortexInstaller\Utils\Tui; class ProvisionType extends AbstractHandler { @@ -20,11 +21,33 @@ public function label(): string { return 'πŸ¦‹ Provision type'; } + /** + * {@inheritdoc} + */ + public static function description(array $responses): string { + $label1 = Tui::bold('Import from database dump'); + $label2 = Tui::bold('Install from profile'); + + return << 'Drupal, installed from profile', + self::DRUPAL_LOAD_DATABASE_DEMO => 'Drupal, loaded from the demo database', + ]; + } + + /** + * {@inheritdoc} + */ + public function default(array $responses): null|string|bool|array { + return self::DRUPAL_LOAD_DATABASE_DEMO; + } + + /** + * {@inheritdoc} + */ + public function discover(): null|string|bool|array { + return NULL; + } + + /** + * {@inheritdoc} + */ + public function process(): void { + // @todo Implement. + } + + /** + * {@inheritdoc} + */ + public function postInstall(): ?string { + if ($this->isInstalled()) { + return NULL; + } + + $output = ''; + + if ($this->response == self::DRUPAL_LOAD_DATABASE_DEMO) { + $output .= 'Build project locally:' . PHP_EOL; + $output .= ' ahoy build' . PHP_EOL; + $output .= PHP_EOL; + } + elseif ($this->response == self::DRUPAL_INSTALL_PROFILE) { + $output .= 'Build project locally:' . PHP_EOL; + $output .= ' VORTEX_PROVISION_TYPE=profile ahoy build' . PHP_EOL; + $output .= PHP_EOL; + $output .= 'Export database:' . PHP_EOL; + $output .= ' ahoy export-db db.sql' . PHP_EOL; + $output .= PHP_EOL; + } + + // @todo Update to use separate steps for hosting and CI/CD configuration. + $output .= 'Setup integration with your hosting and CI/CD providers:' . PHP_EOL; + $output .= ' See https://www.vortextemplate.com/docs/quickstart'; + $output .= PHP_EOL; + + return $output; + } + +} diff --git a/.vortex/installer/src/Prompts/Handlers/Theme.php b/.vortex/installer/src/Prompts/Handlers/Theme.php index 0f78f646e..4b3ed4645 100644 --- a/.vortex/installer/src/Prompts/Handlers/Theme.php +++ b/.vortex/installer/src/Prompts/Handlers/Theme.php @@ -21,7 +21,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'We will use this name for the theme directory. Leave empty to skip the theme scaffold.'; + return 'Name for the theme directory. Leave empty to skip scaffolding.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Timezone.php b/.vortex/installer/src/Prompts/Handlers/Timezone.php index 26af41881..9ec7536d4 100644 --- a/.vortex/installer/src/Prompts/Handlers/Timezone.php +++ b/.vortex/installer/src/Prompts/Handlers/Timezone.php @@ -621,7 +621,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Select the timezone for your project.'; + return 'Use ⬆ and ⬇, or start typing to select the timezone for your project.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Tools.php b/.vortex/installer/src/Prompts/Handlers/Tools.php index 62eb6d77a..0e7008466 100644 --- a/.vortex/installer/src/Prompts/Handlers/Tools.php +++ b/.vortex/installer/src/Prompts/Handlers/Tools.php @@ -36,7 +36,7 @@ public function label(): string { * {@inheritdoc} */ public function hint(array $responses): ?string { - return 'Use up and down arrows to select tools. Press space to toggle selection.'; + return 'Use ⬆, ⬇ and Space bar to select one or more tools.'; } /** diff --git a/.vortex/installer/src/Prompts/Handlers/Webroot.php b/.vortex/installer/src/Prompts/Handlers/Webroot.php index fd637f63e..c33999f07 100644 --- a/.vortex/installer/src/Prompts/Handlers/Webroot.php +++ b/.vortex/installer/src/Prompts/Handlers/Webroot.php @@ -96,7 +96,17 @@ public function transform(): ?callable { * {@inheritdoc} */ public function resolvedValue(array $responses): null|string|bool|array { - return $this->discover(); + $discovered = $this->discover(); + + if (!is_null($discovered)) { + return $discovered; + } + + if (($responses[HostingProvider::id()] ?? '') === HostingProvider::ACQUIA) { + return self::DOCROOT; + } + + return NULL; } /** diff --git a/.vortex/installer/src/Prompts/PromptManager.php b/.vortex/installer/src/Prompts/PromptManager.php index 17649dcf7..077796654 100644 --- a/.vortex/installer/src/Prompts/PromptManager.php +++ b/.vortex/installer/src/Prompts/PromptManager.php @@ -30,6 +30,7 @@ use DrevOps\VortexInstaller\Prompts\Handlers\ProfileCustom; use DrevOps\VortexInstaller\Prompts\Handlers\ProvisionType; use DrevOps\VortexInstaller\Prompts\Handlers\Services; +use DrevOps\VortexInstaller\Prompts\Handlers\Starter; use DrevOps\VortexInstaller\Prompts\Handlers\Theme; use DrevOps\VortexInstaller\Prompts\Handlers\Timezone; use DrevOps\VortexInstaller\Prompts\Handlers\Tools; @@ -121,10 +122,8 @@ public function runPrompts(): void { ->add(fn($r, $pr, $n): string => text(...$this->args(OrgMachineName::class, NULL, $r)), OrgMachineName::id()) ->add(fn($r, $pr, $n): string => text(...$this->args(Domain::class, NULL, $r)), Domain::id()) - ->intro('Code repository') - ->add(fn($r, $pr, $n): int|string => select(...$this->args(CodeProvider::class)), CodeProvider::id()) - ->intro('Drupal') + ->add(fn($r, $pr, $n): int|string => select(...$this->args(Starter::class, NULL, $r)), Starter::id()) ->add( fn($r, $pr, $n): int|string => select(...$this->args(Profile::class)), Profile::id() @@ -137,6 +136,9 @@ public function runPrompts(): void { ->add(fn($r, $pr, $n): string => text(...$this->args(ModulePrefix::class, NULL, $r)), ModulePrefix::id()) ->add(fn($r, $pr, $n): string => text(...$this->args(Theme::class, NULL, $r)), Theme::id()) + ->intro('Code repository') + ->add(fn($r, $pr, $n): int|string => select(...$this->args(CodeProvider::class)), CodeProvider::id()) + ->intro('Environment') ->add(fn($r, $pr, $n): string => suggest(...$this->args(Timezone::class)), Timezone::id()) ->add(fn($r, $pr, $n): array => multiselect(...$this->args(Services::class)), Services::id()) @@ -145,6 +147,7 @@ public function runPrompts(): void { ->intro('Hosting') ->add(fn($r, $pr, $n): int|string => select(...$this->args(HostingProvider::class)), HostingProvider::id()) ->add( + // @todo Move into centralised resolver within this class. function (array $r, $pr, $n): string { $handler = $this->handlers[Webroot::id()]; $resolved = $handler->resolvedValue($r); @@ -163,7 +166,6 @@ function (array $r, $pr, $n): string { ->add(fn($r, $pr, $n): array => multiselect(...$this->args(DeployType::class, NULL, $r)), DeployType::id()) ->intro('Workflow') - ->add(fn($r, $pr, $n) => Tui::note('Provisioning is the process of setting up the site in the environment with an already assembled codebase.')) ->add(fn($r, $pr, $n): int|string => select(...$this->args(ProvisionType::class)), ProvisionType::id()) ->addIf( fn($r): bool => $this->handlers[DatabaseDownloadSource::id()]->shouldRun($r), @@ -263,6 +265,7 @@ public function runProcessors(): void { Services::id(), Timezone::id(), CodeProvider::id(), + Starter::id(), ProfileCustom::id(), Profile::id(), Domain::id(), @@ -285,6 +288,32 @@ public function runProcessors(): void { } } + /** + * Run all post-install processors. + */ + public function runPostInstall(): string { + $output = ''; + + $ids = [ + Internal::id(), + Starter::id(), + ]; + + foreach ($ids as $id) { + if (!array_key_exists($id, $this->handlers)) { + throw new \RuntimeException(sprintf('Handler for "%s" not found.', $id)); + } + + $handler_output = $this->handlers[$id]->postInstall(); + + if (is_string($handler_output) && !empty($handler_output)) { + $output .= $handler_output; + } + } + + return $output; + } + /** * Check if the installation should proceed. * @@ -298,9 +327,9 @@ public function shouldProceed(): bool { $proceed = TRUE; if (!$this->config->getNoInteraction()) { + Tui::note(sprintf('Vortex will be installed into your project\'s directory "%s"', $this->config->getDst())); $proceed = confirm( label: 'Proceed with installing Vortex?', - hint: sprintf('Vortex will be installed into your project\'s directory "%s"', $this->config->getDst()) ); } @@ -323,27 +352,20 @@ public function getResponsesSummary(): array { $values['Organization machine name'] = $responses[OrgMachineName::id()]; $values['Public domain'] = $responses[Domain::id()]; - $values['Code repository'] = Tui::LIST_SECTION_TITLE; - $values['Code provider'] = $responses[CodeProvider::id()]; - $values['Drupal'] = Tui::LIST_SECTION_TITLE; + $values['Starter'] = $responses[Starter::id()]; $values['Webroot'] = $responses[Webroot::id()]; $values['Profile'] = $responses[Profile::id()]; - $values['Module prefix'] = $responses[ModulePrefix::id()]; $values['Theme machine name'] = $responses[Theme::id()] ?? ''; + $values['Code repository'] = Tui::LIST_SECTION_TITLE; + $values['Code provider'] = $responses[CodeProvider::id()]; + $values['Environment'] = Tui::LIST_SECTION_TITLE; $values['Timezone'] = $responses[Timezone::id()]; - $values['ClamAV'] = Converter::bool(in_array(Services::CLAMAV, $responses[Services::id()])); - $values['Solr'] = Converter::bool(in_array(Services::SOLR, $responses[Services::id()])); - $values['Valkey'] = Converter::bool(in_array(Services::VALKEY, $responses[Services::id()])); - $values['PHP CodeSniffer'] = Converter::bool(in_array(Tools::PHPCS, $responses[Tools::id()])); - $values['PHP Mess Detector'] = Converter::bool(in_array(Tools::PHPMD, $responses[Tools::id()])); - $values['PHPStan'] = Converter::bool(in_array(Tools::PHPSTAN, $responses[Tools::id()])); - $values['Rector'] = Converter::bool(in_array(Tools::RECTOR, $responses[Tools::id()])); - $values['PHPUnit'] = Converter::bool(in_array(Tools::PHPUNIT, $responses[Tools::id()])); - $values['Behat'] = Converter::bool(in_array(Tools::BEHAT, $responses[Tools::id()])); + $values['Services'] = Converter::toList($responses[Services::id()], ', '); + $values['Tools'] = Converter::toList($responses[Tools::id()], ', '); $values['Hosting'] = Tui::LIST_SECTION_TITLE; $values['Hosting provider'] = $responses[HostingProvider::id()]; @@ -368,7 +390,7 @@ public function getResponsesSummary(): array { $values['Automations'] = Tui::LIST_SECTION_TITLE; $values['Dependency updates provider'] = $responses[DependencyUpdatesProvider::id()]; $values['Auto-assign PR author'] = Converter::bool($responses[AssignAuthorPr::id()]); - $values['Auto-add a CONFLICT label to PRs'] = Converter::bool($responses[LabelMergeConflictsPr::id()]); + $values['Auto-add a CONFLICT label to PRs'] = Converter::bool($responses[LabelMergeConflictsPr::id()]); $values['Documentation'] = Tui::LIST_SECTION_TITLE; $values['Preserve project documentation'] = Converter::bool($responses[PreserveDocsProject::id()]); @@ -494,6 +516,11 @@ private function args(string $handler_class, mixed $default_override = NULL, arr 'validate' => $handler->validate(), ]; + $description = $handler->description($responses); + if (!is_null($description)) { + $args['description'] = PHP_EOL . $description . PHP_EOL; + } + if ($handler->isRequired()) { $args['required'] = TRUE; } diff --git a/.vortex/installer/src/Utils/Strings.php b/.vortex/installer/src/Utils/Strings.php index 2c692fde5..be86c7c0d 100644 --- a/.vortex/installer/src/Utils/Strings.php +++ b/.vortex/installer/src/Utils/Strings.php @@ -16,6 +16,27 @@ public static function strlenPlain(string $text): int { return mb_strwidth($clean_text, 'UTF-8'); } + /** + * Wrap each line in a string with a prefix and/or suffix. + * + * @param string $lines + * The input string containing multiple lines. + * @param string $prefix + * The prefix to add to each line. + * @param string $suffix + * The suffix to add to each line. + * @param string $eol + * The end-of-line character(s) to use for splitting and joining lines. + * + * @return string + * The modified string with each line padded with the specified prefix and + * suffix. + */ + public static function wrapLines(string $lines, string $prefix = '', string $suffix = '', string $eol = PHP_EOL): string { + $eol = $eol === '' ? PHP_EOL : $eol; + return implode($eol, array_map(fn(string $line): string => $prefix . $line . $suffix, explode($eol, $lines))); + } + /** * Checks if a string is a valid regular expression. * diff --git a/.vortex/installer/src/Utils/Tui.php b/.vortex/installer/src/Utils/Tui.php index 7714c8362..2b62ddf65 100644 --- a/.vortex/installer/src/Utils/Tui.php +++ b/.vortex/installer/src/Utils/Tui.php @@ -26,6 +26,10 @@ class Tui { public static function init(OutputInterface $output, bool $is_interactive = TRUE): void { static::$output = $output; + // We cannot use any Symfony console styles here, because Laravel Prompts + // does not correctly calculate the length of strings with style tags, which + // breaks the layout. Instead, we use ANSI escape codes directly using + // helpers in this class. Prompt::setOutput($output); if (!$is_interactive) { @@ -233,6 +237,11 @@ public static function list(array $values, ?string $title): void { } } + $terminal_width = static::terminalWidth(); + + // (margin + 2 x border + 2 x padding) x 2 - 1 collapse divider width. + $column_width = (int) floor(($terminal_width - (1 + (1 + 1) * 2) * 2 - 1) / 2); + $header = []; $rows = []; foreach ($values as $key => $value) { @@ -241,7 +250,13 @@ public static function list(array $values, ?string $title): void { continue; } - $rows[] = [' ' . static::normalizeText($key), static::normalizeText($value)]; + $key = static::normalizeText($key); + $value = static::normalizeText($value); + + $key = ' ' . wordwrap(static::normalizeText($key), $column_width + 2, PHP_EOL . ' ', TRUE); + $value = wordwrap(static::normalizeText($value), $column_width, PHP_EOL, TRUE); + + $rows[] = [$key, $value]; } intro(PHP_EOL . static::normalizeText($title) . PHP_EOL); diff --git a/.vortex/installer/tests/Fixtures/install/ciprovider_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/ciprovider_circleci/.circleci/config.yml index b5c656a89..74fc2ee9b 100644 --- a/.vortex/installer/tests/Fixtures/install/ciprovider_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/ciprovider_circleci/.circleci/config.yml @@ -431,51 +431,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -536,20 +491,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/deploy_type_all_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/deploy_type_all_circleci/.circleci/config.yml index b5c656a89..74fc2ee9b 100644 --- a/.vortex/installer/tests/Fixtures/install/deploy_type_all_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/deploy_type_all_circleci/.circleci/config.yml @@ -431,51 +431,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -536,20 +491,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/deploy_type_none_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/deploy_type_none_circleci/.circleci/config.yml index fd902facf..0465da2ac 100644 --- a/.vortex/installer/tests/Fixtures/install/deploy_type_none_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/deploy_type_none_circleci/.circleci/config.yml @@ -373,51 +373,6 @@ jobs: paths: - code - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -449,20 +404,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/_baseline/.github/workflows/update-dependencies.yml b/.vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_circleci/.github/workflows/update-dependencies.yml similarity index 100% rename from .vortex/installer/tests/Fixtures/install/_baseline/.github/workflows/update-dependencies.yml rename to .vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_circleci/.github/workflows/update-dependencies.yml diff --git a/.vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_gha/.github/workflows/update-dependencies.yml b/.vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_gha/.github/workflows/update-dependencies.yml new file mode 100644 index 000000000..53bc38afd --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/deps_updates_provider_ci_gha/.github/workflows/update-dependencies.yml @@ -0,0 +1,75 @@ +# Self-hosted dependency updates. +# +# Add the following environment variables to the GitHub actions project: +# - RENOVATE_TOKEN: GitHub access token. +# - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. +# Variables provided below can be overridden in the GitHub project settings. +# +# This workflow can be run manually to initiate immediate updates. +# An additional flag can be set to preserve the configured schedules and skip +# updates if they are not due. This allows to replicate automated scheduled runs. +name: Update dependencies + +on: + schedule: + - cron: '45 11,23 * * *' + workflow_dispatch: + inputs: + preserve_schedules: + description: 'Use defined schedules and skip updates if they are not due.' + required: false + default: false + type: boolean + +jobs: + update-dependencies: + runs-on: ubuntu-latest + + steps: + - name: Check requirements + id: check-requirements + run: | + if [ -z "${{ secrets.RENOVATE_TOKEN }}" ]; then + echo "Renovate token is not set. Skipping job." + exit 0 + fi + + if [ -z "${{ vars.RENOVATE_GIT_AUTHOR }}" ]; then + echo "Renovate git author is not set. Skipping job." + exit 0 + fi + + echo "should_run=true" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@__HASH__ # __VERSION__ + + - uses: actions/setup-node@__HASH__ # __VERSION__ + with: + node-version: __VERSION__ + + - name: Process manual trigger + if: github.event_name == 'workflow_dispatch' && inputs.preserve_schedules == false + run: jq 'walk(if type == "object" then del(.schedule) else . end)' renovate.json > renovate.tmp.json && mv -f renovate.tmp.json renovate.json + + - name: Show Renovate configuration + run: cat renovate.json + + - name: Validate Renovate configuration + uses: suzuki-shunsuke/github-action-renovate-config-validator@__HASH__ # __VERSION__ + + - name: Run Renovate + if: steps.check-requirements.outputs.should_run == 'true' + uses: renovatebot/github-action@__HASH__ # __VERSION__ + with: + configurationFile: renovate.json + token: ${{ secrets.RENOVATE_TOKEN }} + env: + RENOVATE_PLATFORM: 'github' + RENOVATE_AUTODISCOVER: false + RENOVATE_REPOSITORIES: ${{ vars.RENOVATE_REPOSITORIES || github.repository }} + RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by GitHub Actions' + RENOVATE_DEPENDENCY_DASHBOARD: ${{ vars.RENOVATE_DEPENDENCY_DASHBOARD || 'false' }} + RENOVATE_DRY_RUN: ${{ vars.RENOVATE_DRY_RUN || 'false' }} + RENOVATE_GIT_AUTHOR: ${{ vars.RENOVATE_GIT_AUTHOR }} + LOG_LEVEL: 'debug' diff --git a/.vortex/installer/tests/Fixtures/install/deps_updates_provider_none/.github/workflows/update-dependencies.yml b/.vortex/installer/tests/Fixtures/install/deps_updates_provider_none/.github/workflows/update-dependencies.yml new file mode 100644 index 000000000..53bc38afd --- /dev/null +++ b/.vortex/installer/tests/Fixtures/install/deps_updates_provider_none/.github/workflows/update-dependencies.yml @@ -0,0 +1,75 @@ +# Self-hosted dependency updates. +# +# Add the following environment variables to the GitHub actions project: +# - RENOVATE_TOKEN: GitHub access token. +# - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. +# Variables provided below can be overridden in the GitHub project settings. +# +# This workflow can be run manually to initiate immediate updates. +# An additional flag can be set to preserve the configured schedules and skip +# updates if they are not due. This allows to replicate automated scheduled runs. +name: Update dependencies + +on: + schedule: + - cron: '45 11,23 * * *' + workflow_dispatch: + inputs: + preserve_schedules: + description: 'Use defined schedules and skip updates if they are not due.' + required: false + default: false + type: boolean + +jobs: + update-dependencies: + runs-on: ubuntu-latest + + steps: + - name: Check requirements + id: check-requirements + run: | + if [ -z "${{ secrets.RENOVATE_TOKEN }}" ]; then + echo "Renovate token is not set. Skipping job." + exit 0 + fi + + if [ -z "${{ vars.RENOVATE_GIT_AUTHOR }}" ]; then + echo "Renovate git author is not set. Skipping job." + exit 0 + fi + + echo "should_run=true" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@__HASH__ # __VERSION__ + + - uses: actions/setup-node@__HASH__ # __VERSION__ + with: + node-version: __VERSION__ + + - name: Process manual trigger + if: github.event_name == 'workflow_dispatch' && inputs.preserve_schedules == false + run: jq 'walk(if type == "object" then del(.schedule) else . end)' renovate.json > renovate.tmp.json && mv -f renovate.tmp.json renovate.json + + - name: Show Renovate configuration + run: cat renovate.json + + - name: Validate Renovate configuration + uses: suzuki-shunsuke/github-action-renovate-config-validator@__HASH__ # __VERSION__ + + - name: Run Renovate + if: steps.check-requirements.outputs.should_run == 'true' + uses: renovatebot/github-action@__HASH__ # __VERSION__ + with: + configurationFile: renovate.json + token: ${{ secrets.RENOVATE_TOKEN }} + env: + RENOVATE_PLATFORM: 'github' + RENOVATE_AUTODISCOVER: false + RENOVATE_REPOSITORIES: ${{ vars.RENOVATE_REPOSITORIES || github.repository }} + RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by GitHub Actions' + RENOVATE_DEPENDENCY_DASHBOARD: ${{ vars.RENOVATE_DEPENDENCY_DASHBOARD || 'false' }} + RENOVATE_DRY_RUN: ${{ vars.RENOVATE_DRY_RUN || 'false' }} + RENOVATE_GIT_AUTHOR: ${{ vars.RENOVATE_GIT_AUTHOR }} + LOG_LEVEL: 'debug' diff --git a/.vortex/installer/tests/Fixtures/install/timezone_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/timezone_circleci/.circleci/config.yml index b5c656a89..74fc2ee9b 100644 --- a/.vortex/installer/tests/Fixtures/install/timezone_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/timezone_circleci/.circleci/config.yml @@ -431,51 +431,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -536,20 +491,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_lint_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_lint_circleci/.circleci/config.yml index 11ceb6455..874890e59 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_lint_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_lint_circleci/.circleci/config.yml @@ -407,51 +407,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -512,20 +467,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_tests_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_tests_circleci/.circleci/config.yml index c40552306..ee430752b 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_tests_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_groups_no_be_tests_circleci/.circleci/config.yml @@ -411,51 +411,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -516,20 +471,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_behat_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_behat_circleci/.circleci/config.yml index 4c082d20b..e25fef5e1 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_behat_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_behat_circleci/.circleci/config.yml @@ -415,51 +415,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -520,20 +475,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_phpcs_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_phpcs_circleci/.circleci/config.yml index 3ac83cc51..cddfd2cd2 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_phpcs_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_phpcs_circleci/.circleci/config.yml @@ -425,51 +425,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -530,20 +485,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_phpmd_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_phpmd_circleci/.circleci/config.yml index a105fb6b0..b2f9d634b 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_phpmd_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_phpmd_circleci/.circleci/config.yml @@ -425,51 +425,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -530,20 +485,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_phpstan_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_phpstan_circleci/.circleci/config.yml index 9c78f2296..bb3a2abab 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_phpstan_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_phpstan_circleci/.circleci/config.yml @@ -425,51 +425,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -530,20 +485,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_phpunit_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_phpunit_circleci/.circleci/config.yml index 654e6ef52..d649af1cc 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_phpunit_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_phpunit_circleci/.circleci/config.yml @@ -427,51 +427,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -532,20 +487,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/install/tools_no_rector_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/install/tools_no_rector_circleci/.circleci/config.yml index 0aa9a7a94..c6363416d 100644 --- a/.vortex/installer/tests/Fixtures/install/tools_no_rector_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/install/tools_no_rector_circleci/.circleci/config.yml @@ -425,51 +425,6 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ @@ -530,20 +485,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Unit/Handlers/AbstractPromptManagerTestCase.php b/.vortex/installer/tests/Unit/Handlers/AbstractPromptManagerTestCase.php index 84730b257..1a866c9fc 100644 --- a/.vortex/installer/tests/Unit/Handlers/AbstractPromptManagerTestCase.php +++ b/.vortex/installer/tests/Unit/Handlers/AbstractPromptManagerTestCase.php @@ -26,6 +26,7 @@ use DrevOps\VortexInstaller\Prompts\Handlers\Profile; use DrevOps\VortexInstaller\Prompts\Handlers\ProvisionType; use DrevOps\VortexInstaller\Prompts\Handlers\Services; +use DrevOps\VortexInstaller\Prompts\Handlers\Starter; use DrevOps\VortexInstaller\Prompts\Handlers\Theme; use DrevOps\VortexInstaller\Prompts\Handlers\Timezone; use DrevOps\VortexInstaller\Prompts\Handlers\Tools; @@ -120,10 +121,11 @@ protected static function getExpectedDefaults(): array { Org::id() => 'myproject Org', OrgMachineName::id() => 'myproject_org', Domain::id() => 'myproject.com', - CodeProvider::id() => CodeProvider::GITHUB, + Starter::id() => Starter::DRUPAL_LOAD_DATABASE_DEMO, Profile::id() => Profile::STANDARD, ModulePrefix::id() => 'mypr', Theme::id() => 'myproject', + CodeProvider::id() => CodeProvider::GITHUB, Timezone::id() => 'UTC', Services::id() => [Services::CLAMAV, Services::SOLR, Services::VALKEY], Tools::id() => [Tools::PHPCS, Tools::PHPMD, Tools::PHPSTAN, Tools::RECTOR, Tools::PHPUNIT, Tools::BEHAT], @@ -134,7 +136,7 @@ protected static function getExpectedDefaults(): array { DatabaseDownloadSource::id() => DatabaseDownloadSource::URL, DatabaseImage::id() => NULL, CiProvider::id() => CiProvider::GITHUB_ACTIONS, - DependencyUpdatesProvider::id() => DependencyUpdatesProvider::RENOVATEBOT_CI, + DependencyUpdatesProvider::id() => DependencyUpdatesProvider::RENOVATEBOT_APP, AssignAuthorPr::id() => TRUE, LabelMergeConflictsPr::id() => TRUE, PreserveDocsProject::id() => TRUE, @@ -188,10 +190,11 @@ public static function defaultTuiAnswers(): array { Org::id() => static::TUI_DEFAULT, OrgMachineName::id() => static::TUI_DEFAULT, Domain::id() => static::TUI_DEFAULT, - CodeProvider::id() => static::TUI_DEFAULT, + Starter::id() => static::TUI_DEFAULT, Profile::id() => static::TUI_DEFAULT, ModulePrefix::id() => static::TUI_DEFAULT, Theme::id() => static::TUI_DEFAULT, + CodeProvider::id() => static::TUI_DEFAULT, Timezone::id() => static::TUI_DEFAULT, Services::id() => static::TUI_DEFAULT, Tools::id() => static::TUI_DEFAULT, diff --git a/.vortex/installer/tests/Unit/Handlers/CodeProviderPromptManagerTest.php b/.vortex/installer/tests/Unit/Handlers/CodeProviderPromptManagerTest.php index f614debf7..363a9e1e5 100644 --- a/.vortex/installer/tests/Unit/Handlers/CodeProviderPromptManagerTest.php +++ b/.vortex/installer/tests/Unit/Handlers/CodeProviderPromptManagerTest.php @@ -29,7 +29,7 @@ public static function dataProviderRunPrompts(): array { [CodeProvider::id() => Key::DOWN . Key::ENTER], [ CodeProvider::id() => CodeProvider::OTHER, - CiProvider::id() => CiProvider::NONE, + CiProvider::id() => CiProvider::CIRCLECI, ] + $expected_defaults, ], @@ -43,9 +43,7 @@ function (AbstractPromptManagerTestCase $test): void { 'code repo - discovery - other' => [ [], - [ - CodeProvider::id() => CodeProvider::OTHER, - ] + $expected_installed, + [CodeProvider::id() => CodeProvider::OTHER] + $expected_installed, function (AbstractPromptManagerTestCase $test, Config $config): void { $test->stubVortexProject($config); Git::init(static::$sut); diff --git a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderPromptManagerTest.php b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderPromptManagerTest.php index 6d02bd54a..f6ca30d75 100644 --- a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderPromptManagerTest.php +++ b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderPromptManagerTest.php @@ -21,7 +21,7 @@ public static function dataProviderRunPrompts(): array { return [ 'dependency updates provider - prompt' => [ [DependencyUpdatesProvider::id() => Key::ENTER], - [DependencyUpdatesProvider::id() => DependencyUpdatesProvider::RENOVATEBOT_CI] + $expected_defaults, + [DependencyUpdatesProvider::id() => DependencyUpdatesProvider::RENOVATEBOT_APP] + $expected_defaults, ], 'dependency updates provider - discovery - renovate self-hosted - gha' => [ diff --git a/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php b/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php new file mode 100644 index 000000000..1e2f0521d --- /dev/null +++ b/.vortex/installer/tests/Unit/Handlers/StarterPromptManagerTest.php @@ -0,0 +1,38 @@ + [ + [Starter::id() => Key::ENTER], + [Starter::id() => Starter::DRUPAL_LOAD_DATABASE_DEMO] + $expected_defaults, + ], + + 'starter - prompt - profile' => [ + [Starter::id() => Key::DOWN . Key::ENTER], + [Starter::id() => Starter::DRUPAL_INSTALL_PROFILE] + $expected_defaults, + ], + + 'starter - discovery' => [ + [], + [Starter::id() => Starter::DRUPAL_LOAD_DATABASE_DEMO] + $expected_defaults, + function (AbstractPromptManagerTestCase $test): void { + // Noop. + }, + ], + ]; + } + +} diff --git a/.vortex/installer/tests/Unit/StringsTest.php b/.vortex/installer/tests/Unit/StringsTest.php index bc2698185..d3202aad8 100644 --- a/.vortex/installer/tests/Unit/StringsTest.php +++ b/.vortex/installer/tests/Unit/StringsTest.php @@ -535,4 +535,155 @@ public static function dataProviderRemoveTrailingSpaces(): array { ]; } + #[DataProvider('dataProviderWrapLines')] + public function testWrapLines(string $input, string $prefix, string $suffix, string $eol, string $expected): void { + $actual = Strings::wrapLines($input, $prefix, $suffix, $eol); + $this->assertEquals($expected, $actual); + } + + public static function dataProviderWrapLines(): array { + return [ + 'empty_string' => [ + '', + '', + '', + PHP_EOL, + '', + ], + 'single_line_no_wrapping' => [ + 'hello world', + '', + '', + PHP_EOL, + 'hello world', + ], + 'single_line_with_prefix' => [ + 'hello world', + '> ', + '', + PHP_EOL, + '> hello world', + ], + 'single_line_with_suffix' => [ + 'hello world', + '', + ' <', + PHP_EOL, + 'hello world <', + ], + 'single_line_with_prefix_and_suffix' => [ + 'hello world', + '[ ', + ' ]', + PHP_EOL, + '[ hello world ]', + ], + 'multiline_with_prefix' => [ + "line one\nline two\nline three", + '> ', + '', + "\n", + "> line one\n> line two\n> line three", + ], + 'multiline_with_suffix' => [ + "line one\nline two\nline three", + '', + ' <--', + "\n", + "line one <--\nline two <--\nline three <--", + ], + 'multiline_with_prefix_and_suffix' => [ + "line one\nline two\nline three", + '| ', + ' |', + "\n", + "| line one |\n| line two |\n| line three |", + ], + 'empty_lines_with_wrapping' => [ + "line one\n\nline three", + '- ', + '', + "\n", + "- line one\n- \n- line three", + ], + 'custom_eol_character' => [ + "line one\r\nline two", + '> ', + ' <', + "\r\n", + "> line one <\r\n> line two <", + ], + 'html_tag_wrapping' => [ + "First paragraph\nSecond paragraph", + '

', + '

', + "\n", + "

First paragraph

\n

Second paragraph

", + ], + 'indentation_wrapping' => [ + "function test()\nreturn 'hello'", + ' ', + '', + "\n", + " function test()\n return 'hello'", + ], + 'comment_wrapping' => [ + "This is a comment\nAnother line", + '// ', + '', + "\n", + "// This is a comment\n// Another line", + ], + 'quote_wrapping' => [ + "First quote\nSecond quote", + '"', + '"', + "\n", + "\"First quote\"\n\"Second quote\"", + ], + 'single_character_eol' => [ + "line1|line2|line3", + '> ', + ' <', + "|", + "> line1 <|> line2 <|> line3 <", + ], + 'whitespace_only_lines' => [ + " \n\t\n ", + '> ', + ' <', + "\n", + "> <\n> \t <\n> <", + ], + 'special_characters_in_prefix_suffix' => [ + "line one\nline two", + '[INFO] ', + ' βœ“', + "\n", + "[INFO] line one βœ“\n[INFO] line two βœ“", + ], + 'unicode_content_and_wrapping' => [ + "Hello δΈ–η•Œ\nGoodbye 🌍", + 'πŸ”Ή ', + ' ✨', + "\n", + "πŸ”Ή Hello δΈ–η•Œ ✨\nπŸ”Ή Goodbye 🌍 ✨", + ], + 'complex_multiline_with_php_eol' => [ + " [ + "line one\nline two\nline three", + '> ', + ' <', + '', + "> line one <" . PHP_EOL . "> line two <" . PHP_EOL . "> line three <", + ], + ]; + } + }