Skip to content

Commit

Permalink
[#1525] Simplified VORTEX_WEBROOT and VORTEX_TZ variables. (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Feb 1, 2025
1 parent f872b3e commit e15ef7f
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 53 deletions.
12 changes: 6 additions & 6 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ commands:
fei:
usage: Install front-end assets.
cmd: ahoy cli "npm --prefix ${VORTEX_WEBROOT}/themes/custom/${DRUPAL_THEME} install"
cmd: ahoy cli "npm --prefix ${WEBROOT}/themes/custom/${DRUPAL_THEME} install"

fe:
usage: Build front-end assets.
cmd: ahoy cli "cd ${VORTEX_WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build"
cmd: ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build"

fed:
usage: Build front-end assets for development.
cmd: ahoy cli "cd ${VORTEX_WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build-dev"
cmd: ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build-dev"

few:
usage: Watch front-end assets during development.
cmd: |
ahoy cli "pkill -9 -f grunt" || true
ahoy cli "cd ${VORTEX_WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run watch"
ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run watch"
lint:
usage: Lint back-end and front-end code.
Expand All @@ -194,7 +194,7 @@ commands:
usage: Lint front-end code.
cmd: |
ahoy cli vendor/bin/twig-cs-fixer lint
ahoy cli "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"
ahoy cli "npm run --prefix \${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"
lint-tests:
usage: Lint tests code.
Expand All @@ -215,7 +215,7 @@ commands:
usage: Fix lint issues of front-end code.
cmd: |
ahoy cli vendor/bin/twig-cs-fixer lint --fix
ahoy cli "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint-fix"
ahoy cli "npm run --prefix \${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint-fix"
test:
usage: Run all tests.
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ jobs:

- run:
name: Lint code with NPM linters
command: docker compose exec -T cli bash -c "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint" || [ "${VORTEX_CI_NPM_LINT_IGNORE_FAILURE:-0}" -eq 1 ]
command: docker compose exec -T cli bash -c "npm run --prefix \${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint" || [ "${VORTEX_CI_NPM_LINT_IGNORE_FAILURE:-0}" -eq 1 ]

- run:
name: Provision site
Expand Down
16 changes: 8 additions & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
VORTEX_PROJECT=your_site

# Name of the web root directory containing a Drupal codebase.
VORTEX_WEBROOT=web
WEBROOT=web

# The timezone for the containers.
VORTEX_TZ="Australia/Melbourne"
# The timezone used in the containers.
TZ="Australia/Melbourne"

################################################################################
# DRUPAL #
Expand Down Expand Up @@ -166,11 +166,6 @@ VORTEX_DB_DOWNLOAD_SOURCE=curl
VORTEX_DB_DOWNLOAD_CURL_URL=
#;> VORTEX_DB_DOWNLOAD_SOURCE_CURL

# Environment to download the database from.
#
# Applies to Acquia and Lagoon environments.
VORTEX_DB_DOWNLOAD_ENVIRONMENT=prod

#;< FTP
# Database dump file sourced from FTP.

Expand All @@ -184,6 +179,11 @@ VORTEX_DB_DOWNLOAD_FTP_PORT=21
VORTEX_DB_DOWNLOAD_FTP_FILE=db.sql
#;> FTP

# Environment to download the database from.
#
# Applies to Acquia and Lagoon environments.
VORTEX_DB_DOWNLOAD_ENVIRONMENT=prod

#;< ACQUIA
# Acquia database name to download the database from.
VORTEX_DB_DOWNLOAD_ACQUIA_DB_NAME=your_site
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ jobs:
continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }}

- name: Lint code with NPM linters
run: docker compose exec -T cli bash -c "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"
run: docker compose exec -T cli bash -c "npm run --prefix \${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"
continue-on-error: ${{ vars.VORTEX_CI_NPM_LINT_IGNORE_FAILURE == '1' }}

- name: Provision site
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# shellcheck disable=SC2034

# Path to public files.
DRUPAL_PUBLIC_FILES="${DRUPAL_PUBLIC_FILES:-./${VORTEX_WEBROOT}/sites/default/files}"
DRUPAL_PUBLIC_FILES="${DRUPAL_PUBLIC_FILES:-./${WEBROOT}/sites/default/files}"

