diff --git a/composer.json b/composer.json index f81e97393..3c1d3e0a5 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "type": "composer-plugin", "license": "GPL-2.0", "require": { + "asm89/twig-lint": "^1.0.2", "composer/installers": "^1.2.0", "composer-plugin-api": "^1.0.0", "doctrine/common": "^2.5", @@ -34,8 +35,7 @@ "consolidation/robo": "^1.1.0", "consolidation/config": "^1.0.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.0", - "tivie/php-os-detector": "^1.0", - "symfony/twig-bridge": "^3.3" + "tivie/php-os-detector": "^1.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 762ffcf63..ce744f3ee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,59 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9351755f817ea16ab00b2087b4e3bbd0", + "content-hash": "9cfb779659e9eeb8bc8314ae14b0a1af", "packages": [ + { + "name": "asm89/twig-lint", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/asm89/twig-lint.git", + "reference": "bbf7bc49689ed55d2900de7528c528c93db19431" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/asm89/twig-lint/zipball/bbf7bc49689ed55d2900de7528c528c93db19431", + "reference": "bbf7bc49689ed55d2900de7528c528c93db19431", + "shasum": "" + }, + "require": { + "symfony/console": "^2.1 || ^3.0", + "symfony/finder": "^2.1 || ^3.0", + "twig/twig": "^1.16.2" + }, + "bin": [ + "bin/twig-lint" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Asm89\\Twig\\Lint\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexander", + "email": "iam.asm89@gmail.com" + } + ], + "description": "Standalone twig linter.", + "homepage": "https://github.com/asm89/twig-lint", + "keywords": [ + "lint", + "twig" + ], + "time": "2016-07-25T21:02:13+00:00" + }, { "name": "chi-teck/drupal-code-generator", "version": "1.19.0", @@ -164,16 +215,16 @@ }, { "name": "consolidation/annotated-command", - "version": "2.4.13", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "abb685e42c83d0b698b4e22059e5d505588f7d3c" + "reference": "5e22a86f53ab1417a6002234fe205e69645326b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/abb685e42c83d0b698b4e22059e5d505588f7d3c", - "reference": "abb685e42c83d0b698b4e22059e5d505588f7d3c", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/5e22a86f53ab1417a6002234fe205e69645326b8", + "reference": "5e22a86f53ab1417a6002234fe205e69645326b8", "shasum": "" }, "require": { @@ -212,20 +263,20 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2017-08-28T20:16:37+00:00" + "time": "2017-09-18T22:52:16+00:00" }, { "name": "consolidation/config", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/consolidation/config.git", - "reference": "e3c7311f8926488fe2fbce0ec6af56be417da504" + "reference": "bcff5f4057c6ece20794d58dfc9e56919e2b33b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/config/zipball/e3c7311f8926488fe2fbce0ec6af56be417da504", - "reference": "e3c7311f8926488fe2fbce0ec6af56be417da504", + "url": "https://api.github.com/repos/consolidation/config/zipball/bcff5f4057c6ece20794d58dfc9e56919e2b33b7", + "reference": "bcff5f4057c6ece20794d58dfc9e56919e2b33b7", "shasum": "" }, "require": { @@ -261,7 +312,7 @@ } ], "description": "Provide configuration services for a commandline tool.", - "time": "2017-07-28T18:05:53+00:00" + "time": "2017-09-16T23:24:55+00:00" }, { "name": "consolidation/log", @@ -471,24 +522,26 @@ }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.4.2", + "version": "v0.4.3", "source": { "type": "git", "url": "https://github.com/DealerDirect/phpcodesniffer-composer-installer.git", - "reference": "17130f536db62570bcfc5cce59464b36e82eb092" + "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DealerDirect/phpcodesniffer-composer-installer/zipball/17130f536db62570bcfc5cce59464b36e82eb092", - "reference": "17130f536db62570bcfc5cce59464b36e82eb092", + "url": "https://api.github.com/repos/DealerDirect/phpcodesniffer-composer-installer/zipball/63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", + "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", "shasum": "" }, "require": { "composer-plugin-api": "^1.0", + "php": "^5.3|^7", "squizlabs/php_codesniffer": "*" }, "require-dev": { - "composer/composer": "*" + "composer/composer": "*", + "wimg/php-compatibility": "^8.0" }, "suggest": { "dealerdirect/qa-tools": "All the PHP QA tools you'll need" @@ -533,7 +586,7 @@ "stylecheck", "tests" ], - "time": "2017-08-16T10:25:17+00:00" + "time": "2017-09-18T07:49:36+00:00" }, { "name": "dflydev/dot-access-data", @@ -2766,16 +2819,16 @@ }, { "name": "symfony/config", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "6ac0cc1f047c1dbc058fc25b7a4d91b068ed4488" + "reference": "f9f19a39ee178f61bb2190f51ff7c517c2159315" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/6ac0cc1f047c1dbc058fc25b7a4d91b068ed4488", - "reference": "6ac0cc1f047c1dbc058fc25b7a4d91b068ed4488", + "url": "https://api.github.com/repos/symfony/config/zipball/f9f19a39ee178f61bb2190f51ff7c517c2159315", + "reference": "f9f19a39ee178f61bb2190f51ff7c517c2159315", "shasum": "" }, "require": { @@ -2824,20 +2877,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-08-03T08:59:45+00:00" + "time": "2017-09-04T16:28:07+00:00" }, { "name": "symfony/console", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6" + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d6596cb5022b6a0bd940eae54a1de78646a5fda6", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6", + "url": "https://api.github.com/repos/symfony/console/zipball/a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", "shasum": "" }, "require": { @@ -2892,20 +2945,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-08-27T14:52:21+00:00" + "time": "2017-09-06T16:40:18+00:00" }, { "name": "symfony/debug", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d" + "reference": "8beb24eec70b345c313640962df933499373a944" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/084d804fe35808eb2ef596ec83d85d9768aa6c9d", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d", + "url": "https://api.github.com/repos/symfony/debug/zipball/8beb24eec70b345c313640962df933499373a944", + "reference": "8beb24eec70b345c313640962df933499373a944", "shasum": "" }, "require": { @@ -2948,11 +3001,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-08-27T14:52:21+00:00" + "time": "2017-09-01T13:23:39+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -3015,7 +3068,7 @@ }, { "name": "symfony/filesystem", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -3064,7 +3117,7 @@ }, { "name": "symfony/finder", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -3172,7 +3225,7 @@ }, { "name": "symfony/process", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -3219,96 +3272,9 @@ "homepage": "https://symfony.com", "time": "2017-07-29T21:54:42+00:00" }, - { - "name": "symfony/twig-bridge", - "version": "v3.3.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "9c12e8f02937a1edfa02fcc73282c7c1a18304b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/9c12e8f02937a1edfa02fcc73282c7c1a18304b2", - "reference": "9c12e8f02937a1edfa02fcc73282c7c1a18304b2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "twig/twig": "~1.34|~2.4" - }, - "conflict": { - "symfony/form": "<3.2.10|~3.3,<3.3.3" - }, - "require-dev": { - "fig/link-util": "^1.0", - "symfony/asset": "~2.8|~3.0", - "symfony/console": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/finder": "~2.8|~3.0", - "symfony/form": "^3.2.10|^3.3.3", - "symfony/http-kernel": "~3.2", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "~2.8|~3.0", - "symfony/security": "~2.8|~3.0", - "symfony/security-acl": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0", - "symfony/templating": "~2.8|~3.0", - "symfony/translation": "~2.8|~3.0", - "symfony/var-dumper": "~2.8.10|~3.1.4|~3.2", - "symfony/web-link": "~3.3", - "symfony/yaml": "~2.8|~3.0" - }, - "suggest": { - "symfony/asset": "For using the AssetExtension", - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/web-link": "For using the WebLinkExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\Twig\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Twig Bridge", - "homepage": "https://symfony.com", - "time": "2017-07-29T21:54:42+00:00" - }, { "name": "symfony/var-dumper", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", @@ -3376,7 +3342,7 @@ }, { "name": "symfony/yaml", - "version": "v3.3.8", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", @@ -3728,16 +3694,16 @@ "packages-dev": [ { "name": "composer/ca-bundle", - "version": "1.0.7", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12" + "reference": "9dd73a03951357922d8aee6cc084500de93e2343" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/b17e6153cb7f33c7e44eb59578dc12eee5dc8e12", - "reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/9dd73a03951357922d8aee6cc084500de93e2343", + "reference": "9dd73a03951357922d8aee6cc084500de93e2343", "shasum": "" }, "require": { @@ -3783,7 +3749,7 @@ "ssl", "tls" ], - "time": "2017-03-06T11:59:08+00:00" + "time": "2017-09-11T07:24:36+00:00" }, { "name": "composer/composer", @@ -3791,12 +3757,12 @@ "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "d9885d5b3bd1b28a6d8c679df848540e565ee818" + "reference": "edece864e7e4c668dcad6601df70777882d22116" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/d9885d5b3bd1b28a6d8c679df848540e565ee818", - "reference": "d9885d5b3bd1b28a6d8c679df848540e565ee818", + "url": "https://api.github.com/repos/composer/composer/zipball/edece864e7e4c668dcad6601df70777882d22116", + "reference": "edece864e7e4c668dcad6601df70777882d22116", "shasum": "" }, "require": { @@ -3860,7 +3826,7 @@ "dependency", "package" ], - "time": "2017-08-21 07:16:59" + "time": "2017-09-19T08:42:10+00:00" }, { "name": "composer/semver", diff --git a/src/Robo/Blt.php b/src/Robo/Blt.php index 8401b4310..2014bfb4f 100644 --- a/src/Robo/Blt.php +++ b/src/Robo/Blt.php @@ -24,7 +24,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Bridge\Twig\Command\LintCommand; /** * The BLT Robo application. @@ -79,7 +78,6 @@ public function __construct( $this->configureContainer($container); $this->addBuiltInCommandsAndHooks(); $this->addPluginsCommandsAndHooks(); - $this->addSymfonyCommands($application); $this->runner = new RoboRunner(); $this->runner->setContainer($container); @@ -117,15 +115,6 @@ private function addPluginsCommandsAndHooks() { $this->commands = array_merge($this->commands, $plugin_commands_hooks); } - /** - * Adds Symfony (non-Robo) command classes to the application. - * - * @param \Acquia\Blt\Robo\Application $application - */ - protected function addSymfonyCommands(Application $application) { - $application->add(new LintCommand('validate:twig:files')); - } - /** * Discovers command classes using CommandFileDiscovery. * @@ -170,7 +159,7 @@ private function getHooks( /** * Add any global arguments or options that apply to all commands. * - * @param \Acquia\Blt\Robo\Application $app + * @param \Symfony\Component\Console\Application $app * The Symfony application. */ private function addDefaultArgumentsAndOptions(Application $app) { diff --git a/src/Robo/Commands/Git/GitCommand.php b/src/Robo/Commands/Git/GitCommand.php index e090f9c3f..18928c953 100644 --- a/src/Robo/Commands/Git/GitCommand.php +++ b/src/Robo/Commands/Git/GitCommand.php @@ -3,8 +3,6 @@ namespace Acquia\Blt\Robo\Commands\Git; use Acquia\Blt\Robo\BltTasks; -use function explode; -use function implode; /** * Defines commands in the "git:*" namespace. @@ -54,9 +52,7 @@ public function preCommitHook($changed_files) { // be sniffed, regardless of the extensions or patterns defined in // phpcs.xml. So, we do not use validate:phpcs:files. 'validate:phpcs' => [], - 'validate:twig:files' => [ - 'file_list' => implode(' ', explode("\n", $changed_files)), - ], + 'validate:twig:files' => ['file_list' => $changed_files], 'validate:yaml:files' => ['file_list' => $changed_files], ]); diff --git a/src/Robo/Commands/Validate/TwigCommand.php b/src/Robo/Commands/Validate/TwigCommand.php index 5194d2892..9ce08c5cc 100644 --- a/src/Robo/Commands/Validate/TwigCommand.php +++ b/src/Robo/Commands/Validate/TwigCommand.php @@ -26,8 +26,35 @@ public function lintFileSets() { $fileset_ids = $this->getConfigValue('validate.twig.filesets'); $filesets = $fileset_manager->getFilesets($fileset_ids); $bin = $this->getConfigValue('composer.bin'); - $command = "'$bin/blt lint:twig:files '%s'"; + $command = "'$bin/twig-lint' lint --only-print-errors '%s'"; $this->executeCommandAgainstFilesets($filesets, $command, TRUE); } + /** + * Executes Twig validator against a list of files, if in twig.filesets. + * + * @command validate:twig:files + * + * @param string $file_list + * A list of files to scan, separated by \n. + */ + public function lintFileList($file_list) { + $this->say("Linting twig files..."); + + $files = explode("\n", $file_list); + + /** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */ + $fileset_manager = $this->getContainer()->get('filesetManager'); + $fileset_ids = $this->getConfigValue('validate.twig.filesets'); + $filesets = $fileset_manager->getFilesets($fileset_ids); + + $bin = $this->getConfigValue('composer.bin'); + $command = "'$bin/twig-lint' lint --only-print-errors '%s'"; + foreach ($filesets as $fileset_id => $fileset) { + $filesets[$fileset_id] = $fileset_manager->filterFilesByFileset($files, $fileset); + } + + $this->executeCommandAgainstFilesets($filesets, $command); + } + }