Skip to content

Commit

Permalink
Changing default composer config to use wikimedia/composer-merge-plug…
Browse files Browse the repository at this point in the history
…in. (acquia#1165)

* Changing default composer config to use wikimedia/composer-merge-plugin.

* Adding wikimedia/composer-merge-plugin.

* Adding empty require-dev and autoload-dev arrays.

* Removing composer munging.

* Removing more composer update functionality.

* Adding update hook.

* Removing prompt to install PhantomJS.

* Adding the plugin.

* Fixing various phantom issues...

* Adding scripts to update.

* Updating dependencies.

* Moving installer-paths.

* Updating composer deps.
  • Loading branch information
grasmash authored Mar 14, 2017
1 parent c544d9f commit 51f258f
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 403 deletions.
4 changes: 0 additions & 4 deletions bin/blt-console
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env php
<?php

use Acquia\Blt\Console\Command\ConfigurePhantomJsCommand;
use Acquia\Blt\Console\Command\ComposerMungeCommand;
use Acquia\Blt\Console\Command\SchemaVersionCommand;
use Acquia\Blt\Console\Command\YamlMungeCommand;
use Acquia\Blt\Console\Command\UpdateCommand;
Expand All @@ -25,8 +23,6 @@ else {
}

$application = new Application();
$application->add(new ConfigurePhantomJsCommand());
$application->add(new ComposerMungeCommand());
$application->add(new YamlMungeCommand());
$application->add(new SchemaVersionCommand());
$application->add(new UpdateCommand());
Expand Down
21 changes: 21 additions & 0 deletions blt-project/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@
"require": {
"acquia/blt": "*@dev"
},
"extra": {
"merge-plugin": {
"require": [
"vendor/acquia/blt/composer.include.json"
],
"merge-extra": true,
"merge-extra-deep": true,
"merge-scripts": true
},
"installer-paths": {
"docroot/core": ["type:drupal-core"],
"docroot/modules/contrib/{$name}": ["type:drupal-module"],
"docroot/modules/custom/{$name}": ["type:drupal-custom-module"],
"docroot/profiles/contrib/{$name}": ["type:drupal-profile"],
"docroot/profiles/custom/{$name}": ["type:drupal-custom-profile"],
"docroot/themes/contrib/{$name}": ["type:drupal-theme"],
"docroot/themes/custom/{$name}": ["type:drupal-custom-theme"],
"docroot/libraries/{$name}": ["type:drupal-library"],
"drush/contrib/{$name}": ["type:drupal-drush"]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
69 changes: 69 additions & 0 deletions composer.include.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
}
},
"require": {
"acquia/lightning": "2.0.3",
"drupal/acquia_connector": "^1.5.0",
"drupal/acsf": "^1.32.0",
"drupal/core": "^8.0",
"drupal/cog": "^1.0.0",
"drupal/features": "^3.0.0",
"drupal/memcache": "2.x-dev",
"drupal/seckit": "^1.0.0-alpha2",
"drupal/security_review": "*",
"drupal/shield": "^1.0.0",
"drush/drush": "^8.1.8"
},
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "~1.7",
"behat/mink-selenium2-driver": "^1.3.1",
"bex/behat-screenshot": "^1.2",
"drupal/console": "^1.0.0-rc13",
"drupal/devel": "^1.0.0-alpha1",
"drupal/drupal-extension": "^3.2",
"drupal-composer/drupal-scaffold": "^2.1.0",
"jarnaiz/behat-junit-formatter": "^1.3.2",
"se/selenium-server-standalone": "^2.53",
"jakoch/phantomjs-installer": "^2.1.1-p07"
},
"autoload-dev": {
"psr-4": {
"Drupal\\Tests\\PHPUnit\\": "tests/phpunit/src/"
}
},
"extra": {
"drupal-scaffold": {
"initial": {
"sites/default/default.services.yml": "sites/default/services.yml",
"sites/default/default.settings.php": "sites/default/settings.php"
},
"excludes": [
"sites/development.services.yml"
]
},
"enable-patching": true,
"patches": {
"drupal/core": {
"Clear Twig caches on deploys": "https://www.drupal.org/files/issues/no_reliable_method-2752961-29.patch"
}
}
},
"scripts": {
"blt-alias": "blt install-alias -Dcreate_alias=true",
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"nuke": [
"rm -rf vendor composer.lock",
"@composer clearcache",
"@composer install"
],
"install-phantomjs": [
"rm -rf vendor/bin/phantomjs",
"PhantomInstaller\\Installer::installPhantomJS"
]
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "^2.7",
"symfony/yaml": "^2.8.11",
"symfony/console": "^2.8.11"
"symfony/console": "^2.8.11",
"wikimedia/composer-merge-plugin": "^1.3"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 50 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions phing/tasks/blt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<!-- Pull in initial template files. -->
<phingcall target="blt:rsync-template"/>
<phingcall target="blt:update-composer"/>

<!--Write project.machine_name to project.yml, using name of working directory as value.. -->
<exec dir="${repo.root}" command="result=${PWD##*/}; printf '%s\n' &quot;${PWD##*/}&quot;" logoutput="false" checkreturn="true" level="${blt.exec_level}" passthru="false" outputProperty="dirname"/>
Expand Down Expand Up @@ -71,7 +70,7 @@
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --include-from=${blt.update.ignore-existing-file} --ignore-existing" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</target>

<target name="update" depends="blt:rsync-template, blt:update-composer, blt:update-yml, blt:update-delta, cleanup" hidden="true">
<target name="update" depends="blt:rsync-template, blt:update-yml, blt:update-delta, cleanup" hidden="true">
<phingcall target="install-alias">
<property name="create_alias" value="true"/>
</phingcall>
Expand All @@ -83,19 +82,6 @@
<exec dir="${repo.root}" command="${composer.bin}/blt-console blt:schema-version ${repo.root} --latest > ${blt.config-files.schema-version}" checkreturn="true" logoutput="true" passthru="true"/>
</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." hidden="true">
<echo level="verbose">Merging BLT's composer.json template with your project's composer.json.</echo>
<echo level="verbose">This MAY overwrite some existing values.</echo>
<exec dir="${repo.root}" command="${composer.bin}/blt-console composer:munge ${repo.root}/composer.json ${blt.root}/template/composer.json > ${repo.root}/composer.json.tmp" logoutput="true" checkreturn="true" level="${blt.exec_level}" returnProperty="composer.munge.return"/>
<if>
<equals arg1="${composer.munge.return}" arg2="0"/>
<then>
<!--@todo Find out why can't we just redirect output directly back to composer.json. -->
<exec dir="${repo.root}" command="mv ${repo.root}/composer.json.tmp ${repo.root}/composer.json" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
</then>
</if>
</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." hidden="true">
<!--@todo Output different message if project.yml does not exist-->
<echo level="verbose">Merging BLT's project.yml template with your project's project.yml.</echo>
Expand Down
36 changes: 1 addition & 35 deletions phing/tasks/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,44 +187,10 @@
</target>

<target name="tests:phantomjs:configure" description="Checks and corrects PhantomJS configuration">
<exec dir="${repo.root}" command="grep 'jakoch/phantomjs-installer' composer.json" logoutput="false" level="${blt.exec_level}" passthru="false" returnProperty="phantom.required"/>
<if>
<isfailure code="${phantom.required}"/>
<then>
<echo level="Warning">jakoch/phantomjs-installer is not required in composer.json.</echo>
<propertyprompt promptText="Do you want to require jakoch/phantomjs-installer via Composer?" propertyName="phantom.do-require" defaultValue="y"/>
<if>
<equals arg1="${phantom.do-require}" arg2="y" casesensitive="false"/>
<then>
<exec dir="${repo.root}" command="composer require jakoch/phantomjs-installer --dev" logoutput="true" level="${blt.exec_level}" passthru="true" />
</then>
<else>
<fail>Cannot launch PhantomJS it is not installed.</fail>
</else>
</if>
</then>
</if>
<exec dir="${repo.root}" command="grep installPhantomJS composer.json" logoutput="false" level="${blt.exec_level}" passthru="false" returnProperty="phantom.scripts"/>
<if>
<isfailure code="${phantom.scripts}"/>
<then>
<echo level="warning">behat.launch-phantomjs is true, but the install-phantomjs script is not defined in composer.json.</echo>
<propertyprompt promptText="Do you want to add an 'install-phantomjs' script to your composer.json?" propertyName="phantom.do-add-script" defaultValue="y"/>
<if>
<equals arg1="${phantom.do-add-script}" arg2="y" casesensitive="false"/>
<then>
<exec command="${composer.bin}/blt-console configure:phantomjs ${repo.root}" logoutput="true" level="${blt.exec_level}" passthru="false" checkreturn="true"/>
</then>
<else>
<fail>Cannot launch PhantomJS because the install-phantomjs script is not present in composer.json. Add it, or use Selenium instead.</fail>
</else>
</if>
</then>
</if>
<if>
<not><available file="${composer.bin}/phantomjs"/></not>
<then>
<exec dir="${repo.root}" command="composer install-phantom" checkreturn="true" logoutput="true" passthru="true" level="${blt.exec_level}"/>
<exec dir="${repo.root}" command="composer run-script install-phantomjs" checkreturn="true" logoutput="true" passthru="true" level="${blt.exec_level}"/>
</then>
</if>
</target>
Expand Down
2 changes: 1 addition & 1 deletion readme/creating-new-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

1. Install the `blt` alias and follow on-screen instructions:

composer blt-alias
composer run-script blt-alias
source ~/.bash_profile

1. Customize `blt/project.yml`.
Expand Down
2 changes: 1 addition & 1 deletion readme/onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you need to make requests via a proxy server, please [configure git to use a

1. If your project uses separate `master` and `develop` branches, checkout the `develop` branch: `git checkout develop`
1. Run `composer install` (you must already have Composer installed).
1. Install `blt` alias: `composer blt-alias`
1. Install `blt` alias: `composer run-script blt-alias`

If your project uses a virtual development environment such as DrupalVM:

Expand Down
30 changes: 3 additions & 27 deletions readme/updating-blt.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,15 @@ If you are already using BLT via Composer, you can update to the latest version

### Modifying update behavior

By default BLT will modify your project's composer.json to conform with the [upstream composer.json template](https://github.com/acquia/blt/blob/8.x/template/composer.json). If you'd like to prevent a specific package or key in composer.json from being modified, use the `composer-exclude-merge` option:
By default BLT will modify a handful of files in your project to conform to the [upstream template](https://github.com/acquia/blt/blob/8.x/template). If you'd like to prevent this, set `extra.blt.update` to `false` in `composer.json`:

"extra": {
"blt": {
"update": true,
"composer-exclude-merge": {
"require": [
"drupal/acsf",
"drupal/acquia_connector",
"drupal/memcache",
"drupal/search_api",
"drupal/search_api_solr"
],
"require-dev": "*"
}
"update": true
}
}

This would prevent the merging of any upstream updates to the composer.json configuration for a handful of modules in `require` and all packages in `require-dev`.

A few other examples of valid usage:

"extra": {
"blt": {
"update": false,
}
}
"extra": {
"blt": {
"update": true,
"composer-exclude-merge": "*"
}
}
Please not that if you choose to do this, it is your responsibility to track upstream changes. This is very likely to cause issues when you upgrade BLT to a new version.

## Updating from a non-Composer-managed (very old) version

Expand Down
12 changes: 0 additions & 12 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,6 @@ protected function executeBltUpdate($version) {
}
elseif ($options['blt']['update']) {
$this->io->write('<info>Updating BLT templated files...</info>');

// Rsyncs, updates composer.json, project.yml, executes scripted updates for version delta.
$pre_composer_json = md5_file($this->getRepoRoot() . DIRECTORY_SEPARATOR . 'composer.json');
$success = $this->executeCommand('blt update', [], TRUE);
if (!$success) {
$this->io->write("<error>BLT update script failed! Run `blt update -verbose` to retry.</error>");
}
$post_composer_json = md5_file($this->getRepoRoot() . DIRECTORY_SEPARATOR . 'composer.json');

if ($pre_composer_json != $post_composer_json) {
$this->io->write('<error>Your composer.json file was modified by BLT, you MUST run "composer update" to re-process and update dependencies.</error>');
}
}
else {
$this->io->write('<comment>Skipping update of BLT templated files</comment>');
Expand Down
Loading

0 comments on commit 51f258f

Please sign in to comment.