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

Commit 16a5a2d

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

File tree

4 files changed

+43
-48
lines changed

4 files changed

+43
-48
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>
+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
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
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."
2020
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, setup:build:profile, frontend:build">
21+
22+
<phingcall target="task:execute">
23+
<property name="task-name" value="setup"/>
24+
</phingcall>
25+
2126
</target>
2227

2328
<target name="setup:build:profile" description="Build a subsidiary makefile shipped with profile">

template/project.yml

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ 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+
tasks:
45+
# Executed after setup:build:all is run.
46+
setup:
47+
dir: ${docroot}/profiles/contrib/lighting
48+
command: npm install && bower install
49+
# Executed when front end assets should be generated.
50+
frontend:
51+
dir: ${docroot}/sites/all/themes/contrib/thunder
52+
command: npm run build
53+
4354
# Hosting environment flags.
4455
# Examples: acsf (Acquia Cloud Site Factory), ac (Acquia Cloud)
4556
# hosting: "acsf"

0 commit comments

Comments
 (0)