cli setup
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
import Login from "./account/Login.svelte";
|
||||
import Verify from "./account/Verify.svelte";
|
||||
import Profile from "./account/Profile.svelte";
|
||||
import SetupIndex from "./setup/Index.svelte";
|
||||
import { setContext } from "svelte";
|
||||
|
||||
const components = {
|
||||
@@ -11,7 +10,6 @@
|
||||
login: Login,
|
||||
verify: Verify,
|
||||
profile: Profile,
|
||||
setup: SetupIndex,
|
||||
};
|
||||
|
||||
export let title;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<script>
|
||||
import Step from "./Step.svelte";
|
||||
|
||||
export let channel;
|
||||
export let steps;
|
||||
export let allSuccess = false;
|
||||
</script>
|
||||
|
||||
<div
|
||||
style="text-align: center;background: var(--p20);padding: 20px;color: var(--p90)"
|
||||
>
|
||||
<h1>
|
||||
<a class="text-decoration-none" href={channel.lucentUrl}
|
||||
>{channel.name ?? "Lucent Setup"}</a
|
||||
>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="wrapper-tiny">
|
||||
{#each steps as step}
|
||||
<Step {step}></Step>
|
||||
{/each}
|
||||
|
||||
<div style="text-align: center;margin-top: 30px;">
|
||||
{#if allSuccess}
|
||||
<a href="/lucent/register" class="bt">Create the first user</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,63 +0,0 @@
|
||||
<script>
|
||||
import Icon from "../common/Icon.svelte";
|
||||
|
||||
export let step;
|
||||
</script>
|
||||
|
||||
<div class="step step-{step.status}">
|
||||
<div class="step-icon">
|
||||
{#if step.status === "success"}
|
||||
<Icon icon="check"></Icon>
|
||||
{:else}
|
||||
<Icon icon="close"></Icon>
|
||||
{/if}
|
||||
</div>
|
||||
<div style="width:100%">
|
||||
<h4>{step.name}</h4>
|
||||
<details>
|
||||
<summary>Instructions</summary>
|
||||
<code class="instructions">{step.instructions}</code>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.step-success .step-icon {
|
||||
background: var(--suc10);
|
||||
color: var(--suc100);
|
||||
}
|
||||
|
||||
.step-fail .step-icon {
|
||||
background: var(--err10);
|
||||
color: var(--err100);
|
||||
}
|
||||
|
||||
.step-icon {
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.step {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: start;
|
||||
gap: 10px;
|
||||
justify-content: space-between;
|
||||
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
details {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.instructions {
|
||||
margin-top: 20px;
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
background: var(--p10);
|
||||
white-space: break-spaces;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -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