public function writeConfig($destinationDir = null) { if (!$destinationDir) { $destinationDir = Platform::rootDir(); } return file_put_contents($destinationDir . '/' . self::PLATFORM_CONFIG, Yaml::dump($this->config, 2)); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { $now = new \DateTime(); // Hopefully this isn't too opinionated? $workingDir = dirname($this->behatLocation); if (!is_dir($workingDir . '/vendor')) { $output->writeln("<error>Assumed behat directory doesn't have depednencies installed: {$workingDir}."); exit(1); } // Try to find the Behat binary $composerData = json_decode(file_get_contents($workingDir . '/composer.json'), true); if (isset($composerData['config']['bin-dir'])) { $binDir = $composerData['config']['bin-dir']; } else { $binDir = 'vendor/bin/'; } $outPath = Platform::rootDir() . '/behat-run-' . $now->getTimestamp() . '.log'; $builder = ProcessBuilder::create([$binDir . 'behat', '--format=pretty', '--out=' . $outPath]); $builder->setWorkingDirectory($workingDir); $builder->setTimeout(null); $process = $builder->getProcess(); // @todo: export environment variables (postponed.) // @note there's also v2 v3 issues we'd have to sort out for exporting. // just run the dang thing. $output->writeln("<info>Running Behat, saving output to {$outPath}"); $this->startSeleniumContainer(); $process->run(); $this->stopSeleniumContainer(); if (!$process->isSuccessful()) { $output->writeln($process->getErrorOutput()); } }
public function testGetRootDir() { $this->assertEquals(self::$tmpName, Platform::rootDir()); mkdir(self::$tmpName . '/sub'); mkdir(self::$tmpName . '/sub/sub'); chdir(self::$tmpName . '/sub/sub'); $this->assertEquals(self::$tmpName, Platform::rootDir()); }
public function testAddExtras() { $config = new ComposeContainers(Platform::rootDir(), Platform::projectName()); $config->addRedis(); $config_converted = Yaml::parse($config->yaml()); $this->assertCount(4, $config_converted); $config->addSolr(); $config_converted = Yaml::parse($config->yaml()); $this->assertCount(5, $config_converted); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { $xhpfg = Platform::rootDir() . '/docker/xhpfg/xhprof-sample-to-flamegraph-stacks'; $fg = Platform::rootDir() . '/docker/fg/flamegraph.pl'; $xhprof = Platform::rootDir() . '/xhprof'; $graphName = $input->getArgument('filename'); $graphDestination = Platform::rootDir() . '/' . $graphName . '.svg'; exec("{$xhpfg} {$xhprof} | {$fg} > {$graphDestination}"); $url = 'file://' . $graphDestination; $this->openUrl($url); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $composeConfig = new ComposeConfig(); // Create docker folder in project. try { $composeConfig->ensureDirectories(); } catch (IOException $e) { $this->stdOut->writeln("<error>Error while trying to create docker-compose directories.</error>"); exit(1); } $composeConfig->copyImages(); $composeConfig->copyConfigs(); $composeContainers = new ComposeContainers(Platform::rootDir(), Config::get('name')); // @todo: With #20 and making tool provider aware, read those configs. Or push those configs to main. if (isset(Config::get()['services'])) { foreach (Config::get('services') as $service) { switch ($service) { case 'redis': $composeContainers->addRedis(); break; case 'solr': $composeContainers->addSolr(); break; case 'memcached': $composeContainers->addMemcached(); break; } } } $composeConfig->writeDockerCompose($composeContainers); // @todo move this into a static class to run configure based on type. $stack = Toolstack::inspect(Platform::webDir()); if ($stack) { $this->stdOut->writeln("<comment>Configuring stack:</comment> " . $stack->type()); switch ($stack->type()) { case Stacks\Drupal::TYPE: $drupal = new Drupal(); $drupal->configure(); break; case Stacks\WordPress::TYPE: $wordpress = new WordPress(); $wordpress->configure(); break; } } $this->stdOut->writeln('<info>Building the containers</info>'); Compose::build(); $this->stdOut->writeln('<info>Bringing up the containers</info>'); Compose::up(['-d']); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */ $process = $this->getHelper('process'); $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); if (!is_dir(Platform::rootDir() . '/docker/fg')) { $process->mustRun($output, ['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', Platform::rootDir() . '/docker/fg']); } if (!is_dir(Platform::rootDir() . '/docker/xhpfg')) { $process->mustRun($output, ['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', Platform::rootDir() . '/docker/xhpfg']); } $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>"); $patchProcess = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir()); $patchProcess->mustRun(); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $composeConfig = new ComposeConfig(); // Create docker folder in project. try { $composeConfig->ensureDirectories(); } catch (IOException $e) { $this->stdOut->writeln("<error>Error while trying to create docker-compose directories.</error>"); exit(1); } $composeConfig->copyImages(); $composeConfig->copyConfigs(); $composeContainers = new ComposeContainers(Platform::rootDir(), Config::get('name')); // @todo check if services.yml has redis $composeContainers->addRedis(); // @todo check to make this optional $composeContainers->addSolr(); $composeConfig->writeDockerCompose($composeContainers); // @todo move this into a static class to run configure based on type. $stack = Toolstack::getStackByDir(Platform::webDir()); if ($stack) { $this->stdOut->writeln("<comment>Configuring stack:</comment> " . $stack->type()); switch ($stack->type()) { case Stacks\Drupal::TYPE: $drupal = new Drupal(); $drupal->configure(); break; case Stacks\WordPress::TYPE: $wordpress = new WordPress(); $wordpress->configure(); break; } } $this->stdOut->writeln('<info>Building the containers</info>'); Compose::build(); $this->stdOut->writeln('<info>Bringing up the containers</info>'); Compose::up(['-d']); }
protected function discoverBehatYml() { $scanDirs = [Platform::sharedDir(), Platform::webDir(), Platform::rootDir() . '/tests']; if (is_dir(Platform::repoDir())) { $scanDirs[] = Platform::repoDir(); } $finder = new Finder(); $finder->files()->in($scanDirs)->name('behat.yml'); return $finder; }
/** * */ public function __construct() { $this->resourcesDir = CLI_ROOT . '/resources'; $this->projectPath = Platform::rootDir(); $this->fs = new Filesystem(); }