Example #1
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>Opens Git gui for the project "<info>%s</info>"</comment>', $projectName));
     if (!is_dir($projectConfig->getLocalGitRepositoryDir())) {
         throw new \RuntimeException(sprintf('The directory "%s" does not exist', $projectConfig->getLocalGitRepositoryDir()));
     }
     $this->getExec()->passthru($this->executable, $projectConfig->getLocalGitRepositoryDir());
 }
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>Git status for project "<info>%s</info>"</comment>', $projectName));
     if (!is_dir($projectConfig->getLocalGitRepositoryDir())) {
         throw new \RuntimeException(sprintf('The directory "%s" does not exist', $projectConfig->getLocalGitRepositoryDir()));
     }
     $this->getExec()->passthru('git status', $projectConfig->getLocalGitRepositoryDir());
     $output->writeln(strtr(ob_get_clean(), ['up-to-date' => '<info>up-to-date</info>', 'is behind' => '<info>is behind</info>', 'can be fast-forwarded' => '<info>can be fast-forwarded</info>', 'modified:' => '<info>modified:</info>', 'both modified' => '<error>both modified:</error>', 'deleted:' => '<error>deleted:</error>', 'deleted by us' => '<error>deleted by us</error>']));
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $this->getSshExec()->passthru(strtr('cd %project_dir% && /usr/local/bin/sami update sami_config.php' . ($output->isDebug() ? ' -v' : ''), ['%project_dir%' => $projectConfig->getRemoteWebappDir()]));
     $localBuildDir = sprintf('%s/build/apidoc', $projectConfig->getLocalWebappDir());
     $apiDocIndexFilepath = strtr('%build_dir%/index.html', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $localBuildDir]);
     if (file_exists($apiDocIndexFilepath)) {
         $this->openFile($apiDocIndexFilepath);
     }
 }
 protected function cloneGitProject($projectName, ProjectConfiguration $config, OutputInterface $output)
 {
     if (is_dir($config->getLocalGitRepositoryDir())) {
         $output->writeln(sprintf('<comment>A project with that name "<info>%s</info>" already exists</comment>', $projectName));
         return;
     }
     $output->writeln(sprintf('<comment>Create git project "<info>%s</info>" in "<info>%s</info>"</comment>', $projectName, $config->getLocalGitRepositoryDir()));
     $this->getExec()->run(strtr('git clone %git_repository_url% %local_git_repository_dir% && cd %local_git_repository_dir% && git checkout %git_target_branch%', ['%local_git_repository_dir%' => $config->getLocalGitRepositoryDir(), '%git_repository_url%' => $config->getGitRepositoryUrl(), '%git_target_branch%' => $config->getGitTargetBranch()]), $output);
 }
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $this->getApplication()->executeCommand('project:symfony:cache:clear', ['--project-name' => $projectName, '--symfony-env' => ['test']], $output);
     $buildReportHtmlPath = !empty($this->remoteBuildDir) ? '--testdox-html ' . $this->remoteBuildDir . '/tests/integration.html' : null;
     $this->getSshExec()->exec(strtr('phpunit --configuration %remote_phpunit_configuration_xml_path%  --colors %build_report_html% ' . ($output->isDebug() ? ' --verbose --debug' : ''), ['%project_dir%' => $projectConfig->getRemoteWebappDir(), '%remote_phpunit_configuration_xml_path%' => $projectConfig->getRemotePhpunitConfigurationXmlPath(), '%build_report_html%' => $buildReportHtmlPath]));
     if ($this->displayStatusText) {
         $output->writeln(sprintf('<comment>Executes integration tests for project "<info>%s</info>"</comment>: %s', $projectName, $this->getSshExec()->getLastReturnStatus() == 0 ? ' <info>SUCCESS</info>' : ' <error>ERROR</error>'));
     }
     return $this->getSshExec()->getLastReturnStatus();
 }
Example #6
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>%s for project "<info>%s</info>"</comment>', $this->getDescription(), $projectName));
     if (strpos($projectName, 'bundle') === false) {
         $commandLine = 'php-parallel-lint -e php -j 10 %project_dir%/app %project_dir%/src %project_dir%/web --exclude %project_dir%/vendor';
     } else {
         $commandLine = 'php-parallel-lint -e php -j 10 %project_dir%/src';
     }
     $this->getSshExec()->run(strtr($commandLine, ['%project_dir%' => $projectConfig->getRemoteWebappDir()]), $output, OutputInterface::VERBOSITY_NORMAL);
     return $this->getSshExec()->getLastReturnStatus();
 }
Example #7
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $returnStatus = 0;
     foreach ($this->getSymfonyEnvs() as $symfonyEnv) {
         $commandLine = strtr('%command_name% %command_arguments% %command_options%', ['%command_name%' => $this->symfonyCommandName, '%command_arguments%' => implode(' ', $this->symfonyCommandArguments), '%command_options%' => implode(' ', $this->symfonyCommandOptions)]);
         $this->getSymfonyRemoteConsoleExec()->exec($projectConfig->getRemoteSymfonyConsolePath(), $commandLine, $symfonyEnv, $output->getVerbosity());
         if (0 == $returnStatus) {
             $returnStatus = $this->getSymfonyRemoteConsoleExec()->getLastReturnStatus();
         }
     }
     return $returnStatus;
 }
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $remoteReportFilePath = strtr('%build_dir%/%project_name%.html', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $this->remoteBuildDir]);
     // Analyse source project code
     $this->getSshExec()->passthru(strtr('mkdir -p %build_dir% && /usr/local/bin/phpmetrics --level=0 --report-html=%report_file% %project_dir%/src' . ($output->isDebug() ? ' --verbose' : ''), ['%report_file%' => $remoteReportFilePath, '%build_dir%' => $this->remoteBuildDir, '%project_dir%' => $projectConfig->getRemoteWebappDir()]));
     $localReportFilePath = str_replace($this->remoteBuildDir, $this->localBuildDir, $remoteReportFilePath);
     $this->getRemoteFilesystem()->copyRemoteFileToLocal($remoteReportFilePath, $localReportFilePath);
     if ($this->getLocalFilesystem()->exists($localReportFilePath)) {
         $this->openFile($localReportFilePath);
     }
     return $this->getSshExec()->getLastReturnStatus();
 }
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $this->getSshExec()->passthru(strtr('cd %project_dir% && phpspec run --format=%format% --stop-on-failure ' . ($output->isDebug() ? ' --verbose' : ''), ['%format%' => $this->format, '%project_dir%' => $projectConfig->getRemoteWebappDir()]));
     $buildDir = $this->remoteBuildDir . '/tests';
     $this->getRemoteFilesystem()->mkdir($buildDir);
     $report = $this->getSshExec()->exec(strtr('cd %project_dir% && phpspec run --format=html --no-interaction > %build_dir%/unit.html', ['%project_dir%' => $projectConfig->getRemoteWebappDir(), '%build_dir%' => $buildDir]));
     $this->getRemoteFilesystem()->syncRemoteToLocal($this->remoteBuildDir, $this->localBuildDir, ['delete' => true]);
     $statusCode = $this->getSshExec()->getLastReturnStatus() == 0 && strpos($report, 'broken') === false ? 0 : 1;
     if ($this->displayStatusText) {
         $output->writeln(sprintf('<comment>Executes unit tests for project "<info>%s</info>"</comment>: %s', $projectName, $statusCode == 0 ? '<info>SUCCESS</info>' : '<error>ERROR</error>'));
     }
     return $statusCode;
 }
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $returnStatus = 0;
     foreach ($this->getSymfonyEnvs() as $symfonyEnv) {
         if (0 !== $returnStatus) {
             break;
         }
         $output->writeln(sprintf('<comment>%s for project "<info>%s</info>" and env "<info>%s</info>"</comment>', $this->getDescription(), $projectName, $symfonyEnv));
         $this->getSymfonyRemoteConsoleExec()->run($projectConfig->getRemoteSymfonyConsolePath(), strtr('assets:install %dir%', ['%dir%' => $projectConfig->getRemoteAssetsDir()]), $symfonyEnv, $output);
         $returnStatus = $this->getSymfonyRemoteConsoleExec()->getLastReturnStatus();
     }
     return $returnStatus;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $remoteBuildDir = sprintf('%s/apidoc', $this->getRemoteBuildDir());
     $localBuildDir = sprintf('%s/apidoc', $this->getLocalBuildDir());
     $this->getSshExec()->run(strtr('cd %project_dir% && sami.php update sami_config.php', ['%project_dir%' => $projectConfig->getRemoteWebappDir()]), $output, OutputInterface::VERBOSITY_NORMAL);
     $this->getRemoteFilesystem()->mkdir($remoteBuildDir);
     $this->getLocalFilesystem()->mkdir($localBuildDir);
     $this->getRemoteFilesystem()->syncRemoteToLocal($remoteBuildDir, $localBuildDir, ['delete' => true]);
     $apiDocIndexFilepath = strtr('%build_dir%/index.html', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $localBuildDir]);
     if (file_exists($apiDocIndexFilepath)) {
         $this->openFile($apiDocIndexFilepath);
     }
 }
