forked from drupal-composer/drupal-project
-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.dist.xml
345 lines (311 loc) · 14.1 KB
/
build.dist.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
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
<?xml version="1.0" encoding="UTF-8" ?>
<project default="help">
<target name="help" description="Phing target list">
<exec executable="${phing.bin}"
passthru="true">
<arg value="-l"/>
</exec>
</target>
<includepath classpath="src/Phing" />
<echo msg="Loading Drush task." />
<taskdef name="drush" classname="\Phing\Drush\Task" />
<echo msg="Loading PHP Codesniffer Configuration task." />
<taskdef name="phpcodesnifferconfiguration" classname="\DrupalProject\Phing\PhpCodeSnifferConfigurationTask" />
<echo msg="Loading PHPUnit Configuration task." />
<taskdef name="phpunitconfiguration" classname="\DrupalProject\Phing\PhpUnitConfigurationTask" />
<!-- Make the settings folder writeable so that the installer can copy settings.php. -->
<target name="writable-settings-folder">
<chmod mode="0755" failonerror="true" verbose="true" quiet="false" file="${website.settings.dir}" />
</target>
<!-- Make settings.php writeable so that the installer can write to it. -->
<target name="writable-settings-php">
<if>
<available file="${website.settings.php}" type="file" property="website.settings.php.available" />
<then>
<chmod mode="0644" failonerror="false" verbose="true" quiet="false" file="${website.settings.php}" />
</then>
</if>
</target>
<!-- Install the website. -->
<target name="install" depends="writable-settings-folder, writable-settings-php">
<drush
command="site-install"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}">
<option name="db-url" value="${drupal.db.url}" />
<option name="site-name" value="${website.site.name}" />
<option name="account-name" value="${drupal.admin.username}" />
<option name="account-pass" value="${drupal.admin.password}" />
<option name="account-mail" value="${drupal.admin.email}" />
<param>${website.profile.name}</param>
<!-- Disable sending of e-mails during installation. -->
<param>install_configure_form.update_status_module='array(FALSE,FALSE)'</param>
</drush>
</target>
<!-- Set up PHP CodeSniffer. -->
<target name="setup-php-codesniffer" description="Generate the configuration file for PHP CodeSniffer.">
<if>
<available file="${phpcs.config}" type="file" property="phpcs.config.available" />
<then>
<echo message="Deleting existing PHP Codesniffer default configuration file." />
<delete file="${phpcs.config}" failonerror="false" />
</then>
</if>
<if>
<available file="${phpcs.global.config}" type="file" property="phpcs.global.config.available" />
<then>
<echo message="Deleting existing PHP Codesniffer global configuration file." />
<delete file="${phpcs.global.config}" failonerror="false" />
</then>
</if>
<echo message="Generating PHP Codesniffer configuration files." />
<phpcodesnifferconfiguration
configFile="${phpcs.config}"
extensions="${phpcs.extensions}"
files="${phpcs.files}"
globalConfig="${phpcs.global.config}"
ignorePatterns="${phpcs.ignore}"
report="${phpcs.report}"
showProgress="${phpcs.progress}"
showSniffCodes="${phpcs.sniffcodes}"
standard="${phpcs.standard}" />
<!-- Set up the git pre-push hook. -->
<phingcall target="disable-pre-push" />
<if>
<equals arg1="${phpcs.prepush.enable}" arg2="1" />
<then>
<symlink link="${phpcs.prepush.destination}" target="${phpcs.prepush.source}" overwrite="true" />
</then>
</if>
</target>
<!-- Disable the PHP CodeSniffer pre-push hook. -->
<target name="disable-pre-push" description="Disable the coding standards check when pushing to a git repository.">
<delete file="${phpcs.prepush.destination}" failonerror="false" />
</target>
<!-- Set up Behat. -->
<target name="setup-behat" description="Generate the configuration file for Behat.">
<if>
<available file="${behat.yml.path}" type="file" property="behat.yml.available" />
<then>
<echo message="Deleting existing behat.yml configuration file" />
<delete file="${behat.yml.path}" failonerror="false" />
</then>
</if>
<echo message="Creating behat.yml configuration file" />
<loadfile property="behat.yml.content" file="${behat.yml.template}" />
<echo message="${behat.yml.content}" file="${behat.yml.path}" />
</target>
<!-- Set up PHPUnit. -->
<target name="setup-phpunit" description="Generate the configuration file for PHPUnit.">
<if>
<available file="${phpunit.config}" type="file" property="phpunit.config.available" />
<then>
<echo message="Deleting existing PHPUnit configuration file." />
<delete file="${phpunit.config}" failonerror="false" />
</then>
</if>
<phpunitconfiguration
configFile="${phpunit.config}"
distFile="${phpunit.dist}"
files="${phpunit.files}"
directories="${phpunit.directories}"
testsuiteName="${phpunit.testsuite.name}"
baseUrl="${phpunit.base_url}"
dbUrl="${phpunit.db_url}"
browsertestOutputDirectory="${phpunit.browsertest_output_dir}"
browsertestOutputFile="${phpunit.browsertest_output_file}" />
<!-- Create the directory and file for browsertest output. -->
<mkdir dir="${phpunit.browsertest_output_dir}" />
<touch file="${phpunit.browsertest_output_file}" />
</target>
<!-- Set up Drush. -->
<target name="setup-drush" description="Generate the configuration file for Drush.">
<if>
<available file="${drush.yml.path}" type="file" property="drush.yml.available" />
<then>
<echo message="Deleting existing drush.yml configuration file" />
<delete file="${drush.yml.path}" failonerror="false" />
</then>
</if>
<echo message="Creating drush.yml configuration file" />
<loadfile property="drush.yml.content" file="${drush.yml.template}" />
<echo message="${drush.yml.content}" file="${drush.yml.path}" />
</target>
<!-- Create demo users. -->
<target name="create-demo-users" description="Create demo users.">
<foreach list="${drupal.demo.users}" param="drupal.demo.user" target="create-demo-user" delimiter="," />
<!-- Create a user with only "authenticated user" role assigned. -->
<drush
command="user-create"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}">
<option name="mail" value="[email protected]" />
<option name="password" value="user" />
<param>user</param>
</drush>
</target>
<!-- Create a demo user. Subtarget of "create-demo-users". -->
<target name="create-demo-user">
<drush
command="user-create"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}">
<option name="mail" value="${drupal.demo.user}@example.com" />
<option name="password" value="${drupal.demo.user}" />
<param>${drupal.demo.user}</param>
</drush>
<drush
command="user-add-role"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}">
<param>${drupal.demo.user}</param>
<param>${drupal.demo.user}</param>
</drush>
</target>
<!-- Set up development configuration, including on-screen error logging and debugging options. -->
<target name="enable-dev-settings">
<phingcall target="include-local-settings" />
<!-- Copy settings file containing development values, but preserve any existing local settings. -->
<copy file="${website.settings.local.php.example}" tofile="${website.settings.local.php}" overwrite="false" />
</target>
<!-- Create an empty local settings file, if it doesn't exist yet. -->
<target name="create-local-settings">
<if>
<not>
<available file="${website.settings.local.php}" type="file" property="website.settings.local.php.available" />
</not>
<then>
<phingcall target="writable-settings-folder" />
<echo
message="<?php${line.separator}"
file="${website.settings.local.php}" />
</then>
</if>
</target>
<!-- Uncomment the inclusion of the local settings file in settings.php. -->
<target name="include-local-settings">
<phingcall target="writable-settings-folder" />
<phingcall target="writable-settings-php" />
<reflexive>
<fileset dir="${website.settings.dir}">
<include pattern="settings.php" />
</fileset>
<filterchain>
<replaceregexp>
<regexp
pattern="^# (if \(file_exists\(\$app_root \. '\/' \. \$site_path \. '\/settings\.local\.php'\)\) \{\n)# ( include \$app_root \. '\/' \. \$site_path \. '\/settings\.local\.php';\n)# (\})"
replace="\1\2\3"
modifiers="m" />
</replaceregexp>
</filterchain>
</reflexive>
</target>
<!-- Enable development modules. -->
<target name="enable-dev-modules">
<foreach list="${drupal.modules.dev}" param="module" target="enable-module" delimiter=" " />
</target>
<!-- Enable a module. -->
<target name="enable-module">
<drush
command="pm-enable"
assume="yes"
root="${website.drupal.dir}"
bin="${drush.bin}">
<param>${module}</param>
</drush>
</target>
<!-- Install Composer dependencies for the build system. -->
<target name="install-composer-dependencies">
<composer command="install" composer="${composer.bin}">
<arg value="--working-dir=${project.basedir}" />
</composer>
</target>
<!-- Install Composer dependencies for a production environment. -->
<target name="install-composer-dependencies-dist">
<composer command="install" composer="${composer.bin}">
<arg value="--working-dir=${project.basedir}" />
<arg value="--no-dev" />
</composer>
</target>
<target name="redirect-outgoing-email">
<reflexive>
<fileset dir="${website.settings.dir}">
<include pattern="settings.local.php" />
</fileset>
<filterchain>
<replaceregexp>
<regexp
pattern="(\n)?\$config\['system.mail'\]\['interface'\]\['default'\] = 'devel_mail_log';(\n)?"
replace="" />
<regexp
pattern="(\n)?\$config\['mailsystem.settings'\]\['defaults'\]\['sender'\] = 'devel_mail_log';(\n)?"
replace="${line.separator}"
modifiers="" />
</replaceregexp>
</filterchain>
</reflexive>
<if>
<equals arg1="${drupal.redirect.email}" arg2="yes" />
<then>
<phingcall target="enable-module">
<property name="module" value="devel" />
</phingcall>
<append
destFile="${website.settings.local.php}"
text="${line.separator}$config['system.mail']['interface']['default'] = 'devel_mail_log';${line.separator}" />
<append
destFile="${website.settings.local.php}"
text="$config['mailsystem.settings']['defaults']['sender'] = 'devel_mail_log';${line.separator}" />
</then>
<else>
<echo message="Skipping redirection of outgoing e-mail. Set 'drupal.redirect.email = yes' to enable." />
</else>
</if>
</target>
<!-- Create services.yml by copying the default file. -->
<target name="create-services-yml">
<if>
<not>
<available file="${website.services.yml}" type="file" property="website.services.yml.available" />
</not>
<then>
<copy file="${website.services.yml.default}" tofile="${website.services.yml}" />
</then>
</if>
</target>
<!-- Make services.yml writeable. -->
<target
name="writable-services-yml"
depends="create-services-yml">
<if>
<available file="${website.services.yml}" type="file" property="website.services.yml.available" />
<then>
<chmod mode="0644" failonerror="false" verbose="true" quiet="false" file="${website.services.yml}" />
</then>
</if>
</target>
<target
name="build-dev"
description="Build a development environment."
depends="install-composer-dependencies, setup-behat, setup-php-codesniffer, setup-phpunit, setup-drush" />
<target
name="setup-dev"
description="Set up 'development mode' for an installed website."
depends="enable-dev-settings, redirect-outgoing-email, enable-dev-modules" />
<target
name="setup-acceptance"
description="Set up an acceptance environment."
depends="create-demo-users, redirect-outgoing-email" />
<target
name="install-dev"
description="Install the website and set up the development environment."
depends="install, setup-dev, create-demo-users" />
<target
name="build-dist"
description="Build a production environment."
depends="install-composer-dependencies-dist" />
</project>