/** * @return int|null|void */ protected function serve() { $this->gpm = new GPM($this->input->getOption('force')); $packages = $this->input->getArgument('package'); $installed = false; if (!count($packages)) { $packages = ['grav']; } foreach ($packages as $package) { $package = strtolower($package); $name = null; $version = null; $updatable = false; if ($package == 'grav') { $name = 'Grav'; $version = GRAV_VERSION; $upgrader = new Upgrader(); if ($upgrader->isUpgradable()) { $updatable = ' [upgradable: v<green>' . $upgrader->getRemoteVersion() . '</green>]'; } } else { // get currently installed version $locator = \Grav\Common\Grav::instance()['locator']; $blueprints_path = $locator->findResource('plugins://' . $package . DS . 'blueprints.yaml'); if (!file_exists($blueprints_path)) { // theme? $blueprints_path = $locator->findResource('themes://' . $package . DS . 'blueprints.yaml'); if (!file_exists($blueprints_path)) { continue; } } $package_yaml = Yaml::parse(file_get_contents($blueprints_path)); $version = $package_yaml['version']; if (!$version) { continue; } $installed = $this->gpm->findPackage($package); if ($installed) { $name = $installed->name; if ($this->gpm->isUpdatable($package)) { $updatable = ' [updatable: v<green>' . $installed->available . '</green>]'; } } } $updatable = $updatable ?: ''; if ($installed || $package == 'grav') { $this->output->writeln('You are running <white>' . $name . '</white> v<cyan>' . $version . '</cyan>' . $updatable); } else { $this->output->writeln('Package <red>' . $package . '</red> not found'); } } }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->setupConsole($input, $output); $this->gpm = new GPM($this->input->getOption('force')); $packages = $this->input->getArgument('package'); $installed = false; if (!count($packages)) { $packages = ['grav']; } foreach ($packages as $package) { $package = strtolower($package); $name = null; $version = null; $updatable = false; if ($package == 'grav') { $name = 'Grav'; $version = GRAV_VERSION; $upgrader = new Upgrader(); if ($upgrader->isUpgradable()) { $updatable = ' [upgradable: v<green>' . $upgrader->getRemoteVersion() . '</green>]'; } } else { if ($installed = $this->gpm->findPackage($package)) { $name = $installed->name; $version = $installed->version; if ($this->gpm->isUpdatable($package)) { $updatable = ' [updatable: v<green>' . $installed->available . '</green>]'; } } } $updatable = $updatable ?: ''; if ($installed || $package == 'grav') { $this->output->writeln('You are running <white>' . $name . '</white> v<cyan>' . $version . '</cyan>' . $updatable); } else { $this->output->writeln('Package <red>' . $package . '</red> not found'); } } }
public static function selfupgrade() { $upgrader = new Upgrader(); if (!Installer::isGravInstance(GRAV_ROOT)) { return false; } if (is_link(GRAV_ROOT . DS . 'index.php')) { Installer::setError(Installer::IS_LINK); return false; } $update = $upgrader->getAssets()['grav-update']; $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid(); $file = self::_downloadSelfupgrade($update, $tmp); Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]); $errorCode = Installer::lastErrorCode(); Folder::delete($tmp); if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) { return false; } return true; }
public static function selfupgrade() { $upgrader = new Upgrader(); if (!Installer::isGravInstance(GRAV_ROOT)) { return false; } if (is_link(GRAV_ROOT . DS . 'index.php')) { Installer::setError(Installer::IS_LINK); return false; } if (!$upgrader->meetsRequirements()) { $error = []; $error[] = '<p>Grav has increased the minimum PHP requirement.<br />'; $error[] = 'You are currently running PHP <strong>' . PHP_VERSION . '</strong>'; $error[] = ', but PHP <strong>' . GRAV_PHP_MIN . '</strong> is required.</p>'; $error[] = '<p><a href="http://getgrav.org/blog/changing-php-requirements-to-5.5" class="button button-small secondary">Additional information</a></p>'; Installer::setError(implode("\n", $error)); return false; } $update = $upgrader->getAssets()['grav-update']; $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid(); $file = self::_downloadSelfupgrade($update, $tmp); Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]); $errorCode = Installer::lastErrorCode(); Folder::delete($tmp); if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) { return false; } return true; }