Stop using "db_version", check versions instead.

This commit is contained in:
James Cole
2025-10-02 06:53:23 +02:00
parent 87d3d14504
commit 3b85f87502
5 changed files with 131 additions and 95 deletions

View File

@@ -26,16 +26,18 @@ namespace FireflyIII\Console\Commands\System;
use Carbon\Carbon;
use FireflyIII\Support\System\GeneratesInstallationId;
use FireflyIII\Support\System\IsOldVersion;
use Illuminate\Console\Command;
use Random\RandomException;
class OutputsInstructions extends Command
{
use GeneratesInstallationId;
use IsOldVersion;
protected $description = 'Instructions in case of upgrade trouble.';
protected $signature = 'firefly-iii:instructions {task=install}';
protected $signature = 'firefly-iii:instructions {task=install}';
/**
* Execute the console command.
@@ -58,26 +60,26 @@ class OutputsInstructions extends Command
*/
private function updateInstructions(): void
{
$version = (string) config('firefly.version');
$version = (string)config('firefly.version');
/** @var array $config */
$config = config('upgrade.text.upgrade');
$text = '';
$config = config('upgrade.text.upgrade');
$text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare];
$text = (string)$config[$compare];
}
}
// validate some settings.
if ('' === $text && 'local' === (string) config('app.env')) {
if ('' === $text && 'local' === (string)config('app.env')) {
$text = 'Please set APP_ENV=production for a safer environment.';
}
$prefix = 'v';
$prefix = 'v';
if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {
$prefix = '';
}
@@ -114,8 +116,8 @@ class OutputsInstructions extends Command
*/
private function showLogo(): void
{
$today = Carbon::now()->format('m-d');
$month = Carbon::now()->format('m');
$today = Carbon::now()->format('m-d');
$month = Carbon::now()->format('m');
// variation in colors and effects just because I can!
// default is Ukraine flag:
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
@@ -164,7 +166,7 @@ class OutputsInstructions extends Command
{
$parts = explode("\n", wordwrap($text));
foreach ($parts as $string) {
$this->line('| '.sprintf('%-77s', $string).'|');
$this->line('| ' . sprintf('%-77s', $string) . '|');
}
}
@@ -175,7 +177,7 @@ class OutputsInstructions extends Command
{
$parts = explode("\n", wordwrap($text));
foreach ($parts as $string) {
$this->info('| '.sprintf('%-77s', $string).'|');
$this->info('| ' . sprintf('%-77s', $string) . '|');
}
}
@@ -191,26 +193,26 @@ class OutputsInstructions extends Command
*/
private function installInstructions(): void
{
$version = (string) config('firefly.version');
$version = (string)config('firefly.version');
/** @var array $config */
$config = config('upgrade.text.install');
$text = '';
$config = config('upgrade.text.install');
$text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare];
$text = (string)$config[$compare];
}
}
// validate some settings.
if ('' === $text && 'local' === (string) config('app.env')) {
if ('' === $text && 'local' === (string)config('app.env')) {
$text = 'Please set APP_ENV=production for a safer environment.';
}
$prefix = 'v';
$prefix = 'v';
if (str_starts_with($version, 'develop')) {
$prefix = '';
}
@@ -242,14 +244,15 @@ class OutputsInstructions extends Command
private function someQuote(): void
{
$lines = [
'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.',
'A year from now you will wish you had started today.',
$lines = [
'"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."',
'"A year from now you will wish you had started today."',
'🇺🇦 Слава Україні!',
'🇺🇦 Slava Ukraini!',
];
$addQuotes = true;
// fuck the Russian aggression in Ukraine.
@@ -260,8 +263,7 @@ class OutputsInstructions extends Command
// going on, to allow that to happen.
if ('ru_RU' === config('firefly.default_language')) {
$addQuotes = false;
$lines = [
$lines = [
'🇺🇦 Слава Україні!',
'🇺🇦 Slava Ukraini!',
];
@@ -272,11 +274,6 @@ class OutputsInstructions extends Command
} catch (RandomException) {
$random = 0;
}
if ($addQuotes) {
$this->line(sprintf(' "%s"', $lines[$random]));
return;
}
$this->line(sprintf(' %s', $lines[$random]));
}