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

Commit

Permalink
Merge pull request #8 from Sweetchuck/remove-asset-jar
Browse files Browse the repository at this point in the history
Remove AssetJar
  • Loading branch information
Sweetchuck authored Jul 30, 2017
2 parents 92a96a8 + 66ad92e commit 48c34a7
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 178 deletions.
2 changes: 2 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

namespace: 'Sweetchuck\Robo\TsLint\Test'

actor: Tester

paths:
Expand Down
2 changes: 1 addition & 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 All @@ -29,6 +28,7 @@
"autoload-dev": {
"psr-4": {
"Sweetchuck\\Robo\\TsLint\\Composer\\": "src-dev/Composer/",
"Sweetchuck\\Robo\\TsLint\\Test\\": "tests/_support/",
"Sweetchuck\\Robo\\TsLint\\Tests\\Unit\\": "tests/unit/",
"Sweetchuck\\Robo\\TsLint\\Tests\\Acceptance\\": "tests/acceptance/"
}
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.

72 changes: 51 additions & 21 deletions src/Task/Run.php → src/Task/TsLintRunTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sweetchuck\Robo\TsLint\Task;

use Sweetchuck\AssetJar\AssetJarAware;
use Sweetchuck\AssetJar\AssetJarAwareInterface;
use Sweetchuck\LintReport\ReporterInterface;
use Sweetchuck\LintReport\ReportWrapperInterface;
use Sweetchuck\Robo\TsLint\LintReportWrapper\ReportWrapper;
Expand All @@ -28,15 +26,13 @@
*
* @package Sweetchuck\Robo\TsLint\Task
*/
class Run extends BaseTask implements
AssetJarAwareInterface,
class TsLintRunTask extends BaseTask implements
CommandInterface,
ContainerAwareInterface,
BuilderAwareInterface,
OutputAwareInterface
{

use AssetJarAware;
use ContainerAwareTrait;
use FsLoadTasks;
use FsShortCuts;
Expand Down Expand Up @@ -71,6 +67,29 @@ class Run extends BaseTask implements
protected $processClass = Process::class;

//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.
/**
* @var string
Expand Down Expand Up @@ -456,6 +475,13 @@ public function removeLintReporter(string $id)
//endregion
//endregion

/**
* @var array
*/
protected $assets = [
'report' => [],
];

protected $options = [
'config' => 'value',
'exclude' => 'multi-value',
Expand Down Expand Up @@ -510,8 +536,8 @@ public function options(array $options)
{
foreach ($options as $name => $value) {
switch ($name) {
case 'assetJarMapping':
$this->setAssetJarMapping($value);
case 'assetNamePrefix':
$this->setAssetNamePrefix($value);
break;

case 'workingDirectory':
Expand Down Expand Up @@ -645,8 +671,8 @@ public function run()
$numOfErrors = $reportWrapper->numOfErrors();
$numOfWarnings = $reportWrapper->numOfWarnings();

if ($this->isReportHasToBePutBackIntoJar()) {
$this->setAssetJarValue('report', $reportWrapper);
if ($this->isLintSuccess()) {
$this->assets['report'] = $reportWrapper;
}

foreach ($lintReporters as $lintReporter) {
Expand All @@ -667,9 +693,7 @@ public function run()
$this,
$exitCode,
$this->getExitMessage($exitCode) ?: $process->getErrorOutput(),
[
'time' => $this->getExecutionTime(),
]
$this->getAssetsWithPrefixedNames()
);
}

Expand Down Expand Up @@ -743,15 +767,6 @@ protected function buildCommandOptions(): array
];
}

protected function isReportHasToBePutBackIntoJar(): bool
{
return (
$this->hasAssetJar()
&& $this->getAssetJarMap('report')
&& $this->isLintSuccess()
);
}

protected function isOutputFormatMachineReadable(): bool
{
return ($this->getFormat() === 'json');
Expand Down Expand Up @@ -871,4 +886,19 @@ protected function prepareOutputDirectory(): Result

return $result;
}

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;
}
}
12 changes: 3 additions & 9 deletions src/TsLintTaskLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
use League\Container\ContainerAwareInterface;
use Robo\Contract\OutputAwareInterface;

/**
* Class LoadTasks.
*
* @package Sweetchuck\Robo\TsLint\Task
*/
trait TsLintTaskLoader
{
/**
Expand All @@ -20,13 +15,12 @@ trait TsLintTaskLoader
* @param string[] $paths
* File paths.
*
* @return \Sweetchuck\Robo\TsLint\Task\Run
* A lint runner task instance.
* @return \Sweetchuck\Robo\TsLint\Task\TsLintRunTask|\Robo\Collection\CollectionBuilder
*/
protected function taskTsLintRun(array $options = [], array $paths = [])
{
/** @var \Sweetchuck\Robo\TSLint\Task\Run $task */
$task = $this->task(Task\Run::class, $options, $paths);
/** @var \Sweetchuck\Robo\TSLint\Task\TsLintRunTask $task */
$task = $this->task(Task\TsLintRunTask::class, $options, $paths);
if ($this instanceof ContainerAwareInterface) {
$task->setContainer($this->getContainer());
}
Expand Down
13 changes: 3 additions & 10 deletions tests/_data/RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
use Sweetchuck\LintReport\Reporter\BaseReporter;
use Sweetchuck\LintReport\Reporter\SummaryReporter;
use Sweetchuck\LintReport\Reporter\VerboseReporter;
use League\Container\ContainerAwareInterface;
use League\Container\ContainerInterface;
use Robo\Contract\ConfigAwareInterface;

/**
* Class RoboFile.
*/
// @codingStandardsIgnoreStart
class RoboFile extends \Robo\Tasks
{
Expand All @@ -22,8 +17,6 @@ class RoboFile extends \Robo\Tasks
protected $reportsDir = 'actual';

/**
* @param \League\Container\ContainerInterface $container
*
* @return $this
*/
public function setContainer(ContainerInterface $container)
Expand All @@ -36,7 +29,7 @@ public function setContainer(ContainerInterface $container)
}

/**
* @return \Sweetchuck\Robo\TsLint\Task\Run
* @return \Sweetchuck\Robo\TsLint\Task\TsLintRunTask|\Robo\Collection\CollectionBuilder
*/
public function lintStylishStdOutput()
{
Expand All @@ -47,7 +40,7 @@ public function lintStylishStdOutput()
}

/**
* @return \Sweetchuck\Robo\TsLint\Task\Run
* @return \Sweetchuck\Robo\TsLint\Task\TsLintRunTask|\Robo\Collection\CollectionBuilder
*/
public function lintStylishFile()
{
Expand All @@ -59,7 +52,7 @@ public function lintStylishFile()
}

/**
* @return \Sweetchuck\Robo\TsLint\Task\Run
* @return \Sweetchuck\Robo\TsLint\Task\TsLintRunTask|\Robo\Collection\CollectionBuilder
*/
public function lintAllInOne()
{
Expand Down
12 changes: 8 additions & 4 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use \PHPUnit_Framework_Assert as Assert;
namespace Sweetchuck\Robo\TsLint\Test;

use \PHPUnit\Framework\Assert as Assert;

/**
* Inherited Methods
Expand Down Expand Up @@ -28,9 +30,11 @@ public function clearTheReportsDir()
{
$reportsDir = codecept_data_dir('actual');
if (is_dir($reportsDir)) {
$finder = new \Symfony\Component\Finder\Finder();
$finder->in($reportsDir);
foreach ($finder->files() as $file) {
$finder = (new \Symfony\Component\Finder\Finder())
->in($reportsDir)
->files();
/** @var \Symfony\Component\Finder\SplFileInfo $file */
foreach ($finder as $file) {
unlink($file->getPathname());
}
}
Expand Down
7 changes: 1 addition & 6 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?php

namespace Helper;
namespace Sweetchuck\Robo\TsLint\Test\Helper;

use Codeception\Module;

/**
* Class Unit.
*
* @package Helper
*/
class Acceptance extends Module
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

namespace Helper\Dummy;
namespace Sweetchuck\Robo\TsLint\Test\Helper\Dummy;

/**
* Class Output.
*
* @package Helper\Dummy
*/
class Output extends \Symfony\Component\Console\Output\Output
class DummyOutput extends \Symfony\Component\Console\Output\Output
{

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

namespace Helper\Dummy;
namespace Sweetchuck\Robo\TsLint\Test\Helper\Dummy;

/**
* Class Process.
*
* @package Helper
*/
class Process extends \Symfony\Component\Process\Process
class DummyProcess extends \Symfony\Component\Process\Process
{

/**
Expand All @@ -16,7 +11,7 @@ class Process extends \Symfony\Component\Process\Process
public static $prophecy = [];

/**
* @var \Helper\Dummy\Process[]
* @var static[]
*/
public static $instances = null;

Expand Down
2 changes: 1 addition & 1 deletion tests/_support/Helper/Module/Cli.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Helper\Module;
namespace Sweetchuck\Robo\TsLint\Test\Helper\Module;

use Codeception\Module as CodeceptionModule;
use Symfony\Component\Process\Process;
Expand Down
7 changes: 1 addition & 6 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?php

namespace Helper;
namespace Sweetchuck\Robo\TsLint\Test\Helper;

use Codeception\Module;

/**
* Class Unit.
*
* @package Helper
*/
class Unit extends Module
{

Expand Down
Loading

0 comments on commit 48c34a7

Please sign in to comment.