-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
328 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Ninjify\Composer\Script; | ||
|
||
abstract class AbstractScript | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Ninjify\Composer\Script; | ||
|
||
use Composer\Script\Event; | ||
|
||
final class CodeFixer extends AbstractScript | ||
{ | ||
|
||
/** @var Event */ | ||
private $event; | ||
|
||
/** @var array */ | ||
private $config; | ||
|
||
/** | ||
* @param Event $event | ||
* @param array $config | ||
*/ | ||
public function __construct(Event $event, array $config) | ||
{ | ||
$this->event = $event; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* API ********************************************************************* | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @param Event $event | ||
* @return void | ||
*/ | ||
public static function execute(Event $event) | ||
{ | ||
$extra = $event->getComposer()->getPackage()->getExtra(); | ||
|
||
if (!isset($extra['ninjify'])) { | ||
$event->getIO()->writeError('You have to setup "ninjify" in "extra" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa'])) { | ||
$event->getIO()->writeError('You have to setup "qa" in "extra.ninjify" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa']['codefixer'])) { | ||
$event->getIO()->writeError('You have to setup "codefixer" in "extra.ninjify.qa" section.'); | ||
|
||
return; | ||
} | ||
|
||
// CodeFixer config | ||
$config = $extra['ninjify']['qa']['codefixer']; | ||
$script = new CodeFixer($event, $config); | ||
$script->process(); | ||
} | ||
|
||
/** | ||
* IMPLEMENTATION ********************************************************** | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function process() | ||
{ | ||
if (!isset($this->config['folders']) || empty($this->config['folders'])) { | ||
$this->event->getIO()->writeError('You have to add any folders in "extra.ninjify.qa.codefixer.folders" section.'); | ||
|
||
return; | ||
} | ||
|
||
$folders = $this->config['folders']; | ||
$binDir = $this->event->getComposer()->getConfig()->get('bin-dir'); | ||
passthru(sprintf('%s/codefixer %s', $binDir, implode(' ', $folders))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Ninjify\Composer\Script; | ||
|
||
use Composer\Script\Event; | ||
|
||
final class CodeSniffer extends AbstractScript | ||
{ | ||
|
||
/** @var Event */ | ||
private $event; | ||
|
||
/** @var array */ | ||
private $config; | ||
|
||
/** | ||
* @param Event $event | ||
* @param array $config | ||
*/ | ||
public function __construct(Event $event, array $config) | ||
{ | ||
$this->event = $event; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* API ********************************************************************* | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @param Event $event | ||
* @return void | ||
*/ | ||
public static function execute(Event $event) | ||
{ | ||
$extra = $event->getComposer()->getPackage()->getExtra(); | ||
|
||
if (!isset($extra['ninjify'])) { | ||
$event->getIO()->writeError('You have to setup "ninjify" in "extra" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa'])) { | ||
$event->getIO()->writeError('You have to setup "qa" in "extra.ninjify" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa']['codesniffer'])) { | ||
$event->getIO()->writeError('You have to setup "codesniffer" in "extra.ninjify.qa" section.'); | ||
|
||
return; | ||
} | ||
|
||
// CodeSniffer config | ||
$config = $extra['ninjify']['qa']['codesniffer']; | ||
$script = new CodeSniffer($event, $config); | ||
$script->process(); | ||
} | ||
|
||
/** | ||
* IMPLEMENTATION ********************************************************** | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function process() | ||
{ | ||
if (!isset($this->config['folders']) || empty($this->config['folders'])) { | ||
$this->event->getIO()->writeError('You have to add any folders in "extra.ninjify.qa.codesniffer.folders" section.'); | ||
|
||
return; | ||
} | ||
|
||
$folders = $this->config['folders']; | ||
$binDir = $this->event->getComposer()->getConfig()->get('bin-dir'); | ||
passthru(sprintf('%s/codesniffer %s', $binDir, implode(' ', $folders))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Ninjify\Composer\Script; | ||
|
||
use Composer\Script\Event; | ||
|
||
final class Linter extends AbstractScript | ||
{ | ||
|
||
/** @var Event */ | ||
private $event; | ||
|
||
/** @var array */ | ||
private $config; | ||
|
||
/** | ||
* @param Event $event | ||
* @param array $config | ||
*/ | ||
public function __construct(Event $event, array $config) | ||
{ | ||
$this->event = $event; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* API ********************************************************************* | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @param Event $event | ||
* @return void | ||
*/ | ||
public static function execute(Event $event) | ||
{ | ||
$extra = $event->getComposer()->getPackage()->getExtra(); | ||
|
||
if (!isset($extra['ninjify'])) { | ||
$event->getIO()->writeError('You have to setup "ninjify" in "extra" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa'])) { | ||
$event->getIO()->writeError('You have to setup "qa" in "extra.ninjify" section.'); | ||
|
||
return; | ||
} | ||
|
||
if (!isset($extra['ninjify']['qa']['linter'])) { | ||
$event->getIO()->writeError('You have to setup "linter" in "extra.ninjify.qa" section.'); | ||
|
||
return; | ||
} | ||
|
||
// Linter config | ||
$config = $extra['ninjify']['qa']['linter']; | ||
$script = new Linter($event, $config); | ||
$script->process(); | ||
} | ||
|
||
/** | ||
* IMPLEMENTATION ********************************************************** | ||
* ************************************************************************* | ||
*/ | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function process() | ||
{ | ||
if (!isset($this->config['folders']) || empty($this->config['folders'])) { | ||
$this->event->getIO()->writeError('You have to add any folders in "extra.ninjify.qa.linter.folders" section.'); | ||
|
||
return; | ||
} | ||
|
||
$folders = $this->config['folders']; | ||
$binDir = $this->event->getComposer()->getConfig()->get('bin-dir'); | ||
passthru(sprintf('%s/linter %s', $binDir, implode(' ', $folders))); | ||
} | ||
|
||
} |