Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit f76d903

Browse files
committed
Adding support for custom commands in frontend and setup targets.
1 parent 995eda8 commit f76d903

File tree

5 files changed

+56
-79
lines changed

5 files changed

+56
-79
lines changed

template/build/core/phing/build.xml

+23
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,27 @@
5757
<exec dir="${repo.root}" command="./blt.sh -q -l" passthru="true"/>
5858
</target>
5959

60+
<target name="task:execute">
61+
<fail unless="task-name"/>
62+
63+
<if>
64+
<available property="${task-name}.command" />
65+
<then>
66+
<if>
67+
<available file="${tasks.${task-name}.dir}" type="dir" property="taskDirExists" />
68+
<then>
69+
<exec dir="${hooks.${task-name}.dir}" command="${scripts.${task-name}.command}" logoutput="true" checkreturn="true" />
70+
</then>
71+
<else>
72+
<fail>The directory ${scripts.${task-name}.dir} does not exist. Will not run command for ${task-name}.</fail>
73+
</else>
74+
</if>
75+
</then>
76+
<else>
77+
<echo>No commands are defined for ${task-name}. Skipping.</echo>
78+
</else>
79+
</if>
80+
81+
</target>
82+
6083
</project>

template/build/core/phing/tasks/deploy.xml

+8-16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626

2727
<!-- Build artifact and commit locally. -->
2828
<phingcall target="deploy:build"/>
29+
30+
<!--Allow custom commands to be run before commit.-->
31+
<phingcall target="task:execute">
32+
<property name="task-name" value="deploy"/>
33+
</phingcall>
34+
35+
<!--Commit artifact. -->
2936
<phingcall target="deploy:commit"/>
3037

3138
<!-- Push up changes to remotes if this is not a dry run.-->
@@ -63,7 +70,7 @@
6370
</target>
6471

6572
<target name="deploy:build" description="Generates a deploy-ready build in deploy.dir."
66-
depends="frontend:build, deploy:copy, deploy:composer:install, deploy:profile:make, deploy:sanitize">
73+
depends="frontend:build, deploy:copy, deploy:composer:install, deploy:sanitize">
6774
<!-- If we are using ACSF, run the ACSF Deploy command. -->
6875
<if>
6976
<equals arg1="${hosting}" arg2="acsf"/>
@@ -90,21 +97,6 @@
9097
<exec dir="${deploy.dir}" command="export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --no-dev --prefer-dist --no-interaction" passthru="true" logoutput="true" checkreturn="true"/>
9198
</target>
9299

93-
<target name="deploy:profile:make" description="Build a subsidiary makefile shipped with profile.">
94-
<if>
95-
<equals arg1="${project.profile.contrib}" arg2="true"/>
96-
<then>
97-
<echo message="Building make file for ${project.profile.name}"/>
98-
<property name="profile.dir" value="${deploy.dir}/docroot/profiles/contrib/${project.profile.name}"/>
99-
<drush command="make" assume="yes" verbose="TRUE">
100-
<param>"${profile.dir}/drupal-org.make"</param>
101-
<param>"${profile.dir}"</param>
102-
<option name="no-core"></option>
103-
</drush>
104-
</then>
105-
</if>
106-
</target>
107-
108100
<target name="deploy:copy" description="Copy required files from /docroot/sites to /deploy/docroot/sites.">
109101
<!-- Make sites/default writable so that we can copy files. -->
110102
<!-- @todo Support multisite. -->
+4-48
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,9 @@
11
<project name="frontend" default="frontend:install">
22

3-
<target name="frontend:build" depends="frontend:install" description="Uses gulp to build front end dependencies for all themes.">
4-
<if>
5-
<isset property="project.themes"/>
6-
<then>
7-
<foreach list="${project.themes}" param="frontend.theme" target="frontend:build:run"/>
8-
</then>
9-
</if>
3+
<target name="frontend:build" description="Uses gulp to build front end dependencies for all themes.">
4+
<phingcall target="task:execute">
5+
<property name="task-name" value="frontend"/>
6+
</phingcall>
107
</target>
118

