Skip to content

Commit e934c5e

Browse files
committed
Updated footers.
1 parent a5b122a commit e934c5e

13 files changed

Lines changed: 494 additions & 253 deletions

File tree

.vortex/docs/static/img/installer.json

Lines changed: 186 additions & 198 deletions
Large diffs are not rendered by default.

.vortex/docs/static/img/installer.svg

Lines changed: 1 addition & 1 deletion
Loading

.vortex/installer/src/Command/InstallCommand.php

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class InstallCommand extends Command implements CommandRunnerAwareInterface, Exe
5050

5151
const OPTION_BUILD = 'build';
5252

53+
const BUILD_RESULT_SUCCESS = 'success';
54+
55+
const BUILD_RESULT_SKIPPED = 'skipped';
56+
57+
const BUILD_RESULT_FAILED = 'failed';
58+
5359
/**
5460
* Defines default command name.
5561
*
@@ -206,15 +212,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
206212
);
207213

208214
if (!$build_ok) {
209-
Tui::error('Site build failed. Vortex was installed, but the site build process encountered errors.');
210-
Tui::line('');
211-
Tui::line('Next steps:');
212-
Tui::line(' - Run: ahoy build');
213-
Tui::line(' - Or inspect logs for details with `ahoy logs`');
214-
Tui::line('');
215+
$this->footerBuildFailed();
215216

216217
return Command::FAILURE;
217218
}
219+
220+
$this->footerBuildSucceeded();
221+
}
222+
else {
223+
$this->footerBuildSkipped();
218224
}
219225

220226
// Cleanup should take place only in case of the successful installation.
@@ -553,7 +559,6 @@ public function footer(): void {
553559
}
554560
else {
555561
$title = 'Finished installing Vortex';
556-
$output .= 'Next steps:' . PHP_EOL;
557562

558563
// Check for required tools and provide conditional instructions.
559564
$missing_tools = $this->checkRequiredTools();
@@ -562,17 +567,94 @@ public function footer(): void {
562567
foreach ($missing_tools as $tool => $instructions) {
563568
$tools_output .= sprintf(' %s: %s', $tool, $instructions) . PHP_EOL;
564569
}
565-
$tools_output .= PHP_EOL;
566570
$output .= Strings::wrapLines($tools_output, $prefix);
571+
$output .= PHP_EOL;
567572
}
568573

569-
// Allow post-install handlers to add their messages.
570-
$output .= Strings::wrapLines($this->promptManager->runPostInstall(), $prefix);
574+
$output .= 'Add and commit all files:' . PHP_EOL;
575+
$output .= $prefix . 'git add -A' . PHP_EOL;
576+
$output .= $prefix . 'git commit -m "Initial commit."' . PHP_EOL;
571577
}
572578

573579
Tui::box($output, $title);
574580
}
575581

582+
/**
583+
* Display footer after build succeeded.
584+
*/
585+
public function footerBuildSucceeded(): void {
586+
$output = '';
587+
$prefix = ' ';
588+
589+
$output .= 'Get site info:' . $prefix . 'ahoy info' . PHP_EOL;
590+
$output .= 'Login:' . $prefix . $prefix . $prefix . 'ahoy login' . PHP_EOL;
591+
$output .= PHP_EOL;
592+
593+
$handler_output = $this->promptManager->runPostBuild(self::BUILD_RESULT_SUCCESS);
594+
if (!empty($handler_output)) {
595+
$output .= $handler_output;
596+
}
597+
598+
Tui::box($output, 'Site is ready');
599+
}
600+
601+
/**
602+
* Display footer after build was skipped.
603+
*/
604+
public function footerBuildSkipped(): void {
605+
$output = '';
606+
$prefix = ' ';
607+
608+
$responses = $this->promptManager->getResponses();
609+
$starter = $responses[Starter::id()] ?? Starter::LOAD_DATABASE_DEMO;
610+
$is_profile = in_array($starter, [Starter::INSTALL_PROFILE_CORE, Starter::INSTALL_PROFILE_DRUPALCMS], TRUE);
611+
612+
$output .= 'Build the site:' . PHP_EOL;
613+
if ($is_profile) {
614+
$output .= $prefix . 'VORTEX_PROVISION_TYPE=profile ahoy build' . PHP_EOL;
615+
}
616+
else {
617+
$output .= $prefix . 'ahoy build' . PHP_EOL;
618+
}
619+
$output .= PHP_EOL;
620+
621+
if ($is_profile) {
622+
$output .= 'Export database after build:' . PHP_EOL;
623+
$output .= $prefix . 'ahoy export-db db.sql' . PHP_EOL;
624+
$output .= PHP_EOL;
625+
}
626+
627+
$handler_output = $this->promptManager->runPostBuild(self::BUILD_RESULT_SKIPPED);
628+
if (!empty($handler_output)) {
629+
$output .= $handler_output;
630+
}
631+
632+
Tui::box($output, 'Ready to build');
633+
}
634+
635+
/**
636+
* Display footer after build failed.
637+
*/
638+
public function footerBuildFailed(): void {
639+
$output = '';
640+
$prefix = ' ';
641+
642+
$output .= 'Vortex was installed, but the build process failed.' . PHP_EOL;
643+
$output .= PHP_EOL;
644+
$output .= 'Troubleshooting:' . PHP_EOL;
645+
$output .= $prefix . 'Check logs:' . $prefix . $prefix . 'ahoy logs' . PHP_EOL;
646+
$output .= $prefix . 'Retry build:' . $prefix . 'ahoy build' . PHP_EOL;
647+
$output .= $prefix . 'Diagnostics:' . $prefix . 'ahoy doctor' . PHP_EOL;
648+
$output .= PHP_EOL;
649+
650+
$handler_output = $this->promptManager->runPostBuild(self::BUILD_RESULT_FAILED);
651+
if (!empty($handler_output)) {
652+
$output .= $handler_output;
653+
}
654+
655+
Tui::box($output, 'Build encountered errors');
656+
}
657+
576658
/**
577659
* Check for required development tools.
578660
*

.vortex/installer/src/Prompts/Handlers/AbstractHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ public function postInstall(): ?string {
170170
return NULL;
171171
}
172172

173+
/**
174+
* {@inheritdoc}
175+
*/
176+
public function postBuild(string $result): ?string {
177+
return NULL;
178+
}
179+
173180
/**
174181
* Check that Vortex is installed for this project.
175182
*

.vortex/installer/src/Prompts/Handlers/CiProvider.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,36 @@ public function process(): void {
119119
}
120120
}
121121

122+
/**
123+
* {@inheritdoc}
124+
*/
125+
public function postInstall(): ?string {
126+
return NULL;
127+
}
128+
129+
/**
130+
* {@inheritdoc}
131+
*/
132+
public function postBuild(string $result): ?string {
133+
if ($this->isInstalled()) {
134+
return NULL;
135+
}
136+
137+
$v = $this->getResponseAsString();
138+
139+
if ($v === self::GITHUB_ACTIONS) {
140+
return 'Setup GitHub Actions:' . PHP_EOL
141+
. ' https://www.vortextemplate.com/docs/continuous-integration/github-actions#onboarding' . PHP_EOL
142+
. PHP_EOL;
143+
}
144+
145+
if ($v === self::CIRCLECI) {
146+
return 'Setup CircleCI:' . PHP_EOL
147+
. ' https://www.vortextemplate.com/docs/continuous-integration/circleci#onboarding' . PHP_EOL
148+
. PHP_EOL;
149+
}
150+
151+
return NULL;
152+
}
153+
122154
}

