Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding validation for installers-path. #1186

Merged
merged 1 commit into from
Mar 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,37 @@ public static function getSubscribedEvents() {
return array(
PackageEvents::POST_PACKAGE_INSTALL => "onPostPackageEvent",
PackageEvents::POST_PACKAGE_UPDATE => "onPostPackageEvent",
ScriptEvents::PRE_INSTALL_CMD => 'checkInstallerPaths',
ScriptEvents::POST_UPDATE_CMD => 'onPostCmdEvent',
);
}

/**
* Verify that composer.json contains correct values for installer-paths.
*
* Unfortunately, these values cannot be placed in composer.include.json.
*
* @see https://github.com/wikimedia/composer-merge-plugin/issues/139
*
* @param \Composer\Script\Event $event
*/
public function checkInstallerPaths(Event $event) {
$extra = $this->composer->getPackage()->getExtra();
if (empty($extra['installer-paths'])) {
$this->io->write('<error>Error: extras.installer-paths is missing from your composer.json file.</error>');
}
else {
$composer_include_json_filename = $this->getVendorPath() . '/acquia/blt/template/composer.json';
if (file_exists($composer_include_json_filename)) {
$composer_include_json = json_decode(file_get_contents($composer_include_json_filename), TRUE);
if ($composer_include_json['extra']['installer-paths'] != $extra['installer-paths']) {
$this->io->write('<warning>Warning: The value for extras.installer-paths in composer.json differs from BLT\'s recommended values.</warning>');
$this->io->write('<warning>See https://github.com/acquia/blt/blob/8.x/template/composer.json</warning>');
}
}
}
}

/**
* Marks blt to be processed after an install or update command.
*
Expand Down Expand Up @@ -191,7 +218,6 @@ public function getVendorPath() {
protected function getOptions() {
$defaults = [
'update' => TRUE,
'composer-exclude-merge' => [],
];
$extra = $this->composer->getPackage()->getExtra() + ['blt' => []];
$extra['blt'] = $extra['blt'] + $defaults;
Expand Down