Skip to content

Commit

Permalink
Merge pull request #39 from ec-europa/improvement/MULTISITE-19240
Browse files Browse the repository at this point in the history
MULTISITE-19240: Toolkit compatibility
  • Loading branch information
jonhy81 authored Jan 26, 2018
2 parents be1ca44 + 3424cc2 commit 8ee4f4c
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
bin/phpcbf
bin/phpcs
bin/phpunit
bin/phing
composer.lock
vendor/
10 changes: 5 additions & 5 deletions bin/qa
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env php
<?php

use Symfony\Component\Console\Application;
use QualityAssurance\Component\Console\Command\CheckCodingStandardsCommand;
use QualityAssurance\Component\Console\Command\ScanCodingStandardsIgnoreCommand;
use QualityAssurance\Component\Console\Command\ScanCommentedCodeCommand;
Expand All @@ -15,6 +14,7 @@ use QualityAssurance\Component\Console\Command\DiffMakeFilesCommand;
use QualityAssurance\Component\Console\Command\ReviewThisCommand;
use QualityAssurance\Component\Console\Command\ReviewThemeCommand;
use QualityAssurance\Component\Console\Command\ReviewFullCommand;
use Symfony\Component\Console\Application;

if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
require $autoload;
Expand All @@ -32,8 +32,7 @@ if (is_file($autoload = __DIR__ . '/../vendor/autoload.php')) {
);
exit(1);
}

$application = new Application('Quality Assurance', '@package_version@');
$application = new Application();
$commands = array();
$commands[] = new ReviewThisCommand();
$commands[] = new ReviewThemeCommand();
Expand All @@ -44,9 +43,10 @@ $commands[] = new ScanCronCommand();
$commands[] = new ScanCommentedCodeCommand();
$commands[] = new ScanTodosCommand();
$commands[] = new ScanThemeNameConflict();
$commands[] = new CheckStarterkitCommand();
//$commands[] = new CheckStarterkitCommand();
$commands[] = new ScanPlatformProvidedCommand();
$commands[] = new DiffUpdateHooksCommand();
$commands[] = new DiffMakeFilesCommand();
$application->addCommands($commands);
$application->run();

$application->run();
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"symfony/console": "~2.3.10|^2.4.2|~3.0",
"symfony/finder": "^3.2",
"squizlabs/php_codesniffer": "2.9.0",
"wimg/php-compatibility": "^8.1"
"wimg/php-compatibility": "^8.1",
"phing/phing": "~2.16.0"
},
"require-dev": {
"phpunit/phpunit": ">=3.7 <5.0"
Expand Down
20 changes: 10 additions & 10 deletions src/Console/Command/CheckCodingStandardsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace QualityAssurance\Component\Console\Command;

use QualityAssurance\Component\Console\Helper\PhingPropertiesHelper;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -25,36 +26,35 @@ class CheckCodingStandardsCommand extends Command
protected function configure()
{
$phingPropertiesHelper = new PhingPropertiesHelper(new NullOutput());
$properties = $phingPropertiesHelper->requestSettings(array(
'phpcs-config' => 'phpcs.config',
'basedir' => 'project.basedir',
));
$properties = $phingPropertiesHelper->getAllSettings();

// @codingStandardsIgnoreStart
$this
->setName('phpcs:run')
->setDescription('Perform a phpcs run with provided phpcs.xml standard.')
->addOption('directory', null, InputOption::VALUE_OPTIONAL, 'Path to run PHPCS on.')
->addOption('standard', null, InputOption::VALUE_OPTIONAL, 'PHPCS standard.', $properties['phpcs-config'])
->addOption('standard', null, InputOption::VALUE_OPTIONAL, 'PHPCS standard.', $properties['phpcs.config'])
->addOption('exclude-dirs', null, InputOption::VALUE_OPTIONAL, 'Directories to exclude.')
->addOption('width', null, InputOption::VALUE_OPTIONAL, 'Width of the report.')
->addOption('show', null, InputOption::VALUE_NONE, 'If option is given description is shown.')
->addOption('basedir', null, InputOption::VALUE_REQUIRED, 'The project basedir to find phpcs.', $properties['basedir']);
->addOption('toolkit.dir.bin', null, InputOption::VALUE_REQUIRED, 'The binary to phpcs.', $properties['toolkit.dir.bin'])
->addOption('project.basedir', null, InputOption::VALUE_REQUIRED, 'The project basedir to find phpcs.', $properties['project.basedir']);
// @codingStandardsIgnoreEnd
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$dirname = !empty($input->getOption('directory')) ? $input->getOption('directory') : getcwd();

$dirname = !empty($input->getOption('directory')) ? $input->getOption('directory') : '';
// @codingStandardsIgnoreLine
$exclude_dirs = !empty($input->getOption('exclude-dirs')) ? '--ignore=' . $input->getOption('exclude-dirs') . ' ' : '';
$standard = !empty($input->getOption('standard')) ? $input->getOption('standard') : $properties['phpcs-config'];
$basedir = $input->getOption('basedir');
$standard = !empty($input->getOption('standard')) ? $input->getOption('standard') : '';
$basedir = $input->getOption('project.basedir');
$executable = $input->getOption('toolkit.dir.bin') . '/phpcs';

//$width = !empty($input->getOption('width')) ? $input->getOption('width') : 80;
$show = $input->getOption('show') ? true : false;
ob_start();
$executable = $basedir . "/ssk/phpcs";
passthru($executable . " --standard=$standard $exclude_dirs --report=emacs -qvs " . $dirname, $error);
$phpcs = ob_get_contents();
ob_end_clean();
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Command/CheckStarterkitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure()
->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'Starterkit branch.')
->addOption('remote', null, InputOption::VALUE_OPTIONAL, 'Starterkit remote.')
->addOption('repository', null, InputOption::VALUE_OPTIONAL, 'Starterkit repository on github.')
->addOption('basedir', null, InputOption::VALUE_OPTIONAL, 'Project base directory.')
->addOption('project.basedir', null, InputOption::VALUE_OPTIONAL, 'Project base directory.')
;
}

