Skip to content
2 changes: 2 additions & 0 deletions build.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
<!-- Make these commands available by default. -->
<import file="vendor/palantirnet/the-build/tasks/drupal.xml" />
<import file="vendor/palantirnet/the-build/tasks/acquia.xml" />
<import file="vendor/palantirnet/the-build/tasks/styleguide.xml" />


<!-- Default target: build -->
<target name="build" description="Build the application.">
<phingcall target="drupal-build" />
<phingcall target="styleguide" />
Comment thread
byrond marked this conversation as resolved.
</target>


Expand Down
9 changes: 9 additions & 0 deletions docs/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ Cool! This phing-ism is what powers our environment-specific property layering a

[More info](../tasks/drupal.xml#L16-L38)

### Style Guide

| Property | Default value | What is it? |
|---|---|---|
| `styleguide.root` | `styleguide` | Location of the style guide, relative to the project root. |
| `styleguide.command` | `yarn default` | Command to compile the style guide assets, for use during the build and artifact steps. |

[More info](../tasks/styleguide.xml#L22-L24)

### Code Review

| Property | Default value | What is it? |
Expand Down
1 change: 1 addition & 0 deletions tasks/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<echo message="Configure the default environment..." />
<phing target="configure" phingfile="${phing.dir.install}/boilerplate.xml" />
<phing target="drupal-configure" phingfile="${phing.dir.install}/drupal.xml" />
<phing target="styleguide-configure" phingfile="${phing.dir.install}/styleguide.xml" />
<phing target="drush-prepare-drushrc" phingfile="${phing.dir.install}/drupal.xml" />

<echo message="To configure properties for more environments, run: vendor/bin/phing configure -Dbuild.env=your_environment" />
Expand Down
91 changes: 91 additions & 0 deletions tasks/styleguide.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0"?>

<!--
@file styleguide.xml
Targets for managing the styleguide.

Copyright 2018 Palantir.net, Inc.
-->

<project name="Styleguide" default="styleguide">
<!--
Include this file in your build.xml with:
<import file="vendor/palantirnet/the-build/tasks/styleguide.xml" />
-->


<fail unless="build.dir" />
<fail unless="build.env" />
<fail unless="projectname" />


<!-- These properties will generally be set in the default build properties file. -->
<property name="styleguide.root" value="styleguide" />
<property name="styleguide.command" value="yarn default" />

<!-- This is resolved at runtime. -->
<resolvepath propertyName="styleguide.root.resolved" file="${styleguide.root}" dir="${build.dir}" />


<!-- Target: styleguide-configure -->
<target name="styleguide-configure" description="Configure the styleguide build.">
<phing phingfile="${phing.dir.styleguide}/configure.xml" inheritAll="false" dir="${build.dir}">
<property name="build.env" value="${build.env}" />
<property name="build.dir" value="${build.dir}" />

<!-- Load properties from the environment we're editing, with the prefix "default.*" -->
<property file="${build.dir}/conf/build.${build.env}.properties" prefix="default" />
<property file="${build.dir}/conf/build.default.properties" prefix="default" />

<!-- Prompts and defaults -->
<property name="prompt.styleguide.root" value="Style guide directory, relative to the project root" />
<property name="default.styleguide.root" value="${styleguide.root}" />

<property name="prompt.styleguide.command" value="Style guide build command" />
<property name="default.styleguide.command" value="${styleguide.command}" />

<property name="update" value="styleguide.root,styleguide.command" />
<property name="dump" value="" />
</phing>
</target>


<!-- Target: styleguide -->
<target name="styleguide" description="Install and build the style guide.">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test whether the properties are set first? That way they can be only run on Circle, if desired.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point -- especially re: the nodejs installs that vary by platform.

The thing is, where the styleguide is built tends to vary between development roles -- folks doing design and front end development will build it locally, but folks doing engineering, devops, or support will build the styleguide within the VM.

So I'm not sure where to go with this...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@becw and @russom-woldezghi, I think I have resolved this by checking for a linux-x64-59 binding in node-sass. If it isn't there, Phing will run yarn install, which actually allows you to use Butler on both the host and VM to build the styleguide (assuming the Node versions match).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested by building the styleguide on my host, then running phing build in the VM, which ran successfully. I was also able to go back to my host and build the styleguide again.

<phingcall target="styleguide-install" />

<!-- Run the styleguide build command. -->
<echo>Running build command in ${styleguide.root}: ${styleguide.command}</echo>
<exec dir="${styleguide.root.resolved}" command="${styleguide.command}" passthru="true" checkreturn="true" />
</target>


<!-- Target: styleguide-install -->
<target name="styleguide-install" description="Install the style guide.">

<!-- Run composer install in the styleguide. -->
<if>
<and>
<available file="${styleguide.root.resolved}/composer.lock" type="file" />
<not><available file="${styleguide.root.resolved}/vendor/autoload.php" type="file" /></not>
</and>
<then>
<exec dir="${styleguide.root.resolved}" command="composer install --no-interaction" passthru="true" checkreturn="true" />
</then>
</if>

<!-- Run yarn install in the styleguide. -->
<if>
<and>
<available file="${styleguide.root.resolved}/yarn.lock" type="file" />
<not><available file="${styleguide.root.resolved}/node_modules/.yarn-integrity" type="file" /></not>
</and>
<then>
<exec dir="${styleguide.root.resolved}" command="yarn install --non-interactive --no-progress --prefer-offline" passthru="true" checkreturn="true" />
</then>
</if>
</target>


</project>