@@ -37,65 +37,65 @@ |
||
37 | 37 | |
38 | 38 | class Check extends Command { |
39 | 39 | |
40 | - /** |
|
41 | - * @var Installer $installer |
|
42 | - */ |
|
43 | - private $installer; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var AppManager $appManager |
|
47 | - */ |
|
48 | - private $appManager; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var UpdateChecker $updateChecker |
|
52 | - */ |
|
53 | - private $updateChecker; |
|
54 | - |
|
55 | - public function __construct(AppManager $appManager, UpdateChecker $updateChecker, Installer $installer) { |
|
56 | - parent::__construct(); |
|
57 | - $this->installer = $installer; |
|
58 | - $this->appManager = $appManager; |
|
59 | - $this->updateChecker = $updateChecker; |
|
60 | - } |
|
61 | - |
|
62 | - protected function configure(): void { |
|
63 | - $this |
|
64 | - ->setName('update:check') |
|
65 | - ->setDescription('Check for server and app updates') |
|
66 | - ; |
|
67 | - } |
|
68 | - |
|
69 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | - $updatesAvailableCount = 0; |
|
71 | - |
|
72 | - // Server |
|
73 | - $r = $this->updateChecker->getUpdateState(); |
|
74 | - if (isset($r['updateAvailable']) && $r['updateAvailable']) { |
|
75 | - $output->writeln($r['updateVersionString'] . ' is available. Get more information on how to update at '. $r['updateLink'] . '.'); |
|
76 | - $updatesAvailableCount += 1; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - // Apps |
|
81 | - $apps = $this->appManager->getInstalledApps(); |
|
82 | - foreach ($apps as $app) { |
|
83 | - $update = $this->installer->isUpdateAvailable($app); |
|
84 | - if ($update !== false) { |
|
85 | - $output->writeln('Update for ' . $app . ' to version ' . $update . ' is available.'); |
|
86 | - $updatesAvailableCount += 1; |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - // Report summary |
|
91 | - if ($updatesAvailableCount === 0) { |
|
92 | - $output->writeln('<info>Everything up to date</info>'); |
|
93 | - } elseif ($updatesAvailableCount === 1) { |
|
94 | - $output->writeln('<comment>1 update available</comment>'); |
|
95 | - } else { |
|
96 | - $output->writeln('<comment>' . $updatesAvailableCount . ' updates available</comment>'); |
|
97 | - } |
|
98 | - |
|
99 | - return 0; |
|
100 | - } |
|
40 | + /** |
|
41 | + * @var Installer $installer |
|
42 | + */ |
|
43 | + private $installer; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var AppManager $appManager |
|
47 | + */ |
|
48 | + private $appManager; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var UpdateChecker $updateChecker |
|
52 | + */ |
|
53 | + private $updateChecker; |
|
54 | + |
|
55 | + public function __construct(AppManager $appManager, UpdateChecker $updateChecker, Installer $installer) { |
|
56 | + parent::__construct(); |
|
57 | + $this->installer = $installer; |
|
58 | + $this->appManager = $appManager; |
|
59 | + $this->updateChecker = $updateChecker; |
|
60 | + } |
|
61 | + |
|
62 | + protected function configure(): void { |
|
63 | + $this |
|
64 | + ->setName('update:check') |
|
65 | + ->setDescription('Check for server and app updates') |
|
66 | + ; |
|
67 | + } |
|
68 | + |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | + $updatesAvailableCount = 0; |
|
71 | + |
|
72 | + // Server |
|
73 | + $r = $this->updateChecker->getUpdateState(); |
|
74 | + if (isset($r['updateAvailable']) && $r['updateAvailable']) { |
|
75 | + $output->writeln($r['updateVersionString'] . ' is available. Get more information on how to update at '. $r['updateLink'] . '.'); |
|
76 | + $updatesAvailableCount += 1; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + // Apps |
|
81 | + $apps = $this->appManager->getInstalledApps(); |
|
82 | + foreach ($apps as $app) { |
|
83 | + $update = $this->installer->isUpdateAvailable($app); |
|
84 | + if ($update !== false) { |
|
85 | + $output->writeln('Update for ' . $app . ' to version ' . $update . ' is available.'); |
|
86 | + $updatesAvailableCount += 1; |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + // Report summary |
|
91 | + if ($updatesAvailableCount === 0) { |
|
92 | + $output->writeln('<info>Everything up to date</info>'); |
|
93 | + } elseif ($updatesAvailableCount === 1) { |
|
94 | + $output->writeln('<comment>1 update available</comment>'); |
|
95 | + } else { |
|
96 | + $output->writeln('<comment>' . $updatesAvailableCount . ' updates available</comment>'); |
|
97 | + } |
|
98 | + |
|
99 | + return 0; |
|
100 | + } |
|
101 | 101 | } |