-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from fourkitchens/feature/phpcs-command
FIre phpCS command
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Standard Drupal Project"> | ||
<description>PHP CodeSniffer configuration for myproject development.</description> | ||
<file>web/modules/custom</file> | ||
<file>web/themes/custom</file> | ||
<exclude-pattern>vendor</exclude-pattern> | ||
<exclude-pattern>contrib</exclude-pattern> | ||
<exclude-pattern>tests</exclude-pattern> | ||
<exclude-pattern>pattern-lab</exclude-pattern> | ||
<exclude-pattern>patternlab</exclude-pattern> | ||
<exclude-pattern>node_modules</exclude-pattern> | ||
<exclude-pattern>*components/_twig-components*</exclude-pattern> | ||
<exclude-pattern>*/themes/custom/**/dist/*</exclude-pattern> | ||
|
||
<config name="drupal_core_version" value="8"/> | ||
<arg name="extensions" value="php,module,inc,install,test,profile,theme,info"/> | ||
|
||
<!-- If you have Coder installed locally then you can reference the Drupal | ||
standards with relative paths. Otherwise simply use "Drupal" and | ||
"DrupalPractice. --> | ||
<rule ref="Drupal"> | ||
<!-- Example how you would disable a rule you are not compliant with yet: | ||
<exclude name="Drupal.Commenting.Deprecated"/> | ||
--> | ||
</rule> | ||
<rule ref="DrupalPractice"/> | ||
|
||
<!-- Example how you would disable an external rule you do not like: | ||
<rule ref="PEAR.Functions.ValidDefaultValue.NotAtEnd"> | ||
<severity>0</severity> | ||
</rule> | ||
--> | ||
</ruleset> |
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,49 @@ | ||
<?php | ||
|
||
namespace Fire\Robo\Plugin\Commands; | ||
|
||
use Robo\Symfony\ConsoleIO; | ||
use Robo\Robo; | ||
|
||
/** | ||
* Provides a command To easylly setup and Run phpcs over your local env. | ||
*/ | ||
class LintPhpCommand extends FireCommandBase { | ||
|
||
/** | ||
* Runs and configure Phpcs for you local env. | ||
* | ||
* Usage Example: fire local:lint:php | ||
* | ||
* @command local:lint:php | ||
* @aliases phpcs | ||
* | ||
*/ | ||
public function phpcsRun(ConsoleIO $io) { | ||
$composerJson = file_get_contents($this->getLocalEnvRoot() . '/composer.json'); | ||
$composerJson = json_decode($composerJson, TRUE); | ||
$installComposerPackages = FALSE; | ||
$createPhpCsFile = FALSE; | ||
if (!isset($composerJson['require-dev']['drupal/coder'])) { | ||
$installComposerPackages = $io->confirm("You don't have the Coder composer package installed, Do you want us to install it for you (Required for linting)?", TRUE); | ||
} | ||
if (!file_exists($this->getLocalEnvRoot() . '/phpcs.xml')) { | ||
$createPhpCsFile = $io->confirm("You don't have a Base PHPCS configuration file (phpcs.xml), Do you want us to create one for your Project?", TRUE); | ||
} | ||
$tasks = $this->collectionBuilder($io); | ||
if ($installComposerPackages) { | ||
$tasks->addTask($this->taskComposerRequire() | ||
->dependency('drupal/coder') | ||
->dir($this->getLocalEnvRoot()) | ||
->dev() | ||
->ignorePlatformRequirements() | ||
); | ||
} | ||
if ($createPhpCsFile) { | ||
$assets = dirname(__DIR__, 4) . '/assets/templates/'; | ||
$tasks->addTask($this->taskFilesystemStack()->copy($assets . 'phpcs.xml', $this->getLocalEnvRoot() . '/phpcs.xml')); | ||
} | ||
$tasks->addTask($this->taskExec('./vendor/bin/phpcs -d memory_limit=-1')); | ||
return $tasks; | ||
} | ||
} |