diff --git a/composer.json b/composer.json index 3c7c462..cb7a824 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ "prefer-stable": true, "require": { "php": ">=7.1", - "sweetchuck/asset-jar": "^0.0", "consolidation/robo": "^1.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index d1dadea..0819939 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "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": "c97cae4909929448ce918f616835a8bb", + "content-hash": "465f397383a422c76387d894d7008c4d", "packages": [ { "name": "consolidation/annotated-command", @@ -727,41 +727,6 @@ ], "time": "2016-10-10T12:19:37+00:00" }, - { - "name": "sweetchuck/asset-jar", - "version": "v0.0.2", - "source": { - "type": "git", - "url": "https://github.com/Sweetchuck/asset-jar.git", - "reference": "a6d4d67db8eef018aa10779b3906fb109bcb6508" - }, - "dist": { - "type": "zip", - "url": "https://github.com/gitapi/repos/Sweetchuck/asset-jar/zipball/a6d4d67db8eef018aa10779b3906fb109bcb6508", - "reference": "a6d4d67db8eef018aa10779b3906fb109bcb6508", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/php-code-coverage": "^4.0", - "phpunit/phpunit": "^5.4", - "squizlabs/php_codesniffer": "^2.6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Sweetchuck\\AssetJar\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "description": "Provides a very simple, shared, in-memory data storage.", - "time": "2017-07-29T07:37:14+00:00" - }, { "name": "symfony/console", "version": "v3.3.5", diff --git a/src/Task/BaseTask.php b/src/Task/BaseTask.php index fba5089..638253c 100644 --- a/src/Task/BaseTask.php +++ b/src/Task/BaseTask.php @@ -2,8 +2,6 @@ namespace Sweetchuck\Robo\Bundler\Task; -use Sweetchuck\AssetJar\AssetJarAware; -use Sweetchuck\AssetJar\AssetJarAwareInterface; use Sweetchuck\Robo\Bundler\Utils; use Robo\Common\OutputAwareTrait; use Robo\Contract\CommandInterface; @@ -13,9 +11,8 @@ use Robo\TaskInfo; use Symfony\Component\Process\Process; -abstract class BaseTask extends RoboBaseTask implements AssetJarAwareInterface, CommandInterface, OutputAwareInterface +abstract class BaseTask extends RoboBaseTask implements CommandInterface, OutputAwareInterface { - use AssetJarAware; use OutputAwareTrait; /** @@ -60,6 +57,28 @@ abstract class BaseTask extends RoboBaseTask implements AssetJarAwareInterface, //region Options. + // region Option - assetNamePrefix. + /** + * @var string + */ + protected $assetNamePrefix = ''; + + public function getAssetNamePrefix(): string + { + return $this->assetNamePrefix; + } + + /** + * @return $this + */ + public function setAssetNamePrefix(string $value) + { + $this->assetNamePrefix = $value; + + return $this; + } + // endregion + //region Option - workingDirectory. /** * Directory to step in before run the `scss-lint`. @@ -212,14 +231,9 @@ public function __construct(array $options = []) public function setOptions(array $option) { foreach ($option as $name => $value) { - // @codingStandardsIgnoreStart switch ($name) { - case 'assetJar': - $this->setAssetJar($value); - break; - - case 'assetJarMapping': - $this->setAssetJarMapping($value); + case 'assetNamePrefix': + $this->setAssetNamePrefix($value); break; case 'workingDirectory': @@ -246,7 +260,6 @@ public function setOptions(array $option) $this->setNoColor($value); break; } - // @codingStandardsIgnoreEnd } return $this; @@ -370,7 +383,6 @@ public function run() ->runHeader() ->runAction() ->runProcessOutputs() - ->runReleaseAssets() ->runReturn(); } @@ -409,31 +421,13 @@ protected function runProcessOutputs() return $this; } - /** - * @return $this - */ - protected function runReleaseAssets() - { - if ($this->hasAssetJar()) { - $assetJar = $this->getAssetJar(); - foreach ($this->assets as $name => $value) { - $mapping = $this->getAssetJarMap($name); - if ($mapping) { - $assetJar->setValue($mapping, $value); - } - } - } - - return $this; - } - protected function runReturn(): Result { return new Result( $this, $this->actionExitCode, $this->actionStdError, - $this->assets + $this->getAssetsWithPrefixedNames() ); } @@ -472,6 +466,21 @@ protected function getCommandOptions(): array ]; } + protected function getAssetsWithPrefixedNames(): array + { + $prefix = $this->getAssetNamePrefix(); + if (!$prefix) { + return $this->assets; + } + + $data = []; + foreach ($this->assets as $key => $value) { + $data["{$prefix}{$key}"] = $value; + } + + return $data; + } + /** * {@inheritdoc} */ diff --git a/src/Task/BundleInstallTask.php b/src/Task/BundleInstallTask.php index b2d989b..faada08 100644 --- a/src/Task/BundleInstallTask.php +++ b/src/Task/BundleInstallTask.php @@ -426,7 +426,6 @@ public function setOptions(array $option) { parent::setOptions($option); foreach ($option as $name => $value) { - // @codingStandardsIgnoreStart switch ($name) { case 'binStubs': $this->setBinStubs($value); @@ -500,7 +499,6 @@ public function setOptions(array $option) $this->setWithOrWithout($value); break; } - // @codingStandardsIgnoreEnd } return $this; diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 7b90936..77912a7 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -2,6 +2,8 @@ namespace Sweetchuck\Robo\Bundler\Test; +use Codeception\Actor; + /** * Inherited Methods * @method void wantToTest($text) @@ -17,7 +19,7 @@ * * @SuppressWarnings(PHPMD) */ -class AcceptanceTester extends \Codeception\Actor +class AcceptanceTester extends Actor { use _generated\AcceptanceTesterActions; } diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php index eaefc17..0bd07d1 100644 --- a/tests/_support/Helper/Acceptance.php +++ b/tests/_support/Helper/Acceptance.php @@ -2,7 +2,9 @@ namespace Sweetchuck\Robo\Bundler\Test\Helper; -class Acceptance extends \Codeception\Module +use Codeception\Module; + +class Acceptance extends Module { } diff --git a/tests/_support/Helper/RoboFiles/BundleRoboFile.php b/tests/_support/Helper/RoboFiles/BundleRoboFile.php index b56d3fa..b056f9f 100644 --- a/tests/_support/Helper/RoboFiles/BundleRoboFile.php +++ b/tests/_support/Helper/RoboFiles/BundleRoboFile.php @@ -56,6 +56,6 @@ public function showPaths(): TaskInterface protected function dataDir(string $suffix = ''): string { - return Path::canonicalize(Path::join(__DIR__, '../../../_data/', $suffix)); + return Path::join(__DIR__, '../../../_data/', $suffix); } } diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index f711221..28c00a7 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -2,7 +2,9 @@ namespace Sweetchuck\Robo\Bundler\Test\Helper; -class Unit extends \Codeception\Module +use Codeception\Module; + +class Unit extends Module { } diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php index de8327c..5ff9478 100644 --- a/tests/_support/UnitTester.php +++ b/tests/_support/UnitTester.php @@ -2,6 +2,8 @@ namespace Sweetchuck\Robo\Bundler\Test; +use Codeception\Actor; + /** * Inherited Methods * @method void wantToTest($text) @@ -17,7 +19,7 @@ * * @SuppressWarnings(PHPMD) */ -class UnitTester extends \Codeception\Actor +class UnitTester extends Actor { use _generated\UnitTesterActions; } diff --git a/tests/unit/Task/BundleShowPathsTaskTest.php b/tests/unit/Task/BundleShowPathsTaskTest.php index 0b5a0aa..b42ac8f 100644 --- a/tests/unit/Task/BundleShowPathsTaskTest.php +++ b/tests/unit/Task/BundleShowPathsTaskTest.php @@ -2,7 +2,6 @@ namespace Sweetchuck\Robo\Bundler\Tests\Unit\Task; -use Sweetchuck\AssetJar\AssetJar; use Sweetchuck\Robo\Bundler\Task\BundleShowPathsTask; use Sweetchuck\Robo\Bundler\Test\Helper\Dummy\Output as DummyOutput; use Sweetchuck\Robo\Bundler\Test\Helper\Dummy\Process as DummyProcess; @@ -119,12 +118,6 @@ public function testRun(array $expected, array $options = [], array $processProp $mainStdOutput = new DummyOutput([]); - $assetJar = new AssetJar(); - $options += [ - 'assetJar' => $assetJar, - 'assetJarMapping' => ['paths' => ['bundleShowPaths', 'paths']], - ]; - /** @var \Sweetchuck\Robo\Bundler\Task\BundleShowPathsTask $task */ $task = Stub::construct( BundleShowPathsTask::class, @@ -148,12 +141,6 @@ public function testRun(array $expected, array $options = [], array $processProp 'Exit code is different than the expected.' ); - $this->tester->assertEquals( - $expected['paths'], - $task->getAssetJarValue('paths'), - 'AssetJar content: paths' - ); - $this->tester->assertEquals( $expected['paths'], $result['paths'],