cli setup
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Lucent\Setup\Data\SetupStepStatus;
|
||||
use Lucent\Setup\Step\ComposerStep;
|
||||
use Lucent\Setup\Step\DatabaseSetupStep;
|
||||
use Lucent\Setup\Step\LaravelEnvStep;
|
||||
use Lucent\Setup\Step\LucentConfigStep;
|
||||
use Lucent\Setup\Step\StorageLinkSetupStep;
|
||||
use Lucent\Setup\Step\StorageSetupStep;
|
||||
|
||||
class Setup extends Command
|
||||
{
|
||||
protected $signature = "lucent:setup";
|
||||
|
||||
protected $description = "Check the Lucent setup requirements";
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$steps = [
|
||||
new ComposerStep(),
|
||||
new LucentConfigStep(),
|
||||
new LaravelEnvStep(),
|
||||
new StorageLinkSetupStep(),
|
||||
new DatabaseSetupStep(),
|
||||
];
|
||||
|
||||
$allSuccess = true;
|
||||
|
||||
foreach ($steps as $step) {
|
||||
$result = $step();
|
||||
|
||||
if ($result->status === SetupStepStatus::SUCCESS) {
|
||||
$this->line(" <fg=green>✔</> {$result->name}");
|
||||
} else {
|
||||
$this->line(" <fg=red>✘</> {$result->name}");
|
||||
$this->line(" <fg=yellow>{$result->instructions}</>");
|
||||
$allSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
|
||||
if ($allSuccess) {
|
||||
$this->info("All checks passed. Lucent is ready.");
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$this->error("Some checks failed. Fix the issues above and run again.");
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,7 @@ use Lucent\Http\Controller\HomeController;
|
||||
use Lucent\Http\Controller\MemberController;
|
||||
use Lucent\Http\Controller\RecordController;
|
||||
use Lucent\Http\Controller\RevisionController;
|
||||
use Lucent\Http\Controller\SetupController;
|
||||
|
||||
Route::get("/lucent/setup", [SetupController::class, "setup"]);
|
||||
Route::get("/lfs-{disk}/{any}", [FileController::class, "fromDisk"])->where(
|
||||
"any",
|
||||
".*",
|
||||
|
||||
@@ -22,6 +22,7 @@ use Lucent\Commands\RemoveOrphanEdges;
|
||||
use Lucent\Commands\SetupDatabase;
|
||||
use Lucent\Commands\Export;
|
||||
use Lucent\Commands\Import;
|
||||
use Lucent\Commands\Setup;
|
||||
use Lucent\Data\ChannelAuth;
|
||||
use Lucent\File\FileService;
|
||||
use Lucent\Query\DatabaseGraph\DatabaseGraph;
|
||||
@@ -100,6 +101,7 @@ class LucentServiceProvider extends ServiceProvider
|
||||
GenerateCollectionSchema::class,
|
||||
Export::class,
|
||||
Import::class,
|
||||
Setup::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Setup\Step;
|
||||
|
||||
use Lucent\Setup\Data\SetupStep;
|
||||
|
||||
class StorageSetupStep implements IStep
|
||||
{
|
||||
|
||||
public function __invoke(): SetupStep
|
||||
{
|
||||
|
||||
$storage = config("filesystems.disks.lucent");
|
||||
|
||||
$name = "Storage setup";
|
||||
|
||||
$instructions = <<<EOD
|
||||
# You can use your local filesystem or s3 compatible storage. Lucent expects you to have a valid configuration inside config/filesystems.php
|
||||
# example:
|
||||
|
||||
return [
|
||||
'disks' => [
|
||||
'lucent' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
EOD;
|
||||
|
||||
|
||||
return match (!empty($storage)) {
|
||||
true => SetupStep::makeSuccess($name, $instructions),
|
||||
false => SetupStep::makeFail($name, $instructions),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user