Repository navigation
Expand file tree
/
Copy path.ahoy.yml
More file actions
461 lines (400 loc) Β· 16.9 KB
/
Copy path.ahoy.yml
File metadata and controls
461 lines (400 loc) Β· 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#
# Ahoy configuration file.
# http://www.ahoycli.com/
#
# Provides development experience shortcuts to work with the stack.
# Any command can be copy-pasted directly into terminal and ran without using
# Ahoy.
#
# Do not add values directly into this file. Use .env file instead.
# Run `ahoy up cli` to apply environment variables changes to containers.
#;
#; Comments starting with '#;<' and '#;>' are internal Vortex comments
#; and will be removed during installation or update of Vortex.
---
ahoyapi: v2
commands:
build:
usage: Build or rebuild the project.
aliases: [rebuild]
cmd: |
ahoy confirm "All containers, build files and database will be removed. Proceed?" && export AHOY_CONFIRM_RESPONSE=y && export AHOY_CONFIRM_WAIT_SKIP=1 || exit 0
ahoy preflight # Check the host before the reset removes the tooling.
ahoy reset # Reset the project.
ahoy up --build --force-recreate # Start the stack.
ahoy composer install # Install Composer dependencies.
ahoy fei # Install front-end dependencies.
#;< DRUPAL_THEME
ahoy fe # Build front-end assets.
#;> DRUPAL_THEME
VORTEX_SHOW_LOGIN=0 ahoy provision # Provision the site.
VORTEX_SHOW_LOGIN=1 ahoy info # Show information and a login link.
info:
usage: Show information about this project.
aliases: [status, describe, ps]
cmd: |
export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-${PWD##*/}}
export VORTEX_HOST_DB_PORT=$(docker compose port database 3306 2>/dev/null | cut -d : -f 2)
#;< MIGRATION
export VORTEX_HOST_DB2_PORT=$(docker compose port database2 3306 2>/dev/null | cut -d : -f 2)
#;> MIGRATION
#;< SERVICE_SOLR
export VORTEX_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2)
#;> SERVICE_SOLR
#;< SERVICE_DBUI
export VORTEX_HOST_DBUI_PORT=$(docker compose port dbui 80 2>/dev/null | cut -d : -f 2)
#;> SERVICE_DBUI
#;< STORYBOOK
export VORTEX_HOST_STORYBOOK_PORT=$(docker compose port cli ${VORTEX_STORYBOOK_PORT:-6006} 2>/dev/null | cut -d : -f 2)
#;> STORYBOOK
export VORTEX_HOST_SELENIUM_VNC_PORT=$(docker compose port chrome 7900 2>/dev/null | cut -d : -f 2)
export VORTEX_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true)
ahoy cli ./vendor/bin/vortex-info "$@"
db:
usage: Browse the database in a GUI client.
aliases: [dbui]
cmd: ./vendor/bin/vortex-dbui
#;< MIGRATION
db2:
usage: Browse the migration database in a GUI client.
aliases: [db2ui, dbui2]
cmd: VORTEX_DB_INDEX=2 ./vendor/bin/vortex-dbui
#;> MIGRATION
# ----------------------------------------------------------------------------
# Container commands.
# ----------------------------------------------------------------------------
up:
usage: Build and start containers.
cmd: |
ahoy preflight
# A container attached to a removed network starts only after it is recreated.
docker compose up --detach "$@" || { echo "Starting containers failed. Recreating them and trying again."; docker compose up --detach --force-recreate "$@"; }
if docker compose logs | grep -q "\[Error\]"; then exit 1; fi
down:
usage: Stop and remove containers, images, volumes and networks.
aliases: [destroy]
cmd: |
ahoy confirm "Running this command will remove your current database. Are you sure?" || exit 0
if [ -f "docker-compose.yml" ]; then docker compose down --remove-orphans --volumes > /dev/null 2>&1; fi
start:
usage: Start existing containers, or create them if there are none.
cmd: |
ahoy preflight
docker compose up --detach --no-recreate "$@" || { echo "Starting containers failed. Recreating them and trying again."; docker compose up --detach --force-recreate "$@"; }
stop:
usage: Stop running containers.
cmd: docker compose stop "$@"
restart:
usage: Restart stopped or running containers.
cmd: docker compose restart "$@"
logs:
usage: Show container logs for services.
cmd: docker compose logs "$@"
# Drop into a shell if no arguments are supplied, otherwise run the command.
# Environment variables are passed from the host and filtered by prefix.
# Use \" (slash followed by a double quote) to escape double quotes in
# arguments that contain spaces.
cli:
usage: Start a shell or run a command inside the CLI service container.
aliases: [ssh, shell]
cmd: |
if [ "${#}" -ne 0 ]; then
docker compose exec $(env | cut -f1 -d= | grep -E '^(TERM|LOCALDEV_URL)$|^(COMPOSE|GITHUB|PACKAGE|DOCKER|DRUPAL|VORTEX|ENVIRONMENT)_' | sed 's/^/-e /') cli bash -c "$*"
else
docker compose exec $(env | cut -f1 -d= | grep -E '^(TERM|LOCALDEV_URL)$|^(COMPOSE|GITHUB|PACKAGE|DOCKER|DRUPAL|VORTEX|ENVIRONMENT)_' | sed 's/^/-e /') cli bash
fi
composer:
usage: Run Composer commands in the CLI service container.
cmd: |
ahoy cli " \
if [ -n \"\${PACKAGE_TOKEN:-}\" ]; then composer config --global --auth github-oauth.github.com \"\${PACKAGE_TOKEN}\"; fi && \
COMPOSER_MEMORY_LIMIT=-1 composer --ansi $@"
drush:
usage: Run Drush commands in the CLI service container.
cmd: ahoy cli "vendor/bin/drush -l \${LOCALDEV_URL} $*"
#;< SERVICE_REDIS
flush-redis:
usage: Flush Redis cache.
cmd: docker compose exec redis redis-cli flushall
#;> SERVICE_REDIS
# ----------------------------------------------------------------------------
# Application commands.
# ----------------------------------------------------------------------------
login:
usage: Unblock user 1 and generate a one time login link.
cmd: ahoy cli ./vendor/bin/vortex-login
#;< !PROVISION_TYPE_PROFILE
fetch-db:
usage: Fetch database. Run with "--fresh" option to force fresh database backup.
aliases: [download-db, db-download, db-fetch]
cmd: |
case " $* " in *" --fresh "*) export VORTEX_FETCH_DB_FRESH=1 VORTEX_FETCH_DB_FORCE=1;; esac
./vendor/bin/vortex-fetch-db
#;< MIGRATION
fetch-db2:
usage: Fetch second database (migration). Run with "--fresh" to force.
aliases: [download-db2, db2-download, db2-fetch]
cmd: |
case " $* " in *" --fresh "*) export VORTEX_FETCH_DB2_FRESH=1 VORTEX_FETCH_DB2_FORCE=1;; esac
VORTEX_DB_INDEX=2 ./vendor/bin/vortex-fetch-db
#;> MIGRATION
#;> !PROVISION_TYPE_PROFILE
fetch-files:
usage: Fetch public files.
aliases: [download-files, files-download, files-fetch]
cmd: ./vendor/bin/vortex-fetch-files
reload-db:
usage: Reload the database container using local database image.
cmd: |
ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
docker compose rm --force --stop --volumes database
docker compose build database
ahoy up
#;< MIGRATION
reload-db2:
usage: Reload the migration database container using local database image.
cmd: |
ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
docker compose rm --force --stop --volumes database2
ahoy up -- --build database2
#;> MIGRATION
provision:
usage: Provision a site from the database dump or profile.
cmd: |
ahoy confirm "Running this command will remove your current database. Are you sure?" || exit 0
#;< DB_FETCH_SOURCE_CONTAINER_REGISTRY
AHOY_CONFIRM_RESPONSE=y ahoy reload-db
#;> DB_FETCH_SOURCE_CONTAINER_REGISTRY
ahoy cli ./vendor/bin/vortex-provision
[ "${VORTEX_SHOW_LOGIN:-1}" = "1" ] && ahoy login || true
export-db:
usage: Export database dump or database image (if VORTEX_DB_IMAGE variable is set).
aliases: [db-export, db-dump, dump-db]
cmd: |
./vendor/bin/vortex-export-db "$@"
import-db:
usage: Import database from dump.
aliases: [db-import]
cmd: |
ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
./vendor/bin/vortex-import-db "$@"
#;< DB_FETCH_SOURCE_CONTAINER_REGISTRY
pull-db:
usage: Download database image with the latest nightly dump. Run "ahoy reload-db" to reload DB in the running stack.
cmd: docker pull "${VORTEX_DB_IMAGE}"
#;> DB_FETCH_SOURCE_CONTAINER_REGISTRY
reset:
usage: Remove containers, all build files. Use with `--hard` to reset repository to the last commit.
aliases: [prune, delete]
cmd: |
ahoy confirm "All containers and build files will be removed. Proceed?" || exit 0
AHOY_CONFIRM_RESPONSE=y ahoy down || true
if [ -f ./vendor/bin/vortex-reset ]; then
bash ./vendor/bin/vortex-reset "$@"
fi
fei:
usage: Install front-end assets.
aliases: [fe-install]
cmd: |
#;< TOOL_NPM
ahoy cli "npm ci"
#;> TOOL_NPM
#;< DRUPAL_THEME
ahoy cli "npm --prefix=${WEBROOT}/themes/custom/${DRUPAL_THEME} ci"
#;> DRUPAL_THEME
#;< DRUPAL_THEME
fe:
usage: Build front-end assets.
aliases: [fe-build]
cmd: ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build"
fed:
usage: Build front-end assets for development.
aliases: [fe-build-dev]
cmd: ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run build-dev"
few:
usage: Watch front-end assets during development.
aliases: [fe-watch]
cmd: |
ahoy cli "pkill -9 -f grunt" || true
ahoy cli "cd ${WEBROOT}/themes/custom/${DRUPAL_THEME} && npm run watch"
#;< STORYBOOK
storybook:
usage: Start Storybook for component development. Stories are regenerated as their Twig templates change.
cmd: |
export VORTEX_HOST_STORYBOOK_PORT=$(docker compose port cli ${VORTEX_STORYBOOK_PORT:-6006} 2>/dev/null | cut -d : -f 2)
ahoy cli ./vendor/bin/vortex-storybook dev "$@"
storybook-build:
usage: Build the Storybook component library served at /storybook.
cmd: ahoy cli ./vendor/bin/vortex-storybook build
storybook-stories:
usage: Generate Storybook stories from Twig templates. Run with "--watch" to regenerate them as they change.
cmd: ahoy cli ./vendor/bin/vortex-storybook stories "$@"
#;> STORYBOOK
#;> DRUPAL_THEME
lint:
usage: Lint back-end and front-end code.
cmd: |
ahoy lint-be
ahoy lint-fe
ahoy lint-tests
lint-be:
usage: Lint back-end code.
cmd: |
ahoy cli vendor/bin/phpcs
ahoy cli vendor/bin/phpstan
ahoy cli vendor/bin/rector --dry-run
#;< TOOL_PHPSTAN
lint-be-baseline:
usage: Record the current PHPStan violations in the baseline to onboard an existing codebase.
cmd: ahoy cli vendor/bin/phpstan --generate-baseline=phpstan-baseline.neon --allow-empty-baseline
#;> TOOL_PHPSTAN
lint-fe:
usage: Lint front-end code.
cmd: |
ahoy cli vendor/bin/twig-cs-fixer lint
ahoy cli "npm run lint"
#;< DRUPAL_THEME
ahoy cli "npm run --prefix=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"
#;> DRUPAL_THEME
lint-tests:
usage: Lint tests code.
cmd: |
ahoy cli vendor/bin/gherkinlint lint tests/behat/features
#;< DRUPAL_THEME
#;< MODULE_SDC_DEVEL
lint-sdc:
usage: Validate Single Directory Components (requires a provisioned site).
cmd: |
ahoy cli " \
output=\$(vendor/bin/drush sdc-devel:validate \${DRUPAL_THEME} 2>&1); \
echo \"\${output}\"; \
if echo \"\${output}\" | grep -qE 'Critical|Errors?|Warnings?'; then echo 'SDC validation reported problems.'; exit 1; fi"
#;> MODULE_SDC_DEVEL
#;> DRUPAL_THEME
lint-fix:
usage: Fix lint issues of back-end and front-end code.
cmd: |
ahoy lint-be-fix
ahoy lint-fe-fix
lint-be-fix:
usage: Fix lint issues of back-end code.
cmd: |
ahoy cli vendor/bin/rector
ahoy cli vendor/bin/phpcbf
lint-fe-fix:
usage: Fix lint issues of front-end code.
cmd: |
ahoy cli vendor/bin/twig-cs-fixer lint --fix
ahoy cli "npm run lint-fix"
#;< DRUPAL_THEME
ahoy cli "npm run --prefix=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint-fix"
#;> DRUPAL_THEME
#;< TOOL_PHPUNIT
test:
usage: Run all PHPUnit tests.
aliases: [phpunit]
cmd: ahoy cli vendor/bin/phpunit "$@"
test-unit:
usage: Run PHPUnit unit tests.
cmd: ahoy cli vendor/bin/phpunit --testsuite=unit "$@"
test-kernel:
usage: Run PHPUnit kernel tests.
cmd: ahoy cli vendor/bin/phpunit --testsuite=kernel "$@"
test-functional:
usage: Run PHPUnit functional tests.
cmd: ahoy cli vendor/bin/phpunit --testsuite=functional "$@"
test-functional-javascript:
usage: Run PHPUnit functional JavaScript tests.
cmd: ahoy cli vendor/bin/phpunit --testsuite=functional-javascript "$@"
#;> TOOL_PHPUNIT
#;< TOOL_JEST
test-js:
usage: Run Jest JavaScript unit tests.
cmd: ahoy cli "npm test"
#;> TOOL_JEST
#;< TOOL_BEHAT
test-bdd:
usage: Run BDD tests.
aliases: [test-behat]
cmd: ahoy cli php -d memory_limit=-1 vendor/bin/behat --colors "$@"
#;> TOOL_BEHAT
#;< LIGHTHOUSE
test-lighthouse:
usage: Run Lighthouse performance, accessibility, best practices and SEO audits. Pass paths to audit them instead of the configured pages.
aliases: [lighthouse]
cmd: docker compose run --rm $(env | cut -f1 -d= | grep -E '^(TERM|LOCALDEV_URL)$|^(COMPOSE|DOCKER|DRUPAL|VORTEX|ENVIRONMENT)_' | sed 's/^/-e /') lighthouse ./vendor/bin/vortex-lighthouse "$@"
#;> LIGHTHOUSE
debug:
usage: Enable PHP Xdebug.
aliases: [xdebug]
cmd: |
ahoy cli php -v | grep -q Xdebug && echo "Debug configuration is already enabled. Use 'ahoy up' to disable." || \
(XDEBUG_ENABLE=true ahoy up cli php nginx && sleep 1 && ahoy cli php -v | grep -q Xdebug && echo "Enabled debug configuration. Use 'ahoy up' to disable.")
deploy:
usage: Run remote deployment procedures.
cmd: |
ahoy confirm "Deployment usually runs in CI. Are you sure you want to proceed with manual deployment? (Run as ahoy deploy [type1,[type2..]], where [type] is 'artifact', 'webhook', or 'lagoon')" || exit 0
./vendor/bin/vortex-deploy "$@"
doctor:
usage: Find problems with current project setup.
aliases: [diagnose, health]
cmd: |
./vendor/bin/vortex-doctor "$@"
update-vortex:
usage: Update project from the Vortex template repository.
cmd: |
./vendor/bin/vortex-update "$@"
local:
usage: Custom local commands. See `ahoy local help`.
optional: true
imports: [.ahoy.local.yml]
# ----------------------------------------------------------------------------
# Utilities.
# ----------------------------------------------------------------------------
# Internal utility command to confirm actions before running them.
# Accepts a message as an argument and waits for user confirmation.
# Will proceed only if the user types 'y' or 'true'.
# If AHOY_CONFIRM_RESPONSE is set, it will use that value without prompting
# the user, and will print the prompt with an answer. It will also give a
# 3 seconds delay before proceeding to allow the user to cancel the operation.
# If AHOY_CONFIRM_WAIT_SKIP is also set to '1', it will skip the wait and
# proceed immediately.
confirm:
cmd: |
if [ -z "${AHOY_CONFIRM_RESPONSE}" ]; then
read -r -p "$( echo -e "\033[31m>> $1\033[0m \033[2m[y/N]\033[0m " )" AHOY_CONFIRM_RESPONSE
if [ "${AHOY_CONFIRM_RESPONSE}" != "y" ] && [ "${AHOY_CONFIRM_RESPONSE}" != "true" ]; then
echo "The operation was canceled."
exit 1
fi
else
if [ "${AHOY_CONFIRM_WAIT_SKIP}" != "1" ]; then
echo -e "\033[31m>> $1\033[0m \033[2m[y/N] ${AHOY_CONFIRM_RESPONSE}\033[0m"
echo "Waiting for 3 seconds... Press Ctrl+C to cancel."
sleep 3
fi
fi
hide: true
# Internal utility command to run the Doctor pre-flight checks before the
# containers start. Skipped while the tooling is not installed, for example
# right after a reset.
preflight:
cmd: if [ -f ./vendor/bin/vortex-doctor ]; then ./vendor/bin/vortex-doctor preflight; fi
hide: true
# Override entrypoint to alter default behavior of Ahoy.
# 1. Exit the script if any statement returns a non-true return value.
# 2. Read variables from .env file (while respecting existing values) to load
# and pass updated environment variables' values into already running
# containers.
# 3. Ensure the Vortex tooling package is present in vendor/ so host-side
# commands work on a fresh clone before a full 'composer install' has run.
entrypoint:
- bash
- -c
- -e
- |
t=$(mktemp) && export -p > "$t" && set -a && . ./.env && if [ -f ./.env.local ];then . ./.env.local;fi && set +a && . "$t" && rm "$t" && unset t
if [ -z "${AHOY_VORTEX_TOOLING_READY:-}" ]; then export AHOY_VORTEX_TOOLING_READY=1; ./scripts/vortex-tooling.sh; fi
bash -e -c "$0" "$@"
- '{{cmd}}'
- '{{name}}'