Beispiel #1
0
 /**
  * Remove the files and directories created for this test.
  */
 public function tearDown()
 {
     if ($this->fs->exists($this->root)) {
         $this->fs->remove($this->root);
     }
     parent::tearDown();
 }
Beispiel #2
0
 /**
  * Executes the flo project-setup command.
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  *
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->checkGitRoot();
     $fs = new Filesystem();
     $helper = $this->getHelper('question');
     if ($fs->exists($this::FLO_YAML_PATH)) {
         throw new \Exception("flo.yml already exists.");
     }
     // Questions.
     $org_question = new Question('Please enter the name of the GitHub organization/username: '******'NBCUOTS');
     $repo_question = new Question('Please enter the name of your github repository: ');
     $shortname_question = new Question('Please enter project short name: ');
     $github_question = new Question('Please enter the GitHub git url: ');
     $acquia_question = new Question('Please enter the Acquia git url: ');
     $pull_request_question = new Question('Please enter the pull-request domain: ');
     $pull_request_prefix_question = new Question('Please enter the pull-request prefix (ex: p7): ');
     // Prompts.
     $organization = $helper->ask($input, $output, $org_question);
     $repository = $helper->ask($input, $output, $repo_question);
     $shortname = $helper->ask($input, $output, $shortname_question);
     $github_git_url = $helper->ask($input, $output, $github_question);
     $acquia_git_url = $helper->ask($input, $output, $acquia_question);
     $pull_request_domain = $helper->ask($input, $output, $pull_request_question);
     $pull_request_prefix = $helper->ask($input, $output, $pull_request_prefix_question);
     $flo_yml = array('organization' => $organization, 'repository' => $repository, 'shortname' => $shortname, 'github_git_uri' => $github_git_url, 'acquia_git_uri' => $acquia_git_url, 'pull_request' => array('domain' => $pull_request_domain, 'prefix' => $pull_request_prefix));
     $fs->dumpFile($this::FLO_YAML_PATH, Yaml::dump($flo_yml, 2, 2));
     if ($fs->exists($this::FLO_YAML_PATH)) {
         $output->writeln("<info>Flo.yml created.</info>");
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $destroy_prs = array();
     $pull_request = $this->getConfigParameter('pull_request');
     $pr_directories = $this->getConfigParameter('pr_directories');
     // Get deployed PR's based on directories in $pr_directories and compare
     // that to the PR's open on GitHub.
     if ($input->getOption('closed')) {
         $deployed_prs = array();
         $finder = new Finder();
         // @TODO need to ensure that prefix is alphanumeric ONLY.
         $pattern = '/^' . $pull_request['prefix'] . '\\-([0-9]+)/';
         $iterator = $finder->directories()->name($pattern)->depth(0)->in($pr_directories);
         foreach ($iterator as $directory) {
             preg_match($pattern, $directory->getFilename(), $matches);
             $deployed_prs[] = $matches[1];
         }
         if (!empty($deployed_prs)) {
             $github = $this->getGithub();
             $open_prs = array();
             $paginator = new Github\ResultPager($github);
             $prs = $paginator->fetchAll($github->api('pr'), 'all', array($this->getConfigParameter('organization'), $this->getConfigParameter('repository'), array('state' => 'open')));
             foreach ($prs as $pr) {
                 $open_prs[] = $pr['number'];
             }
             // PR's to destroy are deployed PR's that are not open.
             $destroy_prs = array_diff($deployed_prs, $open_prs);
         }
     } else {
         $pr_number = $input->getArgument('pull-request');
         if (!is_numeric($pr_number)) {
             throw new \Exception("PR must be a number.");
         }
         $destroy_prs[] = $pr_number;
     }
     if (!empty($destroy_prs)) {
         $fs = new Filesystem();
         $site_dir = $input->getOption('site-dir');
         foreach ($destroy_prs as $destroy_pr) {
             // @TODO get this path from a central place.
             $pr_path = rtrim($pr_directories, '/') . "/{$pull_request['prefix']}-{$destroy_pr}.{$pull_request['domain']}";
             if ($fs->exists($pr_path)) {
                 // Drop the database.
                 // @TODO set/get database name in central place, and use in DrupalSettings.
                 $database = $pull_request['prefix'] . '_' . $destroy_pr;
                 $process = new Process("drush sqlq 'DROP database {$database}'", $pr_path . "/docroot/sites/" . $site_dir);
                 $process->run();
                 // Remove the PR's web root.
                 $fs->remove($pr_path);
                 // @TODO destroy memcache bins.
                 $output->writeln("<info>Successfully destroyed PR #{$destroy_pr}</info>");
             }
         }
     } else {
         $output->writeln("<info>No PR's to destroy.</info>");
     }
 }
Beispiel #4
0
 /**
  * Process the New Release command.
  *
  * {@inheritDoc}
  *
  * - Update the version.php file
  * - Commit the change and tag it
  *
  * This command assumes you are running it from the root of the repository.
  * Additionally, this command makes changes to the master branch.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Get the version information from the project config.
     $config_vars = $this->getConfigParameter('vars');
     if (array_key_exists('version_file', $config_vars)) {
         $version_file = $config_vars['version_file'];
     } else {
         throw new \Exception("You must have a vars:version_file set up in your project-config.yml. Ex. version_file: ./version.php");
     }
     if (array_key_exists('version_constant', $config_vars)) {
         $version_constant = $config_vars['version_constant'];
     } else {
         throw new \Exception("You must have a vars:version_constant set up in your project-config.yml. Ex. version_constant: MY_PROJECT_VERSION");
     }
     // Determine the new version number.
     $increment = $input->getArgument('increment');
     try {
         // This will succeed when a specific version number is provided (as
         // opposed to "major" or "minor" or "patch"), otherwise an exception will
         // be thrown and the "catch" is used.
         $version = new version($increment);
         $version_number = $version->getVersion();
     } catch (\Exception $e) {
         // Get the current version from the version file if it exists. Otherwise
         // we're starting from scratch.
         if (file_exists($version_file)) {
             include $version_file;
         }
         $current_version = defined($version_constant) ? new version(constant($version_constant)) : new version('0.0.0');
         $version_number = $current_version->inc($increment);
     }
     // Update version file.
     $fs = new Filesystem();
     $fs->dumpFile($version_file, "<?php define('{$version_constant}', '{$version_number}');\n");
     $output->writeln("<info>Successfully updated the {$version_file} file and set the {$version_constant} to {$version_number}</info>");
     // Commit the updated version file.
     $process = new Process('git add ' . $version_file . ' && git commit -m "Preparing for new tag: ' . $version_number . '"');
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     // Tag the commit.
     $process = new Process('git tag ' . $version_number);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $dumper = new Dumper();
     $home_directory = $this->getHome();
     $flo_config_file = $home_directory . '/.config/flo';
     if (!$fs->exists($flo_config_file)) {
         $fs->dumpFile($flo_config_file, "");
         $output->writeln("<error>No flo config file exist.</error>");
     }
     $flo_config = Yaml::parse($flo_config_file);
     $config_name = $input->getArgument('config-name');
     $config_value = $input->getArgument('config-value');
     $flo_config[$config_name] = $config_value;
     $updated_config = $dumper->dump($flo_config, 1);
     $fs->dumpFile($flo_config_file, $updated_config);
     $output->writeln("<info>{$config_name}: {$config_value} has been saved.</info>");
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $dumper = new Dumper();
     $home_directory = $this->getHome();
     $flo_config_file = $home_directory . '/.config/flo';
     if (!$fs->exists($flo_config_file)) {
         return $output->writeln("<error>No flo config file exist.</error>");
     }
     $flo_config = Yaml::parse($flo_config_file);
     $config_name = $input->getArgument('config-name');
     if (isset($flo_config[$config_name])) {
         // If it exists remove the key and resaved the config file.
         unset($flo_config[$config_name]);
         $updated_config = $dumper->dump($flo_config, 1);
         $fs->dumpFile($flo_config_file, $updated_config);
         $output->writeln("<info>{$config_name} has been deleted.</info>");
     } else {
         // No config exist as info since they wanted to remove it anyways.
         $output->writeln("<info>No config key '{$config_name}' exist.</info>");
     }
 }
 /**
  * Remove the files and directories created for this test.
  */
 public function tearDown()
 {
     $fs = new Filesystem();
     if ($fs->exists($this->root)) {
         $fs->remove($this->root);
     }
 }
Beispiel #8
0
 /**
  * Remove the files and directories created for this test.
  */
 public function tearDown()
 {
     if ($this->fs->exists($this->file)) {
         $this->fs->remove($this->file);
     }
 }