style updates

This commit is contained in:
Mark Gregory
2026-07-24 14:59:44 +01:00
parent 24ab771cd3
commit dd23205d0b
482 changed files with 7173 additions and 1435 deletions
@@ -7,6 +7,7 @@ use Illuminate\Console\Command;
final class InspectModulesCommand extends Command
{
protected $signature = 'module:inspect {name?} {--json}';
protected $description = 'Validate module manifests and display dependencies and providers.';
public function handle(): int
@@ -16,8 +17,14 @@ final class InspectModulesCommand extends Command
$rows = [];
foreach ($files as $file) {
$manifest = json_decode((string) file_get_contents($file), true);
if (! is_array($manifest)) { $this->error("Invalid JSON: {$file}"); return self::FAILURE; }
if ($name && strcasecmp((string) ($manifest['name'] ?? ''), (string) $name) !== 0) { continue; }
if (! is_array($manifest)) {
$this->error("Invalid JSON: {$file}");
return self::FAILURE;
}
if ($name && strcasecmp((string) ($manifest['name'] ?? ''), (string) $name) !== 0) {
continue;
}
$rows[] = [
'name' => $manifest['name'] ?? basename(dirname($file)),
'version' => $manifest['version'] ?? 'unknown',
@@ -25,8 +32,13 @@ final class InspectModulesCommand extends Command
'providers' => count($manifest['providers'] ?? []),
];
}
if ($this->option('json')) { $this->line(json_encode($rows, JSON_PRETTY_PRINT)); return self::SUCCESS; }
if ($this->option('json')) {
$this->line(json_encode($rows, JSON_PRETTY_PRINT));
return self::SUCCESS;
}
$this->table(['Module', 'Version', 'Requires', 'Providers'], $rows);
return self::SUCCESS;
}
}
@@ -9,15 +9,24 @@ use Throwable;
final class MakeCrudCommand extends Command
{
protected $signature = 'crud:make {model} {--module=} {--force}';
protected $description = 'Generate model, migration, request, controller, views and test inside a module.';
public function handle(CrudGenerator $generator): int
{
$module = $this->option('module') ?: $this->choice('Select the target module', $this->modules());
try { $files = $generator->generate((string) $module, $this->argument('model'), (bool) $this->option('force')); }
catch (Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; }
foreach ($files as $file) { $this->line("<info>created</info> {$file}"); }
try {
$files = $generator->generate((string) $module, $this->argument('model'), (bool) $this->option('force'));
} catch (Throwable $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
foreach ($files as $file) {
$this->line("<info>created</info> {$file}");
}
$this->warn('Register the generated controller routes in the target module Routes/web.php file.');
return self::SUCCESS;
}
@@ -9,14 +9,24 @@ use Throwable;
final class MakeModuleCommand extends Command
{
protected $signature = 'module:make {name} {--force}';
protected $description = 'Generate a complete modular Laravel module scaffold.';
public function handle(ModuleGenerator $generator): int
{
try { $files = $generator->generate($this->argument('name'), (bool) $this->option('force')); }
catch (Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; }
foreach ($files as $file) { $this->line("<info>created</info> {$file}"); }
$this->newLine(); $this->info('Enable the module in modules_statuses.json, then run composer dump-autoload.');
try {
$files = $generator->generate($this->argument('name'), (bool) $this->option('force'));
} catch (Throwable $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
foreach ($files as $file) {
$this->line("<info>created</info> {$file}");
}
$this->newLine();
$this->info('Enable the module in modules_statuses.json, then run composer dump-autoload.');
return self::SUCCESS;
}
}
@@ -9,13 +9,22 @@ use Throwable;
final class MakeThemeCommand extends Command
{
protected $signature = 'theme:make {name} {--force}';
protected $description = 'Generate a theme scaffold with metadata, layout and assets.';
public function handle(ThemeGenerator $generator): int
{
try { $files = $generator->generate($this->argument('name'), (bool) $this->option('force')); }
catch (Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; }
foreach ($files as $file) { $this->line("<info>created</info> {$file}"); }
try {
$files = $generator->generate($this->argument('name'), (bool) $this->option('force'));
} catch (Throwable $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
foreach ($files as $file) {
$this->line("<info>created</info> {$file}");
}
return self::SUCCESS;
}
}
@@ -38,6 +38,7 @@ final class CrudGenerator extends Generator
private function controller(string $module, string $model): string
{
$plural = str($model)->plural()->kebab();
return "<?php\n\nnamespace Modules\\{$module}\\Http\\Controllers;\n\nuse Illuminate\\Http\\RedirectResponse;\nuse Illuminate\\View\\View;\nuse Modules\\{$module}\\Http\\Requests\\Store{$model}Request;\nuse Modules\\{$module}\\Models\\{$model};\n\nfinal class {$model}Controller\n{\n public function index(): View\n {\n return view('".str($module)->snake()."::admin.{$plural}.index', ['records' => {$model}::query()->latest()->paginate()]);\n }\n\n public function store(Store{$model}Request \$request): RedirectResponse\n {\n {$model}::query()->create(\$request->validated());\n return back()->with('status', '{$model} created.');\n }\n}\n";
}
+5 -2
View File
@@ -13,9 +13,12 @@ final class ThemeGenerator extends Generator
"$root/views/layouts/app.blade.php" => "<!DOCTYPE html><html lang=\"{{ str_replace('_', '-', app()->getLocale()) }}\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>{{ \$title ?? config('app.name') }}</title>@vite(['resources/css/app.css', 'resources/js/app.js'])</head><body>{{ \$slot }}</body></html>\n",
"$root/views/home.blade.php" => "<x-layouts.app><main><h1>{{ config('app.name') }}</h1></main></x-layouts.app>\n",
"$root/assets/css/theme.css" => ":root { --theme-radius: 0.5rem; }\n",
"$root/README.md" => "# ".str($name)->headline()." Theme\n\nGenerated by `php artisan theme:make {$name}`.\n",
"$root/README.md" => '# '.str($name)->headline()." Theme\n\nGenerated by `php artisan theme:make {$name}`.\n",
];
foreach ($files as $path => $contents) { $this->write($path, $contents, $force); }
foreach ($files as $path => $contents) {
$this->write($path, $contents, $force);
}
return array_keys($files);
}
}