Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 51f258f

Browse files
authored
Changing default composer config to use wikimedia/composer-merge-plugin. (#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.
1 parent c544d9f commit 51f258f

16 files changed

+300
-403
lines changed

bin/blt-console

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Acquia\Blt\Console\Command\ConfigurePhantomJsCommand;
5-
use Acquia\Blt\Console\Command\ComposerMungeCommand;
64
use Acquia\Blt\Console\Command\SchemaVersionCommand;
75
use Acquia\Blt\Console\Command\YamlMungeCommand;
86
use Acquia\Blt\Console\Command\UpdateCommand;
@@ -25,8 +23,6 @@ else {
2523
}
2624

2725
$application = new Application();
28-
$application->add(new ConfigurePhantomJsCommand());
29-
$application->add(new ComposerMungeCommand());
3026
$application->add(new YamlMungeCommand());
3127
$application->add(new SchemaVersionCommand());
3228
$application->add(new UpdateCommand());

blt-project/composer.json

+21
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@
2020
"require": {
2121
"acquia/blt": "*@dev"
2222
},
23+
"extra": {
24+
"merge-plugin": {
25+
"require": [
26+
"vendor/acquia/blt/composer.include.json"
27+
],
28+
"merge-extra": true,
29+
"merge-extra-deep": true,
30+
"merge-scripts": true
31+
},
32+
"installer-paths": {
33+
"docroot/core": ["type:drupal-core"],
34+
"docroot/modules/contrib/{$name}": ["type:drupal-module"],
35+
"docroot/modules/custom/{$name}": ["type:drupal-custom-module"],
36+
"docroot/profiles/contrib/{$name}": ["type:drupal-profile"],
37+
"docroot/profiles/custom/{$name}": ["type:drupal-custom-profile"],
38+
"docroot/themes/contrib/{$name}": ["type:drupal-theme"],
39+
"docroot/themes/custom/{$name}": ["type:drupal-custom-theme"],
40+
"docroot/libraries/{$name}": ["type:drupal-library"],
41+
"drush/contrib/{$name}": ["type:drupal-drush"]
42+
}
43+
},
2344
"minimum-stability": "dev",
2445
"prefer-stable": true
2546
}

