public function configure()
 {
     if (!$this->isEnabled()) {
         return;
     }
     $default = $this->settings->getDefaultValueFor('phpSrcPath', array('src'));
     $this->settings['phpSrcPath'] = $this->multiplePathHelper->askPaths("At which paths is the PHP source code located?", implode(',', $default));
 }
 /**
  * Asks user what the path to Php source is.
  */
 public function configure()
 {
     $default = $this->settings->getDefaultValueFor('enablePhpTools', true);
     $this->settings['enablePhpTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for PHP?", $default);
     if ($this->settings['enablePhpTools']) {
         $this->output->writeln("\n<info>Configuring PHP inspections</info>\n");
     }
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enableComposer'] = false;
         return false;
     }
     $this->settings['enableComposer'] = $this->dialog->askConfirmation($this->output, "Do you want to run `./composer.phar install` on every commit?", $this->settings->getDefaultValueFor('enableComposer', false));
 }
 /**
  *
  */
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpLint'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpLint', true);
     $this->settings['enablePhpLint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Lint?", $default);
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpSecurityChecker'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpSecurityChecker', true);
     $this->settings['enablePhpSecurityChecker'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the Sensiolabs Security Checker?", $default);
 }
 /**
  * @inheritdoc
  * @codeCoverageIgnore
  */
 public function writeConfig()
 {
     $filesystem = new Filesystem();
     try {
         $filesystem->dumpFile($this->settings->getBaseDir() . '/phpmd.xml', $this->twig->render('phpmd.xml.dist', $this->settings->getArrayCopy()));
         $filesystem->dumpFile($this->settings->getBaseDir() . '/phpmd-pre-commit.xml', $this->twig->render('phpmd-pre-commit.xml.dist', $this->settings->getArrayCopy()));
     } catch (IOException $e) {
         $this->output->writeln(sprintf('<error>Could not write phpmd.xml, error: "%s"</error>', $e->getMessage()));
         return;
     }
     $this->output->writeln("\n<info>Config file for PHP Mess Detector written</info>");
 }
 /**
  * Asks user what the path to javascript source is.
  */
 public function configure()
 {
     if (!$this->settings['enableJsHint']) {
         return;
     }
     $baseDir = $this->settings->getBaseDir();
     $default = $this->settings->getDefaultValueFor('javaScriptSrcPath', 'src');
     $this->settings['javaScriptSrcPath'] = $this->dialog->askAndValidate($this->output, "What is the path to the JavaScript source code? [{$default}] ", function ($data) use($baseDir) {
         if (is_dir($baseDir . '/' . $data)) {
             return $data;
         }
         throw new \Exception("That path doesn't exist");
     }, false, $default);
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpCopyPasteDetection'] = false;
         return;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpCopyPasteDetection', false);
     $this->settings['enablePhpCopyPasteDetection'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Copy Paste Detection?", $default);
     if (!$this->settings['enablePhpCopyPasteDetection']) {
         return;
     }
     // Tests is the Symfony default
     $default = $this->settings->getDefaultValueFor('phpCpdExcludePatterns', 'Tests');
     $this->settings['phpCpdExcludePatterns'] = $this->multiplePathHelper->askPatterns(" - Which patterns should be excluded for PHP Copy Paste detection?", $default, " - Do you want to exclude patterns for PHP Copy Paste detection?");
 }
 /**
  * @param ConfiguratorInterface $configurator
  * @throws \RuntimeException
  */
 public function register(ConfiguratorInterface $configurator)
 {
     if (!$configurator instanceof ConfigurationWriterInterface) {
         parent::register($configurator);
         return;
     }
     // This really ought to be done differently... with proper DI and consistent usage of SF/Filesystem component
     // we could just write to tmp dirs and test it properly (see FilesystemTestCase in File component)
     $className = explode('\\', get_class($configurator));
     $className = end($className);
     $mockClass = "Ibuildings\\QA\\tests\\mock\\Configurator\\" . $className;
     if (!class_exists($mockClass)) {
         throw new \RuntimeException(sprintf('Configurator "%s" implements ConfigurationWriterInterface. A mock of this configurator should be' . 'made so that the writeConfig method does not write to disk but stores the contents', get_class($configurator)));
     }
     $requiresMultiplePathHelper = array('PhpMessDetectorConfigurator', 'PhpCodeSnifferConfigurator', 'PhpUnitConfigurator');
     if (in_array($className, $requiresMultiplePathHelper)) {
         $multiplePathHelper = new MultiplePathHelper($this->outputInterface, $this->dialogHelper, $this->settings->getBaseDir());
         $writingMockedConfigurator = new $mockClass($this->outputInterface, $this->dialogHelper, $multiplePathHelper, $this->settings, $this->twig);
     } elseif ($className === 'JsHintConfigurator') {
         $writingMockedConfigurator = new $mockClass($this->inputInterface, $this->outputInterface, $this->dialogHelper, $this->settings, $this->twig, $this->installJsHintCommand);
     } else {
         $writingMockedConfigurator = new $mockClass($this->outputInterface, $this->dialogHelper, $this->settings, $this->twig);
     }
     // should be resolved asap
     $this->configurators[get_class($configurator)] = $writingMockedConfigurator;
 }
Exemple #10
0
 /**
  * @throws \Exception
  * @return array
  */
 protected function parseComposerConfig()
 {
     if (!file_exists($this->settings->getBaseDir() . DIRECTORY_SEPARATOR . 'composer.json')) {
         throw new \Exception("Could not find composer.json in project root dir '" . $this->settings->getBaseDir() . "'");
     }
     $file = file_get_contents($this->settings->getBaseDir() . DIRECTORY_SEPARATOR . 'composer.json');
     $parsedFile = json_decode($file, true);
     if ($parsedFile === null) {
         throw new \Exception("Could not read composer.json. Is it valid JSON?");
     }
     $this->composerConfig = array();
     if (array_key_exists('config', $parsedFile)) {
         $this->composerConfig = $parsedFile['config'];
     }
     if (array_key_exists('bin-dir', $this->composerConfig)) {
         $this->settings['composerBinDir'] = $this->composerConfig['bin-dir'];
     } else {
         $this->settings['composerBinDir'] = 'vendor/bin';
     }
 }
 /**
  * Writes config file
  * @codeCoverageIgnore
  */
 public function writeConfig()
 {
     $filesystem = new Filesystem();
     try {
         $filesystem->dumpFile($this->settings->getBaseDir() . '/.jshintrc', $this->twig->render('.jshintrc.dist', $this->settings->getArrayCopy()));
     } catch (IOException $e) {
         $this->output->writeln(sprintf('<error>Could not write .jshintrc, error: "%s"</error>', $e->getMessage()));
         return;
     }
     $this->output->writeln("\n<info>Config file for JSHint written</info>");
 }
 /**
  * @return string
  */
 private function askSlackToken()
 {
     $question = "Please paste your slack credentials \n" . "  (see http://docs.travis-ci.com/user/notifications/#Slack-notifications): \n";
     // very basic validation
     $validator = function ($token) {
         // we must have a string, that contains a : not at the starting position
         // token format is username:hashedtoken
         if (is_string($token) && strpos($token, ':')) {
             return $token;
         }
         throw new \Exception("Please enter a valid token");
     };
     return $this->dialog->askAndValidate($this->output, $question, $validator, false, $this->settings->getDefaultValueFor('travis.slack.token', null));
 }
 /**
  * Install a Behat feature example.
  *
  * @param OutputInterface $output
  *
  * @codeCoverageIgnore
  */
 protected function writeBehatExamples(OutputInterface $output)
 {
     if (is_dir($this->settings['featuresDir'])) {
         $output->writeln("<error>Features directory already present. No example features are installed.</error>");
         return;
     }
     try {
         $filesystem = new Filesystem();
         $filesystem->mirror($this->settings->getPackageBaseDir() . '/config-dist/features', $this->settings['featuresDir']);
     } catch (\Exception $e) {
         $output->writeln("<error>Something went wrong when creating the features directory" . $e->getMessage() . "</error>");
         return;
     }
 }
 /**
  * Asks user what the path to javascript source is.
  */
 public function configure()
 {
     $default = $this->settings->getDefaultValueFor('enableJsTools', true);
     $this->settings['enableJsTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for Javascript?", $default);
 }
 /**
  * @return string
  */
 private function askArtifactWritePath()
 {
     $default = $this->settings->getDefaultValueFor('buildArtifacts.path', self::DEFAULT_ARTIFACT_PATH);
     return $this->dialog->askAndValidate($this->output, sprintf('Where do you want to store the build artifacts? [%s] ', $default), array($this, 'validateArtifactWritePath'), false, $default);
 }