Skip to content

Commit

Permalink
Revert "Adding support for custom commands in frontend and setup targ…
Browse files Browse the repository at this point in the history
…ets." (#194)
  • Loading branch information
grasmash authored Jun 21, 2016
1 parent 93c916d commit 275a2d3
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 56 deletions.
23 changes: 0 additions & 23 deletions template/build/core/phing/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,4 @@
<exec dir="${repo.root}" command="./blt.sh -q -l" passthru="true"/>
</target>

<target name="task:execute">
<fail unless="task-name"/>

<if>
<available property="${tasks.${task-name}.command}" />
<then>
<if>
<available file="${tasks.${task-name}.dir}" type="dir" property="taskDirExists" />
<then>
<exec dir="${hooks.${task-name}.dir}" command="${scripts.${task-name}.command}" logoutput="true" checkreturn="true" />
</then>
<else>
<fail>The directory ${scripts.${task-name}.dir} does not exist. Will not run command for ${task-name}.</fail>
</else>
</if>
</then>
<else>
<echo>No commands are defined for ${task-name}. Skipping.</echo>
</else>
</if>

</target>

</project>
24 changes: 16 additions & 8 deletions template/build/core/phing/tasks/deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@

<!-- Build artifact and commit locally. -->
<phingcall target="deploy:build"/>

<!--Allow custom commands to be run before commit.-->
<phingcall target="task:execute">
<property name="task-name" value="deploy"/>
</phingcall>

<!--Commit artifact. -->
<phingcall target="deploy:commit"/>

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

<target name="deploy:build" description="Generates a deploy-ready build in deploy.dir."
depends="frontend:build, deploy:copy, deploy:composer:install, deploy:sanitize">
depends="frontend:build, deploy:copy, deploy:composer:install, deploy:profile:make, deploy:sanitize">
<!-- If we are using ACSF, run the ACSF Deploy command. -->
<if>
<equals arg1="${hosting}" arg2="acsf"/>
Expand All @@ -97,6 +90,21 @@
<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"/>
</target>

<target name="deploy:profile:make" description="Build a subsidiary makefile shipped with profile.">
<if>
<equals arg1="${project.profile.contrib}" arg2="true"/>
<then>
<echo message="Building make file for ${project.profile.name}"/>
<property name="profile.dir" value="${deploy.dir}/docroot/profiles/contrib/${project.profile.name}"/>
<drush command="make" assume="yes" verbose="TRUE">
<param>"${profile.dir}/drupal-org.make"</param>
<param>"${profile.dir}"</param>
<option name="no-core"></option>
</drush>
</then>
</if>
</target>

<target name="deploy:copy" description="Copy required files from /docroot/sites to /deploy/docroot/sites.">
<!-- Make sites/default writable so that we can copy files. -->
<!-- @todo Support multisite. -->
Expand Down
52 changes: 48 additions & 4 deletions template/build/core/phing/tasks/frontend.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,53 @@
<project name="frontend" default="frontend:install">

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

<target name="frontend:build:run" depends="frontend:install" description="Uses gulp to build front end dependencies for a theme.">
<if>
<!-- We assume that if the theme name is not thunder, then a subtheme of thunder is being used. -->
<not><equals arg1="${frontend.theme}" arg2="thunder" /></not>
<then>
<exec dir="${docroot}/themes/custom/${frontend.theme}" command="npm run build" logoutput="true" checkreturn="true" />
</then>
</if>

<property name="project.frontend.nvmrc.file" value="${docroot}/themes/custom/${frontend.theme}/.nvmrc" />
<if>
<available file="${project.frontend.nvmrc.file}" />
<then>
<copy file="${project.frontend.nvmrc.file}" todir="${repo.root}" />
</then>
</if>
</target>

<target name="frontend:install" description="Installs front end dependencies for themes.">
<!-- Enable support for multiple themes (Base + Subtheme or multisite deployments) -->
<if>
<isset property="project.themes" />
<then>
<foreach list="${project.themes}" param="frontend.theme" target="frontend:install:run"/>
</then>
<else>
<!-- Skip and tell user no themes were found -->
<echo message="No Themes were found, skipping frontend:install."/>
</else>
</if>
</target>

<target name="frontend:install:run" description="Installs front end dependencies for a theme.">
<if>
<!-- We assume that if the theme name is not thunder, then a subtheme of thunder is being used. -->
<not><equals arg1="${frontend.theme}" arg2="thunder" /></not>
<then>
<exec dir="${docroot}/themes/custom/${frontend.theme}" command="npm run install-tools" logoutput="true" checkreturn="true" />
</then>
</if>
</target>
</project>
20 changes: 15 additions & 5 deletions template/build/core/phing/tasks/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@

<!-- This is run when a project is cloned to a new environment. -->
<target name="setup:build:all" 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:build">

<phingcall target="task:execute">
<property name="task-name" value="setup"/>
</phingcall>
depends="setup:git-hooks, setup:drupal:settings, setup:behat, setup:composer:install, setup:build:profile, frontend:build">
</target>

<target name="setup:build:profile" description="Build a subsidiary makefile shipped with profile">
<if>
<equals arg1="${project.profile.contrib}" arg2="true"/>
<then>
<echo message="Building make file for ${project.profile.name}"/>
<property name="profile.dir" value="${docroot}/profiles/contrib/${project.profile.name}"/>
<drush command="make" assume="yes" verbose="TRUE">
<option name="no-core"></option>
<param>"${profile.dir}/drupal-org.make"</param>
<param>${profile.dir}</param>
</drush>
</then>
</if>
</target>

<target name="setup:clean" description="Removes .gitignored files and directories.">
Expand Down
16 changes: 0 additions & 16 deletions template/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ drush:
# The default drush alias to be used when no environment is specified.
default_alias: ${drush.aliases.local}

# Custom tasks that are triggered at pre-defined times in the build process.
# Available keys are setup, frontend.
tasks:
# Executed after setup:build:all is run.
setup:
dir: ${docroot}/profiles/contrib/lighting
command: npm install && bower install
# Executed when front end assets should be generated.
frontend:
dir: ${docroot}/sites/all/themes/contrib/thunder
command: npm run build
# Executed after deployment artifact is created.
deploy:
dir: ${deploy.dir}
command: cd docroot/profiles/contrib/lightning && npm install && bower install

# Hosting environment flags.
# Examples: acsf (Acquia Cloud Site Factory), ac (Acquia Cloud)
# hosting: "acsf"
Expand Down

0 comments on commit 275a2d3

Please sign in to comment.