fix: replace console messages with unified command.

This commit is contained in:
James Cole
2023-06-20 07:16:56 +02:00
parent f2b2c2109f
commit 42043de34f
62 changed files with 767 additions and 512 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Console\Commands\VerifiesAccessToken;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Console\Command;
@@ -33,6 +34,7 @@ use Illuminate\Support\Facades\Schema;
class ForceMigration extends Command
{
use ShowsFriendlyMessages;
use VerifiesAccessToken;
/**
@@ -58,13 +60,13 @@ class ForceMigration extends Command
public function handle(): int
{
if (!$this->verifyAccessToken()) {
$this->error('Invalid access token.');
$this->friendlyError('Invalid access token.');
return 1;
}
$this->error('Running this command is dangerous and can cause data loss.');
$this->error('Please do not continue.');
$this->friendlyError('Running this command is dangerous and can cause data loss.');
$this->friendlyError('Please do not continue.');
$question = $this->confirm('Do you want to continue?');
if (true === $question) {
$user = $this->getUser();
@@ -80,16 +82,16 @@ class ForceMigration extends Command
private function forceMigration(): void
{
DB::commit();
$this->line('Dropping "migrations" table...');
$this->friendlyLine('Dropping "migrations" table...');
sleep(2);
Schema::dropIfExists('migrations');
$this->line('Re-run all migrations...');
$this->friendlyLine('Re-run all migrations...');
Artisan::call('migrate', ['--seed' => true]);
sleep(2);
$this->line('');
$this->line('There is a good chance you just saw a lot of error messages.');
$this->line('No need to panic yet. First try to access Firefly III (again).');
$this->line('The issue, whatever it was, may have been solved now.');
$this->line('');
$this->friendlyLine('');
$this->friendlyWarning('There is a good chance you just saw a lot of error messages.');
$this->friendlyWarning('No need to panic yet. First try to access Firefly III (again).');
$this->friendlyWarning('The issue, whatever it was, may have been solved now.');
$this->friendlyLine('');
}
}