Skip to content

Commit

Permalink
Simplifying drupal vm aliases. (#308)
Browse files Browse the repository at this point in the history
* Simplifying drupal vm aliases.

* Updating tests

* More VM fixes.
  • Loading branch information
grasmash authored Aug 17, 2016
1 parent a17237c commit e360448
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 3 additions & 1 deletion phing/tasks/blt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<target name="create-project" depends="init">
<exec dir="${repo.root}" command="git init" logoutput="true" checkreturn="true" passthru="true"/>
<echo>Updating composer dependencies, this make take a while...</echo>
<exec dir="${repo.root}" command="composer update" logoutput="true" checkreturn="true" passthru="true"/>
<exec dir="${repo.root}" command="export COMPOSER_PROCESS_TIMEOUT=600; composer update" logoutput="true" checkreturn="true" passthru="true"/>
<exec dir="${repo.root}" command="git add -A" logoutput="true" checkreturn="true" passthru="true"/>
<exec dir="${repo.root}" command="git commit -m 'Initial commit.'" logoutput="true" checkreturn="true" passthru="true"/>
<exec dir="${repo.root}" command="rm LICENSE.txt" logoutput="true" checkreturn="true"/>
Expand Down Expand Up @@ -37,6 +37,7 @@
</target>

<target name="blt:update-composer" description="Updates project composer.json with a subset of new key value pairs from upstream. This WILL overwrite existing values.">
<!--@todo Output different message if composer.json does not exist.-->
<echo>Merging BLT's composer.json template with your project's composer.json.</echo>
<echo>This MAY overwrite some existing values.</echo>
<!--Values in the project's existing composer.json file will be overwritten.-->
Expand All @@ -47,6 +48,7 @@
</target>

<target name="blt:update-yml" description="Updates project BLT .yml files with new key value pairs from upstream. This WILL NOT overwrite existing values.">
<!--@todo Output different message if project.yml does not exist-->
<echo>Merging BLT's project.yml template with your project's project.yml</echo>
<echo>This WILL NOT overwrite existing values.</echo>
<!--Values in the project's existing project.yml file will be preserved and not overridden.-->
Expand Down
2 changes: 1 addition & 1 deletion phing/tasks/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<not><equals arg1="${drush.alias}" arg2="self"/></not>
<then>
<echo>Unsetting drush.root because a remote alias is being used.</echo>
<property name="drush.root" value=""/>
<property name="drush.root" value="" override="true"/>
</then>
</if>

Expand Down
24 changes: 19 additions & 5 deletions phing/tasks/vm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
<target name="vm:init" description="Initializes Drupal VM for this project.">
<echo>BLT support for Drupal VM is EXPERIMENTAL. Not all BLT features currently work with Drupal VM. </echo>

<copy file="${blt.root}/scripts/drupal-vm/drupal-vm.aliases.drushrc.php" todir="${repo.root}/drush/site-aliases">
<echo>Creating a drush alias for the new VM.</echo>
<exec dir="${repo.root}" command="cat ${blt.root}/scripts/drupal-vm/drupal-vm.aliases.drushrc.php >> ${repo.root}/drush/site-aliases/aliases.drushrc.php" checkreturn="true" logoutput="true"/>
<reflexive>
<fileset dir="${repo.root}">
<include name="drush/site-aliases/aliases.drushrc.php" />
</fileset>
<filterchain>
<expandproperties />
</filterchain>
</copy>
</reflexive>
<mkdir dir="${repo.root}/box" mode="755"/>
<exec dir="${repo.root}" command="composer require --dev geerlingguy/drupal-vm:~3.1" logoutput="true" checkreturn="true"/>
<echo>Adding geerlingguy/drupal-vm to composer dev dependencies.</echo>
<exec dir="${repo.root}" command="composer require --dev geerlingguy/drupal-vm:~3.1" logoutput="true" checkreturn="true" passthru="true"/>
<copy file="${blt.root}/scripts/drupal-vm/config.yml" tofile="${repo.root}/box/config.yml">
<filterchain>
<expandproperties />
Expand All @@ -27,8 +33,16 @@
<echo>https://github.com/geerlingguy/drupal-vm#quick-start-guide</echo>
<echo></echo>
<echo>To boot the VM, run "vagrant up" from the project root.</echo>
<echo>To run drush commands against the VM, use the @${project.drush.aliases.local} alias.</echo>
<echo>You may pin yourself to this alias using "drush use @${project.drush.aliases.local}"</echo>
<echo>To run drush commands against the VM, use the @${drush.aliases.local} alias.</echo>
<echo>You may pin yourself to this alias using "drush use @${drush.aliases.local}"</echo>

<exec dir="${repo.root}" command="vagrant plugin list | grep vagrant-hostsupdater" outputProperty="vagrant.hostsupdater.exists"/>
<if>
<not><istrue value="${vagrant.hostsupdater.exists}"/></not>
<then>
<echo>The vagrant-hostsupdater plugin is not installed!</echo>
</then>
</if>
</target>

</project>
2 changes: 1 addition & 1 deletion template/drush.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ DOCROOT=$(${DIR}/vendor/bin/blt echo-property -Dproperty.name=drush.root -S -e)
if [ -z "$DOCROOT" ]; then
vendor/bin/drush.launcher --alias-path=${DIR}/drush/site-aliases "$@"
else
vendor/bin/drush.launcher --alias-path=${DIR}/drush/site-aliases "$@" -r ${DIR}/docroot
vendor/bin/drush.launcher --alias-path=${DIR}/drush/site-aliases "$@" -r $DOCROOT
fi
11 changes: 7 additions & 4 deletions tests/phpunit/DrupalVmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ public function __construct() {
public function testVmInit() {
$this->assertFileExists($this->newProjectDir . '/Vagrantfile');
$this->assertFileExists($this->newProjectDir . '/box/config.yml');
$this->assertFileExists($this->newProjectDir . '/drush/site-aliases/drupal-vm.aliases.drushrc.php');

$this->assertNotContains(
'${project.machine_name}',
file_get_contents($this->newProjectDir . '/box/config.yml')
);
$this->assertNotContains(
'${project.machine_name}',
file_get_contents($this->newProjectDir . '/drush/site-aliases/drupal-vm.aliases.drushrc.php')
$this->assertContains(
$this->config['project']['machine_name'] . '.local',
file_get_contents($this->newProjectDir . '/drush/site-aliases/aliases.drushrc.php')
);
$this->assertContains(
$this->config['project']['machine_name'] . '.local',
file_get_contents($this->newProjectDir . '/project.yml')
);
}

Expand Down

0 comments on commit e360448

Please sign in to comment.