diff --git a/front/js/svelte/Account.svelte b/front/js/svelte/Account.svelte index 09cf17c..3dd51eb 100644 --- a/front/js/svelte/Account.svelte +++ b/front/js/svelte/Account.svelte @@ -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; diff --git a/front/js/svelte/setup/Index.svelte b/front/js/svelte/setup/Index.svelte deleted file mode 100644 index 0c8a37f..0000000 --- a/front/js/svelte/setup/Index.svelte +++ /dev/null @@ -1,20 +0,0 @@ - -
- - {#each steps as step} - - {/each} - -
- {#if allSuccess} - Create the first user - {/if} -
-
\ No newline at end of file diff --git a/front/js/svelte/setup/Step.svelte b/front/js/svelte/setup/Step.svelte deleted file mode 100644 index 955fb7e..0000000 --- a/front/js/svelte/setup/Step.svelte +++ /dev/null @@ -1,67 +0,0 @@ - - - -
-
- {#if step.status === "success"} - - {:else} - - {/if} -
-
-

{step.name}

-
- Instuctions - {step.instructions} -
-
- - -
- - \ No newline at end of file diff --git a/src/Commands/Setup.php b/src/Commands/Setup.php new file mode 100644 index 0000000..badd9b4 --- /dev/null +++ b/src/Commands/Setup.php @@ -0,0 +1,58 @@ +updateComposer(); + $this->call('vendor:publish', ['--tag' => 'lucent-config']); + $this->call('vendor:publish', ['--tag' => 'lucent']); + $this->database(); + $this->info("Head to /lucent in your browser to create the first user"); + + } + + private function updateComposer() + { + + if (!$this->confirm('Update composer.json?')) { + return; + } + + $composerFile = json_decode(file_get_contents(base_path("composer.json")), true); + $postAutoloadDumpList = data_get($composerFile, "scripts.post-autoload-dump", []); + + if (in_array("@php artisan vendor:publish --tag=lucent --force", $postAutoloadDumpList)) { + $this->info("Composer file was already correct"); + return; + } + + $composerFile["scripts"]["post-autoload-dump"][] = "@php artisan vendor:publish --tag=lucent --force"; + file_put_contents(base_path("composer.json"), json_encode($composerFile, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->info("Composer file was updated"); + + } + + private function database(): void + { + $databaseConnectionName = config("lucent.database"); + if (!$this->confirm("Your current database connection is $databaseConnectionName. Running the database migration script will wipe off any existing data. Run?")) { + return; + } + $this->call('lucent:setup-db'); + } + + +} diff --git a/src/Commands/SetupDatabase.php b/src/Commands/SetupDatabase.php index 8f7bdad..c08c2b2 100644 --- a/src/Commands/SetupDatabase.php +++ b/src/Commands/SetupDatabase.php @@ -18,8 +18,8 @@ class SetupDatabase extends Command { $dbConnection = config("lucent.database"); - $databasePath = config("database.connections.$dbConnection.database"); + $databasePath = config("database.connections.$dbConnection.database"); if(file_exists($databasePath)){ $this->error("Database already exists."); return 0; diff --git a/src/Http/Controller/SetupController.php b/src/Http/Controller/SetupController.php deleted file mode 100644 index b9d4dd0..0000000 --- a/src/Http/Controller/SetupController.php +++ /dev/null @@ -1,72 +0,0 @@ - array_merge($carry, [$setupStep()]), []); - $allSuccess = array_reduce($steps, fn(bool $carry, SetupStep $step) => !$carry ? false : $step->status === SetupStepStatus::SUCCESS, true); - - if($allSuccess){ - if ($this->accountService->countUsers() > 0) { - return redirect($this->channelService->channel->lucentUrl . "/login"); - } - } - - return $this->svelte->render( - layout: "account", - view: "setup", - title: "Setup Lucent", - data: [ - "steps" => $steps, - "allSuccess" => $allSuccess, - ] - - ); - } - - -} diff --git a/src/Http/web.php b/src/Http/web.php index 0da82e4..ccbac44 100644 --- a/src/Http/web.php +++ b/src/Http/web.php @@ -10,10 +10,8 @@ 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', '.*'); @@ -23,7 +21,6 @@ Route::group([ ], function () { - Route::middleware(['lucent.guest'])->group(function () { Route::get('/', [AuthController::class, 'login']); @@ -95,6 +92,5 @@ Route::group([ }); - }); diff --git a/src/LucentServiceProvider.php b/src/LucentServiceProvider.php index 397f9ba..5397d49 100644 --- a/src/LucentServiceProvider.php +++ b/src/LucentServiceProvider.php @@ -13,6 +13,7 @@ use Lucent\Commands\GenerateCollectionSchema; use Lucent\Commands\GenerateFileSchema; use Lucent\Commands\RebuildThumbnails; use Lucent\Commands\RemoveOrphanEdges; +use Lucent\Commands\Setup; use Lucent\Commands\SetupDatabase; use Lucent\Commands\UpgradeFiles122; use Lucent\File\FileService; @@ -75,6 +76,7 @@ class LucentServiceProvider extends ServiceProvider if ($this->app->runningInConsole()) { $this->commands([ + Setup::class, CompileSchemas::class, RebuildThumbnails::class, RemoveOrphanEdges::class, diff --git a/src/Setup/Data/SetupStep.php b/src/Setup/Data/SetupStep.php deleted file mode 100644 index d836a99..0000000 --- a/src/Setup/Data/SetupStep.php +++ /dev/null @@ -1,24 +0,0 @@ - SetupStep::makeSuccess($name, $instructions), - false => SetupStep::makeFail($name, $instructions), - }; - } -} \ No newline at end of file diff --git a/src/Setup/Step/DatabaseSetupStep.php b/src/Setup/Step/DatabaseSetupStep.php deleted file mode 100644 index aa63d7f..0000000 --- a/src/Setup/Step/DatabaseSetupStep.php +++ /dev/null @@ -1,60 +0,0 @@ - [ - '$databaseConnectionName' => [ - 'driver' => 'sqlite', - 'url' => env('LUCENT_DATABASE_URL'), - 'database' => env('LUCENT_DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - ], -EOD; - return SetupStep::makeFail($name, $instructions); - } - - - if(!in_array($driver = $databaseConfig["driver"],["sqlite","pgsql"])){ - $instructions = <<table("records")->get(); - } catch (QueryException $e) { - $instructions = <<getSchemeAndHttpHost()) { - true => SetupStep::makeSuccess($name, $instructions), - false => SetupStep::makeFail($name, $instructions), - }; - } -} \ No newline at end of file diff --git a/src/Setup/Step/LucentConfigStep.php b/src/Setup/Step/LucentConfigStep.php deleted file mode 100644 index 79f2bdb..0000000 --- a/src/Setup/Step/LucentConfigStep.php +++ /dev/null @@ -1,32 +0,0 @@ - SetupStep::makeSuccess($name, $instructions), - false => SetupStep::makeFail($name, $instructions), - }; - } -} \ No newline at end of file diff --git a/src/Setup/Step/StorageLinkSetupStep.php b/src/Setup/Step/StorageLinkSetupStep.php deleted file mode 100644 index 125da88..0000000 --- a/src/Setup/Step/StorageLinkSetupStep.php +++ /dev/null @@ -1,39 +0,0 @@ - !$carry ? false : is_link($link) , true); - - return match ($allLinksExist) { - true => SetupStep::makeSuccess($name, $instructions), - false => SetupStep::makeFail($name, $instructions), - }; - } -} \ No newline at end of file diff --git a/src/Setup/Step/StorageSetupStep.php b/src/Setup/Step/StorageSetupStep.php deleted file mode 100644 index 0206ad7..0000000 --- a/src/Setup/Step/StorageSetupStep.php +++ /dev/null @@ -1,42 +0,0 @@ - [ - '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), - }; - } -} \ No newline at end of file