Example #12
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $returnStatus = 0;
     foreach ($this->getSymfonyEnvs() as $symfonyEnv) {
         if (0 !== $returnStatus) {
             break;
         }
         $output->writeln(sprintf('<comment>%s for project "<info>%s</info>" and env "<info>%s</info>"</comment>', $this->getDescription(), $projectName, $symfonyEnv));
         if (!file_exists($projectConfig->getLocalVendorDir())) {
             $this->getApplication()->executeCommand('project:composer:install', ['--project-name' => $projectName], $output);
         }
         $this->getSymfonyRemoteConsoleExec()->run($projectConfig->getRemoteSymfonyConsolePath(), strtr('yaml:lint %project_dir%/src', ['%project_dir%' => $projectConfig->getRemoteWebappDir()]), $symfonyEnv, $output);
         $returnStatus = $this->getSymfonyRemoteConsoleExec()->getLastReturnStatus();
     }
     return $returnStatus;
 }
Example #13
0
 protected function getGiturl(ProjectConfiguration $projectConfig)
 {
     $giturl = $this->getExec()->exec('git config --get remote.' . $this->remote . '.url', $projectConfig->getLocalGitRepositoryDir());
     if ($this->getExec()->getLastReturnStatus() !== 0) {
         throw new \LogicException('Error retrieve git URL');
     }
     if (0 === strpos($giturl, 'git@')) {
         $giturl = str_replace(':', '/', $giturl);
         $giturl = str_replace('git@', 'http://', $giturl);
     }
     if (false !== strpos($giturl, '.git')) {
         $giturl = str_replace('.git', '', $giturl);
     }
     $branchName = null === $this->branchName ? $this->getCurrentBranch($projectConfig) : $this->branchName;
     $giturl .= '/tree/' . $branchName;
     return $giturl;
 }
