wip setup guide

This commit is contained in:
2024-09-06 20:59:56 +03:00
parent ab1517cc8f
commit ff54bcc2ef
13 changed files with 296 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Lucent\Setup\Data;
class SetupStep
{
public function __construct(
public string $name,
public string $instructions,
public SetupStepStatus $status,
)
{
}
public static function makeSuccess(string $name, string $instructions): self
{
return new self($name, $instructions, SetupStepStatus::SUCCESS);
}
public static function makeFail(string $name, string $instructions): self
{
return new self($name, $instructions, SetupStepStatus::FAIL);
}
}
+9
View File
@@ -0,0 +1,9 @@
<?php
namespace Lucent\Setup\Data;
enum SetupStepStatus: string
{
case SUCCESS = "success";
case FAIL = "fail";
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace Lucent\Setup;
use Lucent\Setup\Data\SetupStep;
class Setup
{
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace Lucent\Setup\Step;
use Lucent\Setup\Data\SetupStep;
class ComposerStep implements IStep
{
public function __invoke(): SetupStep
{
$composerFile = json_decode(file_get_contents(base_path("composer.json")), true);
$postAutoloadDumpList = data_get($composerFile, "scripts.post-autoload-dump", []);
$name = "Composer File";
$instructions = <<<EOD
# Append this line in post-autoload-dump in your composer.json.:
"@php artisan vendor:publish --tag=lucent --force"
example:
{
"scripts": {
"post-autoload-dump": [
"@php artisan vendor:publish --tag=lucent --force"
]
}
}
EOD;
return match (in_array("@php artisan vendor:publish --tag=lucent --force", $postAutoloadDumpList)) {
true => SetupStep::makeSuccess($name, $instructions),
false => SetupStep::makeFail($name, $instructions),
};
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Lucent\Setup\Step;
use Lucent\Setup\Data\SetupStep;
interface IStep
{
public function __invoke(): SetupStep;
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Lucent\Setup\Step;
use Lucent\Setup\Data\SetupStep;
class LucentConfigStep implements IStep
{
public function __invoke(): SetupStep
{
$lucentConfig = config("lucent.schemasPath");
$name = "Generate Lucent config";
$instructions = <<<EOD
# Run the following command to generate the configuration file:
php8.3 artisan vendor:publish --tag=lucent-config
# Choose "Lucent" from the prompted options.
A lucent.php file will be created in your config folder
EOD;
return match (!empty($lucentConfig)) {
true => SetupStep::makeSuccess($name, $instructions),
false => SetupStep::makeFail($name, $instructions),
};
}
}