Exemplo n.º 1
0
 protected function installGitHook($gitHookName, ProjectConfiguration $projectConfig, OutputInterface $output)
 {
     $content = $this->renderTemplate($gitHookName, $projectConfig->getProjectName());
     $filename = $this->getTargetGitHookFile($gitHookName, $projectConfig);
     $this->getLocalFilesystem()->dumpFile($filename, $content);
     $this->getExec()->exec('chmod +x ' . $filename);
     $output->writeln(sprintf('<comment>Install git hook <info>%s</info> for project "<info>%s</info>"</comment>', $gitHookName, $projectConfig->getProjectName()));
 }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
 /**
  * @{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();
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
 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>');
     }
 }
 /**
  * {@inheritDoc}
  */
 public function remove(ProjectConfiguration $configuration)
 {
     $rows = [];
     foreach ($this->getProjectConfigurationCollection() as $row) {
         if ($configuration->getProjectName() == $row->getProjectName()) {
             continue;
         }
         $rows[] = $row;
     }
     $this->save($rows);
 }
 /**
  * {@inheritdoc}
  */
 public function remove(ProjectConfiguration $configuration)
 {
     $projectName = $configuration->getProjectName();
     if (isset($this->projectConfigs[$projectName])) {
         unset($this->projectConfigs[$projectName]);
     }
     $this->save();
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
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]);
 }
Exemplo n.º 10
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;
     }
 }