Example #14
0
 /**
  * {@inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>Git %s for project "<info>%s</info>"</comment>', $this->getName(), $projectName));
     if (!is_dir($projectConfig->getLocalGitRepositoryDir())) {
         throw new \RuntimeException(sprintf('The directory "%s" does not exist', $projectConfig->getLocalGitRepositoryDir()));
     }
     if (empty($this->gitCommand)) {
         throw new \LogicException('Git command is empty');
     }
     if ($this->colorsConsoleOutput) {
         ob_start();
     }
     $this->getExec()->passthru(sprintf('git %s', $this->gitCommand), $projectConfig->getLocalGitRepositoryDir());
     if ($this->colorsConsoleOutput) {
         $output->writeln(strtr(ob_get_clean(), ['up-to-date' => '<info>up-to-date</info>', 'is behind' => '<info>is behind</info>', 'can be fast-forwarded' => '<info>can be fast-forwarded</info>', 'modified:' => '<info>modified:</info>', 'both modified' => '<error>both modified:</error>', 'deleted:' => '<error>deleted:</error>', 'deleted by us' => '<error>deleted by us</error>', '-  ' => '<error>- </error>', '+  ' => '<info>+</info>']));
     }
     return $this->getExec()->getLastReturnStatus();
 }
 protected function openProjectWithSublimeText(ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $projectConfigPath = sprintf('%s/sublimetext/%s.sublime-project', $this->configDir, $projectConfig->getProjectName());
     !$this->logger ?: $this->logger->debug(sprintf('Checks the existence of file %s', $projectConfigPath));
     if (!$this->getLocalFilesystem()->exists($projectConfigPath) || $this->rewritesConfigFile) {
         $configData = ['folders' => [['follow_symlinks' => false, 'name' => $projectConfig->getProjectName(), 'path' => realpath($projectConfig->getLocalGitRepositoryDir())], ['follow_symlinks' => false, 'name' => 'vendor', 'path' => realpath($projectConfig->getLocalVendorDir())]]];
         if ($projectConfig->getLocalAssetsDir()) {
             $configData['folders'][] = ['follow_symlinks' => false, 'name' => 'assets_project', 'path' => realpath($projectConfig->getLocalAssetsDir())];
         }
         foreach ($this->directoriesConfig as $configCommonDirectory) {
             $configData['folders'][] = $configCommonDirectory;
         }
         $content = json_encode($configData, JSON_PRETTY_PRINT);
         !$this->logger ?: $this->logger->debug(sprintf('Dumps project json config into a file "<info>%s</info>".', $projectConfigPath));
         $this->getLocalFilesystem()->dumpFile($projectConfigPath, $content);
     }
     if ('' !== exec('which subl')) {
         $commandLine = 'subl -n ' . $projectConfigPath . (defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`');
         !$this->logger ?: $this->logger->debug(sprintf('Executes command line %s', $commandLine));
         system($commandLine);
     } else {
         $output->writeln('<error><info>subl</info> command not found</error>');
     }
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>Git contributors for project "<info>%s</info>"</comment>', $projectName));
     if (!is_dir($projectConfig->getLocalGitRepositoryDir())) {
         throw new \RuntimeException(sprintf('The directory "%s" does not exist', $projectConfig->getLocalGitRepositoryDir()));
     }
     $output->writeln('repo age: ' . $this->getRepositoryAge($projectConfig->getLocalGitRepositoryDir()));
     $output->writeln('commits: ' . $this->getCommitCount($projectConfig->getLocalGitRepositoryDir()));
     $output->writeln('authors:');
     $output->writeln($this->getListAuthors($projectConfig->getLocalGitRepositoryDir()));
     $output->writeln('');
 }
Example #17
0
 protected function installCommandGitUp(ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     // Il faut utiliser l'option --user pour forcer l'installation en mode user only
     $output->writeln('<error>git up command doesn\'t exist.</error>');
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('Do you want to install git up? (y/n)', false);
     if (!$helper->ask($this->input, $output, $question)) {
         return;
     }
     if (!$this->commandExist('pip')) {
         $this->getExec()->run('sudo easy_install pip');
     }
     $this->getExec()->run('pip install --user git-up', $output, $projectConfig->getLocalGitRepositoryDir());
     if (0 == $this->getExec()->getLastReturnStatus()) {
         $output->writeln('<comment>Adding a path to the .bashrc file</comment>');
         $output->writeln('export PATH=$PATH:$HOME/.local/bin');
     }
     return $this->getExec()->getLastReturnStatus();
 }
 protected function getGraphComposer(ProjectConfiguration $projectConfig)
 {
     $composerJsonFileContent = $this->getRemoteFilesystem()->getRemoteFileContent($projectConfig->getRemoteWebappDir() . '/composer.json');
     $composerLockFileContent = $this->getRemoteFilesystem()->getRemoteFileContent($projectConfig->getRemoteWebappDir() . '/composer.lock');
     $installedFileContent = $this->getRemoteFilesystem()->getRemoteFileContent($projectConfig->getRemoteVendorDir() . '/composer/installed.json');
     if (null === $this->dependencyAnalyzer) {
         $this->dependencyAnalyzer = new DependencyAnalyzer();
     }
     $dependencyGraph = $this->dependencyAnalyzer->analyze($composerJsonFileContent, $composerLockFileContent, $installedFileContent);
     $class = $this->getGraphComposerClass();
     return new $class($dependencyGraph);
 }
Example #19
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $this->getSshExec()->passthru(strtr('cd %project_dir%;%command_name%', ['%project_dir%' => $projectConfig->getRemoteWebappDir(), '%command_name%' => escapeshellcmd($this->commandName)]));
     return $this->getSshExec()->getLastReturnStatus();
 }
 /**
  * {@inheritDoc}
  */
 public function remove(ProjectConfiguration $configuration)
 {
     $rows = [];
     foreach ($this->getProjectConfigurationCollection() as $row) {
         if ($configuration->getProjectName() == $row->getProjectName()) {
             continue;
         }
         $rows[] = $row;
     }
     $this->save($rows);
 }
