Skip to content

Commit 465afec

Browse files
authored
Merge pull request #24 from dennisinteractive/27689_refactor
Case 27689; Allow root to be overriden by environment variables
2 parents 61445b2 + bee96ac commit 465afec

19 files changed

+410
-139
lines changed

README.md

Lines changed: 100 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,74 +10,137 @@ Provides custom Drupal console commands and chains.
1010

1111
curl -L https://goo.gl/UnjUuW | sh
1212

13-
# Commands
13+
## Commands
1414
These are custom commands used to build a site. The information about the site comes from ~/.console/sites/site-name.yml.
1515
e.g. https://raw.githubusercontent.com/dennisinteractive/drupal_console_commands/master/example/site-example.yml
1616

1717
- drupal **site:new**
1818
Builds a new site using Drupal project as template https://github.com/dennisinteractive/drupal-project
19-
- drupal **site:checkout** *site-mame* --
19+
20+
- drupal **site:checkout** *site-name*
2021
Performs a git clone and checks out the specified branch
22+
2123
- drupal **site:compose** *site-name*
22-
Runs *composer install*. Alternatively, it will run *composer update* if there is a composer.lock.
24+
Runs *composer*
25+
26+
- drupal **site:npm** **site:new**
27+
Runs NPM
28+
29+
- drupal **site:grunt** **site:new**
30+
Runs Grunt
31+
2332
- drupal **site:settings:db** *site-name*
2433
Creates *settings.db.php* in the *web/sites/default* folder. This file contains DB credentials and should not be committed.
34+
2535
- drupal **site:settings:local** *site-name*
2636
Creates *settings.local.php* in the *web/sites/default* folder. This file contains local settings overrides and should not be committed.
37+
2738
- drupal **site:settings:memcache** *site-name*
2839
Creates *settings.memcache.php* in the *web/sites/default* folder. This file contains Memcache configuration and should not be committed.
40+
41+
- drupal **site:drush:alias** *site-name*
42+
Sets up drush aliases
43+
2944
- drupal **site:phpunit:setup** *site-name*
3045
Creates *phpunit.xml* in the root. This file contains PHPUnit configuration and should not be committed.
46+
3147
- drupal **site:behat:setup** *site-name*
3248
Creates *behat.yml* in the *tests* folder. This file contains Behat configuration and should not be committed.
49+
3350
- drupal **site:db:import** *site-name*
3451
If a database dump is available, it will drop the current database and import the dump. The db-dump information comes from *~/.console/sites/site-name.yml*.
3552
The command will copy the dump from the original place to */tmp*. If you run the command again, it will only copy the file once the original has changed. This is very useful when working remotely on slow networks.
3653
If no db-dump information is available or there is no dump at the location, it will run a site install.
3754
Supported extensions: **.sql**, **.sql.gz**.
38-
- drupal **site:build**
39-
A chain that will call all the commands below:
40-
- site:checkout
41-
- site:rebuild
42-
- drupal **site:rebuild**
43-
A chain that will call all the commands below:
44-
- site:compile
45-
- site:configure
46-
- site:db:import
47-
- site:construct
48-
- drupal **site:rebuild-prod**
49-
A chain that will call all the commands below:
50-
- site:compile
51-
- site:construct
52-
- drupal **site:compile**
53-
A chain that will call all the commands below:
54-
- site:compose
55-
- 'exec' command that runs npm in supported directories.
56-
- 'exec' command that runs grunt in supported directories.
57-
- drupal **site:configure**
58-
A chain that will call all the commands below:
55+
56+
## Chains
57+
Chains that can be reused on various environments
58+
59+
- drupal **site:configure** A chain that will call all the commands below:
5960
- site:settings:db
6061
- site:settings:local
6162
- site:settings:memcache
62-
- drupal **site:construct**
63-
A chain that will call all the commands below:
64-
- 'exec' command that clears drupal caches.
65-
- 'exec' command that sets drush aliases.
66-
- 'exec' command that runs drupal updates.
67-
- 'exec' command that imports drupal config twice.
68-
- 'exec' command that clears drupal caches.
69-
- drupal **site:test**
70-
A chain that will call all the commands below:
63+
- site:drush:alias
64+
65+
- drupal **site:update** Used to run updates and import configuration
66+
- drush cr (Clear caches)
67+
- drush site-set @site (Set default drush alias)
68+
- drush updb (Runs updates)
69+
- drush cim (Imports configuration)
70+
- drush cr (Clear caches)
71+
72+
- drupal **site:test:setup** Sets the test suites
7173
- site:phpunit:setup
7274
- site:behat:setup
73-
- 'exec' command that runs behat tests.
74-
- 'exec' command that runs phpunit tests.
7575

