Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 123 additions & 229 deletions .vortex/docs/static/img/installer.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .vortex/docs/static/img/installer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions .vortex/installer/src/Prompts/Handlers/HostingProjectName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php

declare(strict_types=1);

namespace DrevOps\VortexInstaller\Prompts\Handlers;

use DrevOps\VortexInstaller\Utils\Converter;
use DrevOps\VortexInstaller\Utils\Env;
use DrevOps\VortexInstaller\Utils\File;

class HostingProjectName extends AbstractHandler {

/**
* {@inheritdoc}
*/
public function label(): string {
return 'Hosting project name';
}

/**
* {@inheritdoc}
*/
public function hint(array $responses): ?string {
return 'Name as found in the hosting configuration. Usually the same as the site machine name.';
}

/**
* {@inheritdoc}
*/
public function placeholder(array $responses): ?string {
return 'E.g. my_site';
}

/**
* {@inheritdoc}
*/
public function isRequired(): bool {
return TRUE;
}

/**
* {@inheritdoc}
*/
public function shouldRun(array $responses): bool {
return isset($responses[HostingProvider::id()]) &&
(
$responses[HostingProvider::id()] === HostingProvider::LAGOON ||
$responses[HostingProvider::id()] === HostingProvider::ACQUIA
);
}

/**
* {@inheritdoc}
*/
public function default(array $responses): null|string|bool|array {
if (isset($responses[MachineName::id()]) && !empty($responses[MachineName::id()])) {
return $responses[MachineName::id()];
}

return NULL;
}

/**
* {@inheritdoc}
*/
public function discover(): null|string|bool|array {
// Try Acquia.
$v = Env::getFromDotenv('VORTEX_ACQUIA_APP_NAME', $this->dstDir);
if (!empty($v)) {
return $v;
}

// Try to discover from settings.acquia.php.
$acquia_settings_file = $this->dstDir . sprintf('/%s/sites/default/includes/providers/settings.acquia.php', $this->webroot);
if (file_exists($acquia_settings_file)) {
$content = file_get_contents($acquia_settings_file);
// Require '/var/www/site-php/your_site/your_site-settings.inc';.
if ($content !== FALSE && preg_match('/require\s+[\'"]\/var\/www\/site-php\/([a-z0-9_]+)\/[a-z0-9_]+-settings\.inc[\'"]\s*;/', $content, $matches) && !empty($matches[1])) {
return $matches[1];
}
}

// Try Lagoon.
$v = Env::getFromDotenv('LAGOON_PROJECT', $this->dstDir);
if (!empty($v)) {
return $v;
}

// Try to discover from drush/sites/lagoon.site.yml.
$lagoon_site_file = $this->dstDir . '/drush/sites/lagoon.site.yml';
if (file_exists($lagoon_site_file)) {
$content = file_get_contents($lagoon_site_file);
if ($content !== FALSE && preg_match('/user:\s*([a-z0-9_]+)-/', $content, $matches) && (!empty($matches[1]) && $matches[1] !== 'your_site')) {
return $matches[1];
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

return NULL;
}

/**
* {@inheritdoc}
*/
public function validate(): ?callable {
return fn($v): ?string => Converter::phpPackageName($v) !== $v ? 'Please enter a valid machine name: only lowercase letters, numbers, hyphens and underscores are allowed.' : NULL;
}

/**
* {@inheritdoc}
*/
public function transform(): ?callable {
return fn(string $v): string => trim($v);
}

/**
* {@inheritdoc}
*/
public function process(): void {
if (!in_array($this->responses[HostingProvider::id()], [HostingProvider::LAGOON, HostingProvider::ACQUIA])) {
return;
}

$v = $this->getResponseAsString();
$t = $this->tmpDir;
$w = $this->webroot;

Env::writeValueDotenv('VORTEX_ACQUIA_APP_NAME', $v, $t . '/.env');
File::replaceContentInFile($t . '/' . $w . '/sites/default/includes/providers/settings.acquia.php', 'your_site', $v);

Env::writeValueDotenv('LAGOON_PROJECT', $v, $t . '/.env');
File::replaceContentInFile($t . '/drush/sites/lagoon.site.yml', 'your_site-${env-name}', $v . '-${env-name}');
File::replaceContentInFile($t . '/drush/sites/lagoon.site.yml', '.your_site.au2.amazee.io', '.' . $v . '.au2.amazee.io');
}

}
12 changes: 11 additions & 1 deletion .vortex/installer/src/Prompts/PromptManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use DrevOps\VortexInstaller\Prompts\Handlers\Domain;
use DrevOps\VortexInstaller\Prompts\Handlers\Dotenv;
use DrevOps\VortexInstaller\Prompts\Handlers\HandlerInterface;
use DrevOps\VortexInstaller\Prompts\Handlers\HostingProjectName;
use DrevOps\VortexInstaller\Prompts\Handlers\HostingProvider;
use DrevOps\VortexInstaller\Prompts\Handlers\Internal;
use DrevOps\VortexInstaller\Prompts\Handlers\LabelMergeConflictsPr;
Expand Down Expand Up @@ -62,7 +63,7 @@ class PromptManager {
*
* Used to display the progress of the prompts.
*/
const TOTAL_RESPONSES = 25;
const TOTAL_RESPONSES = 26;

/**
* Array of responses.
Expand Down Expand Up @@ -158,6 +159,11 @@ function (array $r, $pr, $n): string {

->intro('Hosting')
->add(fn($r, $pr, $n): int|string => select(...$this->args(HostingProvider::class)), HostingProvider::id())
->addIf(
fn($r): bool => $this->handlers[HostingProjectName::id()]->shouldRun($r),
fn($r, $pr, $n): string => text(...$this->args(HostingProjectName::class, NULL, $r)),
HostingProjectName::id()
)
->add(
function (array $r, $pr, $n): string {
return $this->resolveOrPrompt(Webroot::id(), $r, fn(): string => text(...$this->args(Webroot::class, NULL, $r)));
Expand Down Expand Up @@ -278,6 +284,7 @@ public function runProcessors(): void {
ProfileCustom::id(),
Profile::id(),
Domain::id(),
HostingProjectName::id(),
ModulePrefix::id(),
ThemeCustom::id(),
Theme::id(),
Expand Down Expand Up @@ -379,6 +386,9 @@ public function getResponsesSummary(): array {

$values['Hosting'] = Tui::LIST_SECTION_TITLE;
$values['Hosting provider'] = $responses[HostingProvider::id()];
if (in_array($this->responses[HostingProvider::id()], [HostingProvider::LAGOON, HostingProvider::ACQUIA])) {
$values['Hosting project name'] = $responses[HostingProjectName::id()];
}

$values['Deployment'] = Tui::LIST_SECTION_TITLE;
$values['Deployment types'] = Converter::toList($responses[DeployType::id()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
+################################################################################
+
+# Acquia application name.
+VORTEX_ACQUIA_APP_NAME=
+VORTEX_ACQUIA_APP_NAME=star_wars
+
+################################################################################
# DATABASE SOURCE #
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@@ -16,7 +16,7 @@
ARG LAGOON_PR_HEAD_SHA=""
ENV LAGOON_PR_HEAD_SHA=${LAGOON_PR_HEAD_SHA}

-ARG WEBROOT=web
+ARG WEBROOT=docroot
ENV WEBROOT=${WEBROOT}

# Token is used to access private repositories. Not exposed as an environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@@ -14,7 +14,7 @@
FROM uselagoon/nginx-drupal:__VERSION__

# Webroot is used for Nginx web root configuration.
-ARG WEBROOT=web
+ARG WEBROOT=docroot
ENV WEBROOT=${WEBROOT}

RUN apk add --no-cache tzdata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@@ -8,17 +8,17 @@
*

# Do not ignore web.
-!web
+!docroot

# Do not ignore config.
!config

# But still ignore Drupal directories generated by Composer.
-web/core
-web/modules/contrib
-web/themes/contrib
-web/profiles/contrib
-web/libraries
+docroot/core
+docroot/modules/contrib
+docroot/themes/contrib
+docroot/profiles/contrib
+docroot/libraries
!drush
drush/contrib/

@@ -51,3 +51,5 @@
!rector.php
!scripts
!tests
+
+!hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@@ -29,7 +29,7 @@
VORTEX_PROJECT=star_wars

# Name of the web root directory containing a Drupal codebase.
-WEBROOT=web
+WEBROOT=docroot

# The timezone used within the containers.
TZ=UTC
@@ -120,6 +120,13 @@
VORTEX_PROVISION_USE_MAINTENANCE_MODE=1

################################################################################
+# HOSTING #
+################################################################################
+
+# Acquia application name.
+VORTEX_ACQUIA_APP_NAME=my_custom_acquia-project
+
+################################################################################
# DATABASE SOURCE #
################################################################################

@@ -142,13 +149,8 @@
VORTEX_DB_FILE=db.sql

# Database download source.
-VORTEX_DB_DOWNLOAD_SOURCE=url
+VORTEX_DB_DOWNLOAD_SOURCE=acquia

-# Database dump file sourced from a URL.
-#
-# HTTP Basic Authentication credentials should be embedded into the value.
-VORTEX_DB_DOWNLOAD_URL=
-
# Environment to download the database from.
#
# Applies to hosting environments.
@@ -156,6 +158,9 @@
# a branch name or an environment name.
VORTEX_DB_DOWNLOAD_ENVIRONMENT=prod

+# Acquia database name to download the database from.
+VORTEX_DB_DOWNLOAD_ACQUIA_DB_NAME=star_wars
+
################################################################################
# DEPLOYMENT #
################################################################################
@@ -162,7 +167,7 @@

# Deployment occurs when tests pass in the CI environment.
# @see https://www.vortextemplate.com/docs/workflows/deployment
-VORTEX_DEPLOY_TYPES=webhook
+VORTEX_DEPLOY_TYPES=artifact

################################################################################
# NOTIFICATIONS #
@@ -179,7 +184,7 @@
# An email address to send notifications from.
#
# Applies to email notifications.
-VORTEX_NOTIFY_EMAIL_FROM=webmaster@star-wars.com
+VORTEX_NOTIFY_EMAIL_FROM=docrootmaster@star-wars.com

# Email address(es) to send notifications to.
#
@@ -189,17 +194,3 @@
# with optional names in the format "email|name".
# Example: "to1@example.com|Jane Doe, to2@example.com|John Doe"
VORTEX_NOTIFY_EMAIL_RECIPIENTS="webmaster@star-wars.com|Webmaster"
-
-################################################################################
-# DEMO #
-################################################################################
-# #
-# Override project-specific values for demonstration purposes. #
-# Used to showcase Vortex without asking users to perform additional steps. #
-# #
-# Remove this section after completing database download integration. #
-# #
-################################################################################
-
-# URL of the database used for demonstration with URL database download type.
-VORTEX_DB_DOWNLOAD_URL=https://github.com/drevops/vortex/releases/download/25.4.0/db_d11.demo.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@@ -32,3 +32,11 @@

# Always override existing downloaded DB dump.
VORTEX_DB_DOWNLOAD_FORCE=1
+
+# Database dump file sourced from Acquia.
+# Acquia Cloud API token: Acquia Cloud UI -> Account -> API tokens -> Create Token
+
+# Acquia Cloud API key.
+VORTEX_ACQUIA_KEY=
+# Acquia Cloud API secret.
+VORTEX_ACQUIA_SECRET=
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@@ -32,3 +32,11 @@

# Always override existing downloaded DB dump.
VORTEX_DB_DOWNLOAD_FORCE=1
+
+# Database dump file sourced from Acquia.
+# Acquia Cloud API token: Acquia Cloud UI -> Account -> API tokens -> Create Token
+
+# Acquia Cloud API key.
+VORTEX_ACQUIA_KEY=
+# Acquia Cloud API secret.
+VORTEX_ACQUIA_SECRET=
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@@ -1,10 +1,10 @@
node_modules/
vendor/
-web/core/
-web/libraries/
-web/modules/contrib/
-web/profiles/contrib/
-web/themes/contrib/
-web/sites/*/files/
+docroot/core/
+docroot/libraries/
+docroot/modules/contrib/
+docroot/profiles/contrib/
+docroot/themes/contrib/
+docroot/sites/*/files/
*.min.js
*.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@@ -124,6 +124,9 @@
VORTEX_DB_DOWNLOAD_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh
echo "db_hash=${{ hashFiles('.data') }}" >> "$GITHUB_ENV"
timeout-minutes: 30
+ env:
+ VORTEX_ACQUIA_KEY: ${{ secrets.VORTEX_ACQUIA_KEY }}
+ VORTEX_ACQUIA_SECRET: ${{ secrets.VORTEX_ACQUIA_SECRET }}

- name: Export DB
run: |
Loading