2016-01-17 00:50:09 -06:00
|
|
|
<?php
|
2016-05-20 04:59:54 -05:00
|
|
|
/**
|
|
|
|
* UpgradeFireflyInstructions.php
|
2018-05-11 03:08:34 -05:00
|
|
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
2016-05-20 04:59:54 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* This file is part of Firefly III.
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 07:41:58 -06:00
|
|
|
* along with Firefly III. If not, see <http://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;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
/**
|
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
|
|
|
{
|
2018-07-25 23:10:17 -05:00
|
|
|
if ('update' === (string)$this->argument('task')) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->updateInstructions();
|
|
|
|
}
|
2018-07-25 23:10:17 -05:00
|
|
|
if ('install' === (string)$this->argument('task')) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->installInstructions();
|
|
|
|
}
|
2018-08-06 12:14:30 -05:00
|
|
|
|
2018-07-22 03:05:06 -05:00
|
|
|
return 0;
|
2017-01-20 03:08:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Show a nice box.
|
2017-01-20 03:08:38 -06:00
|
|
|
*
|
|
|
|
* @param string $text
|
|
|
|
*/
|
2018-07-05 14:18:53 -05:00
|
|
|
private function boxed(string $text): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
foreach ($parts as $string) {
|
2017-01-24 04:49:05 -06:00
|
|
|
$this->line('| ' . sprintf('%-77s', $string) . '|');
|
2017-01-20 03:08:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Show a nice info box.
|
2017-01-20 03:08:38 -06:00
|
|
|
*
|
|
|
|
* @param string $text
|
|
|
|
*/
|
2018-07-05 14:18:53 -05:00
|
|
|
private function boxedInfo(string $text): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
foreach ($parts as $string) {
|
2017-01-24 04:49:05 -06:00
|
|
|
$this->info('| ' . sprintf('%-77s', $string) . '|');
|
2017-01-20 03:08:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-15 10:26:43 -05:00
|
|
|
/**
|
|
|
|
* Render instructions.
|
|
|
|
*/
|
2018-07-05 14:18:53 -05:00
|
|
|
private function installInstructions(): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
2016-04-26 14:40:15 -05:00
|
|
|
/** @var string $version */
|
|
|
|
$version = config('firefly.version');
|
2017-01-20 03:08:38 -06:00
|
|
|
$config = config('upgrade.text.install');
|
|
|
|
$text = '';
|
2016-09-14 13:35:45 -05:00
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
// if string starts with:
|
2018-07-05 14:18:53 -05:00
|
|
|
if (0 === strpos($version, $compare)) {
|
2016-09-14 13:35:45 -05:00
|
|
|
$text = $config[$compare];
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->showLine();
|
|
|
|
$this->boxed('');
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null === $text) {
|
2017-08-15 10:26:43 -05:00
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxedInfo('There are no extra installation instructions.');
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
|
|
|
|
$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 = '+';
|
2017-11-15 05:25:49 -06:00
|
|
|
for ($i = 0; $i < 78; ++$i) {
|
2017-02-16 23:42:36 -06:00
|
|
|
$line .= '-';
|
|
|
|
}
|
|
|
|
$line .= '+';
|
|
|
|
$this->line($line);
|
|
|
|
}
|
|
|
|
|
2017-08-15 10:26:43 -05:00
|
|
|
/**
|
|
|
|
* Render upgrade instructions.
|
|
|
|
*/
|
2018-07-05 14:18:53 -05:00
|
|
|
private function updateInstructions(): void
|
2017-01-20 03:08:38 -06:00
|
|
|
{
|
|
|
|
/** @var string $version */
|
|
|
|
$version = config('firefly.version');
|
|
|
|
$config = config('upgrade.text.upgrade');
|
|
|
|
$text = '';
|
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
// if string starts with:
|
2018-07-05 14:18:53 -05:00
|
|
|
if (0 === strpos($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) {
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s', $version));
|
|
|
|
$this->boxedInfo('There are no extra upgrade instructions.');
|
|
|
|
$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
|
|
|
|
2017-01-20 03:08:38 -06:00
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s!', $version));
|
|
|
|
$this->boxedInfo($text);
|
|
|
|
$this->boxed('');
|
|
|
|
$this->showLine();
|
2016-01-17 00:50:09 -06:00
|
|
|
}
|
|
|
|
}
|