aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/App
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/App')
-rw-r--r--core/Command/App/Disable.php38
-rw-r--r--core/Command/App/Enable.php58
-rw-r--r--core/Command/App/GetPath.php54
-rw-r--r--core/Command/App/Install.php59
-rw-r--r--core/Command/App/ListApps.php99
-rw-r--r--core/Command/App/Remove.php57
-rw-r--r--core/Command/App/Update.php64
7 files changed, 171 insertions, 258 deletions
diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php
index 05d35053b13..121ad3f010c 100644
--- a/core/Command/App/Disable.php
+++ b/core/Command/App/Disable.php
@@ -1,26 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\App;
@@ -33,12 +15,12 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Disable extends Command implements CompletionAwareInterface {
- protected IAppManager $appManager;
protected int $exitCode = 0;
- public function __construct(IAppManager $appManager) {
+ public function __construct(
+ protected IAppManager $appManager,
+ ) {
parent::__construct();
- $this->appManager = $appManager;
}
protected function configure(): void {
@@ -63,14 +45,14 @@ class Disable extends Command implements CompletionAwareInterface {
}
private function disableApp(string $appId, OutputInterface $output): void {
- if ($this->appManager->isInstalled($appId) === false) {
+ if ($this->appManager->isEnabledForAnyone($appId) === false) {
$output->writeln('No such app enabled: ' . $appId);
return;
}
try {
$this->appManager->disableApp($appId);
- $appVersion = \OC_App::getAppVersion($appId);
+ $appVersion = $this->appManager->getAppVersion($appId);
$output->writeln($appId . ' ' . $appVersion . ' disabled');
} catch (\Exception $e) {
$output->writeln($e->getMessage());
@@ -83,7 +65,7 @@ class Disable extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeOptionValues($optionName, CompletionContext $context) {
+ public function completeOptionValues($optionName, CompletionContext $context): array {
return [];
}
@@ -92,7 +74,7 @@ class Disable extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
return array_diff(\OC_App::getEnabledApps(true, true), $this->appManager->getAlwaysEnabledApps());
}
diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php
index c7a071e27b5..3936acfbf6e 100644
--- a/core/Command/App/Enable.php
+++ b/core/Command/App/Enable.php
@@ -1,27 +1,10 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Sander Ruitenbeek <s.ruitenbeek@getgoing.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\App;
@@ -39,14 +22,14 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Enable extends Command implements CompletionAwareInterface {
- protected IAppManager $appManager;
- protected IGroupManager $groupManager;
protected int $exitCode = 0;
- public function __construct(IAppManager $appManager, IGroupManager $groupManager) {
+ public function __construct(
+ protected IAppManager $appManager,
+ protected IGroupManager $groupManager,
+ private Installer $installer,
+ ) {
parent::__construct();
- $this->appManager = $appManager;
- $this->groupManager = $groupManager;
}
protected function configure(): void {
@@ -75,7 +58,7 @@ class Enable extends Command implements CompletionAwareInterface {
protected function execute(InputInterface $input, OutputInterface $output): int {
$appIds = $input->getArgument('app-id');
$groups = $this->resolveGroupIds($input->getOption('groups'));
- $forceEnable = (bool) $input->getOption('force');
+ $forceEnable = (bool)$input->getOption('force');
foreach ($appIds as $appId) {
$this->enableApp($appId, $groups, $forceEnable, $output);
@@ -95,21 +78,18 @@ class Enable extends Command implements CompletionAwareInterface {
return $group->getDisplayName();
}, $groupIds);
- if ($this->appManager->isInstalled($appId) && $groupIds === []) {
+ if ($this->appManager->isEnabledForUser($appId) && $groupIds === []) {
$output->writeln($appId . ' already enabled');
return;
}
try {
- /** @var Installer $installer */
- $installer = \OC::$server->query(Installer::class);
-
- if (false === $installer->isDownloaded($appId)) {
- $installer->downloadApp($appId);
+ if ($this->installer->isDownloaded($appId) === false) {
+ $this->installer->downloadApp($appId);
}
- $installer->installApp($appId, $forceEnable);
- $appVersion = \OC_App::getAppVersion($appId);
+ $this->installer->installApp($appId, $forceEnable);
+ $appVersion = $this->appManager->getAppVersion($appId);
if ($groupIds === []) {
$this->appManager->enableApp($appId, $forceEnable);
@@ -147,7 +127,7 @@ class Enable extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeOptionValues($optionName, CompletionContext $context) {
+ public function completeOptionValues($optionName, CompletionContext $context): array {
if ($optionName === 'groups') {
return array_map(function (IGroup $group) {
return $group->getGID();
@@ -161,9 +141,9 @@ class Enable extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
- $allApps = \OC_App::getAllApps();
+ $allApps = $this->appManager->getAllAppsInAppsFolders();
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
}
return [];
diff --git a/core/Command/App/GetPath.php b/core/Command/App/GetPath.php
index 2ec72385191..3ba4ed7781b 100644
--- a/core/Command/App/GetPath.php
+++ b/core/Command/App/GetPath.php
@@ -1,35 +1,29 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\App;
use OC\Core\Command\Base;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class GetPath extends Base {
- protected function configure() {
+ public function __construct(
+ protected IAppManager $appManager,
+ ) {
+ parent::__construct();
+ }
+
+ protected function configure(): void {
parent::configure();
$this
@@ -46,20 +40,20 @@ class GetPath extends Base {
/**
* Executes the current command.
*
- * @param InputInterface $input An InputInterface instance
+ * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return int 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$appName = $input->getArgument('app');
- $path = \OC_App::getAppPath($appName);
- if ($path !== false) {
- $output->writeln($path);
- return 0;
+ try {
+ $path = $this->appManager->getAppPath($appName);
+ } catch (AppPathNotFoundException) {
+ // App not found, exit with non-zero
+ return self::FAILURE;
}
-
- // App not found, exit with non-zero
- return 1;
+ $output->writeln($path);
+ return self::SUCCESS;
}
/**
@@ -67,9 +61,9 @@ class GetPath extends Base {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app') {
- return \OC_App::getAllApps();
+ return $this->appManager->getAllAppsInAppsFolders();
}
return [];
}
diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php
index a699a2e7af0..c8a396c8e36 100644
--- a/core/Command/App/Install.php
+++ b/core/Command/App/Install.php
@@ -1,33 +1,15 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Maxopoly <max@dermax.org>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author sualko <klaus@jsxc.org>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\App;
use OC\Installer;
+use OCP\App\IAppManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -35,7 +17,14 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Install extends Command {
- protected function configure() {
+ public function __construct(
+ protected IAppManager $appManager,
+ private Installer $installer,
+ ) {
+ parent::__construct();
+ }
+
+ protected function configure(): void {
$this
->setName('app:install')
->setDescription('install an app')
@@ -67,34 +56,26 @@ class Install extends Command {
protected function execute(InputInterface $input, OutputInterface $output): int {
$appId = $input->getArgument('app-id');
- $forceEnable = (bool) $input->getOption('force');
+ $forceEnable = (bool)$input->getOption('force');
- if (\OC_App::getAppPath($appId)) {
+ if ($this->appManager->isEnabledForAnyone($appId)) {
$output->writeln($appId . ' already installed');
return 1;
}
try {
- /** @var Installer $installer */
- $installer = \OC::$server->query(Installer::class);
- $installer->downloadApp($appId, $input->getOption('allow-unstable'));
- $result = $installer->installApp($appId, $forceEnable);
+ $this->installer->downloadApp($appId, $input->getOption('allow-unstable'));
+ $result = $this->installer->installApp($appId, $forceEnable);
} catch (\Exception $e) {
$output->writeln('Error: ' . $e->getMessage());
return 1;
}
- if ($result === false) {
- $output->writeln($appId . ' couldn\'t be installed');
- return 1;
- }
-
- $appVersion = \OC_App::getAppVersion($appId);
+ $appVersion = $this->appManager->getAppVersion($appId);
$output->writeln($appId . ' ' . $appVersion . ' installed');
if (!$input->getOption('keep-disabled')) {
- $appClass = new \OC_App();
- $appClass->enable($appId);
+ $this->appManager->enableApp($appId);
$output->writeln($appId . ' enabled');
}
diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php
index 365ac48e080..dc947bea55f 100644
--- a/core/Command/App/ListApps.php
+++ b/core/Command/App/ListApps.php
@@ -1,27 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\App;
@@ -33,14 +14,13 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ListApps extends Base {
- protected IAppManager $manager;
-
- public function __construct(IAppManager $manager) {
+ public function __construct(
+ protected IAppManager $appManager,
+ ) {
parent::__construct();
- $this->manager = $manager;
}
- protected function configure() {
+ protected function configure(): void {
parent::configure();
$this
@@ -52,6 +32,18 @@ class ListApps extends Base {
InputOption::VALUE_REQUIRED,
'true - limit to shipped apps only, false - limit to non-shipped apps only'
)
+ ->addOption(
+ 'enabled',
+ null,
+ InputOption::VALUE_NONE,
+ 'shows only enabled apps'
+ )
+ ->addOption(
+ 'disabled',
+ null,
+ InputOption::VALUE_NONE,
+ 'shows only disabled apps'
+ )
;
}
@@ -62,32 +54,43 @@ class ListApps extends Base {
$shippedFilter = null;
}
- $apps = \OC_App::getAllApps();
+ $showEnabledApps = $input->getOption('enabled') || !$input->getOption('disabled');
+ $showDisabledApps = $input->getOption('disabled') || !$input->getOption('enabled');
+
+ $apps = $this->appManager->getAllAppsInAppsFolders();
$enabledApps = $disabledApps = [];
- $versions = \OC_App::getAppVersions();
+ $versions = $this->appManager->getAppInstalledVersions();
//sort enabled apps above disabled apps
foreach ($apps as $app) {
- if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) {
+ if ($shippedFilter !== null && $this->appManager->isShipped($app) !== $shippedFilter) {
continue;
}
- if ($this->manager->isInstalled($app)) {
+ if ($this->appManager->isEnabledForAnyone($app)) {
$enabledApps[] = $app;
} else {
$disabledApps[] = $app;
}
}
- $apps = ['enabled' => [], 'disabled' => []];
+ $apps = [];
- sort($enabledApps);
- foreach ($enabledApps as $app) {
- $apps['enabled'][$app] = $versions[$app] ?? true;
+ if ($showEnabledApps) {
+ $apps['enabled'] = [];
+
+ sort($enabledApps);
+ foreach ($enabledApps as $app) {
+ $apps['enabled'][$app] = $versions[$app] ?? true;
+ }
}
- sort($disabledApps);
- foreach ($disabledApps as $app) {
- $apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
+ if ($showDisabledApps) {
+ $apps['disabled'] = [];
+
+ sort($disabledApps);
+ foreach ($disabledApps as $app) {
+ $apps['disabled'][$app] = $this->appManager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
+ }
}
$this->writeAppList($input, $output, $apps);
@@ -99,14 +102,18 @@ class ListApps extends Base {
* @param OutputInterface $output
* @param array $items
*/
- protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
+ protected function writeAppList(InputInterface $input, OutputInterface $output, $items): void {
switch ($input->getOption('output')) {
case self::OUTPUT_FORMAT_PLAIN:
- $output->writeln('Enabled:');
- parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
-
- $output->writeln('Disabled:');
- parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
+ if (isset($items['enabled'])) {
+ $output->writeln('Enabled:');
+ parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
+ }
+
+ if (isset($items['disabled'])) {
+ $output->writeln('Disabled:');
+ parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
+ }
break;
default:
@@ -120,7 +127,7 @@ class ListApps extends Base {
* @param CompletionContext $context
* @return array
*/
- public function completeOptionValues($optionName, CompletionContext $context) {
+ public function completeOptionValues($optionName, CompletionContext $context): array {
if ($optionName === 'shipped') {
return ['true', 'false'];
}
@@ -132,7 +139,7 @@ class ListApps extends Base {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
return [];
}
}
diff --git a/core/Command/App/Remove.php b/core/Command/App/Remove.php
index 2aa453132e4..d43bfa96ccc 100644
--- a/core/Command/App/Remove.php
+++ b/core/Command/App/Remove.php
@@ -1,28 +1,10 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2018, Patrik Kernstock <info@pkern.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Patrik Kernstock <info@pkern.at>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Command\App;
@@ -39,18 +21,15 @@ use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
class Remove extends Command implements CompletionAwareInterface {
- protected IAppManager $manager;
- private Installer $installer;
- private LoggerInterface $logger;
-
- public function __construct(IAppManager $manager, Installer $installer, LoggerInterface $logger) {
+ public function __construct(
+ protected IAppManager $manager,
+ private Installer $installer,
+ private LoggerInterface $logger,
+ ) {
parent::__construct();
- $this->manager = $manager;
- $this->installer = $installer;
- $this->logger = $logger;
}
- protected function configure() {
+ protected function configure(): void {
$this
->setName('app:remove')
->setDescription('remove an app')
@@ -70,9 +49,9 @@ class Remove extends Command implements CompletionAwareInterface {
protected function execute(InputInterface $input, OutputInterface $output): int {
$appId = $input->getArgument('app-id');
- // Check if the app is installed
- if (!\OC_App::getAppPath($appId)) {
- $output->writeln($appId . ' is not installed');
+ // Check if the app is enabled
+ if (!$this->manager->isEnabledForAnyone($appId)) {
+ $output->writeln($appId . ' is not enabled');
return 1;
}
@@ -116,7 +95,7 @@ class Remove extends Command implements CompletionAwareInterface {
return 1;
}
- $appVersion = \OC_App::getAppVersion($appId);
+ $appVersion = $this->manager->getAppVersion($appId);
$output->writeln($appId . ' ' . $appVersion . ' removed');
return 0;
@@ -127,7 +106,7 @@ class Remove extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeOptionValues($optionName, CompletionContext $context) {
+ public function completeOptionValues($optionName, CompletionContext $context): array {
return [];
}
@@ -136,9 +115,9 @@ class Remove extends Command implements CompletionAwareInterface {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
- return \OC_App::getAllApps();
+ return $this->manager->getEnabledApps();
}
return [];
}
diff --git a/core/Command/App/Update.php b/core/Command/App/Update.php
index 6a6d43c28e5..71c7f84e5b0 100644
--- a/core/Command/App/Update.php
+++ b/core/Command/App/Update.php
@@ -1,33 +1,15 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2018, michag86 (michag86@arcor.de)
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author michag86 <micha_g@arcor.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Command\App;
use OC\Installer;
+use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
@@ -37,18 +19,15 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Update extends Command {
- protected IAppManager $manager;
- private Installer $installer;
- private LoggerInterface $logger;
-
- public function __construct(IAppManager $manager, Installer $installer, LoggerInterface $logger) {
+ public function __construct(
+ protected IAppManager $manager,
+ private Installer $installer,
+ private LoggerInterface $logger,
+ ) {
parent::__construct();
- $this->manager = $manager;
- $this->installer = $installer;
- $this->logger = $logger;
}
- protected function configure() {
+ protected function configure(): void {
$this
->setName('app:update')
->setDescription('update an app or all apps')
@@ -80,19 +59,20 @@ class Update extends Command {
protected function execute(InputInterface $input, OutputInterface $output): int {
$singleAppId = $input->getArgument('app-id');
+ $updateFound = false;
if ($singleAppId) {
$apps = [$singleAppId];
try {
$this->manager->getAppPath($singleAppId);
- } catch (\OCP\App\AppPathNotFoundException $e) {
+ } catch (AppPathNotFoundException $e) {
$output->writeln($singleAppId . ' not installed');
return 1;
}
} elseif ($input->getOption('all') || $input->getOption('showonly')) {
- $apps = \OC_App::getAllApps();
+ $apps = $this->manager->getAllAppsInAppsFolders();
} else {
- $output->writeln("<error>Please specify an app to update or \"--all\" to update all updatable apps\"</error>");
+ $output->writeln('<error>Please specify an app to update or "--all" to update all updatable apps"</error>');
return 1;
}
@@ -100,6 +80,7 @@ class Update extends Command {
foreach ($apps as $appId) {
$newVersion = $this->installer->isUpdateAvailable($appId, $input->getOption('allow-unstable'));
if ($newVersion) {
+ $updateFound = true;
$output->writeln($appId . ' new version available: ' . $newVersion);
if (!$input->getOption('showonly')) {
@@ -111,19 +92,28 @@ class Update extends Command {
'exception' => $e,
]);
$output->writeln('Error: ' . $e->getMessage());
+ $result = false;
$return = 1;
}
if ($result === false) {
$output->writeln($appId . ' couldn\'t be updated');
$return = 1;
- } elseif ($result === true) {
+ } else {
$output->writeln($appId . ' updated');
}
}
}
}
+ if (!$updateFound) {
+ if ($singleAppId) {
+ $output->writeln($singleAppId . ' is up-to-date or no updates could be found');
+ } else {
+ $output->writeln('All apps are up-to-date or no updates could be found');
+ }
+ }
+
return $return;
}
}