2016-01-17 00:50:09 -06:00
|
|
|
<?php
|
2016-05-20 04:59:54 -05:00
|
|
|
/**
|
|
|
|
* UpgradeFireflyInstructions.php
|
2020-01-23 13:35:02 -06:00
|
|
|
* Copyright (c) 2020 james@firefly-iii.org
|
2016-05-20 04:59:54 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* 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.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 01:40:00 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-05-20 04:59:54 -05:00
|
|
|
*/
|
2016-01-17 00:50:09 -06:00
|
|
|
|
2018-05-11 03:08:34 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-01-17 00:50:09 -06:00
|
|
|
namespace FireflyIII\Console\Commands;
|
|
|
|
|
2020-06-05 23:57:44 -05:00
|
|
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
2016-01-17 00:50:09 -06:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Class UpgradeFireflyInstructions.
|
2018-08-23 11:33:07 -05:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
2016-01-17 00:50:09 -06:00
|
|
|
*/
|
|
|
|
class UpgradeFireflyInstructions extends Command
|
|
|
|
{
|
2020-06-05 23:57:44 -05:00
|
|
|
use GeneratesInstallationId;
|
|
|
|
|
2016-01-17 00:50:09 -06:00
|
|
|
/**
|
2016-01-19 06:59:54 -06:00
|
|
|
* The console command description.
|
2016-01-17 00:50:09 -06:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-07-15 15:26:08 -05:00
|
|
|
protected $description = 'Instructions in case of upgrade trouble.';
|
2016-01-17 00:50:09 -06:00
|
|
|
/**
|
2016-01-19 06:59:54 -06:00
|
|
|
* The name and signature of the console command.
|
2016-01-17 00:50:09 -06:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2017-01-20 03:08:38 -06:00
|
|
|
protected $signature = 'firefly:instructions {task}';
|
2016-01-17 00:50:09 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
2018-07-22 03:05:06 -05:00
|
|
|
public function handle(): int
|
2016-01-17 00:50:09 -06:00
|
|
|
{
|
2020-06-05 23:57:44 -05:00
|
|
|
$this->generateInstallationId();
|
2020-09-10 12:16:03 -05:00
|
|
|
if ('update' === (string)$this->argument('task')) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->updateInstructions();
|
|
|
|
}
|
2020-09-10 12:16:03 -05:00
|
|
|
if ('install' === (string)$this->argument('task')) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->installInstructions();
|
|
|
|
}
|
2020-03-21 09:43:41 -05:00
|
|
|
|
2018-07-22 03:05:06 -05:00
|
|
|
return 0;
|
2017-01-20 03:08:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-21 03:15:40 -05:00
|
|
|
* Render upgrade instructions.
|
2017-08-15 10:26:43 -05:00
|
|
|
*/
|
2021-03-21 03:15:40 -05:00
|
|
|
private function updateInstructions(): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
2016-04-26 14:40:15 -05:00
|
|
|
/** @var string $version */
|
|
|
|
$version = config('firefly.version');
|
2021-03-21 03:15:40 -05:00
|
|
|
$config = config('upgrade.text.upgrade');
|
|
|
|
$text = '';
|
2016-09-14 13:35:45 -05:00
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
// if string starts with:
|
2021-05-24 01:50:17 -05:00
|
|
|
if (str_starts_with($version, $compare)) {
|
2016-09-14 13:35:45 -05:00
|
|
|
$text = $config[$compare];
|
|
|
|
}
|
|
|
|
}
|
2020-03-20 12:05:40 -05:00
|
|
|
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->showLine();
|
|
|
|
$this->boxed('');
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null === $text) {
|
2021-03-21 03:15:40 -05:00
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s', $version));
|
|
|
|
$this->boxedInfo('There are no extra upgrade instructions.');
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxed('Firefly III should be ready for use.');
|
|
|
|
$this->boxed('');
|
|
|
|
$this->showLine();
|
2017-02-16 23:42:36 -06:00
|
|
|
|
2016-12-27 12:34:05 -06:00
|
|
|
return;
|
2016-01-17 00:50:09 -06:00
|
|
|
}
|
|
|
|
|
2021-03-21 03:15:40 -05:00
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s!', $version));
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxedInfo($text);
|
|
|
|
$this->boxed('');
|
|
|
|
$this->showLine();
|
|
|
|
}
|
2016-12-27 12:34:05 -06:00
|
|
|
|
2017-02-16 23:42:36 -06:00
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Show a line.
|
2017-02-16 23:42:36 -06:00
|
|
|
*/
|
2018-07-05 14:18:53 -05:00
|
|
|
private function showLine(): void
|
2017-02-16 23:42:36 -06:00
|
|
|
{
|
|
|
|
$line = '+';
|
2021-05-24 01:50:17 -05:00
|
|
|
$line .= str_repeat('-', 78);
|
2017-02-16 23:42:36 -06:00
|
|
|
$line .= '+';
|
|
|
|
$this->line($line);
|
|
|
|
}
|
|
|
|
|
2017-08-15 10:26:43 -05:00
|
|
|
/**
|
2021-03-21 03:15:40 -05:00
|
|
|
* Show a nice box.
|
|
|
|
*
|
|
|
|
* @param string $text
|
2017-08-15 10:26:43 -05:00
|
|
|
*/
|
2021-03-21 03:15:40 -05:00
|
|
|
private function boxed(string $text): void
|
|
|
|
{
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
foreach ($parts as $string) {
|
|
|
|
$this->line('| ' . sprintf('%-77s', $string) . '|');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a nice info box.
|
|
|
|
*
|
|
|
|
* @param string $text
|
|
|
|
*/
|
|
|
|
private function boxedInfo(string $text): void
|
|
|
|
{
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
foreach ($parts as $string) {
|
|
|
|
$this->info('| ' . sprintf('%-77s', $string) . '|');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render instructions.
|
|
|
|
*/
|
|
|
|
private function installInstructions(): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
|
|
|
/** @var string $version */
|
|
|
|
$version = config('firefly.version');
|
2021-03-21 03:15:40 -05:00
|
|
|
$config = config('upgrade.text.install');
|
|
|
|
$text = '';
|
2017-01-20 03:08:38 -06:00
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
// if string starts with:
|
2021-05-24 01:50:17 -05:00
|
|
|
if (str_starts_with($version, $compare)) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$text = $config[$compare];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->showLine();
|
|
|
|
$this->boxed('');
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null === $text) {
|
2021-03-21 03:15:40 -05:00
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
|
|
|
|
$this->boxedInfo('There are no extra installation instructions.');
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxed('Firefly III should be ready for use.');
|
|
|
|
$this->boxed('');
|
|
|
|
$this->showLine();
|
2017-02-16 23:42:36 -06:00
|
|
|
|
2017-01-20 03:08:38 -06:00
|
|
|
return;
|
|
|
|
}
|
2016-11-02 01:02:22 -05:00
|
|
|
|
2021-03-21 03:15:40 -05:00
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxedInfo($text);
|
|
|
|
$this->boxed('');
|
|
|
|
$this->showLine();
|
2016-01-17 00:50:09 -06:00
|
|
|
}
|
|
|
|
}
|