cli setup

This commit is contained in:
2026-05-07 21:38:07 +03:00
parent a5161cb6b4
commit daa4b268a6
7 changed files with 56 additions and 137 deletions
+54
View File
@@ -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;
}
}
-2
View File
@@ -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",
".*",
+2
View File
@@ -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,
]);
}
-42
View File
@@ -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),
};
}
}