Skip to content

Commit 0be424b

Browse files
committed
Merge pull request #20 from drupal-composer/explicit-only
Fixes #9: Do not download the scaffold files after `composer install`.
2 parents d1efb2b + 41c5b86 commit 0be424b

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ vendor directory.
1212

1313
## Usage
1414

15-
`composer require drupal-composer/drupal-scaffold:dev-master` in your composer
15+
Run `composer require drupal-composer/drupal-scaffold:dev-master` in your composer
1616
project before installing or updating `drupal/core`.
1717

18+
Once drupal-scaffold is required by your project, it will automatically update
19+
your scaffold files whenever `composer update` changes the version of
20+
`drupal/core` installed.
21+
1822
## Configuration
1923

2024
You can configure the plugin with providing some settings in the `extra` section
@@ -90,6 +94,8 @@ specifically, from the most recent development .tar.gz archive). This might
9094
not be what you want when using an old development version (e.g. when the
9195
version is fixed via composer.lock). To avoid problems, always commit your
9296
scaffold files to the repository any time that composer.lock is committed.
97+
Note that the correct scaffold files are retrieved when using a tagged release
98+
of `drupal/core` (recommended).
9399

94100
## Custom command
95101

@@ -107,3 +113,9 @@ command callback to the `scripts`-section of your root `composer.json`, like thi
107113

108114
After that you can manually download the scaffold files according to your
109115
configuration by using `composer drupal-scaffold`.
116+
117+
Note that drupal-scaffold does not automatically run after `composer install`.
118+
It is assumed that the scaffold files will be committed to the repository, to
119+
ensure that the correct files are used on the CI server (see **Limitation**,
120+
above). After running `composer install` for the first time, also run
121+
`composer drupal-scaffold`, and commit the scaffold files to your repository.

src/Handler.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,13 @@ public function onPostPackageEvent(\Composer\Installer\PackageEvent $event){
8383
public function onPostCmdEvent(\Composer\Script\Event $event) {
8484
// Only install the scaffolding if drupal/core was installed,
8585
// AND there are no scaffolding files present.
86-
if (isset($this->drupalCorePackage) && $this->checkAction($event)) {
86+
if (isset($this->drupalCorePackage)) {
8787
$this->downloadScaffold();
88+
// Generate the autoload.php file after generating the scaffold files.
8889
$this->generateAutoload();
8990
}
9091
}
9192

92-
/**
93-
* Return 'TRUE' if the download scaffold action should be done.
94-
*/
95-
public function checkAction(\Composer\Script\Event $event) {
96-
// TODO: check options based on $event->getName()
97-
$options = $this->getOptions();
98-
99-
return TRUE;
100-
}
101-
10293
/**
10394
* Downloads drupal scaffold files for the current process.
10495
*/

src/Plugin.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function getSubscribedEvents() {
4444
PackageEvents::POST_PACKAGE_INSTALL => 'postPackage',
4545
PackageEvents::POST_PACKAGE_UPDATE => 'postPackage',
4646
//PackageEvents::POST_PACKAGE_UNINSTALL => 'postPackage',
47-
ScriptEvents::POST_INSTALL_CMD => 'postCmd',
47+
//ScriptEvents::POST_INSTALL_CMD => 'postCmd',
4848
ScriptEvents::POST_UPDATE_CMD => 'postCmd',
4949
);
5050
}
@@ -76,16 +76,7 @@ public function postCmd(\Composer\Script\Event $event) {
7676
public static function scaffold(\Composer\Script\Event $event) {
7777
$handler = new Handler($event->getComposer(), $event->getIO());
7878
$handler->downloadScaffold();
79-
}
80-
81-
/**
82-
* Script callback for putting in composer scripts to generate the
83-
* autoload file at the project root.
84-
*
85-
* @param \Composer\Script\Event $event
86-
*/
87-
public static function generateAutoload(\Composer\Script\Event $event) {
88-
$handler = new Handler($event->getComposer(), $event->getIO());
79+
// Generate the autoload.php file after generating the scaffold files.
8980
$handler->generateAutoload();
9081
}
9182
}

tests/PluginTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public function testComposerInstallAndUpdate() {
6969
$this->composer('install');
7070
$this->assertFileExists($this->tmpDir . DIRECTORY_SEPARATOR . 'core', 'Drupal core is installed.');
7171
$exampleScaffoldFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'index.php';
72-
$this->assertFileExists($exampleScaffoldFile, 'Scaffold file given.');
72+
$this->assertFileNotExists($exampleScaffoldFile, 'Scaffold file should not be automatically installed.');
73+
$this->composer('drupal-scaffold');
74+
$this->assertFileExists($exampleScaffoldFile, 'Scaffold file should be installed by "drupal-scaffold" command.');
7375

7476
// We touch a scaffold file, so we can check the file was modified after
7577
// the scaffold update.

0 commit comments

Comments
 (0)