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
4 changes: 2 additions & 2 deletions .vortex/docs/content/development/modules/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ assertions in a single pass.
|-----------|----------|--------|
| Composer requirement | `require` in [`composer.json`](https://github.com/drevops/vortex/blob/main/composer.json) | Makes the module available to the site. ➡️ See [composer.json](../composer.mdx#require) |
| Settings override | `web/sites/default/includes/modules/settings.<module>.php` | Applies configuration conditioned on the detected environment, reading values from environment variables. ➡️ See [Settings](../settings.mdx#per-module-overrides) |
| Config export exclusion | `$settings['config_exclude_modules']` in a settings override | Keeps a development-only module out of the exported configuration, so enabling it locally never dirties the config. ➡️ See [Settings](../settings.mdx#per-module-overrides) |
| Config export exclusion | `$settings['config_exclude_modules']` in a settings override | Keeps a module that never reaches production out of the exported configuration, so enabling it locally never dirties the config. ➡️ See [Settings](../settings.mdx#per-module-overrides) |
| Provisioning | [`scripts/provision-00-enable-demo-modules.sh`](https://github.com/drevops/vortex/blob/main/scripts/provision-00-enable-demo-modules.sh) | Stands up the demo site in the `local`, `ci`, `dev` and `stage` environments: applies the `recipes/page` content model, sets the site name, installs the contrib, service and custom site modules (including core's `media` and `navigation`), and runs their deploy hooks. ➡️ See [Provision](../provision.mdx#demo-modules) |
| Development provisioning | [`scripts/provision-10-enable-dev-modules.sh`](https://github.com/drevops/vortex/blob/main/scripts/provision-10-enable-dev-modules.sh) | Installs the development-only modules in the same four environments. ➡️ See [Provision](../provision.mdx#development-modules) |
| Development provisioning | [`scripts/provision-10-enable-dev-modules.sh`](https://github.com/drevops/vortex/blob/main/scripts/provision-10-enable-dev-modules.sh) | Installs the modules that never reach production - the development tools and the email rerouting safety net - in the same four environments. ➡️ See [Provision](../provision.mdx#development-modules) |
| Module dependency | [`ys_demo.info.yml`](https://github.com/drevops/vortex/blob/main/web/modules/custom/ys_demo/ys_demo.info.yml) | Installs the module as a dependency of the demo module. ➡️ See [Demo module](module-scaffold.mdx#demo-module) |

A module can be required without being installed anywhere: the settings
Expand Down
17 changes: 11 additions & 6 deletions .vortex/docs/content/development/modules/contributed-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ intended recipients. This prevents accidental email delivery to real users in
non-production environments while still allowing email functionality to be
tested.

- **Installed:** During development provisioning by [`scripts/provision-10-enable-dev-modules.sh`](https://github.com/drevops/vortex/blob/main/scripts/provision-10-enable-dev-modules.sh), so the safety net survives the demo script being adapted or removed.

### Configuration

[`settings.reroute_email.php`](https://github.com/drevops/vortex/blob/main/web/sites/default/includes/modules/settings.reroute_email.php) enables rerouting in every environment except `local`, `ci`, `stage` and `prod`.
[`settings.reroute_email.php`](https://github.com/drevops/vortex/blob/main/web/sites/default/includes/modules/settings.reroute_email.php) excludes the module from the exported configuration and enables rerouting in every environment except `local`, `ci` and `prod`.

Rerouting replaces the recipient of an outgoing message with the configured address, unless that recipient matches `DRUPAL_REROUTE_EMAIL_ALLOWED`. With rerouting disabled, every message reaches its intended recipient. Rerouting is therefore disabled only where that delivery is either wanted or already intercepted by other means.

Expand All @@ -179,15 +181,17 @@ Rerouting replaces the recipient of an outgoing message with the configured addr
| Local | No | [Pygmy](../environment/pygmy.mdx) already catches outgoing mail |
| CI | No | The [mail collector](../testing/behat.mdx#email) stores messages instead of sending them |
| Dev | **Yes** | Prevents accidental delivery to real users |
| Stage | No | Stage may require real email delivery for UAT |
| Stage | **Yes** | Stage runs a copy of production content, so any address that survives database sanitization is a real one |
| Prod | No | Production emails must reach actual recipients |

Rerouting is also enabled in any custom environments (e.g., PR environments)
that do not match the standard environment types listed above.
Rerouting is the fall-through default, so it is also enabled in any custom
environments (e.g., PR environments) that do not match the standard environment
types listed above. Those environments install the module only if their
environment type is added to the provisioning scripts. ➡️ See [Provision](../provision.mdx#development-modules)

Rerouting is off in `ci` so that tests can assert on the address a message was sent to. With rerouting on, every message would carry the rerouting address instead of the intended one.

A site that deselects this module during [installation](../../installation.mdx) still sends no mail from `ci`, because the mail collector stores messages there regardless. That site does send mail to real recipients in `dev` and in custom environments.
A site that deselects this module during [installation](../../installation.mdx) still sends no mail from `ci`, because the mail collector stores messages there regardless. That site does send mail to real recipients in `dev`, `stage` and custom environments.

**Environment variables:**

Expand All @@ -199,7 +203,8 @@ A site that deselects this module during [installation](../../installation.mdx)
**Overriding default behavior:**

Set `DRUPAL_REROUTE_EMAIL_DISABLED` to any non-empty value to completely disable
email rerouting in an environment where it would otherwise be enabled.
email rerouting in an environment where it would otherwise be enabled. This is
the supported way for a `stage` environment to send real mail during UAT.

<details>
<summary>Example of the `Reroute Email` module `settings.reroute_email.php` file</summary>
Expand Down
20 changes: 13 additions & 7 deletions .vortex/docs/content/development/provision.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ e.g., `provision-50-custom.sh`, `provision-60-another-custom.sh`.
| Script | Purpose | Present when |
|---------------------------------------|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `provision-00-enable-demo-modules.sh` | Enables the modules and content model the demo site uses | Always; the installer trims its operations to the selected modules |
| `provision-10-enable-dev-modules.sh` | Enables the development modules and generates content | Any of `devel`, `sdc_devel`, `generated_content` or `testmode` is selected; removed by the installer otherwise |
| `provision-10-enable-dev-modules.sh` | Enables the development modules and generates content | Any of `devel`, `sdc_devel`, `generated_content`, `testmode` or `reroute_email` is selected; removed by the installer otherwise |
| `provision-20-migration.sh` | Runs the content migration | The migration feature is selected; removed by the installer otherwise |
| `provision-30-search-index.sh` | Rebuilds the search index | The Solr service is selected; removed by the installer otherwise |
| `provision-40-example.sh` | A runnable example that performs no operations | Always; copy it as a starting point or remove it |
Expand Down Expand Up @@ -413,15 +413,21 @@ relying on the demo content.
**Vortex** ships a `scripts/provision-10-enable-dev-modules.sh` custom script that
installs the development modules - [Devel](https://www.drupal.org/project/devel),
[SDC Devel](https://www.drupal.org/project/sdc_devel) and
[Testmode](https://www.drupal.org/project/testmode).
[Testmode](https://www.drupal.org/project/testmode) - and the
[Reroute Email](https://www.drupal.org/project/reroute_email) safety net.

Development modules live in their own script so that they stay enabled after the
demo and example scripts are adapted or removed. They are also the modules kept
out of the exported configuration, so provisioning is the only place that can
These modules live in their own script so that they stay enabled after the demo
and example scripts are adapted or removed. They are also the modules kept out
of the exported configuration, so provisioning is the only place that can
install them.

Both scripts run only in the `local`, `ci`, `dev` and `stage` environments. To
opt out of either set of modules, remove the corresponding script.
Both scripts run only in the `local`, `ci`, `dev` and `stage` environments, and
skip every other environment type. A project that introduces a custom
environment type has to add it to both scripts to have these modules installed
there, including the email rerouting that
[the settings file](modules/contributed-modules.mdx#reroute-email) enables for
every environment outside `local`, `ci` and `prod`. To opt out of either set of
modules, remove the corresponding script.

### Generated content

Expand Down
8 changes: 4 additions & 4 deletions .vortex/installer/src/Prompts/Handlers/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class Modules extends AbstractHandler {
/**
* Modules driven by the development modules provision script.
*
* These modules are development and testing tools that are deliberately kept
* out of the exported configuration, so the provision script is the only
* place that can install them. Adding a module here also requires a fenced
* These modules are not installed in production and are deliberately kept out
* of the exported configuration, so the provision script is the only place
* that can install them. Adding a module here also requires a fenced
* 'MODULE_<NAME>' block in the script.
*
* The script has operations to perform while any one of these is selected.
*
* @var string[]
*/
protected const DEV_MODULES = ['devel', 'sdc_devel', 'generated_content', 'testmode'];
protected const DEV_MODULES = ['devel', 'sdc_devel', 'generated_content', 'testmode', 'reroute_email'];

/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fi
pass "Set up the administration navigation."

task "Installing contrib modules."
drush pm:install coffee config_split config_update media environment_indicator navigation_extra_tools pathauto redirect reroute_email robotstxt shield stage_file_proxy xmlsitemap
drush pm:install coffee config_split config_update media environment_indicator navigation_extra_tools pathauto redirect robotstxt shield stage_file_proxy xmlsitemap
pass "Installed contrib modules."

task "Installing Redis module."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ task "Installing Testmode module."
drush pm:install testmode
pass "Installed Testmode module."

task "Installing Reroute Email module."
drush pm:install reroute_email
pass "Installed Reroute Email module."

task "Installing Generated content module."
if [ "${DRUPAL_GENERATED_CONTENT_SKIP}" = "1" ]; then
note "Content generation skipped. DRUPAL_GENERATED_CONTENT_SKIP is set to 1."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function testEnvironmentNoOverrides(): void {
$settings['config_exclude_modules'] = [
'devel',
'generated_content',
'reroute_email',
'sdc_devel',
'testmode',
];
Expand Down Expand Up @@ -172,6 +173,7 @@ public function testEnvironmentOverrides(): void {
$settings['config_exclude_modules'] = [
'devel',
'generated_content',
'reroute_email',
'sdc_devel',
'testmode',
];
Expand Down Expand Up @@ -229,6 +231,7 @@ public function testEnvironmentLocal(): void {
$settings['config_exclude_modules'] = [
'devel',
'generated_content',
'reroute_email',
'sdc_devel',
'testmode',
];
Expand Down Expand Up @@ -286,6 +289,7 @@ public function testEnvironmentLocalContainer(): void {
$settings['config_exclude_modules'] = [
'devel',
'generated_content',
'reroute_email',
'sdc_devel',
'testmode',
];
Expand Down Expand Up @@ -386,6 +390,7 @@ public function testEnvironmentGha(): void {
$settings['config_exclude_modules'] = [
'devel',
'generated_content',
'reroute_email',
'sdc_devel',
'testmode',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,12 @@ public static function dataProviderRerouteEmail(): \Iterator {
],
];

// Stage: disabled by default.
// Stage: enabled by default.
yield [
self::ENVIRONMENT_STAGE,
[],
[
'reroute_email.settings' => ['enable' => FALSE, 'address' => 'webmaster@star-wars.com', 'allowed' => '*@star-wars.com'],
'reroute_email.settings' => ['enable' => TRUE, 'address' => 'webmaster@star-wars.com', 'allowed' => '*@star-wars.com'],
],
];

Expand Down Expand Up @@ -757,6 +757,17 @@ public static function dataProviderRerouteEmail(): \Iterator {
],
];

// Stage with DRUPAL_REROUTE_EMAIL_DISABLED: forced off.
yield [
self::ENVIRONMENT_STAGE,
[
'DRUPAL_REROUTE_EMAIL_DISABLED' => 1,
],
[
'reroute_email.settings' => ['enable' => FALSE],
],
];

// Custom address and allowed list.
yield [
self::ENVIRONMENT_DEV,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@

declare(strict_types=1);

$settings['config_exclude_modules'][] = 'reroute_email';

$config['reroute_email.settings']['address'] = getenv('DRUPAL_REROUTE_EMAIL_ADDRESS') ?: 'webmaster@star-wars.com';
$config['reroute_email.settings']['allowed'] = getenv('DRUPAL_REROUTE_EMAIL_ALLOWED') ?: '*@star-wars.com';

if (!in_array($settings['environment'], [ENVIRONMENT_LOCAL, ENVIRONMENT_CI, ENVIRONMENT_STAGE, ENVIRONMENT_PROD], TRUE)) {
if (in_array($settings['environment'], [ENVIRONMENT_LOCAL, ENVIRONMENT_CI, ENVIRONMENT_PROD], TRUE)) {
// Deliver every message to its intended recipient. Local and CI capture
// outgoing mail by other means, and production sends to real recipients.
$config['reroute_email.settings']['enable'] = FALSE;
}
else {
// Send every outgoing message to the address above instead of to its
// intended recipient, unless that recipient matches the allowed list.
$config['reroute_email.settings']['enable'] = TRUE;
}
else {
// Deliver every message to its intended recipient.
$config['reroute_email.settings']['enable'] = FALSE;
}

// Allow an environment to opt out of the rerouting set above.
if (!empty(getenv('DRUPAL_REROUTE_EMAIL_DISABLED'))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -352,9 +352,9 @@
@@ -356,9 +356,9 @@
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -352,9 +352,9 @@
@@ -356,9 +356,9 @@
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -352,9 +352,9 @@
@@ -356,9 +356,9 @@
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -352,9 +352,9 @@
@@ -356,9 +356,9 @@
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -352,9 +352,9 @@
@@ -356,9 +356,9 @@
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@

declare(strict_types=1);

$settings['config_exclude_modules'][] = 'reroute_email';

$config['reroute_email.settings']['address'] = getenv('DRUPAL_REROUTE_EMAIL_ADDRESS') ?: 'webmaster@star-wars.com';
$config['reroute_email.settings']['allowed'] = getenv('DRUPAL_REROUTE_EMAIL_ALLOWED') ?: '*@star-wars.com';

if (!in_array($settings['environment'], [ENVIRONMENT_LOCAL, ENVIRONMENT_CI, ENVIRONMENT_STAGE, ENVIRONMENT_PROD], TRUE)) {
if (in_array($settings['environment'], [ENVIRONMENT_LOCAL, ENVIRONMENT_CI, ENVIRONMENT_PROD], TRUE)) {
// Deliver every message to its intended recipient. Local and CI capture
// outgoing mail by other means, and production sends to real recipients.
$config['reroute_email.settings']['enable'] = FALSE;
}
else {
// Send every outgoing message to the address above instead of to its
// intended recipient, unless that recipient matches the allowed list.
$config['reroute_email.settings']['enable'] = TRUE;
}
else {
// Deliver every message to its intended recipient.
$config['reroute_email.settings']['enable'] = FALSE;
}

// Allow an environment to opt out of the rerouting set above.
if (!empty(getenv('DRUPAL_REROUTE_EMAIL_DISABLED'))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}

/**
@@ -403,6 +447,331 @@
@@ -408,6 +452,337 @@
$settings['maintenance_theme'] = 'claro';
$settings['skip_permissions_hardening'] = TRUE;
$settings['config_sync_directory'] = '../config/default';
Expand Down Expand Up @@ -90,6 +90,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down Expand Up @@ -143,6 +144,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down Expand Up @@ -183,7 +185,7 @@
+ $config['environment_indicator.settings']['favicon'] = TRUE;
+ $config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
+ $config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
+ $config['reroute_email.settings']['enable'] = FALSE;
+ $config['reroute_email.settings']['enable'] = TRUE;
+ $config['reroute_email.settings']['address'] = 'webmaster@star-wars.com';
+ $config['reroute_email.settings']['allowed'] = '*@star-wars.com';
+ $config['shield.settings']['shield_enable'] = TRUE;
Expand All @@ -196,6 +198,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down Expand Up @@ -246,6 +249,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down Expand Up @@ -300,6 +304,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down Expand Up @@ -361,6 +366,7 @@
+ $settings['config_exclude_modules'] = [
+ 'devel',
+ 'generated_content',
+ 'reroute_email',
+ 'sdc_devel',
+ 'testmode',
+ ];
Expand Down
Loading