.vortex/installer/src/Prompts/Handlers/HandlerInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,15 @@ public function process(): void;
184184
*/
185185
public function postInstall(): ?string;
186186

187+
/**
188+
* Actions to perform and messages to print after build is complete.
189+
*
190+
* @param string $result
191+
* The result of the build operation.
192+
*
193+
* @return string|null
194+
* The output to display, or NULL if none.
195+
*/
196+
public function postBuild(string $result): ?string;
197+
187198
}

.vortex/installer/src/Prompts/Handlers/HostingProvider.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,36 @@ protected function removeLagoon(): void {
127127
File::removeTokenAsync('SETTINGS_PROVIDER_LAGOON');
128128
}
129129

130+
/**
131+
* {@inheritdoc}
132+
*/
133+
public function postInstall(): ?string {
134+
return NULL;
135+
}
136+
137+
/**
138+
* {@inheritdoc}
139+
*/
140+
public function postBuild(string $result): ?string {
141+
if ($this->isInstalled()) {
142+
return NULL;
143+
}
144+
145+
$v = $this->getResponseAsString();
146+
147+
if ($v === self::ACQUIA) {
148+
return 'Setup Acquia hosting:' . PHP_EOL
149+
. ' https://www.vortextemplate.com/docs/hosting/acquia#onboarding' . PHP_EOL
150+
. PHP_EOL;
151+
}
152+
153+
if ($v === self::LAGOON) {
154+
return 'Setup Lagoon hosting:' . PHP_EOL
155+
. ' https://www.vortextemplate.com/docs/hosting/lagoon#onboarding' . PHP_EOL
156+
. PHP_EOL;
157+
}
158+
159+
return NULL;
160+
}
161+
130162
}