76-
# Useful arguments and options
76+
- drupal **site:test** Runs test suites
77+
- site:test:setup
78+
- behat (Runs behat tests)
79+
- phpunit (Runs phpunit tests)
80+
81+
## Environment specific chains
82+
Each environment will have its own chain that executes the relevant commands and chains
83+
84+
### Dev
85+
- drupal **site:build** Builds a site for development
86+
- site:checkout
87+
- site:rebuild (chain)
88+
89+
- drupal **site:rebuild** Performs necessary steps to rebuild the site from a given source
90+
- site:compose
91+
- site:npm
92+
- site:grunt
93+
- site:configure (chain)
94+
- site:test:setup (chain)
95+
- site:db:import
96+
- site:update (chain)
97+
98+
### Artifact
99+
- drupal **site:build** Builds a site for artifacts
100+
- site:checkout
101+
- site:rebuild (chain)
102+
103+
- drupal **site:build:artifact** Prepare artifacts
104+
- site:compose
105+
- site:npm
106+
- site:grunt
107+
108+
### CI
109+
- drupal **site:build:ci** Builds a site for CI
110+
- site:configure (chain)
111+
- site:db:import
112+
- site:update (chain)
113+
- site:test (chain)
114+
115+
### QA
116+
- drupal **site:build:qa** Builds a site for QA
117+
- site:configure (chain)
118+
- site:db:import
119+
- site:update (chain)
120+
- site:test (chain)
121+
122+
### Staging
123+
- drupal **site:build:staging** Builds a site for Staging
124+
- site:configure (chain)
125+
- site:db:import
126+
- site:update (chain)
127+
128+
### Production
129+
- drupal **site:build:prod** Runs updates on production
130+
- site:update (chain)
131+
132+
## Useful arguments and options
77133
- **-h** Show all the available arguments and options
78134
- **--no-interaction** Will execute the command without asking any optional argument
79135

80-
# Usage example
136+
## Environment variables
137+
By default, the commands will use parameters from the site.yml, but it is possible to override them using environment variables.
138+
139+
For example, to override the root directory you can set the variable before calling `site:build`
140+
141+
`export site_destination_directory="/directory/"`
142+
143+
## Usage example
81144
```
82145
drupal site:build
83146
drupal site:db:import [site_name]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Usage: drupal site:build:artifact --placeholder="name:subscriptions"
2+
command:
3+
name: site:build:artifact
4+
description: 'Prepare artifacts.'
5+
commands:
6+
# Run composer.
7+
- command: site:compose
8+
arguments:
9+
name: '%{{name}}'
10+
# Run NPM.
11+
- command: site:npm
12+
arguments:
13+
name: '%{{name}}'
14+
# Run Grunt.
15+
- command: site:grunt
16+
arguments:
17+
name: '%{{name}}'

chain/chain-site-build-ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Usage: drupal site:build:ci --placeholder="name:subscriptions"
2+
command:
3+
name: site:build:ci
4+
description: 'Builds site for CI.'
5+
commands:
6+
# Generate the settings.
7+
- command: site:configure
8+
options:
9+
placeholder:
10+
- 'name:%{{name}}'
11+
# Imports db or installs a site
12+
- command: site:db:import
13+
arguments:
14+
name: '%{{name}}'
15+
# Run updates.
16+
- command: site:update
17+
options:
18+
placeholder:
19+
- 'name:%{{name}}'
20+
# Run tests.
21+
- command: site:test
22+
options:
23+
placeholder:
24+
- 'name:%{{name}}'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Usage: drupal site:build:prod --placeholder="name:subscriptions"
2+
command:
3+
name: site:build:prod
4+
description: 'Runs updates on Production.'
5+
commands:
6+
# Run updates.
7+
- command: site:update
8+
options:
9+
placeholder:
10+
- 'name:%{{name}}'

chain/chain-site-build-qa.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Usage: drupal site:build:qa --placeholder="name:subscriptions"
2+
command:
3+
name: site:build:qa
4+
description: 'Builds site for QA.'
5+
commands:
6+
# Generate the settings.
7+
- command: site:configure
8+
options:
9+
placeholder:
10+
- 'name:%{{name}}'
11+
# Imports db or installs a site
12+
- command: site:db:import
13+
arguments:
14+
name: '%{{name}}'
15+
# Run updates.
16+
- command: site:update
17+
options:
18+
placeholder:
19+
- 'name:%{{name}}'
20+
# Run tests.
21+
- command: site:test
22+
options:
23+
placeholder:
24+
- 'name:%{{name}}'

chain/chain-site-build-staging.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Usage: drupal site:build:staging --placeholder="name:subscriptions"
2+
command:
3+
name: site:build:staging
4+
description: 'Builds site for Staging.'
5+
commands:
6+
# Generate the settings.
7+
- command: site:configure
8+
options:
9+
placeholder:
10+
- 'name:%{{name}}'
11+
# Imports db or installs a site
12+
- command: site:db:import
13+
arguments:
14+
name: '%{{name}}'
15+
# Run updates.
16+
- command: site:update
17+
options:
18+
placeholder:
19+
- 'name:%{{name}}'

chain/chain-site-build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Usage: drupal site:build --placeholder="name:subscriptions" --placeholder="root:/vagrant/repos"
1+
# Usage: drupal site:build --placeholder="name:subscriptions"
22
command:
33
name: site:build
4-
description: 'Builds a new site.'
4+
description: 'Builds a site.'
55
commands:
66
# Checkout site
77
- command: site:checkout
@@ -14,4 +14,3 @@ commands:
1414
options:
1515
placeholder:
1616
- 'name:%{{name}}'
17-
- 'root:%{{root|/vagrant/repos}}'

chain/chain-site-compile-artifact.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

chain/chain-site-compile.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

chain/chain-site-construct.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)