12-
<target name="frontend:build:run" depends="frontend:install" description="Uses gulp to build front end dependencies for a theme.">
13-
<if>
14-
<!-- We assume that if the theme name is not thunder, then a subtheme of thunder is being used. -->
15-
<not><equals arg1="${frontend.theme}" arg2="thunder" /></not>
16-
<then>
17-
<exec dir="${docroot}/themes/custom/${frontend.theme}" command="npm run build" logoutput="true" checkreturn="true" />
18-
</then>
19-
</if>
20-
21-
<property name="project.frontend.nvmrc.file" value="${docroot}/themes/custom/${frontend.theme}/.nvmrc" />
22-
<if>
23-
<available file="${project.frontend.nvmrc.file}" />
24-
<then>
25-
<copy file="${project.frontend.nvmrc.file}" todir="${repo.root}" />
26-
</then>
27-
</if>
28-
</target>
29-
30-
<target name="frontend:install" description="Installs front end dependencies for themes.">
31-
<!-- Enable support for multiple themes (Base + Subtheme or multisite deployments) -->
32-
<if>
33-
<isset property="project.themes" />
34-
<then>
35-
<foreach list="${project.themes}" param="frontend.theme" target="frontend:install:run"/>
36-
</then>
37-
<else>
38-
<!-- Skip and tell user no themes were found -->
39-
<echo message="No Themes were found, skipping frontend:install."/>
40-
</else>
41-
</if>
42-
</target>
43-
44-
<target name="frontend:install:run" description="Installs front end dependencies for a theme.">
45-
<if>
46-
<!-- We assume that if the theme name is not thunder, then a subtheme of thunder is being used. -->
47-
<not><equals arg1="${frontend.theme}" arg2="thunder" /></not>
48-
<then>
49-
<exec dir="${docroot}/themes/custom/${frontend.theme}" command="npm run install-tools" logoutput="true" checkreturn="true" />
50-
</then>
51-
</if>
52-
</target>
539
</project>

template/build/core/phing/tasks/setup.xml

+5-15
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,12 @@
1717

1818
<!-- This is run when a project is cloned to a new environment. -->
1919
<target name="setup:build:all" description="Generates all required files for a full build. E.g., (re)builds docroot, etc."
20-
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, setup:build:profile, frontend:build">
21-
</target>
20+
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, frontend:build">
21+
22+
<phingcall target="task:execute">
23+
<property name="task-name" value="setup"/>
24+
</phingcall>
2225

23-
<target name="setup:build:profile" description="Build a subsidiary makefile shipped with profile">
24-
<if>
25-
<equals arg1="${project.profile.contrib}" arg2="true"/>
26-
<then>
27-
<echo message="Building make file for ${project.profile.name}"/>
28-
<property name="profile.dir" value="${docroot}/profiles/contrib/${project.profile.name}"/>
29-
<drush command="make" assume="yes" verbose="TRUE">
30-
<option name="no-core"></option>
31-
<param>"${profile.dir}/drupal-org.make"</param>
32-
<param>${profile.dir}</param>
33-
</drush>
34-
</then>
35-
</if>
3626
</target>
3727

3828
<target name="setup:clean" description="Removes .gitignored files and directories.">

template/project.yml

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ drush:
4040
# The default drush alias to be used when no environment is specified.
4141
default_alias: ${drush.aliases.local}
4242

43+
# Custom tasks that are triggered at pre-defined times in the build process.
44+
# Available keys are setup, frontend.
45+
tasks:
46+
# Executed after setup:build:all is run.
47+
setup:
48+
dir: ${docroot}/profiles/contrib/lighting
49+
command: npm install && bower install
50+
# Executed when front end assets should be generated.
51+
frontend:
52+
dir: ${docroot}/sites/all/themes/contrib/thunder
53+
command: npm run build
54+
# Executed after deployment artifact is created.
55+
deploy:
56+
dir: ${deploy.dir}
57+
command: cd docroot/profiles/contrib/lightning && npm install && bower install
58+
4359
# Hosting environment flags.
4460
# Examples: acsf (Acquia Cloud Site Factory), ac (Acquia Cloud)
4561
# hosting: "acsf"

0 commit comments

Comments
 (0)