Skip to content

Commit 34cff07

Browse files
committed
Added local Ahoy config.
1 parent 6c79383 commit 34cff07

File tree

3 files changed

+69
-22
lines changed

3 files changed

+69
-22
lines changed

.ahoy.local.example.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
ahoyapi: v2
3+
usage: Project specific ahoy commands.
4+
5+
commands:
6+
help:
7+
cmd: |
8+
echo "[INFO] Custom local commands"
9+
echo "You may add custom local commands to your toolchain. This local Ahoy file will not be comitted to the repository"
10+
echo
11+
12+
# mylocalcommand:
13+
# cmd: |
14+
# echo "Anything complex you can do on the command line."

.ahoy.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ commands:
1111
ahoy clean
1212
ahoy up
1313
ahoy install
14-
ahoy install-site
15-
ahoy title "Build complete"
14+
ahoy provision
1615
ahoy doctor
1716
ahoy info
17+
ahoy title "Build complete"
1818
1919
cli:
2020
usage: Start a shell inside CLI container or run a command.
@@ -78,19 +78,48 @@ commands:
7878

7979
# Utilities.
8080
title:
81-
cmd: printf "$(tput -Txterm setaf 4)==> ${1}$(tput -Txterm sgr0)\n"
81+
cmd: printf "$(tput -Txterm setaf 4)[INFO] ${1}$(tput -Txterm sgr0)\n"
8282
hide: true
8383

8484
pre-flight:
8585
cmd: echo "Would run pre-flight checks."
8686
hide: true
8787

88+
local:
89+
usage: Custom local commands. See `ahoy local help`.
90+
cmd: |
91+
if [ -f .ahoy.local.yml ]; then
92+
ahoy -f ".ahoy.local.yml" "$@"
93+
else
94+
echo ".ahoy.local.yml does not exist."
95+
echo "Copy .ahoy.local.example.yml to .ahoy.local.yml and rerun this command.";
96+
fi
97+
98+
# ----------------------------------------------------------------------------
99+
# Utilities.
100+
# ----------------------------------------------------------------------------
101+
confirm:
102+
cmd: |
103+
if [ -z "$AHOY_CONFIRM_RESPONSE" ]; then
104+
read -r -p ">> $1 [y/N] " AHOY_CONFIRM_RESPONSE
105+
[ "$AHOY_CONFIRM_RESPONSE" = "y" ] || [ "$AHOY_CONFIRM_RESPONSE" = true ] || ( echo "The operation was canceled." && exit 1 )
106+
else
107+
echo ">> $1 [y/N] $AHOY_CONFIRM_RESPONSE" \
108+
&& if [ "${AHOY_CONFIRM_WAIT_SKIP}" != "1" ]; then echo "Waiting for 3 seconds... Press Ctrl+C to cancel."; sleep 3; fi
109+
fi
110+
hide: true
111+
112+
# Override entrypoint to alter default behaviour of Ahoy.
88113
entrypoint:
114+
# Run all commands in Bash.
89115
- bash
90-
- "-c"
91-
- "-e"
116+
# Read the commands from the string.
117+
- -c
118+
# Exit the script if any statement returns a non-true return value.
119+
- -e
120+
# Read variables from .env file, respecting existing environment variable values.
92121
- |
93-
[ -f .env ] && [ -s .env ] && export $(grep -v '^#' .env | xargs) && if [ -f .env.local ] && [ -s .env.local ]; then export $(grep -v '^#' .env.local | xargs); fi
122+
[ -f .env ] && [ -s .env ] && t=$(mktemp) && export -p > "$t" && set -a && . ./.env && if [ -f ./.env.local ];then . ./.env.local;fi && set +a && . "$t" && rm "$t" && unset t
94123
bash -e -c "$0" "$@"
95124
- '{{cmd}}'
96125
- '{{name}}'

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ way.
2626

2727
Depending on your language or a framework, you may create your own
2828
implementation of
29-
the [.ahoy.yml](https://github.com/integratedexperts/dx/blob/master/.ahoy.yml)
29+
the [.ahoy.yml](https://github.com/drevops/dx/blob/master/.ahoy.yml)
3030
file.
3131

3232
Check it out locally and run `ahoy build` to see how it works (you need to have
3333
Ahoy installed):
3434

35-
```
35+
```bash
3636
$ ahoy build
37-
==> Building project
37+
[INFO] Building project
3838
Would run pre-flight checks.
3939
Would remove containers and all build files.
4040
Would build and start Docker containers.
4141
Would install project and all dependencies.
4242
Would run provision operations.
43-
==> Build complete
4443
Would find problems with current project setup.
4544
Would print project information
45+
[INFO] Build complete
4646
```
4747

4848
## Existing implementations
@@ -54,7 +54,7 @@ Would print project information
5454
## Similar and partial implementations (that would be nice to unify)
5555

5656
- GovCMS (PHP,
57-
Drupal, [https://github.com/govCMS/govCMS/blob/7.x-3.x/.ahoy.yml](https://github.com/govCMS/govCMS/blob/7.x-3.x/.ahoy.yml))
57+
Drupal, [https://github.com/govCMS/GovCMS/blob/3.x-develop/.ahoy.yml](https://github.com/govCMS/GovCMS/blob/3.x-develop/.ahoy.yml))
5858
- SDP (PHP,
5959
Drupal, [https://github.com/dpc-sdp/dev-tools/blob/master/.ahoy.yml](https://github.com/dpc-sdp/dev-tools/blob/master/.ahoy.yml))
6060

@@ -76,7 +76,7 @@ Would print project information
7676

7777
- Install project and all dependencies.
7878

79-
## `provision` (for web-based projects)
79+
## `provision`
8080

8181
- Perform application-level operations to guarantee consistent application
8282
state.
@@ -90,8 +90,8 @@ Would print project information
9090

9191
## `test-unit`
9292

93-
- Run unit tests
94-
- Agnostic to framework
93+
- Run unit tests.
94+
- Agnostic to framework.
9595
- Must run all tests if no arguments provided.
9696

9797
## `test-bdd`
@@ -110,20 +110,19 @@ Would print project information
110110

111111
## `clean`
112112

113-
- Bring project to default state
114-
- Remove installed dependencies
113+
- Bring project to default state.
114+
- Remove installed dependencies.
115115

116116
## `update`
117-
-
118117

119-
- Update ahoy configuration itself
120-
- Possible to update some platform files
118+
- Update ahoy configuration itself.
119+
- Possible to update some platform files.
121120

122121
## `doctor`
123122

124-
- Identify any problems with the stack
125-
- Offer resolution suggestions
126-
- Run before build in pre-flight mode
123+
- Identify any problems with the stack.
124+
- Offer resolution suggestions.
125+
- Run before build in pre-flight mode.
127126

128127
## Command wrapper
129128

@@ -133,6 +132,11 @@ to create and maintain unified commands within a single YAML file.
133132
[.ahoy.yml](https://github.com/drevops/dx/blob/main/.ahoy.yml) file
134133
in this repository is an example of the command configuration file.
135134

135+
[.ahoy.local.example.yml](https://github.com/drevops/dx/blob/main/.ahoy.local.example.yml)
136+
file in this repository is an example of the local command configuration file
137+
that would be excluded from the repository. This file is used to define
138+
additional local commands.
139+
136140
### Ahoy config
137141

138142
- Contain as less custom code as possible: rely on scripts or binaries that can

0 commit comments

Comments
 (0)