# Path to private files.
DRUPAL_PRIVATE_FILES="${DRUPAL_PRIVATE_FILES:-${DRUPAL_PUBLIC_FILES}/private}"
Expand Down
2 changes: 1 addition & 1 deletion .vortex/docs/content/contributing/maintenance/scripts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Follow these guidelines when creating or updating **Vortex** variables.
third-party variables.

3. Global variables MAY be re-used as-is across scripts. For instance, the
`VORTEX_WEBROOT` variable is used in several scripts.
`WEBROOT` variable is used in several scripts.

4. **Vortex** action-specific script variables MUST be scoped within their own
script. For instance, the `VORTEX_PROVISION_OVERRIDE_DB`
Expand Down
6 changes: 3 additions & 3 deletions .vortex/docs/content/tools/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Any other variables should be defined in the `.env` file.
Consider the example:

```
TZ: ${VORTEX_TZ:-Australia/Melbourne}
TZ: ${TZ:-Australia/Melbourne}
# Local development URL.
VORTEX_LOCALDEV_URL: &default-url ${COMPOSE_PROJECT_NAME:-example-site}.docker.amazee.io
# Local development route used in Lagoon images and Pygmy to route requests.
Expand All @@ -175,8 +175,8 @@ Consider the example:

where

- `TZ: ${VORTEX_TZ:-Australia/Melbourne}` - defines a variable `TZ` with a
default value of `Australia/Melbourne`, but only if `VORTEX_TZ` variable is
- `TZ: ${TZ:-Australia/Melbourne}` - defines a variable `TZ` with a
default value of `Australia/Melbourne`, but only if `TZ` variable is
not defined.
- `VORTEX_LOCALDEV_URL: &default-url ${COMPOSE_PROJECT_NAME:-example-site}.docker.amazee.io`
- defines a variable `VORTEX_LOCALDEV_URL` with a default value of
Expand Down
20 changes: 10 additions & 10 deletions .vortex/docs/content/workflows/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Defined in: `.env`, `scripts/vortex/provision.sh`

Path to public files.

Default value: `./${VORTEX_WEBROOT}/sites/default/files`
Default value: `./${WEBROOT}/sites/default/files`

Defined in: `docker-compose.yml`

Expand Down Expand Up @@ -302,6 +302,14 @@ Default value: `${target_env}`

Defined in: `scripts/vortex/task-purge-cache-acquia.sh`

### `TZ`

The timezone used in the containers.

Default value: `Australia/Melbourne`

Defined in: `.env`

### `VORTEX_ACQUIA_APP_NAME`

Acquia application name.
Expand Down Expand Up @@ -1895,15 +1903,7 @@ Default value: `UNDEFINED`

Defined in: `scripts/vortex/task-custom-lagoon.sh`

### `VORTEX_TZ`

The timezone for the containers.

Default value: `Australia/Melbourne`

Defined in: `.env`

### `VORTEX_WEBROOT`
### `WEBROOT`

Name of the web root directory containing a Drupal codebase.

Expand Down
2 changes: 1 addition & 1 deletion .vortex/installer/src/Traits/PromptsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ protected function discoverValueDomain(): ?string {
}

protected function discoverValueWebroot(): ?string {
$webroot = $this->getValueFromDstDotenv('VORTEX_WEBROOT');
$webroot = $this->getValueFromDstDotenv('WEBROOT');

if (empty($webroot) && $this->isInstalled()) {
// Try from composer.json.
Expand Down
6 changes: 3 additions & 3 deletions .vortex/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ prepare_sut() {
substep "Initialise the project with default settings"

# Run default install
export VORTEX_WEBROOT="${webroot}"
export WEBROOT="${webroot}"
run_installer_quiet

assert_files_present_common "" "" "" "" "" "${webroot}"
Expand Down Expand Up @@ -233,7 +233,7 @@ assert_timezone() {

# Assert that .env contains a default value.
# Note that AEDT changes to AEST during winter.
assert_file_contains ".env" 'VORTEX_TZ="Australia/Melbourne"'
assert_file_contains ".env" 'TZ="Australia/Melbourne"'
run docker compose exec cli date
assert_output_contains "AE"
run docker compose exec php date
Expand All @@ -244,7 +244,7 @@ assert_timezone() {
assert_output_contains "AE"

# Add variable to the .env file and apply the change to container.
add_var_to_file .env "VORTEX_TZ" '"Australia/Perth"'
add_var_to_file .env "TZ" '"Australia/Perth"'
sync_to_container
run ahoy up

Expand Down
2 changes: 1 addition & 1 deletion .vortex/tests/bats/docker-compose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ load _helper.bash
cp "${ROOT_DIR}/.env" .env

echo "COMPOSE_PROJECT_NAME=the_matrix" >>.env
echo "VORTEX_WEBROOT=docroot" >>.env
echo "WEBROOT=docroot" >>.env
echo "VORTEX_DB_IMAGE=myorg/my_db_image" >>.env
echo "XDEBUG_ENABLE=1" >>.env
echo "DRUPAL_SHIELD_USER=jane" >>.env
Expand Down
2 changes: 1 addition & 1 deletion .vortex/tests/bats/install.existing.bats
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ load _helper.bash
}

@test "Install into existing: previously installed bespoke project; custom webroot; discovery; quiet" {
echo "VORTEX_WEBROOT=rootdoc" >>".env"
echo "WEBROOT=rootdoc" >>".env"

# Populate current dir with a project at current version.
output=$(run_installer_quiet)
Expand Down
2 changes: 1 addition & 1 deletion .vortex/tests/bats/install.parameters.bats
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fixture_preinstalled() {
# Sets 'preserve_onboarding' to 'Yes'.
mktouch docs/onboarding.md

echo "VORTEX_WEBROOT=${webroot}" >>.env
echo "WEBROOT=${webroot}" >>.env

# Sets 'domain' to 'www.resistance-star-wars.com'.
echo "DRUPAL_STAGE_FILE_PROXY_ORIGIN=http://www.resistance-star-wars.com/" >>.env
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ x-user: &default-user
# Note that these variables are not read from here in Lagoon environment.
#;> LAGOON
x-environment: &default-environment
TZ: ${VORTEX_TZ:-Australia/Melbourne}
TZ: ${TZ:-Australia/Melbourne}
# Local development URL.
VORTEX_LOCALDEV_URL: &default-url ${COMPOSE_PROJECT_NAME:-example-site}.docker.amazee.io
# Local development route used in Lagoon images and Pygmy to route requests.
Expand Down Expand Up @@ -85,7 +85,7 @@ services:
context: .
dockerfile: .docker/cli.dockerfile
args:
WEBROOT: "${VORTEX_WEBROOT:-web}"
WEBROOT: "${WEBROOT:-web}"
GITHUB_TOKEN: "${GITHUB_TOKEN:-}"

image: &cli-image ${COMPOSE_PROJECT_NAME:-example_site}
Expand All @@ -109,7 +109,7 @@ services:
dockerfile: .docker/nginx-drupal.dockerfile
args:
CLI_IMAGE: *cli-image
WEBROOT: "${VORTEX_WEBROOT:-web}"
WEBROOT: "${WEBROOT:-web}"
DRUPAL_CONFIG_PATH: ${DRUPAL_CONFIG_PATH:-/app/config/default}
DRUPAL_PUBLIC_FILES: ${DRUPAL_PUBLIC_FILES:-/app/web/sites/default/files}
DRUPAL_PRIVATE_FILES: ${DRUPAL_PRIVATE_FILES:-/app/web/sites/default/files/private}
Expand Down
4 changes: 2 additions & 2 deletions scripts/vortex/download-db-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ VORTEX_DB_DIR="${VORTEX_DB_DIR:-./.data}"
VORTEX_DB_FILE="${VORTEX_DB_FILE:-db.sql}"

# Name of the webroot directory with Drupal codebase.
VORTEX_WEBROOT="${VORTEX_WEBROOT:-web}"
WEBROOT="${WEBROOT:-web}"

#-------------------------------------------------------------------------------

Expand Down Expand Up @@ -115,7 +115,7 @@ ssh \
"if [ ! -f \"${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE}\" ] || [ \"${VORTEX_DB_DOWNLOAD_REFRESH}\" == \"1\" ] ; then \
[ -n \"${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE_CLEANUP}\" ] && rm -f \"${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}\"\/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE_CLEANUP} && echo \"Removed previously created DB dumps.\"; \
echo \" > Creating a database dump ${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE}.\"; \
/app/vendor/bin/drush --root=./${VORTEX_WEBROOT} sql:dump --structure-tables-key=common --structure-tables-list=ban,event_log_track,flood,login_security_track,purge_queue,queue,webform_submission,webform_submission_data,webform_submission_log,watchdog,cache* --extra-dump=--no-tablespaces > \"${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE}\"; \
/app/vendor/bin/drush --root=./${WEBROOT} sql:dump --structure-tables-key=common --structure-tables-list=ban,event_log_track,flood,login_security_track,purge_queue,queue,webform_submission,webform_submission_data,webform_submission_log,watchdog,cache* --extra-dump=--no-tablespaces > \"${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE}\"; \
else \
echo \" > Using existing dump ${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_DIR}/${VORTEX_DB_DOWNLOAD_LAGOON_REMOTE_FILE}.\"; \
fi"
Expand Down
4 changes: 2 additions & 2 deletions scripts/vortex/info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -eu
[ "${VORTEX_DEBUG-}" = "1" ] && set -x

# Name of the webroot directory with Drupal codebase.
VORTEX_WEBROOT="${VORTEX_WEBROOT:-web}"
WEBROOT="${WEBROOT:-web}"

# Show one-time login link.
VORTEX_SHOW_LOGIN="${VORTEX_SHOW_LOGIN:-}"
Expand All @@ -32,7 +32,7 @@ echo
note "Project name : ${VORTEX_PROJECT}"
note "Docker Compose project name : ${COMPOSE_PROJECT_NAME:-}"
note "Site local URL : http://${VORTEX_LOCALDEV_URL}"
note "Path to web root : $(pwd)/${VORTEX_WEBROOT}"
note "Path to web root : $(pwd)/${WEBROOT}"
note "DB host : ${DATABASE_HOST}"
note "DB username : ${DATABASE_USERNAME}"
note "DB password : ${DATABASE_PASSWORD}"
Expand Down
4 changes: 2 additions & 2 deletions scripts/vortex/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ VORTEX_PROVISION_POST_OPERATIONS_SKIP="${VORTEX_PROVISION_POST_OPERATIONS_SKIP:-
VORTEX_PROVISION_ENVIRONMENT="${VORTEX_PROVISION_ENVIRONMENT:-}"

# Name of the webroot directory with Drupal codebase.
VORTEX_WEBROOT="${VORTEX_WEBROOT:-web}"
WEBROOT="${WEBROOT:-web}"

# Drupal site name.
DRUPAL_SITE_NAME="${DRUPAL_SITE_NAME:-${VORTEX_PROJECT:-Example site}}"
Expand Down Expand Up @@ -100,7 +100,7 @@ echo
note "Drupal core version : ${drupal_version}"
note "Drush version : ${drush_version}"
echo
note "Webroot path : $(pwd)/${VORTEX_WEBROOT}"
note "Webroot path : $(pwd)/${WEBROOT}"
note "Public files path : ${DRUPAL_PUBLIC_FILES-<empty>}"
note "Private files path : ${DRUPAL_PRIVATE_FILES-<empty>}"
note "Temporary files path : ${DRUPAL_TEMPORARY_FILES-<empty>}"
Expand Down
12 changes: 6 additions & 6 deletions scripts/vortex/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ info "Started reset."

rm -rf \
"./vendor" \
"./${VORTEX_WEBROOT}/core" \
"./${VORTEX_WEBROOT}/profiles/contrib" \
"./${VORTEX_WEBROOT}/modules/contrib" \
"./${VORTEX_WEBROOT}/themes/contrib" \
"./${VORTEX_WEBROOT}/themes/custom/*/build" \
"./${VORTEX_WEBROOT}/themes/custom/*/scss/_components.scss"
"./${WEBROOT}/core" \
"./${WEBROOT}/profiles/contrib" \
"./${WEBROOT}/modules/contrib" \
"./${WEBROOT}/themes/contrib" \
"./${WEBROOT}/themes/custom/*/build" \
"./${WEBROOT}/themes/custom/*/scss/_components.scss"

# shellcheck disable=SC2038
find . -type d -name node_modules | xargs rm -Rf
Expand Down

1 comment on commit e15ef7f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.