diff --git a/config/drupal/config.yml b/config/drupal/config.yml index e53b0cf..69c6bb1 100644 --- a/config/drupal/config.yml +++ b/config/drupal/config.yml @@ -14,8 +14,10 @@ application: enabled: false exception: false phpcbf: - enabled: false + enabled: true exception: false + file: + standard: vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml phpcs: enabled: true exception: false diff --git a/config/php/config.yml b/config/php/config.yml deleted file mode 100644 index 462af2b..0000000 --- a/config/php/config.yml +++ /dev/null @@ -1,36 +0,0 @@ -application: - method: - git: - enabled: true - exception: false - composer: - enabled: true - exception: false - analyzer: - parallel-lint: - enabled: true - exception: true - php-cs-fixer: - enabled: true - exception: false - phpcbf: - enabled: true - exception: false - phpcs: - enabled: true - exception: false - phpmd: - enabled: true - exception: false - phploc: - enabled: true - exception: false - phpcpd: - enabled: true - exception: false - phpdcd: - enabled: true - exception: false - phpunit: - enabled: true - exception: true diff --git a/config/symfony/config.yml b/config/symfony/config.yml deleted file mode 100644 index 462af2b..0000000 --- a/config/symfony/config.yml +++ /dev/null @@ -1,36 +0,0 @@ -application: - method: - git: - enabled: true - exception: false - composer: - enabled: true - exception: false - analyzer: - parallel-lint: - enabled: true - exception: true - php-cs-fixer: - enabled: true - exception: false - phpcbf: - enabled: true - exception: false - phpcs: - enabled: true - exception: false - phpmd: - enabled: true - exception: false - phploc: - enabled: true - exception: false - phpcpd: - enabled: true - exception: false - phpdcd: - enabled: true - exception: false - phpunit: - enabled: true - exception: true diff --git a/src/Command/AnalyzeCommand.php b/src/Command/AnalyzeCommand.php index 192eeb0..2d9f75b 100644 --- a/src/Command/AnalyzeCommand.php +++ b/src/Command/AnalyzeCommand.php @@ -17,6 +17,12 @@ class AnalyzeCommand extends Command private $directory; + private $projects = [ + 'php', + 'symfony', + 'drupal' + ]; + protected function configure() { $this @@ -26,7 +32,10 @@ protected function configure() 'project', null, InputOption::VALUE_OPTIONAL, - 'Project name must be (php, symfony, drupal) or could be empty if a phpqa.yml or phpqa.yml.dist exists at current directory.' + sprintf( + 'Project name must be (%) or could be empty if a phpqa.yml or phpqa.yml.dist exists at current directory.', + implode(',', $this->projects) + ) ) ->addOption( 'files', @@ -50,10 +59,22 @@ protected function execute(InputInterface $input, OutputInterface $output) */ $config = $application->getConfig(); - if (!$project && !$config->isCustom()) { + if (!$config->isCustom() && !$project) { + throw new \Exception( + sprintf( + 'No local phpqa.yml or phpqa.yml.dist at current working directory ' . + 'you must provide a valid project value (%s)', + implode(',', $this->projects) + ) + ); + } + + if (!$config->isCustom() && !in_array($project, $this->projects)) { throw new \Exception( - 'No local phpqa.yml or phpqa.yml.dist at current working directory ' . - 'you must provide a valid project name (php, symfony or drupal)' + sprintf( + 'You must provide a valid project value (%s)', + implode(',', $this->projects) + ) ); } diff --git a/src/Command/InitCommand.php b/src/Command/InitCommand.php index c39550c..09f6037 100644 --- a/src/Command/InitCommand.php +++ b/src/Command/InitCommand.php @@ -19,11 +19,11 @@ class InitCommand extends Command 'destination' => 'drupal/config.yml', ], [ - 'source' => 'php/config.yml', + 'source' => '/../phpqa.yml', 'destination' => 'php/config.yml', ], [ - 'source' => 'symfony/config.yml', + 'source' => '/../phpqa.yml', 'destination' => 'symfony/config.yml', ], [ @@ -36,6 +36,17 @@ class InitCommand extends Command ], ]; + private $projects = [ + 'php', + 'symfony', + 'drupal' + ]; + + private $dirs = [ + 'home', + 'current' + ]; + protected function configure() { $this @@ -45,7 +56,19 @@ protected function configure() 'dir', null, InputOption::VALUE_REQUIRED, - 'Directory to copy file(s) valid options home, current' + sprintf( + 'Directory to copy file(s) valid options (%s)', + implode($this->dirs) + ) + ) + ->addOption( + 'project', + null, + InputOption::VALUE_OPTIONAL, + sprintf( + 'Project name to copy config from, must be (%s).', + implode(',', $this->projects) + ) ) ->addOption( 'override', @@ -62,9 +85,22 @@ protected function execute(InputInterface $input, OutputInterface $output) $dir = $input->getOption('dir'); - if (!$dir) { + if (!$dir || !in_array($dir, $this->dirs)) { throw new \Exception( - 'You must provide a valid dir value (home or current)' + sprintf( + 'You must provide a valid dir value (%s)', + implode(',', $this->dirs) + ) + ); + } + + $project = $input->getOption('project'); + if ($project && !in_array($project, $this->projects)) { + throw new \Exception( + sprintf( + 'You must provide a valid project value (%s)', + implode(',', $this->projects) + ) ); } @@ -74,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($dir === 'current') { - $this->copyCurrentDirectory($output, $config, $override); + $this->copyCurrentDirectory($output, $config, $override, $project); } if ($dir === 'home') { @@ -82,12 +118,18 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - private function copyCurrentDirectory($output, $config, $override) + private function copyCurrentDirectory($output, $config, $override, $project) { $baseConfigDirectory = $config->getBaseConfigDirectory(); $currentDirectory = $config->getApplicationDirectory(); $source = $baseConfigDirectory.'/../phpqa.yml'; + + $configFile = $baseConfigDirectory.$project.'/config.yml'; + if (file_exists($configFile)) { + $source = $configFile; + } + $destination = $currentDirectory.'phpqa.yml'; if ($this->copyFile($source, $destination, $override)) {