From 9c69675aa48215d5fb249b40e5c5688f921f291c Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 24 Oct 2016 11:07:44 -0400 Subject: [PATCH 01/22] Adding updater for specific BLT delta migrations. --- src/Blt/Updater.php | 73 +++++++++++++++++++++++++++ src/Composer/Plugin.php | 25 ++++++++- src/Console/Command/UpdateCommand.php | 42 +++++++++++++++ 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 src/Blt/Updater.php create mode 100644 src/Console/Command/UpdateCommand.php diff --git a/src/Blt/Updater.php b/src/Blt/Updater.php new file mode 100644 index 000000000..ae4a3a1e5 --- /dev/null +++ b/src/Blt/Updater.php @@ -0,0 +1,73 @@ +output = new ConsoleOutput(); + $this->output->setFormatter(new OutputFormatter(true)); + } + + public function executeUpdates($starting_version, $ending_version) { + $updates = $this->getUpdates($starting_version, $ending_version); + + foreach ($updates as $method_name => $version) { + $this->{$method_name}(); + } + } + + public function getUpdates($starting_version, $ending_version) { + $updates = []; + $update_methods = $this->getUpdateMethods(); + foreach ($update_methods as $method_name => $version) { + if ($version > $starting_version && $version <= $ending_version) { + $updates[$method_name] = $version; + } + } + + return $updates; + } + + /** + * + * @see drupal_get_schema_versions() + */ + protected function getUpdateMethods() { + $update_methods = []; + + // Prepare regular expression to match all possible defined hook_update_N(). + $regexp = '/^update_(?P\d+)$/'; + $methods = get_class_methods(new Updates()); + // Narrow this down to functions ending with an integer, since all + // update_N() functions end this way, and there are other + // possible functions which may match 'update_'. We use preg_grep() here + // instead of foreaching through all defined functions, since the loop + // through all PHP functions can take significant execution time. + foreach (preg_grep('/_\d+$/', $methods) as $method) { + // If this function is a module update function, add it to the list of + // module updates. + if (preg_match($regexp, $method, $matches)) { + $update_methods[$method][] = $matches['version']; + } + } + + sort($update_methods, SORT_NUMERIC); + + return $update_methods; + } + + /** + * + */ + public function update_850() { + $this->output->writeln('TESTING'); + } +} diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index 1b95ac9ed..9611c692c 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -7,6 +7,7 @@ namespace Acquia\Blt\Composer; +use Acquia\Blt\Updater; use Composer\Composer; use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation; @@ -49,6 +50,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface { */ protected $bltPackage; + /** @var string */ + protected $blt_prior_version; + /** * Apply plugin modifications to composer * @@ -67,12 +71,25 @@ public function activate(Composer $composer, IOInterface $io) { */ public static function getSubscribedEvents() { return array( + PackageEvents::PRE_PACKAGE_INSTALL => "onPrePackageEvent", + PackageEvents::PRE_PACKAGE_INSTALL => "onPrePackageEvent", PackageEvents::POST_PACKAGE_INSTALL => "onPostPackageEvent", PackageEvents::POST_PACKAGE_UPDATE => "onPostPackageEvent", ScriptEvents::POST_UPDATE_CMD => 'onPostCmdEvent' ); } + /** + * Marks initial blt version before install or update command. + * + * @param \Composer\Installer\PackageEvent $event + */ + public function onPrePackageEvent(\Composer\Installer\PackageEvent $event){ + $package = $this->getBltPackage($event->getOperation()); + if ($package) { + $this->blt_prior_version = $package->getVersion(); + } + } /** * Marks blt to be processed after an install or update command. * @@ -95,7 +112,8 @@ public function onPostPackageEvent(\Composer\Installer\PackageEvent $event){ public function onPostCmdEvent(\Composer\Script\Event $event) { // Only install the template files if acquia/blt was installed. if (isset($this->bltPackage)) { - $this->executeBltUpdate(); + $version = $this->bltPackage->getVersion(); + $this->executeBltUpdate($version); } } @@ -120,8 +138,12 @@ protected function executeBltUpdate() { $options = $this->getOptions(); if ($options['blt']['update']) { $this->io->write('Updating BLT templated files'); + // Rsyncs, updates composer.json, project.yml. $this->executeCommand('blt update'); $this->io->write('This may have modified your composer.json and require a subsequent `composer update`'); + // Run specific delta updates. + $updater = new Updater(); + $updater->executeUpdates($this->blt_prior_version, $this->bltPackage->getVersion()); } else { $this->io->write('Skipping update of BLT templated files'); @@ -138,6 +160,7 @@ public function getVendorPath() { $filesystem = new Filesystem(); $filesystem->ensureDirectoryExists($config->get('vendor-dir')); $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir'))); + return $vendorPath; } diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php new file mode 100644 index 000000000..fc3dbee46 --- /dev/null +++ b/src/Console/Command/UpdateCommand.php @@ -0,0 +1,42 @@ +setName('update') + ->setDescription('Performs BLT updates for specific version delta.') + ->addArgument( + 'starting_version', + InputArgument::REQUIRED, + 'The starting version' + ) + ->addArgument( + 'ending_version', + InputArgument::REQUIRED, + 'The ending version.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $starting_version = $input->getArgument('starting_version'); + $ending_version = $input->getArgument('ending_version'); + + $updater = new Updater(); + $updater->executeUpdates($starting_version, $ending_version); + } +} From cb6d1697edf90ff0f740387342e5b2aa8e1ee66e Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 24 Oct 2016 13:21:01 -0400 Subject: [PATCH 02/22] Using annotations. --- composer.json | 3 +- composer.lock | 214 +++++++++++++++++++++++++- src/Annotations/Update.php | 18 +++ src/Console/Command/UpdateCommand.php | 2 +- src/{Blt => }/Updater.php | 35 ++++- 5 files changed, 261 insertions(+), 11 deletions(-) create mode 100644 src/Annotations/Update.php rename src/{Blt => }/Updater.php (59%) diff --git a/composer.json b/composer.json index d0155f5ff..876f3c032 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "squizlabs/php_codesniffer": "^2.7", "symfony/yaml": "^2.8.11", "symfony/console": "^2.8.11", - "symfony/twig-bridge": "^2.8.11" + "symfony/twig-bridge": "^2.8.11", + "doctrine/common": "^2.6" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 2a61c9232..1d9e12ef0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5a569247ba859639075a439aded0c6bd", - "content-hash": "421ea293c853ac6e7c05681341757e84", + "hash": "7d7a40d8afc9db1e4ff23ed8cdf9a469", + "content-hash": "83e9c1c10372dc7245e3c7fbe5d95886", "packages": [ { "name": "alchemy/zippy", @@ -350,6 +350,76 @@ ], "time": "2015-08-31 12:32:49" }, + { + "name": "doctrine/cache", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "shasum": "" + }, + "require": { + "php": "~5.5|~7.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2015-12-31 16:37:02" + }, { "name": "doctrine/collections", "version": "v1.3.0", @@ -416,6 +486,146 @@ ], "time": "2015-04-14 22:21:58" }, + { + "name": "doctrine/common", + "version": "v2.6.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~5.5|~7.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2015-12-25 13:18:31" + }, + { + "name": "doctrine/inflector", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2015-11-06 14:35:42" + }, { "name": "doctrine/instantiator", "version": "1.0.5", diff --git a/src/Annotations/Update.php b/src/Annotations/Update.php new file mode 100644 index 000000000..60cce549a --- /dev/null +++ b/src/Annotations/Update.php @@ -0,0 +1,18 @@ +setName('update') + ->setName('blt:update') ->setDescription('Performs BLT updates for specific version delta.') ->addArgument( 'starting_version', diff --git a/src/Blt/Updater.php b/src/Updater.php similarity index 59% rename from src/Blt/Updater.php rename to src/Updater.php index ae4a3a1e5..9cf8b78dd 100644 --- a/src/Blt/Updater.php +++ b/src/Updater.php @@ -2,6 +2,10 @@ namespace Acquia\Blt; +use Acquia\Blt\Annotations\Update; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; +use Doctrine\Common\Annotations\IndexedReader; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\ConsoleOutput; @@ -14,12 +18,20 @@ public function __construct() { $this->output = new ConsoleOutput(); $this->output->setFormatter(new OutputFormatter(true)); + AnnotationRegistry::registerFile(__DIR__ . '/Annotations/Update.php'); + $this->annotationsReader = new IndexedReader(new AnnotationReader()); } public function executeUpdates($starting_version, $ending_version) { $updates = $this->getUpdates($starting_version, $ending_version); - foreach ($updates as $method_name => $version) { + /** + * @var string $method_name + * @var Update $update + */ + foreach ($updates as $method_name => $update) { + $this->output->writeln("Executing Updater->$method_name:"); + $this->output->writeln(" {$update->description}"); $this->{$method_name}(); } } @@ -28,8 +40,14 @@ public function getUpdates($starting_version, $ending_version) { $updates = []; $update_methods = $this->getUpdateMethods(); foreach ($update_methods as $method_name => $version) { + $reflectionMethod = new \ReflectionMethod($this, $method_name); + $annotations = $this->annotationsReader->getMethodAnnotations($reflectionMethod); + /** @var Update $update_annotation */ + $update_annotation = $annotations['Acquia\Blt\Annotations\Update']; + $version = $update_annotation->version; + if ($version > $starting_version && $version <= $ending_version) { - $updates[$method_name] = $version; + $updates[$method_name] = $update_annotation; } } @@ -45,7 +63,7 @@ protected function getUpdateMethods() { // Prepare regular expression to match all possible defined hook_update_N(). $regexp = '/^update_(?P\d+)$/'; - $methods = get_class_methods(new Updates()); + $methods = get_class_methods($this); // Narrow this down to functions ending with an integer, since all // update_N() functions end this way, and there are other // possible functions which may match 'update_'. We use preg_grep() here @@ -55,19 +73,22 @@ protected function getUpdateMethods() { // If this function is a module update function, add it to the list of // module updates. if (preg_match($regexp, $method, $matches)) { - $update_methods[$method][] = $matches['version']; + $update_methods[$method] = $matches['version']; } } - sort($update_methods, SORT_NUMERIC); + asort($update_methods, SORT_NUMERIC); return $update_methods; } /** - * + * @Update( + * version = "8.5.0", + * description = "Re-provisioning VM." + * ) */ public function update_850() { - $this->output->writeln('TESTING'); + // Do nothing. } } From 85c54b1978ec5d13f418734ec33d9590ca8de612 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 24 Oct 2016 15:29:27 -0400 Subject: [PATCH 03/22] Refactoring Updates to separate class. --- src/Console/Command/UpdateCommand.php | 20 +++++- src/Update/Updater.php | 82 +++++++++++++++++++++++ src/Update/Updates.php | 18 +++++ src/Updater.php | 94 --------------------------- 4 files changed, 118 insertions(+), 96 deletions(-) create mode 100644 src/Update/Updater.php create mode 100644 src/Update/Updates.php delete mode 100644 src/Updater.php diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 570537a26..397d172cd 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -2,12 +2,13 @@ namespace Acquia\Blt\Console\Command; -use Acquia\Blt\Updater; +use Acquia\Blt\Update\Updater; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Exception\ParseException; @@ -37,6 +38,21 @@ protected function execute(InputInterface $input, OutputInterface $output) $ending_version = $input->getArgument('ending_version'); $updater = new Updater(); - $updater->executeUpdates($starting_version, $ending_version); + $updates = $updater->getUpdates($starting_version, $ending_version); + if ($updates) { + $output->writeln("The following BLT updates are outstanding:"); + $updater->printUpdates($updates); + $question = new ConfirmationQuestion( + 'Would you like to perform the listed updates? ', + false + ); + $continue = $this->getHelper('question')->ask($input, $output, $question); + if (!$continue) { + return 1; + } + + $updater->executeUpdates($updates); + } + } } diff --git a/src/Update/Updater.php b/src/Update/Updater.php new file mode 100644 index 000000000..6e0e1f620 --- /dev/null +++ b/src/Update/Updater.php @@ -0,0 +1,82 @@ +output = new ConsoleOutput(); + $this->output->setFormatter(new OutputFormatter(true)); + AnnotationRegistry::registerFile(__DIR__ . '/../Annotations/Update.php'); + $this->annotationsReader = new IndexedReader(new AnnotationReader()); + $this->updateClass = $update_class; + } + + public function executeUpdates($updates) { + /** + * @var string $method_name + * @var Update $update + */ + foreach ($updates as $method_name => $update) { + $this->output->writeln("Executing Updater->$method_name: {$update->description}"); + call_user_func([$this->updateClass, $method_name]); + } + } + + public function printUpdates($updates) { + /** + * @var string $method_name + * @var Update $update + */ + foreach ($updates as $method_name => $update) { + $this->output->writeln("{$update->version}: {$update->description}"); + } + } + + public function getUpdates($starting_version, $ending_version) { + $updates = []; + $update_methods = $this->getAllUpdateMethods(); + /** + * @var string $method_name + * @var Update $metadata + */ + foreach ($update_methods as $method_name => $metadata) { + $version = $metadata->version; + + if ($version > $starting_version && $version <= $ending_version) { + $updates[$method_name] = $metadata; + } + } + + return $updates; + } + + /** + * + * @see drupal_get_schema_versions() + */ + protected function getAllUpdateMethods() { + $update_methods = []; + $methods = get_class_methods($this->updateClass); + foreach ($methods as $method_name) { + $reflectionMethod = new \ReflectionMethod($this->updateClass, $method_name); + $annotations = $this->annotationsReader->getMethodAnnotation($reflectionMethod, 'Acquia\Blt\Annotations\Update'); + if ($annotations) { + $update_methods[$method_name] = $annotations; + } + } + + return $update_methods; + } +} diff --git a/src/Update/Updates.php b/src/Update/Updates.php new file mode 100644 index 000000000..59b1ff68e --- /dev/null +++ b/src/Update/Updates.php @@ -0,0 +1,18 @@ +output = new ConsoleOutput(); - $this->output->setFormatter(new OutputFormatter(true)); - AnnotationRegistry::registerFile(__DIR__ . '/Annotations/Update.php'); - $this->annotationsReader = new IndexedReader(new AnnotationReader()); - } - - public function executeUpdates($starting_version, $ending_version) { - $updates = $this->getUpdates($starting_version, $ending_version); - - /** - * @var string $method_name - * @var Update $update - */ - foreach ($updates as $method_name => $update) { - $this->output->writeln("Executing Updater->$method_name:"); - $this->output->writeln(" {$update->description}"); - $this->{$method_name}(); - } - } - - public function getUpdates($starting_version, $ending_version) { - $updates = []; - $update_methods = $this->getUpdateMethods(); - foreach ($update_methods as $method_name => $version) { - $reflectionMethod = new \ReflectionMethod($this, $method_name); - $annotations = $this->annotationsReader->getMethodAnnotations($reflectionMethod); - /** @var Update $update_annotation */ - $update_annotation = $annotations['Acquia\Blt\Annotations\Update']; - $version = $update_annotation->version; - - if ($version > $starting_version && $version <= $ending_version) { - $updates[$method_name] = $update_annotation; - } - } - - return $updates; - } - - /** - * - * @see drupal_get_schema_versions() - */ - protected function getUpdateMethods() { - $update_methods = []; - - // Prepare regular expression to match all possible defined hook_update_N(). - $regexp = '/^update_(?P\d+)$/'; - $methods = get_class_methods($this); - // Narrow this down to functions ending with an integer, since all - // update_N() functions end this way, and there are other - // possible functions which may match 'update_'. We use preg_grep() here - // instead of foreaching through all defined functions, since the loop - // through all PHP functions can take significant execution time. - foreach (preg_grep('/_\d+$/', $methods) as $method) { - // If this function is a module update function, add it to the list of - // module updates. - if (preg_match($regexp, $method, $matches)) { - $update_methods[$method] = $matches['version']; - } - } - - asort($update_methods, SORT_NUMERIC); - - return $update_methods; - } - - /** - * @Update( - * version = "8.5.0", - * description = "Re-provisioning VM." - * ) - */ - public function update_850() { - // Do nothing. - } -} From 09d13f0765cf73e6af33c95e30479c8fe5e42f59 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 24 Oct 2016 15:40:55 -0400 Subject: [PATCH 04/22] Comparing semvers. --- composer.json | 3 ++- composer.lock | 56 ++++++++++++++++++++++++++++++++++++++++-- src/Update/Updater.php | 9 ++++++- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 876f3c032..263de0a20 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "symfony/yaml": "^2.8.11", "symfony/console": "^2.8.11", "symfony/twig-bridge": "^2.8.11", - "doctrine/common": "^2.6" + "doctrine/common": "^2.6", + "vierbergenlars/php-semver": "^3.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 1d9e12ef0..72ad6b99c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7d7a40d8afc9db1e4ff23ed8cdf9a469", - "content-hash": "83e9c1c10372dc7245e3c7fbe5d95886", + "hash": "6f0ac24db635327cd93e2f506fd26aa2", + "content-hash": "af7e422a7146ed11cf468c196ee71c2e", "packages": [ { "name": "alchemy/zippy", @@ -3807,6 +3807,58 @@ ], "time": "2016-10-05 18:57:41" }, + { + "name": "vierbergenlars/php-semver", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/vierbergenlars/php-semver.git", + "reference": "516bb3061577e60e9420cbecc479362d3ad8c7f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vierbergenlars/php-semver/zipball/516bb3061577e60e9420cbecc479362d3ad8c7f1", + "reference": "516bb3061577e60e9420cbecc479362d3ad8c7f1", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "simpletest/simpletest": "1.1.*" + }, + "bin": [ + "bin/semver", + "bin/update-versions" + ], + "type": "library", + "autoload": { + "psr-0": { + "vierbergenlars\\SemVer\\": "src/", + "vierbergenlars\\LibJs\\": "src/" + }, + "classmap": [ + "src/vierbergenlars/SemVer/internal.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lars Vierbergen", + "email": "vierbergenlars@gmail.com" + } + ], + "description": "The Semantic Versioner for PHP", + "keywords": [ + "semantic", + "semver", + "versioning" + ], + "time": "2015-05-02 19:28:54" + }, { "name": "webmozart/assert", "version": "1.1.0", diff --git a/src/Update/Updater.php b/src/Update/Updater.php index 6e0e1f620..6e844f1e4 100644 --- a/src/Update/Updater.php +++ b/src/Update/Updater.php @@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\IndexedReader; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\ConsoleOutput; +use vierbergenlars\SemVer\version; class Updater { @@ -23,6 +24,9 @@ public function __construct($update_class = 'Acquia\Blt\Update\Updates') $this->updateClass = $update_class; } + /** + * @param $updates \Acquia\Blt\Annotations\Update[] + */ public function executeUpdates($updates) { /** * @var string $method_name @@ -34,6 +38,9 @@ public function executeUpdates($updates) { } } + /** + * @param $updates \Acquia\Blt\Annotations\Update[] + */ public function printUpdates($updates) { /** * @var string $method_name @@ -54,7 +61,7 @@ public function getUpdates($starting_version, $ending_version) { foreach ($update_methods as $method_name => $metadata) { $version = $metadata->version; - if ($version > $starting_version && $version <= $ending_version) { + if (version::gt($version, $starting_version) && version::lte($version, $ending_version)) { $updates[$method_name] = $metadata; } } From a7ae2a4450d9c91281344c1056528596b101f61f Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 24 Oct 2016 15:52:18 -0400 Subject: [PATCH 05/22] Addin command. --- bin/blt-console | 3 +++ src/Composer/Plugin.php | 11 ++++++----- src/Update/Updates.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/blt-console b/bin/blt-console index 592e0101e..56ba7e647 100755 --- a/bin/blt-console +++ b/bin/blt-console @@ -3,6 +3,7 @@ use Acquia\Blt\Console\Command\ComposerMungeCommand; use Acquia\Blt\Console\Command\YamlMungeCommand; +use Acquia\Blt\Console\Command\UpdateCommand; use Symfony\Bridge\Twig\Command\LintCommand; use Symfony\Component\Console\Application; @@ -26,4 +27,6 @@ $application = new Application(); $application->add(new ComposerMungeCommand()); $application->add(new YamlMungeCommand()); $application->add(new \Acquia\Blt\Console\Command\TwigLintCommand); +$application->add(new UpdateCommand()); + $application->run(); diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index 9611c692c..f6b4fbbf2 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -7,7 +7,7 @@ namespace Acquia\Blt\Composer; -use Acquia\Blt\Updater; +use Acquia\Blt\Update\Updater; use Composer\Composer; use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation; @@ -134,16 +134,17 @@ protected function getBltPackage($operation) { return NULL; } - protected function executeBltUpdate() { + protected function executeBltUpdate($version) { $options = $this->getOptions(); if ($options['blt']['update']) { $this->io->write('Updating BLT templated files'); // Rsyncs, updates composer.json, project.yml. $this->executeCommand('blt update'); $this->io->write('This may have modified your composer.json and require a subsequent `composer update`'); - // Run specific delta updates. - $updater = new Updater(); - $updater->executeUpdates($this->blt_prior_version, $this->bltPackage->getVersion()); + + if (isset($this->blt_prior_version)) { + $this->executeCommand("blt-console blt:update {$this->blt_prior_version} $version"); + } } else { $this->io->write('Skipping update of BLT templated files'); diff --git a/src/Update/Updates.php b/src/Update/Updates.php index 59b1ff68e..f49d0e149 100644 --- a/src/Update/Updates.php +++ b/src/Update/Updates.php @@ -8,7 +8,7 @@ class Updates { /** * @Update( - * version = "8.5.0", + * version = "8.5.1", * description = "Re-initialize VM." * ) */ From 4cc5caa5c74a1fb38b90a09cd6463d37ae661a85 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 10:25:37 -0500 Subject: [PATCH 06/22] Downgrading doctrine. --- composer.json | 4 +- composer.lock | 214 +++++++++++++++++++++++++------------------------- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/composer.json b/composer.json index 263de0a20..07ef23205 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ "symfony/yaml": "^2.8.11", "symfony/console": "^2.8.11", "symfony/twig-bridge": "^2.8.11", - "doctrine/common": "^2.6", - "vierbergenlars/php-semver": "^3.0" + "doctrine/common": "^2.5", + "vierbergenlars/php-semver": "^3.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 72ad6b99c..fac6972b6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6f0ac24db635327cd93e2f506fd26aa2", - "content-hash": "af7e422a7146ed11cf468c196ee71c2e", + "hash": "cccdab26f0d5b46cf505a27ae59514a6", + "content-hash": "e036a66c5f77742dc664e908fb5ffde0", "packages": [ { "name": "alchemy/zippy", @@ -352,16 +352,16 @@ }, { "name": "doctrine/cache", - "version": "v1.6.0", + "version": "v1.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b6f544a20f4807e81f7044d31e679ccbb1866dc3", + "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3", "shasum": "" }, "require": { @@ -418,7 +418,7 @@ "cache", "caching" ], - "time": "2015-12-31 16:37:02" + "time": "2016-10-29 11:16:17" }, { "name": "doctrine/collections", @@ -860,16 +860,16 @@ }, { "name": "gabordemooij/redbean", - "version": "v4.3.2", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/gabordemooij/redbean.git", - "reference": "72368f15cedfa7990c7fb228e47d2f00c7f49d4f" + "reference": "1c7ec69850e9f7966ff7feb87b01d8f43a9753d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/gabordemooij/redbean/zipball/72368f15cedfa7990c7fb228e47d2f00c7f49d4f", - "reference": "72368f15cedfa7990c7fb228e47d2f00c7f49d4f", + "url": "https://api.github.com/repos/gabordemooij/redbean/zipball/1c7ec69850e9f7966ff7feb87b01d8f43a9753d3", + "reference": "1c7ec69850e9f7966ff7feb87b01d8f43a9753d3", "shasum": "" }, "require": { @@ -897,7 +897,7 @@ "keywords": [ "orm" ], - "time": "2016-05-01 10:27:43" + "time": "2016-10-03 21:25:17" }, { "name": "guzzlehttp/guzzle", @@ -1114,16 +1114,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.5.4", + "version": "1.5.5", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f" + "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/ea74994a3dc7f8d2f65a06009348f2d63c81e61f", - "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108", + "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108", "shasum": "" }, "require": { @@ -1152,7 +1152,7 @@ "object", "object graph" ], - "time": "2016-09-16 13:37:59" + "time": "2016-10-31 17:19:45" }, { "name": "padraic/humbug_get_contents", @@ -1658,16 +1658,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "5f3f7e736d6319d5f1fc402aff8b026da26709a3" + "reference": "6cba06ff75a1a63a71033e1a01b89056f3af1e8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5f3f7e736d6319d5f1fc402aff8b026da26709a3", - "reference": "5f3f7e736d6319d5f1fc402aff8b026da26709a3", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6cba06ff75a1a63a71033e1a01b89056f3af1e8d", + "reference": "6cba06ff75a1a63a71033e1a01b89056f3af1e8d", "shasum": "" }, "require": { @@ -1717,7 +1717,7 @@ "testing", "xunit" ], - "time": "2016-07-26 14:39:29" + "time": "2016-11-01 05:06:24" }, { "name": "phpunit/php-file-iterator", @@ -1902,16 +1902,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.6.1", + "version": "5.6.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "60c32c5b5e79c2248001efa2560f831da11cc2d7" + "reference": "a9de0dbafeb6b1391b391fbb034734cb0af9f67c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/60c32c5b5e79c2248001efa2560f831da11cc2d7", - "reference": "60c32c5b5e79c2248001efa2560f831da11cc2d7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a9de0dbafeb6b1391b391fbb034734cb0af9f67c", + "reference": "a9de0dbafeb6b1391b391fbb034734cb0af9f67c", "shasum": "" }, "require": { @@ -1980,7 +1980,7 @@ "testing", "xunit" ], - "time": "2016-10-07 13:03:26" + "time": "2016-11-14 06:39:40" }, { "name": "phpunit/phpunit-mock-objects", @@ -2515,16 +2515,16 @@ }, { "name": "sebastian/recursion-context", - "version": "1.0.2", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" + "reference": "938df7a6478e72795e5f8266cff24d06e3136f2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/938df7a6478e72795e5f8266cff24d06e3136f2e", + "reference": "938df7a6478e72795e5f8266cff24d06e3136f2e", "shasum": "" }, "require": { @@ -2564,7 +2564,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" + "time": "2016-11-15 06:55:36" }, { "name": "sebastian/resource-operations", @@ -2776,7 +2776,7 @@ }, { "name": "symfony/config", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/config.git", @@ -2829,16 +2829,16 @@ }, { "name": "symfony/console", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4" + "reference": "7350016c8abcab897046f1aead2b766b84d3eff8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d7a5a88178f94dcc29531ea4028ea614e35452d4", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4", + "url": "https://api.github.com/repos/symfony/console/zipball/7350016c8abcab897046f1aead2b766b84d3eff8", + "reference": "7350016c8abcab897046f1aead2b766b84d3eff8", "shasum": "" }, "require": { @@ -2886,11 +2886,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-09-28 00:10:16" + "time": "2016-10-06 01:43:09" }, { "name": "symfony/css-selector", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -2943,7 +2943,7 @@ }, { "name": "symfony/debug", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -3000,16 +3000,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75" + "reference": "3d61c765daa1a5832f1d7c767f48886b8d8ea64c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ee9ec9ac2b046462d341e9de7c4346142d335e75", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/3d61c765daa1a5832f1d7c767f48886b8d8ea64c", + "reference": "3d61c765daa1a5832f1d7c767f48886b8d8ea64c", "shasum": "" }, "require": { @@ -3059,20 +3059,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-09-24 09:47:20" + "time": "2016-10-24 15:52:36" }, { "name": "symfony/dom-crawler", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "aac03b7ea2a7adff10a3599d614e79e6101230ab" + "reference": "a94f3fe6f179d6453e5ed8188cf4bfdf933d85f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/aac03b7ea2a7adff10a3599d614e79e6101230ab", - "reference": "aac03b7ea2a7adff10a3599d614e79e6101230ab", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/a94f3fe6f179d6453e5ed8188cf4bfdf933d85f4", + "reference": "a94f3fe6f179d6453e5ed8188cf4bfdf933d85f4", "shasum": "" }, "require": { @@ -3115,20 +3115,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:20:35" + "time": "2016-10-18 15:35:45" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8" + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/889983a79a043dfda68f38c38b6dba092dd49cd8", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", + "reference": "25c576abd4e0f212e678fe8b2bd9a9a98c7ea934", "shasum": "" }, "require": { @@ -3175,20 +3175,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-28 16:56:28" + "time": "2016-10-13 01:43:15" }, { "name": "symfony/filesystem", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "44b499521defddf2eae17a18c811bbdae4f98bdf" + "reference": "a3784111af9f95f102b6411548376e1ae7c93898" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/44b499521defddf2eae17a18c811bbdae4f98bdf", - "reference": "44b499521defddf2eae17a18c811bbdae4f98bdf", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/a3784111af9f95f102b6411548376e1ae7c93898", + "reference": "a3784111af9f95f102b6411548376e1ae7c93898", "shasum": "" }, "require": { @@ -3224,11 +3224,11 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-10-18 04:28:30" }, { "name": "symfony/finder", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -3277,16 +3277,16 @@ }, { "name": "symfony/http-foundation", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "91f87d27e9fe99435278c337375b0dce292fe0e2" + "reference": "a6e6c34d337f3c74c39b29c5f54d33023de8897c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/91f87d27e9fe99435278c337375b0dce292fe0e2", - "reference": "91f87d27e9fe99435278c337375b0dce292fe0e2", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a6e6c34d337f3c74c39b29c5f54d33023de8897c", + "reference": "a6e6c34d337f3c74c39b29c5f54d33023de8897c", "shasum": "" }, "require": { @@ -3328,20 +3328,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2016-09-21 19:04:07" + "time": "2016-10-24 15:52:36" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -3353,7 +3353,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -3387,20 +3387,20 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14 01:06:16" }, { "name": "symfony/polyfill-php54", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php54.git", - "reference": "34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1" + "reference": "90e085822963fdcc9d1c5b73deb3d2e5783b16a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1", - "reference": "34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1", + "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/90e085822963fdcc9d1c5b73deb3d2e5783b16a0", + "reference": "90e085822963fdcc9d1c5b73deb3d2e5783b16a0", "shasum": "" }, "require": { @@ -3409,7 +3409,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -3445,20 +3445,20 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14 01:06:16" }, { "name": "symfony/polyfill-php55", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php55.git", - "reference": "bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d" + "reference": "03e3f0350bca2220e3623a0e340eef194405fc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d", - "reference": "bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d", + "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/03e3f0350bca2220e3623a0e340eef194405fc67", + "reference": "03e3f0350bca2220e3623a0e340eef194405fc67", "shasum": "" }, "require": { @@ -3468,7 +3468,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -3501,11 +3501,11 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14 01:06:16" }, { "name": "symfony/process", - "version": "v3.1.5", + "version": "v3.1.6", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -3554,16 +3554,16 @@ }, { "name": "symfony/translation", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7" + "reference": "cca6ff892355876534b01a927f789bac9601c935" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", + "url": "https://api.github.com/repos/symfony/translation/zipball/cca6ff892355876534b01a927f789bac9601c935", + "reference": "cca6ff892355876534b01a927f789bac9601c935", "shasum": "" }, "require": { @@ -3614,25 +3614,25 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" + "time": "2016-10-18 04:28:30" }, { "name": "symfony/twig-bridge", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/twig-bridge.git", - "reference": "5586685d161c411ab33a9ea72d3b25a337337942" + "reference": "b9df700554a19c9c00c662f2cd9fb3f03c0d4bcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/5586685d161c411ab33a9ea72d3b25a337337942", - "reference": "5586685d161c411ab33a9ea72d3b25a337337942", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/b9df700554a19c9c00c662f2cd9fb3f03c0d4bcf", + "reference": "b9df700554a19c9c00c662f2cd9fb3f03c0d4bcf", "shasum": "" }, "require": { "php": ">=5.3.9", - "twig/twig": "~1.26|~2.0" + "twig/twig": "~1.27|~2.0" }, "require-dev": { "symfony/asset": "~2.7|~3.0.0", @@ -3695,20 +3695,20 @@ ], "description": "Symfony Twig Bridge", "homepage": "https://symfony.com", - "time": "2016-10-03 15:49:46" + "time": "2016-10-24 15:52:36" }, { "name": "symfony/yaml", - "version": "v2.8.12", + "version": "v2.8.13", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c" + "reference": "396784cd06b91f3db576f248f2402d547a077787" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e7540734bad981fe59f8ef14b6fc194ae9df8d9c", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c", + "url": "https://api.github.com/repos/symfony/yaml/zipball/396784cd06b91f3db576f248f2402d547a077787", + "reference": "396784cd06b91f3db576f248f2402d547a077787", "shasum": "" }, "require": { @@ -3744,20 +3744,20 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 01:57:56" + "time": "2016-10-21 20:59:10" }, { "name": "twig/twig", - "version": "v1.26.1", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a09d8ee17ac1cfea29ed60c83960ad685c6a898d" + "reference": "3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a09d8ee17ac1cfea29ed60c83960ad685c6a898d", - "reference": "a09d8ee17ac1cfea29ed60c83960ad685c6a898d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97", + "reference": "3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97", "shasum": "" }, "require": { @@ -3770,7 +3770,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.26-dev" + "dev-master": "1.27-dev" } }, "autoload": { @@ -3805,7 +3805,7 @@ "keywords": [ "templating" ], - "time": "2016-10-05 18:57:41" + "time": "2016-10-25 19:17:17" }, { "name": "vierbergenlars/php-semver", From a1613f3c51832817ac80f388a56c41fbc91abdea Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 12:59:09 -0500 Subject: [PATCH 07/22] Adding a real update. --- src/Composer/Plugin.php | 16 +++- src/Console/Command/UpdateCommand.php | 11 ++- src/Update/Updater.php | 102 +++++++++++++++++++++++++- src/Update/Updates.php | 16 +++- 4 files changed, 136 insertions(+), 9 deletions(-) diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index f6b4fbbf2..c83de53a7 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -142,15 +142,29 @@ protected function executeBltUpdate($version) { $this->executeCommand('blt update'); $this->io->write('This may have modified your composer.json and require a subsequent `composer update`'); + // Execute update hooks for this specific version delta. if (isset($this->blt_prior_version)) { - $this->executeCommand("blt-console blt:update {$this->blt_prior_version} $version"); + $this->executeCommand("blt-console blt:update {$this->blt_prior_version} $version {$this->getRepoRoot()}"); } + + // @todo check if require or require-dev changed. If so, run `composer update`. + // @todo if require and require-dev did not change, but something else in composer.json changed, execute `composer update --lock`. } else { $this->io->write('Skipping update of BLT templated files'); } } + /** + * Returns the repo root's filepath, assumed to be one dir above vendor dir. + * + * @return string + * The file path of the repository root. + */ + public function getRepoRoot() { + return dir($this->getVendorPath()); + } + /** * Get the path to the 'vendor' directory. * diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 397d172cd..3cb7ecf41 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -29,6 +29,11 @@ protected function configure() InputArgument::REQUIRED, 'The ending version.' ) + ->addArgument( + 'repo_root', + InputArgument::REQUIRED, + 'The root directory of the repository that utilizes BLT.' + ) ; } @@ -36,8 +41,10 @@ protected function execute(InputInterface $input, OutputInterface $output) { $starting_version = $input->getArgument('starting_version'); $ending_version = $input->getArgument('ending_version'); + $repo_root = $input->getArgument('repo_root'); $updater = new Updater(); + $updater->setRepoRoot($repo_root); $updates = $updater->getUpdates($starting_version, $ending_version); if ($updates) { $output->writeln("The following BLT updates are outstanding:"); @@ -53,6 +60,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $updater->executeUpdates($updates); } - + else { + $output->writeln("There are no scripted updates avaiable between BLT versions $starting_version and $ending_version."); + } } } diff --git a/src/Update/Updater.php b/src/Update/Updater.php index 6e844f1e4..4064d8625 100644 --- a/src/Update/Updater.php +++ b/src/Update/Updater.php @@ -8,6 +8,9 @@ use Doctrine\Common\Annotations\IndexedReader; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Filesystem\Exception\FileNotFoundException; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Process\Process; use vierbergenlars\SemVer\version; class Updater { @@ -15,26 +18,54 @@ class Updater { /** @var \Symfony\Component\Console\Output\ConsoleOutput */ protected $output; + /** @var string */ + protected $repoRoot; + + /** @var \Symfony\Component\Filesystem\Filesystem */ + protected $fs; + + /** + * @return string + */ + public function getRepoRoot() { + return $this->repoRoot; + } + + /** + * @param string $repoRoot + */ + public function setRepoRoot($repoRoot) { + if (!$this->fs->exists($repoRoot)) { + throw new FileNotFoundException(); + } + + $this->repoRoot = $repoRoot; + } + public function __construct($update_class = 'Acquia\Blt\Update\Updates') { $this->output = new ConsoleOutput(); $this->output->setFormatter(new OutputFormatter(true)); AnnotationRegistry::registerFile(__DIR__ . '/../Annotations/Update.php'); $this->annotationsReader = new IndexedReader(new AnnotationReader()); - $this->updateClass = $update_class; + $this->updateClassName = $update_class; + $this->fs = new Filesystem(); } /** * @param $updates \Acquia\Blt\Annotations\Update[] */ public function executeUpdates($updates) { + /** @var Updates $updates_object */ + $updates_object = new $this->updateClassName(); + $updates_object->setUpdater($this); /** * @var string $method_name * @var Update $update */ foreach ($updates as $method_name => $update) { $this->output->writeln("Executing Updater->$method_name: {$update->description}"); - call_user_func([$this->updateClass, $method_name]); + call_user_func([$updates_object, $method_name]); } } @@ -75,9 +106,9 @@ public function getUpdates($starting_version, $ending_version) { */ protected function getAllUpdateMethods() { $update_methods = []; - $methods = get_class_methods($this->updateClass); + $methods = get_class_methods($this->updateClassName); foreach ($methods as $method_name) { - $reflectionMethod = new \ReflectionMethod($this->updateClass, $method_name); + $reflectionMethod = new \ReflectionMethod($this->updateClassName, $method_name); $annotations = $this->annotationsReader->getMethodAnnotation($reflectionMethod, 'Acquia\Blt\Annotations\Update'); if ($annotations) { $update_methods[$method_name] = $annotations; @@ -86,4 +117,67 @@ protected function getAllUpdateMethods() { return $update_methods; } + + /** + * @param string $command + * @param string $cwd + * @param bool $display_output + * Optional. Whether to print command output to screen. Changes return + * value. + * @param bool $mustRun + * + * @return bool|string + * If $display_output is true, method will return TRUE for success, FALSE + * for failure. If $display_output false, method will return command output. + */ + public static function executeCommand($command, $cwd = null, $display_output = true, $mustRun = true) + { + $timeout = 10800; + $env = [ + 'COMPOSER_PROCESS_TIMEOUT' => $timeout + ] + $_ENV; + $process = new Process($command, $cwd, $env, null, $timeout); + $method = $mustRun ? 'mustRun' : 'run'; + if ($display_output) { + $process->$method(function ($type, $buffer) { + print $buffer; + }); + return $process->isSuccessful(); + } else { + $process->$method(); + return $process->getOutput(); + } + } + + /** + * Removes a patch from repo's root composer.json file. + * + * @param string $package + * The composer package name. E.g., 'drupal/features'. + * + * @param string $url + * The URL of the patch. + * + * @return bool + * TRUE if patch was removed, otherwise FALSE. + */ + public function removePatch($package, $url) { + $composer_json_filepath = $this->repoRoot . '/composer.json'; + $composer_json = json_decode(file_get_contents($composer_json_filepath), TRUE); + if (!empty($composer_json['extra']['patches'][$package])) { + foreach ($composer_json['extra']['patches'][$package] as $key => $patch_url) { + if ($patch_url == $url) { + unset($composer_json['extra']['patches'][$package][$key]); + // If that was the only patch for this module, unset the parent too. + if (empty($composer_json['extra']['patches'][$package])) { + unset($composer_json['extra']['patches'][$package]); + } + file_put_contents($composer_json_filepath, json_encode($composer_json, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); + + return TRUE; + } + } + } + return FALSE; + } } diff --git a/src/Update/Updates.php b/src/Update/Updates.php index f49d0e149..70cc77524 100644 --- a/src/Update/Updates.php +++ b/src/Update/Updates.php @@ -6,13 +6,23 @@ class Updates { + /** @var Updater */ + protected $updater; + + /** + * @param Updater $updater + */ + public function setUpdater($updater) { + $this->updater = $updater; + } + /** * @Update( * version = "8.5.1", - * description = "Re-initialize VM." + * description = "Removes deprecated features patch." * ) */ - public static function update_850() { - // Do nothing. + public function update_850() { + $this->updater->removePatch("drupal/features", "https://www.drupal.org/files/issues/features-2808303-2.patch"); } } From 0167129793ee3d2896af85099075239939fe112b Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 13:06:15 -0500 Subject: [PATCH 08/22] Forcing all updates to be applied to dev versions. --- src/Update/Updater.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Update/Updater.php b/src/Update/Updater.php index 4064d8625..e785992bf 100644 --- a/src/Update/Updater.php +++ b/src/Update/Updater.php @@ -85,6 +85,14 @@ public function printUpdates($updates) { public function getUpdates($starting_version, $ending_version) { $updates = []; $update_methods = $this->getAllUpdateMethods(); + $include_all_updates = FALSE; + + if (strpos($starting_version, '-dev') !== FALSE + || strpos($ending_version, '-dev') !== FALSE ) { + $this->output->writeln("You are (or were) using a development branch of BLT. Assuming that you require all scripted updates."); + $include_all_updates = TRUE; + } + /** * @var string $method_name * @var Update $metadata @@ -92,7 +100,8 @@ public function getUpdates($starting_version, $ending_version) { foreach ($update_methods as $method_name => $metadata) { $version = $metadata->version; - if (version::gt($version, $starting_version) && version::lte($version, $ending_version)) { + if ($include_all_updates + || (version::gt($version, $starting_version) && version::lte($version, $ending_version))) { $updates[$method_name] = $metadata; } } From 24ad488e43faee9336cb48ec450ee32fbdad4c1f Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 13:38:12 -0500 Subject: [PATCH 09/22] Trying to make update execute. --- src/Annotations/Update.php | 1 + src/Composer/Plugin.php | 13 +++++++--- src/Console/Command/UpdateCommand.php | 19 +++++++++------ src/Update/Updater.php | 35 +++++++++++++++++++++++++++ src/Update/Updates.php | 2 +- 5 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/Annotations/Update.php b/src/Annotations/Update.php index 60cce549a..e610856fc 100644 --- a/src/Annotations/Update.php +++ b/src/Annotations/Update.php @@ -10,6 +10,7 @@ class Update { /** @Required */ public $version; + /** * @var string * @Required diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index c83de53a7..7d3640b10 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -137,16 +137,23 @@ protected function getBltPackage($operation) { protected function executeBltUpdate($version) { $options = $this->getOptions(); if ($options['blt']['update']) { - $this->io->write('Updating BLT templated files'); + $this->io->write('Updating BLT templated files...'); + // Rsyncs, updates composer.json, project.yml. $this->executeCommand('blt update'); - $this->io->write('This may have modified your composer.json and require a subsequent `composer update`'); // Execute update hooks for this specific version delta. if (isset($this->blt_prior_version)) { - $this->executeCommand("blt-console blt:update {$this->blt_prior_version} $version {$this->getRepoRoot()}"); + $this->io->write("Executing scripted updates for BLT version delta {$this->blt_prior_version} -> $version ..."); + // $this->executeCommand("blt blt:update-delta -Dblt.prior_version={$this->blt_prior_version} -Dblt.version=$version"); + $this->executeCommand("blt-console blt:update {$this->blt_prior_version} $version {$this->repoRoot}"); + } + else { + $this->io->write("Could not detect prior BLT version. Skipping scripted updates."); } + $this->io->write('This may have modified your composer.json and require a subsequent `composer update`'); + // @todo check if require or require-dev changed. If so, run `composer update`. // @todo if require and require-dev did not change, but something else in composer.json changed, execute `composer update --lock`. } diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 3cb7ecf41..7f8e57bd7 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -34,6 +34,7 @@ protected function configure() InputArgument::REQUIRED, 'The root directory of the repository that utilizes BLT.' ) + ->addOption('yes', 'y', InputOption::VALUE_OPTIONAL) ; } @@ -49,13 +50,17 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($updates) { $output->writeln("The following BLT updates are outstanding:"); $updater->printUpdates($updates); - $question = new ConfirmationQuestion( - 'Would you like to perform the listed updates? ', - false - ); - $continue = $this->getHelper('question')->ask($input, $output, $question); - if (!$continue) { - return 1; + + if (!$input->getOption('yes')) { + $question = new ConfirmationQuestion( + 'Would you like to perform the listed updates? ', + false + ); + + $continue = $this->getHelper('question')->ask($input, $output, $question); + if (!$continue) { + return 1; + } } $updater->executeUpdates($updates); diff --git a/src/Update/Updater.php b/src/Update/Updater.php index e785992bf..13c79a26f 100644 --- a/src/Update/Updater.php +++ b/src/Update/Updater.php @@ -25,14 +25,23 @@ class Updater { protected $fs; /** + * Returns $this->repoRoot. + * * @return string + * The filepath of the repository root directory. */ public function getRepoRoot() { return $this->repoRoot; } /** + * The filepath of the repository root directory. + * + * This directory is expected to contain the composer.json that defines + * acquia/blt as a dependency. + * * @param string $repoRoot + * The filepath of the repository root directory. */ public function setRepoRoot($repoRoot) { if (!$this->fs->exists($repoRoot)) { @@ -42,6 +51,12 @@ public function setRepoRoot($repoRoot) { $this->repoRoot = $repoRoot; } + /** + * Updater constructor. + * + * @param string $update_class + * The name of the class containing the update methods to be executed. + */ public function __construct($update_class = 'Acquia\Blt\Update\Updates') { $this->output = new ConsoleOutput(); @@ -53,6 +68,8 @@ public function __construct($update_class = 'Acquia\Blt\Update\Updates') } /** + * Executes an array of updates. + * * @param $updates \Acquia\Blt\Annotations\Update[] */ public function executeUpdates($updates) { @@ -70,6 +87,8 @@ public function executeUpdates($updates) { } /** + * Prints a human-readable list of update methods to the screen. + * * @param $updates \Acquia\Blt\Annotations\Update[] */ public function printUpdates($updates) { @@ -82,6 +101,19 @@ public function printUpdates($updates) { } } + /** + * Gets all applicable updates for a given version delta. + * + * @param string $starting_version + * The starting version. E.g., 8.5.0. + * + * @param string $ending_version + * The ending version. E.g., 8.5.1. + * + * @return array + * An array of applicable update methods, keyed by method name. Each row + * contains the metadata from the Update annotation. + */ public function getUpdates($starting_version, $ending_version) { $updates = []; $update_methods = $this->getAllUpdateMethods(); @@ -110,6 +142,9 @@ public function getUpdates($starting_version, $ending_version) { } /** + * Gather an array of all available update methods. + * + * This will only return methods using the Update annotation. * * @see drupal_get_schema_versions() */ diff --git a/src/Update/Updates.php b/src/Update/Updates.php index 70cc77524..6c03e558b 100644 --- a/src/Update/Updates.php +++ b/src/Update/Updates.php @@ -22,7 +22,7 @@ public function setUpdater($updater) { * description = "Removes deprecated features patch." * ) */ - public function update_850() { + public function update_851() { $this->updater->removePatch("drupal/features", "https://www.drupal.org/files/issues/features-2808303-2.patch"); } } From a2e1e7af16be31b4fc09073a35e7f3756fe7de27 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 13:41:16 -0500 Subject: [PATCH 10/22] Correcting composer hook. --- src/Composer/Plugin.php | 2 +- src/Console/Command/UpdateCommand.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php index 7d3640b10..b462ecab3 100644 --- a/src/Composer/Plugin.php +++ b/src/Composer/Plugin.php @@ -72,7 +72,7 @@ public function activate(Composer $composer, IOInterface $io) { public static function getSubscribedEvents() { return array( PackageEvents::PRE_PACKAGE_INSTALL => "onPrePackageEvent", - PackageEvents::PRE_PACKAGE_INSTALL => "onPrePackageEvent", + PackageEvents::PRE_PACKAGE_UPDATE => "onPrePackageEvent", PackageEvents::POST_PACKAGE_INSTALL => "onPostPackageEvent", PackageEvents::POST_PACKAGE_UPDATE => "onPostPackageEvent", ScriptEvents::POST_UPDATE_CMD => 'onPostCmdEvent' diff --git a/src/Console/Command/UpdateCommand.php b/src/Console/Command/UpdateCommand.php index 7f8e57bd7..c59b13222 100644 --- a/src/Console/Command/UpdateCommand.php +++ b/src/Console/Command/UpdateCommand.php @@ -34,7 +34,12 @@ protected function configure() InputArgument::REQUIRED, 'The root directory of the repository that utilizes BLT.' ) - ->addOption('yes', 'y', InputOption::VALUE_OPTIONAL) + ->addOption( + 'yes', + 'y', + InputOption::VALUE_OPTIONAL, + 'Answers yes to all question prompts' + ) ; } From bef58b56f8da9b67b12e1bb92a3d1790560ae403 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 15 Nov 2016 15:14:55 -0500 Subject: [PATCH 11/22] Addin blt:update-delta target. --- ISSUE_TEMPLATE.md | 0 phing/tasks/blt.xml | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 ISSUE_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..e69de29bb diff --git a/phing/tasks/blt.xml b/phing/tasks/blt.xml index 1f1b770dc..5b4fbfdfc 100644 --- a/phing/tasks/blt.xml +++ b/phing/tasks/blt.xml @@ -48,6 +48,12 @@ To remove deprecated BLT files, run "blt cleanup". + +