Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Remove sweetchuck/asset-jar
Browse files Browse the repository at this point in the history
  • Loading branch information
Sweetchuck committed Jul 31, 2017
1 parent a95dd0d commit 5712e16
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 89 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"prefer-stable": true,
"require": {
"php": ">=7.1",
"sweetchuck/asset-jar": "^0.0",
"consolidation/robo": "^1.0"
},
"require-dev": {
Expand Down
37 changes: 1 addition & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 41 additions & 32 deletions src/Task/BaseTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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':
Expand All @@ -246,7 +260,6 @@ public function setOptions(array $option)
$this->setNoColor($value);
break;
}
// @codingStandardsIgnoreEnd
}

return $this;
Expand Down Expand Up @@ -370,7 +383,6 @@ public function run()
->runHeader()
->runAction()
->runProcessOutputs()
->runReleaseAssets()
->runReturn();
}

Expand Down Expand Up @@ -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()
);
}

Expand Down Expand Up @@ -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}
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Task/BundleInstallTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -500,7 +499,6 @@ public function setOptions(array $option)
$this->setWithOrWithout($value);
break;
}
// @codingStandardsIgnoreEnd
}

return $this;
Expand Down
4 changes: 3 additions & 1 deletion tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Sweetchuck\Robo\Bundler\Test;

use Codeception\Actor;

/**
* Inherited Methods
* @method void wantToTest($text)
Expand All @@ -17,7 +19,7 @@
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
class AcceptanceTester extends Actor
{
use _generated\AcceptanceTesterActions;
}
4 changes: 3 additions & 1 deletion tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Sweetchuck\Robo\Bundler\Test\Helper;

class Acceptance extends \Codeception\Module
use Codeception\Module;

class Acceptance extends Module
{

}
2 changes: 1 addition & 1 deletion tests/_support/Helper/RoboFiles/BundleRoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 3 additions & 1 deletion tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Sweetchuck\Robo\Bundler\Test\Helper;

class Unit extends \Codeception\Module
use Codeception\Module;

class Unit extends Module
{

}
4 changes: 3 additions & 1 deletion tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Sweetchuck\Robo\Bundler\Test;

use Codeception\Actor;

/**
* Inherited Methods
* @method void wantToTest($text)
Expand All @@ -17,7 +19,7 @@
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
class UnitTester extends Actor
{
use _generated\UnitTesterActions;
}
13 changes: 0 additions & 13 deletions tests/unit/Task/BundleShowPathsTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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'],
Expand Down

0 comments on commit 5712e16

Please sign in to comment.