Expand All @@ -44,15 +44,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (empty($input->getOption('branch'))
|| empty($input->getOption('remote'))
|| empty($input->getOption('repository'))
|| empty($input->getOption('basedir'))
|| empty($input->getOption('project.basedir'))
) {
// Get the needed options for if the call came from console and not from phing.
$phingPropertiesHelper = new PhingPropertiesHelper($output);
$options = $phingPropertiesHelper->requestSettings(array(
'branch' => 'starterkit.branch',
'remote' => 'starterkit.remote',
'repository' => 'starterkit.repository',
'basedir' => 'project.basedir',
'project.basedir' => 'project.basedir',
));
}

Expand All @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$remote = !empty($input->getOption('remote')) ? $input->getOption('remote') : $options['remote'];
// @codingStandardsIgnoreLine
$repository = !empty($input->getOption('repository')) ? $input->getOption('repository') : $options['repository'];
$basedir = !empty($input->getOption('basedir')) ? $input->getOption('basedir') : $options['basedir'];
$basedir = !empty($input->getOption('project.basedir')) ? $input->getOption('project.basedir') : $options['project.basedir'];

$subsiteRepository = $this->getGitWrapper()->workingCopy($basedir);
// Add the remote for the starterkit if it doesn't exist yet.
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/ReviewThemeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$phingPropertiesHelper = new PhingPropertiesHelper($output);
$properties = $phingPropertiesHelper->requestSettings(array(
'lib' => 'subsite.resources.lib.dir',
'lib.dir' => 'lib.dir',
));
// Get the application
$application = $this->getApplication();
// Setup the reviewCommandHelper.
$reviewCommandHelper = new ReviewCommandThemeHelper($input, $output, $application);
// Change the lib property to the current folder.
$reviewCommandHelper->setProperties(array('lib' => $properties['lib']));
$reviewCommandHelper->setProperties(array('lib.dir' => $properties['lib.dir']));
// Start the review.
$reviewCommandHelper->startReview('theme');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/ReviewThisCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Setup the reviewCommandHelper.
$reviewCommandHelper = new ReviewCommandHelper($input, $output, $application);
// Change the lib property to the current folder.
$reviewCommandHelper->setProperties(array('lib' => getcwd()));
$reviewCommandHelper->setProperties(array('lib.dir' => getcwd()));
// Start the review.
$reviewCommandHelper->startReview();
}
Expand Down
15 changes: 8 additions & 7 deletions src/Console/Command/ScanCommentedCodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace QualityAssurance\Component\Console\Command;