composer.include.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"repositories": {
3+
"drupal": {
4+
"type": "composer",
5+
"url": "https://packages.drupal.org/8"
6+
}
7+
},
8+
"require": {
9+
"acquia/lightning": "2.0.3",
10+
"drupal/acquia_connector": "^1.5.0",
11+
"drupal/acsf": "^1.32.0",
12+
"drupal/core": "^8.0",
13+
"drupal/cog": "^1.0.0",
14+
"drupal/features": "^3.0.0",
15+
"drupal/memcache": "2.x-dev",
16+
"drupal/seckit": "^1.0.0-alpha2",
17+
"drupal/security_review": "*",
18+
"drupal/shield": "^1.0.0",
19+
"drush/drush": "^8.1.8"
20+
},
21+
"require-dev": {
22+
"behat/behat": "^3.1",
23+
"behat/mink": "~1.7",
24+
"behat/mink-selenium2-driver": "^1.3.1",
25+
"bex/behat-screenshot": "^1.2",
26+
"drupal/console": "^1.0.0-rc13",
27+
"drupal/devel": "^1.0.0-alpha1",
28+
"drupal/drupal-extension": "^3.2",
29+
"drupal-composer/drupal-scaffold": "^2.1.0",
30+
"jarnaiz/behat-junit-formatter": "^1.3.2",
31+
"se/selenium-server-standalone": "^2.53",
32+
"jakoch/phantomjs-installer": "^2.1.1-p07"
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Drupal\\Tests\\PHPUnit\\": "tests/phpunit/src/"
37+
}
38+
},
39+
"extra": {
40+
"drupal-scaffold": {
41+
"initial": {
42+
"sites/default/default.services.yml": "sites/default/services.yml",
43+
"sites/default/default.settings.php": "sites/default/settings.php"
44+
},
45+
"excludes": [
46+
"sites/development.services.yml"
47+
]
48+
},
49+
"enable-patching": true,
50+
"patches": {
51+
"drupal/core": {
52+
"Clear Twig caches on deploys": "https://www.drupal.org/files/issues/no_reliable_method-2752961-29.patch"
53+
}
54+
}
55+
},
56+
"scripts": {
57+
"blt-alias": "blt install-alias -Dcreate_alias=true",
58+
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
59+
"nuke": [
60+
"rm -rf vendor composer.lock",
61+
"@composer clearcache",
62+
"@composer install"
63+
],
64+
"install-phantomjs": [
65+
"rm -rf vendor/bin/phantomjs",
66+
"PhantomInstaller\\Installer::installPhantomJS"
67+
]
68+
}
69+
}

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"phpunit/phpunit": "^4.8",
3030
"squizlabs/php_codesniffer": "^2.7",
3131
"symfony/yaml": "^2.8.11",
32-
"symfony/console": "^2.8.11"
32+
"symfony/console": "^2.8.11",
33+
"wikimedia/composer-merge-plugin": "^1.3"
3334
},
3435
"autoload": {
3536
"psr-4": {

composer.lock

+50-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phing/tasks/blt.xml

+1-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

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

1918
<!--Write project.machine_name to project.yml, using name of working directory as value.. -->
2019
<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"/>
@@ -71,7 +70,7 @@
7170
<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"/>
7271
</target>
7372

74-
<target name="update" depends="blt:rsync-template, blt:update-composer, blt:update-yml, blt:update-delta, cleanup" hidden="true">
73+
<target name="update" depends="blt:rsync-template, blt:update-yml, blt:update-delta, cleanup" hidden="true">
7574
<phingcall target="install-alias">
7675
<property name="create_alias" value="true"/>
7776
</phingcall>
@@ -83,19 +82,6 @@
8382
<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"/>
8483
</target>
8584

86-
<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">
87-
<echo level="verbose">Merging BLT's composer.json template with your project's composer.json.</echo>
88-
<echo level="verbose">This MAY overwrite some existing values.</echo>
89-
<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"/>
90-
<if>
91-
<equals arg1="${composer.munge.return}" arg2="0"/>
92-
<then>
93-
<!--@todo Find out why can't we just redirect output directly back to composer.json. -->
94-
<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"/>
95-
</then>
96-
</if>
97-
</target>
98-
9985
<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">
10086
<!--@todo Output different message if project.yml does not exist-->
10187
<echo level="verbose">Merging BLT's project.yml template with your project's project.yml.</echo>

phing/tasks/tests.xml

+1-35
Original file line numberDiff line numberDiff line change
@@ -187,44 +187,10 @@
187187
</target>
188188

189189
<target name="tests:phantomjs:configure" description="Checks and corrects PhantomJS configuration">
190-
<exec dir="${repo.root}" command="grep 'jakoch/phantomjs-installer' composer.json" logoutput="false" level="${blt.exec_level}" passthru="false" returnProperty="phantom.required"/>
191-
<if>
192-
<isfailure code="${phantom.required}"/>
193-
<then>
194-
<echo level="Warning">jakoch/phantomjs-installer is not required in composer.json.</echo>
195-
<propertyprompt promptText="Do you want to require jakoch/phantomjs-installer via Composer?" propertyName="phantom.do-require" defaultValue="y"/>
196-
<if>
197-
<equals arg1="${phantom.do-require}" arg2="y" casesensitive="false"/>
198-
<then>
199-
<exec dir="${repo.root}" command="composer require jakoch/phantomjs-installer --dev" logoutput="true" level="${blt.exec_level}" passthru="true" />
200-
</then>
201-
<else>
202-
<fail>Cannot launch PhantomJS it is not installed.</fail>
203-
</else>
204-
</if>
205-
</then>
206-
</if>
207-
<exec dir="${repo.root}" command="grep installPhantomJS composer.json" logoutput="false" level="${blt.exec_level}" passthru="false" returnProperty="phantom.scripts"/>
208-
<if>
209-
<isfailure code="${phantom.scripts}"/>
210-
<then>
211-
<echo level="warning">behat.launch-phantomjs is true, but the install-phantomjs script is not defined in composer.json.</echo>
212-
<propertyprompt promptText="Do you want to add an 'install-phantomjs' script to your composer.json?" propertyName="phantom.do-add-script" defaultValue="y"/>
213-
<if>
214-
<equals arg1="${phantom.do-add-script}" arg2="y" casesensitive="false"/>
215-
<then>
216-
<exec command="${composer.bin}/blt-console configure:phantomjs ${repo.root}" logoutput="true" level="${blt.exec_level}" passthru="false" checkreturn="true"/>
217-
</then>
218-
<else>
219-
<fail>Cannot launch PhantomJS because the install-phantomjs script is not present in composer.json. Add it, or use Selenium instead.</fail>
220-
</else>
221-
</if>
222-
</then>
223-
</if>
224190
<if>
225191
<not><available file="${composer.bin}/phantomjs"/></not>
226192
<then>
227-
<exec dir="${repo.root}" command="composer install-phantom" checkreturn="true" logoutput="true" passthru="true" level="${blt.exec_level}"/>
193+
<exec dir="${repo.root}" command="composer run-script install-phantomjs" checkreturn="true" logoutput="true" passthru="true" level="${blt.exec_level}"/>
228194
</then>
229195
</if>
230196
</target>

readme/creating-new-project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

14-
composer blt-alias
14+
composer run-script blt-alias
1515
source ~/.bash_profile
1616

1717
1. Customize `blt/project.yml`.

readme/onboarding.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If you need to make requests via a proxy server, please [configure git to use a
3131

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

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

readme/updating-blt.md

+3-27
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,15 @@ If you are already using BLT via Composer, you can update to the latest version
2121

2222
### Modifying update behavior
2323

24-
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:
24+
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`:
2525

2626
"extra": {
2727
"blt": {
28-
"update": true,
29-
"composer-exclude-merge": {
30-
"require": [
31-
"drupal/acsf",
32-
"drupal/acquia_connector",
33-
"drupal/memcache",
34-
"drupal/search_api",
35-
"drupal/search_api_solr"
36-
],
37-
"require-dev": "*"
38-
}
28+
"update": true
3929
}
4030
}
4131

42-
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`.
43-
44-
A few other examples of valid usage:
45-
46-
"extra": {
47-
"blt": {
48-
"update": false,
49-
}
50-
}
51-
"extra": {
52-
"blt": {
53-
"update": true,
54-
"composer-exclude-merge": "*"
55-
}
56-
}
32+
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.
5733

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

src/Composer/Plugin.php

-12
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ protected function executeBltUpdate($version) {
134134
}
135135
elseif ($options['blt']['update']) {
136136
$this->io->write('<info>Updating BLT templated files...</info>');
137-
138-
// Rsyncs, updates composer.json, project.yml, executes scripted updates for version delta.
139-
$pre_composer_json = md5_file($this->getRepoRoot() . DIRECTORY_SEPARATOR . 'composer.json');
140-
$success = $this->executeCommand('blt update', [], TRUE);
141-
if (!$success) {
142-
$this->io->write("<error>BLT update script failed! Run `blt update -verbose` to retry.</error>");
143-
}
144-
$post_composer_json = md5_file($this->getRepoRoot() . DIRECTORY_SEPARATOR . 'composer.json');
145-
146-
if ($pre_composer_json != $post_composer_json) {
147-
$this->io->write('<error>Your composer.json file was modified by BLT, you MUST run "composer update" to re-process and update dependencies.</error>');
148-
}
149137
}
150138
else {
151139
$this->io->write('<comment>Skipping update of BLT templated files</comment>');

0 commit comments

Comments
 (0)