Skip to content

Commit

Permalink
Defining custom docroot for Drupal VM in project.local.yml. (#172)
Browse files Browse the repository at this point in the history
* Defining custom docroot for Drupal VM in project.local.yml.

* Fixing local:sync target.

* Improving vm:init modification of project.local.yml.

* Fixing tests for vm:init.

* Adding placeholder value to example.project.local.yml.
  • Loading branch information
grasmash authored Jun 16, 2016
1 parent 9faf5e6 commit 4fec96c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
3 changes: 2 additions & 1 deletion template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Ignore configuration files that may contain sensitive information.
local.*
*.local.*
*.local
project.local.yml

# Ignore drupal core.
docroot/core
Expand Down
3 changes: 2 additions & 1 deletion template/build/core/phing/tasks/local-sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<target name="local:sync" description="Synchronize remote environment with local environment."
depends="setup:drupal:settings">
<exec dir="${docroot}" command="${drush.cmd} sql-drop -y" logoutput="true" checkreturn="true"/>
<exec dir="${docroot}" command="${drush.cmd} sql-sync @${drush.aliases.remote} @${drush.aliases.local} --create-db --structure-tables-key=lightweight -y" logoutput="true" checkreturn="true"/>
<!--We cannot use drush.cmd here because it incorrectly assigns an alias to the command. -->
<exec dir="${docroot}" command="${drush.bin} -r ${docroot} -l ${multisite.name} sql-sync @${drush.aliases.remote} @${drush.aliases.local} --create-db --structure-tables-key=lightweight -y" logoutput="true" checkreturn="true"/>
<exec dir="${docroot}" command="${drush.cmd} cc drush" logoutput="true" checkreturn="true"/>
<exec dir="${docroot}" command="${drush.cmd} cr" logoutput="true" checkreturn="true"/>
</target>
Expand Down
1 change: 1 addition & 0 deletions template/build/core/phing/tasks/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<property file="${repo.root}/project.yml" override="true"/>

<!-- Load the local project.local.yml file for this project. -->
<!--@todo Change this so that it is only loaded for local:* targets. -->
<if>
<available file="${repo.root}/project.local.yml" type="file" property="local.properties"/>
<then>
Expand Down
5 changes: 3 additions & 2 deletions template/build/core/phing/tasks/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@

<target name="setup:drupal:settings" description="Create local settings files using default settings files.">
<chmod mode="0755" file="${docroot}/sites/default" failonerror="false" verbose="true"/>
<copy file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php"/>
<copy file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php">
<copy file="${repo.root}/example.project.local.yml" tofile="${repo.root}/project.local.yml" overwrite="false"/>
<copy file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" overwrite="false"/>
<copy file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php" overwrite="false">
<filterchain>
<expandproperties />
</filterchain>
Expand Down
8 changes: 7 additions & 1 deletion template/build/core/phing/tasks/vm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
<!-- Sadly this wipes out comments in the file. -->
<exec dir="${repo.root}" command="${composer.bin}/drupal yaml:update:value ${repo.root}/project.yml drush.default_alias '${project.machine_name}.local'" logoutput="true" checkreturn="true"/>
<exec dir="${repo.root}" command="${composer.bin}/drupal yaml:update:value ${repo.root}/project.yml drush.aliases.local '${project.machine_name}.local'" logoutput="true" checkreturn="true"/>
<exec dir="${repo.root}" command="${composer.bin}/drupal yaml:update:value ${repo.root}/build/custom/phing/build.yml drush.root ''" logoutput="true" checkreturn="true"/>

<!--Add drush.root to example.project.local.yml for those who have not yet generated project.local.yml from it.-->
<exec dir="${repo.root}" command="${composer.bin}/drupal yaml:update:value ${repo.root}/example.project.local.yml drush.root ''" logoutput="true" checkreturn="true"/>
<!-- Attempt to generate project.local.yml. This will not overwrite an existing file. -->
<phingcall target="setup:drupal:settings"/>
<!--Add drush.root to project.local.yml for those who had already generated it.-->
<exec dir="${repo.root}" command="${composer.bin}/drupal yaml:update:value ${repo.root}/project.local.yml drush.root ''" logoutput="true" checkreturn="true"/>

<echo></echo>
<echo>A new "box" directory and a Vagrantfile have been added to ${repo.root}</echo>
Expand Down
19 changes: 10 additions & 9 deletions template/example.project.local.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Override any settings as necessary by copying to project.local.yml
project:
local:
protocol: http
hostname: mysite.dev
#project:
# local:
# protocol: http
# hostname: mysite.dev

drush:
# You can set custom project aliases in drush/site-aliases/aliases.drushrc.php.
aliases:
# The local environment against which all local drush commands are run.
local: local.mysite.dev
# You can set custom project aliases in drush/site-aliases/aliases.drushrc.php.
# All local:* targets are run against drush.aliases.local.
#drush:
# aliases:
# local: local.mysite.dev
example: value
12 changes: 10 additions & 2 deletions tests/phpunit/DrupalVmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ public function testVmInit() {
);
$this->assertContains(
'drush:',
file_get_contents($this->new_project_dir . '/build/custom/phing/build.yml')
file_get_contents($this->new_project_dir . '/example.project.local.yml')
);
$this->assertContains(
'root:',
file_get_contents($this->new_project_dir . '/build/custom/phing/build.yml')
file_get_contents($this->new_project_dir . '/example.project.local.yml')
);
$this->assertContains(
'drush:',
file_get_contents($this->new_project_dir . '/project.local.yml')
);
$this->assertContains(
'root:',
file_get_contents($this->new_project_dir . '/project.local.yml')
);
}

Expand Down

0 comments on commit 4fec96c

Please sign in to comment.