use QualityAssurance\Component\Console\Helper\PhingPropertiesHelper;
use QualityAssurance\Component\Console\Application\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -25,9 +26,8 @@ class ScanCommentedCodeCommand extends Command
protected function configure()
{
$phingPropertiesHelper = new PhingPropertiesHelper(new NullOutput());
$properties = $phingPropertiesHelper->requestSettings(array(
'basedir' => 'project.basedir',
));
$properties = $phingPropertiesHelper->getAllSettings();

// @codingStandardsIgnoreStart
$this
->setName('scan:coco')
Expand All @@ -36,23 +36,24 @@ protected function configure()
->addOption('exclude-dirs', null, InputOption::VALUE_OPTIONAL, 'Directories to exclude.')
->addOption('width', null, InputOption::VALUE_OPTIONAL, 'Width of the report.')
->addOption('show', null, InputOption::VALUE_NONE, 'If option is given description is shown.')
->addOption('basedir', null, InputOption::VALUE_REQUIRED, 'The project basedir to find phpcs.', $properties['basedir']);
->addOption('toolkit.dir.bin', null, InputOption::VALUE_REQUIRED, 'The binary to phpcs.', $properties['toolkit.dir.bin'])
->addOption('project.basedir', null, InputOption::VALUE_REQUIRED, 'The project basedir to find phpcs.', $properties['project.basedir']);
// @codingStandardsIgnoreEnd
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$properties = array(
'basedir' => 'todo',
'project.basedir' => 'todo',
);
$dirname = !empty($input->getOption('directory')) ? $input->getOption('directory') : getcwd();
// @codingStandardsIgnoreLine
$exclude_dirs = !empty($input->getOption('exclude-dirs')) ? '--ignore=' . $input->getOption('exclude-dirs') . ' ' : '';
$basedir = !empty($input->getOption('basedir')) ? $input->getOption('basedir') : $properties['basedir'];
$basedir = !empty($input->getOption('project.basedir')) ? $input->getOption('project.basedir') : $properties['project.basedir'];
//$width = !empty($input->getOption('width')) ? $input->getOption('width') : 80;
$show = $input->getOption('show') ? true : false;
ob_start();
$executable = $basedir . "/ssk/phpcs";
$executable = $input->getOption('toolkit.dir.bin') . '/phpcs';
// @codingStandardsIgnoreLine
passthru($executable . " --standard=" . $basedir . "/resources/custom-rulesets/coco-50.xml $exclude_dirs --report=emacs -qvs " . $dirname, $error);
$phpcs = ob_get_contents();
Expand Down
9 changes: 7 additions & 2 deletions src/Console/Command/ScanPlatformProvidedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

namespace QualityAssurance\Component\Console\Command;

use QualityAssurance\Component\Console\Helper\PhingPropertiesHelper;
use QualityAssurance\Component\Console\Helper\DrupalInfoFormatHelper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;

Expand All @@ -23,13 +25,16 @@ class ScanPlatformProvidedCommand extends Command
{
protected function configure()
{
$phingPropertiesHelper = new PhingPropertiesHelper(new NullOutput());
$properties = $phingPropertiesHelper->getAllSettings();

$this
->setName('scan:mkpd')
->setDescription('Scan for platform provided modules.')
->addOption('directory', null, InputOption::VALUE_OPTIONAL, 'Path to recursively check.')
->addOption('exclude-dirs', null, InputOption::VALUE_OPTIONAL, 'Directories to exclude.')
->addOption('filename', null, InputOption::VALUE_OPTIONAL, 'Modulename.')
->addOption('profile', null, InputOption::VALUE_OPTIONAL, 'Profile.');
->addOption('filename', null, InputOption::VALUE_OPTIONAL, 'Modulename.', $properties['resources.dir.site.make'])
->addOption('profile', null, InputOption::VALUE_OPTIONAL, 'Profile.', $properties['profile']);
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Command/ScanThemeNameConflict.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$phingPropertiesHelper = new PhingPropertiesHelper($output);
$properties = $phingPropertiesHelper->requestSettings(array(
'lib' => 'subsite.resources.lib.dir',
'lib.dir' => 'lib.dir',
));

// Get the current theme name.
$theme_name = $input->getOption('filename');
if (!$theme_name) {
$application = $this->getApplication();
$reviewCommandHelper = new ReviewCommandThemeHelper($input, $output, $application);
$options = $reviewCommandHelper->getThemeFiles($properties['lib']);
$options = $reviewCommandHelper->getThemeFiles($properties['lib.dir']);
}
else {
$options[] = $theme_name;
Expand All @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$finder = new Finder();
$finder->files()
->name($theme_name . '.info')
->in($properties['lib'])
->in($properties['lib.dir'])
->exclude(array('themes'))
->sortByName();

Expand Down
Loading

0 comments on commit 8ee4f4c

Please sign in to comment.