forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.xml
287 lines (253 loc) · 13.1 KB
/
setup.xml
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
<project name="setup" default="setup">
<target name="setup" description="Install dependencies, builds docroot, installs Drupal."
depends="setup:build, setup:drupal:install, install-alias">
<echo>For a full list of available Phing targets, run:</echo>
<echo>blt -l</echo>
<echo></echo>
</target>
<target name="setup:behat" description="Generates tests/behat/local.yml file for executing Behat tests locally.">
<mkdir dir="${reports.localDir}/behat"/>
<echo>Attempting to generate tests/behat/local.yml.</echo>
<copy file="${repo.root}/tests/behat/example.local.yml" tofile="${repo.root}/tests/behat/local.yml" verbose="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<property file="${repo.root}/tests/behat/local.yml" prefix="behatConfig"/>
<if>
<or>
<not><available file="${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.features}"/></not>
<not><available file="${behatConfig.local.suites.default.paths.bootstrap}"/></not>
</or>
<then>
<!--@todo Prompt to re-generate local.yml.-->
<echo></echo>
<echo level="error">One or more values in tests/behat/local.yml reference file paths that do not exist on this system.</echo>
<echo level="error">This is typically related to using a virtual machine.</echo>
<echo level="error"></echo>
<echo level="error">Try one of the following solution:</echo>
<echo level="error">1) Execute the tests on the correct system.</echo>
<echo level="error">2) Correct the value(s).</echo>
<echo level="error">3) Remove tests/behat/local.yml so that it can be regenerated automatically from example.local.yml.</echo>
<echo level="error"></echo>
<echo level="error">Values are:</echo>
<echo level="error">drupal_root: ${behatConfig.local.extensions.Drupal\DrupalExtension.drupal.drupal_root}"</echo>
<echo level="error">features: ${behatConfig.local.suites.default.paths.features}"</echo>
<echo level="error">bootstrap: ${behatConfig.local.suites.default.paths.bootstrap}</echo>
<echo level="error"></echo>
<fail>Your Behat configuration is invalid.</fail>
</then>
</if>
</target>
<!-- This is run when a project is cloned to a new environment. -->
<target name="setup:build" description="Generates all required files for a full build. E.g., (re)builds docroot, etc."
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, frontend">
<if>
<equals arg1="${simplesamlphp}" arg2="true"/>
<then>
<phingcall target="simplesamlphp:build:config"/>
</then>
</if>
<phingcall target="target-hook:invoke">
<property name="hook-name" value="post-setup-build"/>
</phingcall>
</target>
<target name="setup:composer:clean" description="Wipes all composer managed directories and clears composer cache.">
<echo>Removing all composer managed dependencies.</echo>
<delete verbose="true">
<fileset dir="${repo.root}">
<include name="docroot/core"/>
<include name="docroot/libraries"/>
<include name="docroot/modules/contrib"/>
<include name="docroot/profiles/contrib"/>
<include name="docroot/themes/contrib"/>
<include name="drush/contrib"/>
<include name="vendor"/>
</fileset>
</delete>
<exec dir="${repo.root}" command="composer clear-cache" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</target>
<target name="setup:composer:install" description="Installs project dependencies, including drupal core and contrib.">
<exec dir="${repo.root}" command="export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --ansi --no-interaction" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true" />
</target>
<!-- We intentionally do not run setup:behat because we'd like to delay setting values in local.yml until just before they are run. -->
<target name="setup:settings" depends="setup:drupal:settings, setup:drush:settings" description="Creates settings files for Drupal and drush.">
</target>
<target name="setup:drupal:settings" description="Create local settings files using default settings files.">
<echo>Making ${docroot}/sites/default writable.</echo>
<chmod mode="0755" file="${docroot}/sites/default" failonerror="false" verbose="true" />
<!-- Ensure that settings.php exists and that it requires BLT settings files. -->
<if>
<not><available file="${docroot}/sites/default/settings.php"/></not>
<then>
<echo>Generating settings.php from default.settings.php.</echo>
<copy file="${docroot}/sites/default/default.settings.php" tofile="${docroot}/sites/default/settings.php" verbose="true"/>
</then>
</if>
<echo>Making ${docroot}/sites/default/settings.php writable.</echo>
<chmod mode="0644" failonerror="false" file="${docroot}/sites/default/settings.php"/>
<echo>Ensuring that blt.settings.php is required by settings.php</echo>
<exec dir="${docroot}/sites/default" command="grep vendor/acquia/blt/settings/blt.settings.php settings.php || echo 'require DRUPAL_ROOT . "/../vendor/acquia/blt/settings/blt.settings.php";' >> settings.php" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
<echo>Generating local settings files.</echo>
<if>
<not><available file="${repo.root}/project.local.yml" type="file" /></not>
<then>
<copy file="${repo.root}/example.project.local.yml" tofile="${repo.root}/project.local.yml" verbose="true" />
</then>
</if>
<if>
<not><available file="${docroot}/sites/${multisite.name}/settings/local.settings.php" type="file" /></not>
<then>
<if>
<available file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" type="file" />
<then>
<copy file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" verbose="true"/>
</then>
<else>
<copy file="${blt.root}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" verbose="true"/>
<copy file="${blt.root}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" verbose="true" />
</else>
</if>
</then>
</if>
</target>
<target name="setup:drush:settings" description="Create local drush settings files.">
<if>
<not><available file="${docroot}/sites/${multisite.name}/local.drushrc.php" type="file" /></not>
<then>
<if>
<available file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" type="file" />
<then>
<copy file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php" verbose="true" />
</then>
<else>
<copy file="${blt.root}/settings/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/default.local.drushrc.php" verbose="true"/>
<copy file="${blt.root}/settings/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php" verbose="true"/>
</else>
</if>
</then>
</if>
<echo>Expanding Phing variables in ${docroot}/sites/${multisite.name}/local.drushrc.php.</echo>
<reflexive file="${docroot}/sites/${multisite.name}/local.drushrc.php">
<filterchain>
<expandproperties />
</filterchain>
</reflexive>
<!-- Re-extract value of $options['uri'] in case it was not yet set. -->
<!-- @todo Add multisite support. -->
<phpVariable file="${repo.root}/drush/drushrc.php" variable="options[uri]" outputProperty="local_url" />
</target>
<target name="setup:drupal:install"
description="Installs a specific Drupal site."
depends="setup:drupal:settings, setup:drush:settings, setup:hash-salt">
<if>
<istrue value="${drush.verbose}"/>
<then>
<echo>Printing drush status.</echo>
<drush command="status"/>
</then>
</if>
<echo>Installing Drupal.</echo>
<drush command="site-install">
<option name="site-name">"${project.human_name}"</option>
<option name="site-mail">"${drupal.account.mail}"</option>
<option name="account-name">"${drupal.account.name}"</option>
<option name="account-pass">"${drupal.account.password}"</option>
<option name="account-mail">"${drupal.account.mail}"</option>
<param>"${project.profile.name}"</param>
<param>"install_configure_form.update_status_module='array(FALSE,FALSE)'"</param>
</drush>
<phingcall target="setup:config-import"/>
<!-- Set sites directory file permissions. -->
<echo>Making ${docroot}/sites/default writable.</echo>
<chmod mode="0755" failonerror="false">
<fileset dir="${docroot}/sites/default">
<type type="dir" />
<exclude name="files/**" />
</fileset>
</chmod>
<chmod mode="0644" failonerror="false">
<fileset dir="${docroot}/sites/default">
<type type="file" />
<exclude name="files/**" />
</fileset>
</chmod>
</target>
<target name="setup:config-import" description="Import configuration from the config directory.">
<echo>Importing configuration.</echo>
<drush command="pm-enable" assume="yes" alias="${drush.alias}">
<param>config</param>
</drush>
<!-- Make db site uuid match site uuid of exported config. -->
<!--<exec dir="${repo.root}" command="cat ./config/default/system.site.yml | grep uuid | tail -c +7 | head -c 36 | ${drush.cmd} config-set -y system.site uuid -" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>-->
<drush command="config-import" assume="yes" alias="${drush.alias}">
<option name="partial"></option>
<param>sync</param>
</drush>
</target>
<target name="setup:git-hooks" description="Installs git hooks to local .git/hooks directory from version controlled scripts/git-hooks directory.">
<echo>Removing ${repo.root}/.git/hooks, if it exists.</echo>
<!-- Symlink into .git directory. -->
<delete dir="${repo.root}/.git/hooks" quiet="true" failonerror="false"/>
<delete file="${repo.root}/.git/hooks" quiet="true" failonerror="false"/>
<echo>Symlinking ${repo.root}/scripts/git-hooks to ${repo.root}/.git/hooks.</echo>
<exec dir="${repo.root}/.git" command="ln -snv ../vendor/acquia/blt/scripts/git-hooks hooks" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
<!-- Grant execution permissions. -->
<echo>Making git hooks executable.</echo>
<chmod mode="0755">
<fileset dir="${blt.root}/scripts/git-hooks">
<exclude name="**/*.sample" />
<exclude name="**/README.md" />
</fileset>
</chmod>
</target>
<target name="setup:hash-salt" description="Generates and writes a hash salt to ${repo.root}/salt.txt if one does not exist.">
<!-- If a hash salt does not exist, generate one. -->
<echo>Checking for hash salt in ${repo.root}/salt.txt</echo>
<if>
<not><available file="${repo.root}/salt.txt"/></not>
<then>
<echo>Writing hash salt to ${repo.root}/salt.txt</echo>
<randomstring propertyName="project.hash_salt" />
<exec dir="${repo.root}" command="echo '${project.hash_salt}' > salt.txt" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
</then>
<else>
<echo>${repo.root}/salt.txt already exists.</echo>
</else>
</if>
</target>
<target name="setup:update" description="Update current database to reflect the state of the Drupal file system.">
<!-- Import configuration before executing updates, in case any db updates are dependent on new configs to be imported. -->
<drush command="config-import" assume="yes" alias="${drush.alias}">
<option name="partial"></option>
</drush>
<!-- Execute db updates. -->
<drush command="updb" assume="yes" alias="${drush.alias}">
<option name="entity-updates"></option>
</drush>
<!-- Import configuration. -->
<drush command="config-import" assume="yes" alias="${drush.alias}">
<option name="partial"></option>
</drush>
<if>
<isset property="cm.features.bundle"/>
<then>
<!-- Enable features module. -->
<drush command="en" assume="yes" alias="${drush.alias}">
<param>features</param>
</drush>
<!-- Clear drush caches to register features drush commands. -->
<drush command="cc" assume="yes" alias="${drush.alias}">
<param>drush</param>
</drush>
<!-- Revert all features. -->
<drush command="fra" assume="yes" alias="${drush.alias}">
<option name="bundle">${cm.features.bundle}</option>
</drush>
</then>
</if>
<!-- Rebuild caches. -->
<drush command="cr" alias="${drush.alias}"/>
</target>
</project>