.vortex/installer/src/Prompts/Handlers/Internal.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ protected function processDemoMode(array $responses, string $dir): void {
166166
$this->config->set(Config::IS_DEMO, $is_demo);
167167
}
168168

169-
public function postInstall():?string {
169+
/**
170+
* {@inheritdoc}
171+
*/
172+
public function postInstall(): ?string {
170173
$output = '';
171174

172175
if (!$this->isInstalled()) {

.vortex/installer/src/Prompts/Handlers/Starter.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,4 @@ public function process(): void {
132132
}
133133
}
134134

135-
/**
136-
* {@inheritdoc}
137-
*/
138-
public function postInstall(): ?string {
139-
if ($this->isInstalled()) {
140-
return NULL;
141-
}
142-
143-
$output = '';
144-
145-
if ($this->response == self::LOAD_DATABASE_DEMO) {
146-
$output .= 'Build project locally:' . PHP_EOL;
147-
$output .= ' ahoy build' . PHP_EOL;
148-
$output .= PHP_EOL;
149-
}
150-
elseif ($this->response == self::INSTALL_PROFILE_CORE || $this->response == self::INSTALL_PROFILE_DRUPALCMS) {
151-
$output .= 'Build project locally:' . PHP_EOL;
152-
$output .= ' VORTEX_PROVISION_TYPE=profile ahoy build' . PHP_EOL;
153-
$output .= PHP_EOL;
154-
$output .= 'Export database:' . PHP_EOL;
155-
$output .= ' ahoy export-db db.sql' . PHP_EOL;
156-
$output .= PHP_EOL;
157-
}
158-
159-
// @todo Update to use separate steps for hosting and CI/CD configuration.
160-
$output .= 'Setup integration with your hosting and CI/CD providers:' . PHP_EOL;
161-
$output .= ' See https://www.vortextemplate.com/docs/getting-started/installation';
162-
163-
return $output . PHP_EOL;
164-
}
165-
166135
}

.vortex/installer/src/Prompts/PromptManager.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,10 @@ public function runPostInstall(): string {
324324
$output = '';
325325

326326
$ids = [
327-
Internal::id(),
328327
Starter::id(),
328+
HostingProvider::id(),
329+
CiProvider::id(),
330+
Internal::id(),
329331
];
330332

331333
foreach ($ids as $id) {
@@ -343,6 +345,39 @@ public function runPostInstall(): string {
343345
return $output;
344346
}
345347

348+
/**
349+
* Run all post-build processors.
350+
*
351+
* @param string $result
352+
* The result of the build operation.
353+
*
354+
* @return string
355+
* The combined output from all post-build processors.
356+
*/
357+
public function runPostBuild(string $result): string {
358+
$output = '';
359+
360+
$ids = [
361+
Starter::id(),
362+
HostingProvider::id(),
363+
CiProvider::id(),
364+
];
365+
366+
foreach ($ids as $id) {
367+
if (!array_key_exists($id, $this->handlers)) {
368+
throw new \RuntimeException(sprintf('Handler for "%s" not found.', $id));
369+
}
370+
371+
$handler_output = $this->handlers[$id]->postBuild($result);
372+
373+
if (is_string($handler_output) && !empty($handler_output)) {
374+
$output .= $handler_output;
375+
}
376+
}
377+
378+
return $output;
379+
}
380+
346381
/**
347382
* Check if the installation should proceed.
348383
*

0 commit comments

Comments
 (0)