Skip to content

Commit

Permalink
feat: make plugin:install command able to also update the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantos42 committed Oct 11, 2024
1 parent dbee3c4 commit 0e5192d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*

### New commands

* New command `plugin:install` lets you install a plugin from the Marketplace.
* New command `plugin:install-or-update` lets you install or update a plugin from the Marketplace.

## Matomo 5.1.0

Expand Down
13 changes: 4 additions & 9 deletions plugins/CorePluginsAdmin/Commands/InstallPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class InstallPlugin extends ConsoleCommand
{
protected function configure(): void
{
$this->setName('plugin:install');
$this->setDescription('Install a plugin.');
$this->addOptionalArgument('plugin', 'The plugin name you want to install. Multiple plugin names can be specified separated by a space.', null, true);
$this->setName('plugin:install-or-update');
$this->setDescription('Install or update a plugin.');
$this->addOptionalArgument('plugin', 'The name of the plugin you want to install or update. Multiple plugin names can be specified separated by a space.', null, true);
}

protected function doExecute(): int
Expand All @@ -37,18 +37,13 @@ protected function doExecute(): int
$pluginManager = Manager::getInstance();

if (!Marketplace::isMarketplaceEnabled()) {
$output->writeln(sprintf("<error>Marketplace is not enabled, can't install plugins.</error>"));
$output->writeln(sprintf("<error>Marketplace is not enabled, can't install or update plugins.</error>"));
return self::FAILURE;
}

$pluginNames = $input->getArgument('plugin');

foreach ($pluginNames as $pluginName) {
if ($pluginManager->isPluginInstalled($pluginName)) {
$output->writeln(sprintf('<comment>The plugin %s is already installed.</comment>', $pluginName));
continue;
}

try {
$this->installPlugin($pluginName);
$output->writeln(sprintf("Installed plugin <info>%s</info>", $pluginName));
Expand Down

0 comments on commit 0e5192d

Please sign in to comment.