Example #21
0
 /**
  * @param ProjectConfiguration $projectConfig
  * @param OutputInterface      $output
  *
  * @return int Exit code
  */
 protected function synchronizeRemoteProjectVendorToLocal(ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>Synchronize remote project vendor to local for the project "<info>%s</info>"</comment>', $projectConfig->getProjectName()));
     $this->getLocalFilesystem()->mkdir($projectConfig->getLocalVendorDir());
     return $this->getRemoteFilesystem()->syncRemoteToLocal($projectConfig->getRemoteVendorDir(), $projectConfig->getLocalVendorDir(), ['delete' => true]);
 }
Example #22
0
 protected function getTargetGitHookFile($gitHookName, ProjectConfiguration $projectConfig)
 {
     return sprintf('%s/%s', $projectConfig->getLocalGitHooksDir(), $gitHookName);
 }
Example #23
0
 /**
  * @{inheritdoc}
  */
 protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>%s for project "<info>%s</info>"</comment>', $this->getDescription(), $projectName));
     return $this->getPhpCsFixer()->fixRemoteDir($projectConfig->getRemoteWebappDir(), $output, ['level' => $this->level, 'dry-run' => !$this->fixCodingStandardProblems]);
 }
 protected function integrationTests(ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>%s for project "<info>%s</info>"</comment>', 'Running integration tests', $projectConfig->getProjectName()));
     return $this->getApplication()->executeCommand('project:tests:integration', ['--project-name' => $projectConfig->getProjectName(), '--no-display-status-text' => true], $output);
 }
 /**
  * {@inheritdoc}
  */
 public function remove(ProjectConfiguration $configuration)
 {
     $projectName = $configuration->getProjectName();
     if (isset($this->projectConfigs[$projectName])) {
         unset($this->projectConfigs[$projectName]);
     }
     $this->save();
 }
Example #26
0
 protected function getRemoteReportFilePath($format, ProjectConfiguration $projectConfig)
 {
     switch ($format) {
         case 'Checkstyle':
             return strtr('%build_dir%/%project_name%.xml', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $this->scssLintRemoteBuildDir]);
         case 'JSON':
             return strtr('%build_dir%/%project_name%.json', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $this->scssLintRemoteBuildDir]);
         case 'Default':
         default:
             return;
     }
 }