mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
chore: Better handling errors during installation
This commit is contained in:
parent
9f21e5a879
commit
d55a823036
5 changed files with 50 additions and 17 deletions
|
@ -6,6 +6,7 @@ APP_NAME=Koel
|
|||
# pgsql (PostgreSQL)
|
||||
# sqlsrv (Microsoft SQL Server)
|
||||
# sqlite-persistent (Local sqlite file)
|
||||
# IMPORTANT: This value must present for artisan koel:init command to work.
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Exceptions\InstallationFailedException;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Repositories\SettingRepository;
|
||||
|
@ -53,13 +54,21 @@ class InitCommand extends Command
|
|||
$this->info('Running in no-interaction mode');
|
||||
}
|
||||
|
||||
$this->maybeGenerateAppKey();
|
||||
$this->maybeGenerateJwtSecret();
|
||||
$this->maybeSetUpDatabase();
|
||||
$this->migrateDatabase();
|
||||
$this->maybeSeedDatabase();
|
||||
$this->maybeSetMediaPath();
|
||||
$this->compileFrontEndAssets();
|
||||
try {
|
||||
$this->maybeGenerateAppKey();
|
||||
$this->maybeGenerateJwtSecret();
|
||||
$this->maybeSetUpDatabase();
|
||||
$this->migrateDatabase();
|
||||
$this->maybeSeedDatabase();
|
||||
$this->maybeSetMediaPath();
|
||||
$this->compileFrontEndAssets();
|
||||
} catch (Exception $e) {
|
||||
$this->error("Oops! Koel installation or upgrade didn't finish successfully.");
|
||||
$this->error('Please try again, or visit '.config('koel.misc.docs_url').' for manual installation.');
|
||||
$this->error('😥 Sorry for this. You deserve better.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->comment(PHP_EOL.'🎆 Success! Koel can now be run from localhost with `php artisan serve`.');
|
||||
|
||||
|
@ -67,10 +76,13 @@ class InitCommand extends Command
|
|||
$this->comment('You can also scan for media with `php artisan koel:sync`.');
|
||||
}
|
||||
|
||||
$this->comment('Again, for more configuration guidance, refer to');
|
||||
$this->info('📙 '.config('koel.misc.docs_url'));
|
||||
$this->comment('or open the .env file in the root installation folder.');
|
||||
$this->comment('Thanks for using Koel. You rock!');
|
||||
$this->comment('Again, visit 📙 '.config('koel.misc.docs_url').' for the official documentation.');
|
||||
$this->comment(
|
||||
"Feeling generous and want to support Koel's development? Check out "
|
||||
.config('koel.misc.sponsor_github_url')
|
||||
.' 🤗'
|
||||
);
|
||||
$this->comment('Thanks for using Koel. You rock! 🤘');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,16 +249,25 @@ class InitCommand extends Command
|
|||
{
|
||||
$this->info('Now to front-end stuff');
|
||||
|
||||
// We need to run two yarn commands:
|
||||
// We need to run several yarn commands:
|
||||
// - The first to install node_modules in the resources/assets submodule
|
||||
// - The second for the root folder, to build Koel's front-end assets with Mix.
|
||||
// - The second and third for the root folder, to build Koel's front-end assets with Mix.
|
||||
|
||||
chdir('./resources/assets');
|
||||
$this->info('├── Installing Node modules in resources/assets directory');
|
||||
system('yarn --colors');
|
||||
|
||||
$runOkOrThrow = static function (string $command): void {
|
||||
passthru($command, $status);
|
||||
throw_if((bool) $status, InstallationFailedException::class);
|
||||
};
|
||||
|
||||
$runOkOrThrow('yarn install --colors');
|
||||
|
||||
chdir('../..');
|
||||
$this->info('└── Compiling assets');
|
||||
system('yarn --colors');
|
||||
system('yarn production --colors');
|
||||
|
||||
$runOkOrThrow('yarn install --colors');
|
||||
$runOkOrThrow('yarn production --colors');
|
||||
}
|
||||
|
||||
/** @return array<string> */
|
||||
|
|
9
app/Exceptions/InstallationFailedException.php
Normal file
9
app/Exceptions/InstallationFailedException.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InstallationFailedException extends RuntimeException
|
||||
{
|
||||
}
|
|
@ -129,6 +129,8 @@ return [
|
|||
'misc' => [
|
||||
'home_url' => 'https://koel.phanan.net/',
|
||||
'docs_url' => 'https://koel.phanan.net/docs',
|
||||
'sponsor_github_url' => 'https://github.com/users/phanan/sponsorship',
|
||||
'sponsor_open_collective_url' => 'https://opencollective.com/koel',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d4bb207c3307dc69301db821586bd2383c29898a
|
||||
Subproject commit d197c9a443ce4adf4ae661b4abfad8e96555b138
|
Loading…
Reference in a new issue