Plugin-SDK: Oberflächen für Kunden-Plugins, Generator, Doku (0.20.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m46s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m49s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m7s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m46s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m49s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m7s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
46b7b05f94
commit
ea2200cb3e
353 changed files with 2151 additions and 1542 deletions
123
app/Console/Commands/MakePlugin.php
Normal file
123
app/Console/Commands/MakePlugin.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Plugins\PluginManifest;
|
||||
use App\Version;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Plugin-Generator (Plugin-SDK): erzeugt ein lauffähiges Plugin-Gerüst mit Seite,
|
||||
* Startseiten-Kachel, Build-Voreinstellung und Paketier-Skript.
|
||||
*/
|
||||
class MakePlugin extends Command
|
||||
{
|
||||
protected $signature = 'inhaus:make-plugin
|
||||
{slug : Kürzel, z. B. „mav-kalender“ (Kleinbuchstaben, Ziffern, Bindestriche)}
|
||||
{--name= : Anzeigename, z. B. „MAV-Kalender“}
|
||||
{--author= : Autor oder Organisation}
|
||||
{--path= : Zielordner (Standard: plugins/<slug>)}
|
||||
{--force : Vorhandenen Ordner überschreiben}';
|
||||
|
||||
protected $description = 'Neues Plugin mit Oberfläche anlegen (Plugin-SDK)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$slug = (string) $this->argument('slug');
|
||||
|
||||
if (! preg_match(PluginManifest::SLUG_PATTERN, $slug)) {
|
||||
$this->error('Das Kürzel darf nur Kleinbuchstaben, Ziffern und Bindestriche enthalten.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$target = rtrim((string) ($this->option('path') ?: base_path('plugins/'.$slug)), '/');
|
||||
|
||||
if (is_dir($target) && ! $this->option('force')) {
|
||||
$this->error("{$target} existiert bereits (--force zum Überschreiben).");
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$studly = Str::studly($slug);
|
||||
$namespace = 'Inhaus\\Plugins\\'.$studly;
|
||||
$name = (string) ($this->option('name') ?: Str::headline($slug));
|
||||
$versions = $this->frontendVersions();
|
||||
|
||||
$values = [
|
||||
'{{slug}}' => $slug,
|
||||
'{{name}}' => $name,
|
||||
'{{studly}}' => $studly,
|
||||
'{{namespace}}' => $namespace,
|
||||
'{{namespaceJson}}' => str_replace('\\', '\\\\', $namespace),
|
||||
'{{author}}' => (string) ($this->option('author') ?: 'Unbekannt'),
|
||||
'{{description}}' => "{$name} – ein Plugin für Inhaus.",
|
||||
'{{coreVersion}}' => Version::VERSION,
|
||||
'{{v_vite}}' => $versions['vite'],
|
||||
'{{v_vue}}' => $versions['vue'],
|
||||
'{{v_plugin_vue}}' => $versions['@vitejs/plugin-vue'],
|
||||
'{{v_tailwind}}' => $versions['tailwindcss'],
|
||||
'{{v_tailwind_vite}}' => $versions['@tailwindcss/vite'],
|
||||
];
|
||||
|
||||
$files = [
|
||||
'plugin.json' => 'plugin.json.stub',
|
||||
"src/{$studly}Plugin.php" => 'Plugin.php.stub',
|
||||
'src/Http/Controllers/IndexController.php' => 'Controller.php.stub',
|
||||
'routes/web.php' => 'web.php.stub',
|
||||
'resources/js/pages/Index.vue' => 'Index.vue.stub',
|
||||
'resources/js/widgets/Hello.vue' => 'Hello.vue.stub',
|
||||
'resources/css/style.css' => 'style.css.stub',
|
||||
'vite.config.js' => 'vite.config.js.stub',
|
||||
'package.json' => 'package.json.stub',
|
||||
'bin/package' => 'package.stub',
|
||||
'README.md' => 'README.md.stub',
|
||||
];
|
||||
|
||||
foreach ($files as $file => $stub) {
|
||||
$this->write("{$target}/{$file}", strtr((string) file_get_contents(base_path("sdk/stubs/{$stub}")), $values));
|
||||
}
|
||||
|
||||
// Build-Voreinstellung und Design-Tokens aus dem Portal mitgeben
|
||||
$this->write("{$target}/inhaus-sdk/vite.js", (string) file_get_contents(base_path('sdk/vite.js')));
|
||||
$this->write("{$target}/inhaus-sdk/theme.css", (string) file_get_contents(base_path('sdk/theme.css')));
|
||||
$this->write("{$target}/.gitignore", "node_modules/\n*.zip\n");
|
||||
@chmod("{$target}/bin/package", 0755);
|
||||
|
||||
$this->info("Plugin „{$name}“ angelegt: {$target}");
|
||||
$this->line('Weiter:');
|
||||
$this->line(" cd {$target} && npm install && npm run build");
|
||||
$this->line(' Dann unter Administration → Plugins aktivieren (liegt es unter plugins/, erscheint es dort direkt).');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function write(string $path, string $content): void
|
||||
{
|
||||
if (! is_dir(dirname($path))) {
|
||||
mkdir(dirname($path), 0775, true);
|
||||
}
|
||||
|
||||
file_put_contents($path, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gleiche Versionen wie im Portal, damit Vue-Compiler und Laufzeit zusammenpassen.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function frontendVersions(): array
|
||||
{
|
||||
$package = json_decode((string) @file_get_contents(base_path('package.json')), true) ?: [];
|
||||
$all = [...($package['dependencies'] ?? []), ...($package['devDependencies'] ?? [])];
|
||||
|
||||
return [
|
||||
'vite' => $all['vite'] ?? '^8.0.0',
|
||||
'vue' => $all['vue'] ?? '^3.5.0',
|
||||
'@vitejs/plugin-vue' => $all['@vitejs/plugin-vue'] ?? '^6.0.0',
|
||||
'tailwindcss' => $all['tailwindcss'] ?? '^4.0.0',
|
||||
'@tailwindcss/vite' => $all['@tailwindcss/vite'] ?? '^4.0.0',
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue