diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index cc9fd7143..66b17a10a 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -47,6 +47,10 @@ class UpdateCommand extends ConsoleCommand
*/
protected $gpm;
+ protected $all_yes;
+
+ protected $overwrite;
+
/**
*
*/
@@ -73,6 +77,12 @@ class UpdateCommand extends ConsoleCommand
InputOption::VALUE_NONE,
'Assumes yes (or best approach) instead of prompting'
)
+ ->addOption(
+ 'overwrite',
+ 'o',
+ InputOption::VALUE_NONE,
+ 'Option to overwrite packages if they already exist'
+ )
->addOption(
'plugins',
'p',
@@ -101,31 +111,40 @@ class UpdateCommand extends ConsoleCommand
{
$this->gpm = new GPM($this->input->getOption('force'));
+ $this->all_yes = $this->input->getOption('all-yes');
+ $this->overwrite = $this->input->getOption('overwrite');
+
$this->displayGPMRelease();
$this->destination = realpath($this->input->getOption('destination'));
- $skip_prompt = $this->input->getOption('all-yes');
if (!Installer::isGravInstance($this->destination)) {
$this->output->writeln("ERROR: " . Installer::lastErrorMsg());
exit;
}
if ($this->input->getOption('plugins') === false and $this->input->getOption('themes') === false) {
- $list_type_update = ['plugins' => true, 'themes' => true];
+ $list_type = ['plugins' => true, 'themes' => true];
} else {
- $list_type_update['plugins'] = $this->input->getOption('plugins');
- $list_type_update['themes'] = $this->input->getOption('themes');
+ $list_type['plugins'] = $this->input->getOption('plugins');
+ $list_type['themes'] = $this->input->getOption('themes');
+ }
+
+ if ($this->overwrite) {
+ $this->data = $this->gpm->getInstallable($list_type);
+ $description = " can be overwritten";
+ } else {
+ $this->data = $this->gpm->getUpdatable($list_type);
+ $description = " need updating";
}
- $this->data = $this->gpm->getUpdatable($list_type_update);
$only_packages = array_map('strtolower', $this->input->getArgument('package'));
- if (!$this->data['total']) {
+ if (!$this->overwrite && !$this->data['total']) {
$this->output->writeln("Nothing to update.");
exit;
}
- $this->output->write("Found " . $this->gpm->countInstalled() . " extensions installed of which " . $this->data['total'] . " need updating");
+ $this->output->write("Found " . $this->gpm->countInstalled() . " packages installed of which " . $this->data['total'] . "" . $description);
$limit_to = $this->userInputPackages($only_packages);
@@ -145,19 +164,23 @@ class UpdateCommand extends ConsoleCommand
continue;
}
+ if (!$package->available) {
+ $package->available = $package->version;
+ }
+
$this->output->writeln(
// index
str_pad($index++ + 1, 2, '0', STR_PAD_LEFT) . ". " .
// name
"" . str_pad($package->name, 15) . " " .
// version
- "[v" . $package->version . " ➜ v" . $package->available . "]"
+ "[v" . $package->version . " -> v" . $package->available . "]"
);
$slugs[] = $slug;
}
}
- if (!$skip_prompt) {
+ if (!$this->all_yes) {
// prompt to continue
$this->output->writeln("");
$questionHelper = $this->getHelper('question');
@@ -165,7 +188,7 @@ class UpdateCommand extends ConsoleCommand
$answer = $questionHelper->ask($this->input, $this->output, $question);
if (!$answer) {
- $this->output->writeln("Update aborted. Exiting...");
+ $this->output->writeln("Update aborted. Exiting...");
exit;
}
}
@@ -183,7 +206,7 @@ class UpdateCommand extends ConsoleCommand
$command_exec = $install_command->run($args, $this->output);
if ($command_exec != 0) {
- $this->output->writeln("Error: An error occurred while trying to install the extensions");
+ $this->output->writeln("Error: An error occurred while trying to install the packages");
exit;
}
}
@@ -204,7 +227,7 @@ class UpdateCommand extends ConsoleCommand
foreach ($only_packages as $only_package) {
$find = $this->gpm->findPackage($only_package);
- if (!$find || !$this->gpm->isUpdatable($find->slug)) {
+ if (!$find || (!$this->overwrite && !$this->gpm->isUpdatable($find->slug))) {
$name = isset($find->slug) ? $find->slug : $only_package;
$ignore[$name] = $name;
} else {