/** * Stores the environment information for this build * * @return void * * @since 1.0 * @throws \DomainException */ private function storeEnvironmentData() { // Build the container $data = ['phpunit' => \PHPUnit_Runner_Version::id(), 'php' => PHP_VERSION, 'time' => (new \DateTime())->format('D, M d, Y \\a\\t H:i:s T')]; if (!file_put_contents(JPATH_ROOT . '/last_build.json', json_encode($data))) { $this->app->out('Can not write to path: ', JPATH_ROOT); throw new \DomainException('Can not write to path: ' . JPATH_ROOT . '/last_build.json'); } }
/** * Execute the command * * @return void * * @since 1.0 */ public function execute() { // Display status $this->app->out('Parsing the Composer data.'); // Get the Composer data $helper = new Helper(); $packages = $helper->parseComposer(); // Insert the records into the database now foreach ($packages as $name => $package) { // Check to see if the package is already in the database $packageID = $this->db->setQuery($this->db->getQuery(true)->select($this->db->quoteName('id'))->from($this->db->quoteName('#__packages'))->where($this->db->quoteName('package') . ' = ' . $this->db->quote($name))->where($this->db->quoteName('version') . ' = ' . $this->db->quote($package['version'])))->loadResult(); // If not present, insert it if (!$packageID) { $this->db->setQuery($this->db->getQuery(true)->insert($this->db->quoteName('#__packages'))->columns(array($this->db->quoteName('package'), $this->db->quoteName('version')))->values($this->db->quote($name) . ', ' . $this->db->quote($package['version'])))->execute(); } } // Display status $this->app->out('Finished parsing Composer data.'); }
/** * Execute the command * * @return void * * @since 1.0 */ public function execute() { // Check if caching is enabled $twigCache = $this->app->get('template.cache', false); if ($twigCache === false) { $this->app->out('Twig caching is disabled.'); return; } // Display status $this->app->out('Resetting Twig Cache.'); // First remove the existing cache files if (is_dir(JPATH_ROOT . '/' . $twigCache)) { foreach (Folder::folders(JPATH_ROOT . '/' . $twigCache) as $folder) { Folder::delete(JPATH_ROOT . '/' . $twigCache . '/' . $folder); } } // Now get a list of all the templates $files = Folder::files(JPATH_TEMPLATES, '.twig', true, true); // Load each template now /** @var \Joomla\Renderer\TwigRenderer $twigRenderer */ $twigRenderer = $this->app->getContainer()->get('renderer'); $engine = $twigRenderer->getRenderer(); $errorFiles = []; foreach ($files as $file) { $template = str_replace(JPATH_TEMPLATES . '/', '', $file); try { $engine->loadTemplate($template); } catch (\Twig_Error $e) { $errorFiles[] = $file; } } if (count($errorFiles)) { $msg = 'The following Twig resources failed to cache: ' . implode(', ', $errorFiles); } else { $msg = 'The cached Twig resources were successfully created.'; } $this->app->out($msg); }
/** * Process the main SQL file. * * @return $this * * @since 1.0 * @throws \RuntimeException * @throws \UnexpectedValueException */ private function processSql() { $fName = JPATH_ROOT . '/etc/schema.sql'; if (!file_exists($fName)) { throw new \UnexpectedValueException('Install SQL file not found.'); } $sql = file_get_contents($fName); if (!$sql) { throw new \UnexpectedValueException('Unable to read SQL file.'); } $this->app->out(sprintf('Creating tables from file %s', realpath($fName)), false); foreach ($this->db->splitSql($sql) as $query) { $q = trim($this->db->replacePrefix($query)); if (trim($q) == '') { continue; } $this->db->setQuery($q)->execute(); $this->app->out('.', false); } $this->app->out("\nFinished!"); return $this; }
/** * Execute the command. * * @return void * * @since 1.0 * @throws \DomainException * @throws \RuntimeException */ public function execute() { $this->app->out('Updating server to git HEAD'); // Pull from remote repo $this->app->runCommand('cd ' . JPATH_ROOT . ' && git pull 2>&1'); $this->app->out('Updating Composer resources'); // Run Composer update $this->app->runCommand('cd ' . JPATH_ROOT . ' && composer update 2>&1'); // Write the current build to a local file $this->app->out('Writing build info'); $path = JPATH_ROOT . '/current_SHA'; // Generate the build information; compile branch and SHA data; TODO need a tag for describe to work //$info = $this->app->runCommand('cd ' . JPATH_ROOT . ' && git describe --long --abbrev=10 --tags 2>&1'); $branch = $this->app->runCommand('cd ' . JPATH_ROOT . ' && git rev-parse --abbrev-ref HEAD 2>&1'); if (!file_put_contents($path, $branch)) { $this->app->out('Can not write to path: ', JPATH_ROOT); throw new \DomainException('Can not write to path: ' . $path); } $this->app->out('Update Finished'); }