2016-01-17 07:50:09 +01:00
|
|
|
|
<?php
|
2024-11-25 04:18:55 +01:00
|
|
|
|
|
2023-04-16 07:33:12 +02:00
|
|
|
|
/*
|
2016-05-20 11:59:54 +02:00
|
|
|
|
* UpgradeFireflyInstructions.php
|
2023-04-16 07:33:12 +02:00
|
|
|
|
* Copyright (c) 2023 james@firefly-iii.org
|
2016-05-20 11:59:54 +02:00
|
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
|
*
|
2019-10-02 06:37:26 +02: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 08:40:00 +02:00
|
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
|
*
|
2019-10-02 06:37:26 +02: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 11:59:54 +02:00
|
|
|
|
*/
|
2016-01-17 07:50:09 +01:00
|
|
|
|
|
2018-05-11 10:08:34 +02:00
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2023-04-16 07:33:12 +02:00
|
|
|
|
namespace FireflyIII\Console\Commands\System;
|
2016-01-17 07:50:09 +01:00
|
|
|
|
|
2025-05-27 17:02:18 +02:00
|
|
|
|
use Carbon\Carbon;
|
2020-06-06 06:57:44 +02:00
|
|
|
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
2016-01-17 07:50:09 +01:00
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
2024-12-27 09:30:41 +01:00
|
|
|
|
class OutputsInstructions extends Command
|
2016-01-17 07:50:09 +01:00
|
|
|
|
{
|
2020-06-06 06:57:44 +02:00
|
|
|
|
use GeneratesInstallationId;
|
|
|
|
|
|
2016-07-15 22:26:08 +02:00
|
|
|
|
protected $description = 'Instructions in case of upgrade trouble.';
|
2023-11-05 09:54:53 +01:00
|
|
|
|
|
2024-12-27 09:30:41 +01:00
|
|
|
|
protected $signature = 'firefly-iii:instructions {task=install}';
|
2016-01-17 07:50:09 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
*/
|
2018-07-22 10:05:06 +02:00
|
|
|
|
public function handle(): int
|
2016-01-17 07:50:09 +01:00
|
|
|
|
{
|
2020-06-06 06:57:44 +02:00
|
|
|
|
$this->generateInstallationId();
|
2023-11-04 19:06:47 +01:00
|
|
|
|
if ('update' === $this->argument('task')) {
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->updateInstructions();
|
|
|
|
|
}
|
2023-11-04 19:06:47 +01:00
|
|
|
|
if ('install' === $this->argument('task')) {
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->installInstructions();
|
|
|
|
|
}
|
2020-03-21 15:43:41 +01:00
|
|
|
|
|
2018-07-22 10:05:06 +02:00
|
|
|
|
return 0;
|
2017-01-20 10:08:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-21 12:34:58 +02:00
|
|
|
|
* Render upgrade instructions.
|
2023-05-07 20:17:29 +02:00
|
|
|
|
*/
|
2023-06-21 12:34:58 +02:00
|
|
|
|
private function updateInstructions(): void
|
2017-01-20 10:08:38 +01:00
|
|
|
|
{
|
2024-12-22 08:43:12 +01:00
|
|
|
|
$version = (string) config('firefly.version');
|
2023-12-20 19:35:52 +01:00
|
|
|
|
|
2023-11-26 12:10:42 +01:00
|
|
|
|
/** @var array $config */
|
2024-01-01 14:43:56 +01:00
|
|
|
|
$config = config('upgrade.text.upgrade');
|
|
|
|
|
$text = '';
|
2023-12-20 19:35:52 +01:00
|
|
|
|
|
2023-11-26 12:10:42 +01:00
|
|
|
|
/** @var string $compare */
|
2016-09-14 20:35:45 +02:00
|
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
|
// if string starts with:
|
2023-10-29 06:22:57 +01:00
|
|
|
|
if (str_starts_with($version, $compare)) {
|
2024-12-22 08:43:12 +01:00
|
|
|
|
$text = (string) $config[$compare];
|
2016-09-14 20:35:45 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-21 12:34:58 +02:00
|
|
|
|
|
2024-02-18 11:35:08 +01:00
|
|
|
|
// validate some settings.
|
2024-12-22 08:43:12 +01:00
|
|
|
|
if ('' === $text && 'local' === (string) config('app.env')) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$text = 'Please set APP_ENV=production for a safer environment.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$prefix = 'v';
|
2024-12-27 09:30:41 +01:00
|
|
|
|
if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$prefix = '';
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 06:58:35 +02:00
|
|
|
|
$this->newLine();
|
|
|
|
|
$this->showLogo();
|
|
|
|
|
$this->newLine();
|
2025-07-31 15:55:43 +02:00
|
|
|
|
$this->newLine();
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
2023-06-21 12:34:58 +02:00
|
|
|
|
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->boxed('');
|
2023-11-26 12:10:42 +01:00
|
|
|
|
if ('' === $text) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, %s%s', $prefix, $version));
|
2023-06-21 12:34:58 +02:00
|
|
|
|
$this->boxedInfo('There are no extra upgrade instructions.');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->boxed('Firefly III should be ready for use.');
|
|
|
|
|
$this->boxed('');
|
2024-12-27 09:30:41 +01:00
|
|
|
|
$this->donationText();
|
|
|
|
|
$this->boxed('');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
2017-02-17 06:42:36 +01:00
|
|
|
|
|
2016-12-27 19:34:05 +01:00
|
|
|
|
return;
|
2016-01-17 07:50:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$this->boxed(sprintf('Thank you for updating to Firefly III, %s%s!', $prefix, $version));
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->boxedInfo($text);
|
|
|
|
|
$this->boxed('');
|
2024-12-27 09:30:41 +01:00
|
|
|
|
$this->donationText();
|
|
|
|
|
$this->boxed('');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
|
|
|
|
}
|
2016-12-27 19:34:05 +01:00
|
|
|
|
|
2023-06-04 06:58:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* The logo takes up 8 lines of code. So 8 colors can be used.
|
|
|
|
|
*/
|
|
|
|
|
private function showLogo(): void
|
|
|
|
|
{
|
2025-05-27 17:02:18 +02:00
|
|
|
|
$today = Carbon::now()->format('m-d');
|
|
|
|
|
$month = Carbon::now()->format('m');
|
2023-06-04 06:58:35 +02:00
|
|
|
|
// variation in colors and effects just because I can!
|
|
|
|
|
// default is Ukraine flag:
|
|
|
|
|
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
|
|
|
|
|
|
|
|
|
|
// 5th of May is Dutch liberation day and 29th of April is Dutch King's Day and September 17 is my birthday.
|
|
|
|
|
if ('05-01' === $today || '04-29' === $today || '09-17' === $today) {
|
|
|
|
|
$colors = ['red', 'red', 'red', 'white', 'white', 'blue', 'blue', 'blue'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// National Coming Out Day, International Day Against Homophobia, Biphobia and Transphobia and Pride Month
|
|
|
|
|
if ('10-11' === $today || '05-17' === $today || '06' === $month) {
|
|
|
|
|
$colors = ['red', 'bright-red', 'yellow', 'green', 'blue', 'magenta', 'default', 'default'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// International Transgender Day of Visibility
|
|
|
|
|
if ('03-31' === $today) {
|
|
|
|
|
$colors = ['bright-blue', 'bright-red', 'white', 'white', 'bright-red', 'bright-blue', 'default', 'default'];
|
|
|
|
|
}
|
2025-08-24 17:14:07 +02:00
|
|
|
|
if ('ru_RU' === config('firefly.default_language')) {
|
|
|
|
|
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
|
|
|
|
|
}
|
2023-06-04 06:58:35 +02:00
|
|
|
|
|
2023-06-06 12:42:20 +02:00
|
|
|
|
$this->line(sprintf('<fg=%s> ______ _ __ _ _____ _____ _____ </>', $colors[0]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> | ____(_) / _| | |_ _|_ _|_ _| </>', $colors[1]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> | |__ _ _ __ ___| |_| |_ _ | | | | | | </>', $colors[2]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> | __| | | \'__/ _ \ _| | | | | | | | | | | </>', $colors[3]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> | | | | | | __/ | | | |_| | _| |_ _| |_ _| |_ </>', $colors[4]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> |_| |_|_| \___|_| |_|\__, | |_____|_____|_____| </>', $colors[5]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> __/ | </>', $colors[6]));
|
|
|
|
|
$this->line(sprintf('<fg=%s> |___/ </>', $colors[7]));
|
2025-07-31 15:55:43 +02:00
|
|
|
|
$this->someQuote();
|
2023-06-04 06:58:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 17:26:43 +02:00
|
|
|
|
/**
|
2023-06-21 12:34:58 +02:00
|
|
|
|
* Show a line.
|
2021-03-21 09:15:40 +01:00
|
|
|
|
*/
|
2023-06-21 12:34:58 +02:00
|
|
|
|
private function showLine(): void
|
|
|
|
|
{
|
2025-05-04 12:20:54 +02:00
|
|
|
|
$this->line(sprintf('+%s+', str_repeat('-', 78)));
|
2023-06-21 12:34:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show a nice box.
|
|
|
|
|
*/
|
|
|
|
|
private function boxed(string $text): void
|
|
|
|
|
{
|
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
|
foreach ($parts as $string) {
|
2023-12-20 19:35:52 +01:00
|
|
|
|
$this->line('| '.sprintf('%-77s', $string).'|');
|
2023-06-21 12:34:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show a nice info box.
|
|
|
|
|
*/
|
|
|
|
|
private function boxedInfo(string $text): void
|
|
|
|
|
{
|
|
|
|
|
$parts = explode("\n", wordwrap($text));
|
|
|
|
|
foreach ($parts as $string) {
|
2023-12-20 19:35:52 +01:00
|
|
|
|
$this->info('| '.sprintf('%-77s', $string).'|');
|
2023-06-21 12:34:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-04 17:41:26 +02:00
|
|
|
|
private function donationText(): void
|
|
|
|
|
{
|
|
|
|
|
$this->boxed('Did you know you can support the development of Firefly III?');
|
|
|
|
|
$this->boxed('You can donate in many ways, like GitHub Sponsors or Patreon.');
|
|
|
|
|
$this->boxed('For more information, please visit https://bit.ly/donate-to-Firefly-III');
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 12:34:58 +02:00
|
|
|
|
/**
|
|
|
|
|
* Render instructions.
|
|
|
|
|
*/
|
|
|
|
|
private function installInstructions(): void
|
2017-01-20 10:08:38 +01:00
|
|
|
|
{
|
2024-12-22 08:43:12 +01:00
|
|
|
|
$version = (string) config('firefly.version');
|
2023-12-20 19:35:52 +01:00
|
|
|
|
|
2023-11-26 12:10:42 +01:00
|
|
|
|
/** @var array $config */
|
2024-01-01 14:43:56 +01:00
|
|
|
|
$config = config('upgrade.text.install');
|
|
|
|
|
$text = '';
|
2023-12-20 19:35:52 +01:00
|
|
|
|
|
2023-11-26 12:10:42 +01:00
|
|
|
|
/** @var string $compare */
|
2017-01-20 10:08:38 +01:00
|
|
|
|
foreach (array_keys($config) as $compare) {
|
|
|
|
|
// if string starts with:
|
2023-10-29 06:22:57 +01:00
|
|
|
|
if (str_starts_with($version, $compare)) {
|
2024-12-22 08:43:12 +01:00
|
|
|
|
$text = (string) $config[$compare];
|
2017-01-20 10:08:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-18 11:35:08 +01:00
|
|
|
|
|
|
|
|
|
// validate some settings.
|
2024-12-22 08:43:12 +01:00
|
|
|
|
if ('' === $text && 'local' === (string) config('app.env')) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$text = 'Please set APP_ENV=production for a safer environment.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$prefix = 'v';
|
2024-02-22 01:29:01 +01:00
|
|
|
|
if (str_starts_with($version, 'develop')) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$prefix = '';
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 06:58:35 +02:00
|
|
|
|
$this->newLine();
|
|
|
|
|
$this->showLogo();
|
|
|
|
|
$this->newLine();
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
|
|
|
|
$this->boxed('');
|
2023-11-26 12:10:42 +01:00
|
|
|
|
if ('' === $text) {
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, %s%s!', $prefix, $version));
|
2023-06-21 12:34:58 +02:00
|
|
|
|
$this->boxedInfo('There are no extra installation instructions.');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->boxed('Firefly III should be ready for use.');
|
|
|
|
|
$this->boxed('');
|
2024-12-27 09:30:41 +01:00
|
|
|
|
$this->donationText();
|
|
|
|
|
$this->boxed('');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
2017-02-17 06:42:36 +01:00
|
|
|
|
|
2017-01-20 10:08:38 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-02 07:02:22 +01:00
|
|
|
|
|
2024-02-18 11:35:08 +01:00
|
|
|
|
$this->boxed(sprintf('Thank you for installing Firefly III, %s%s!', $prefix, $version));
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->boxedInfo($text);
|
|
|
|
|
$this->boxed('');
|
2024-12-27 09:30:41 +01:00
|
|
|
|
$this->donationText();
|
|
|
|
|
$this->boxed('');
|
2017-01-20 10:08:38 +01:00
|
|
|
|
$this->showLine();
|
2016-01-17 07:50:09 +01:00
|
|
|
|
}
|
2025-07-31 15:55:43 +02:00
|
|
|
|
|
|
|
|
|
private function someQuote(): void
|
|
|
|
|
{
|
2025-08-24 17:14:07 +02:00
|
|
|
|
$lines = [
|
2025-07-31 15:55:43 +02:00
|
|
|
|
'Forgive yourself for not being at peace.',
|
|
|
|
|
'Doesn\'t look like anything to me.',
|
|
|
|
|
'Be proud of what you make.',
|
|
|
|
|
'Be there or forever wonder.',
|
2025-08-01 13:10:11 +02:00
|
|
|
|
'A year from now you will wish you had started today.',
|
2025-07-31 15:55:43 +02:00
|
|
|
|
];
|
2025-08-24 17:14:07 +02:00
|
|
|
|
$addQuotes = true;
|
|
|
|
|
|
|
|
|
|
// fuck the Russian aggression in Ukraine.
|
|
|
|
|
|
|
|
|
|
// There is no point even trying to be neutral, because you can’t. When I say you can’t be neutral on
|
|
|
|
|
// a moving train, it means the world is already moving in certain directions. Children are going
|
|
|
|
|
// hungry, wars are taking place. In a situation like that, to be neutral or to try to be neutral,
|
|
|
|
|
// to stand aside, not to take a stand, not to participate, is to collaborate with whatever is
|
|
|
|
|
// going on, to allow that to happen.
|
|
|
|
|
|
|
|
|
|
if ('ru_RU' === config('firefly.default_language')) {
|
|
|
|
|
$addQuotes = false;
|
|
|
|
|
$lines = [
|
|
|
|
|
'🇺🇦 Слава Україні!',
|
|
|
|
|
'🇺🇦 Slava Ukraini!',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$random = random_int(0, count($lines) - 1);
|
|
|
|
|
if ($addQuotes) {
|
|
|
|
|
$this->line(sprintf(' "%s"', $lines[$random]));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->line(sprintf(' %s', $lines[$random]));
|
|
|
|
|
|
2025-07-31 15:55:43 +02:00
|
|
|
|
}
|
2016-01-17 07:50:09 +01:00
|
|
|
|
}
|