update p:plugin:make command

This commit is contained in:
Boy132 2025-11-10 09:56:43 +01:00
parent 96f0aac4f8
commit e014581ebb

View File

@ -18,7 +18,7 @@ class MakePluginCommand extends Command
{--url=} {--url=}
{--updateUrl=} {--updateUrl=}
{--panels=} {--panels=}
{--composerPackages=}'; {--panelVersion=}';
protected $description = 'Create a new plugin'; protected $description = 'Create a new plugin';
@ -55,7 +55,7 @@ class MakePluginCommand extends Command
$this->info('Creating Plugin "' . $name . '" (' . $id . ') by ' . $author); $this->info('Creating Plugin "' . $name . '" (' . $id . ') by ' . $author);
$description = $this->option('description') ?? $this->ask('Description'); $description = $this->option('description') ?? $this->ask('Description (can be empty)');
$category = $this->option('category') ?? $this->choice('Category', collect(PluginCategory::cases())->mapWithKeys(fn (PluginCategory $category) => [$category->value => $category->getLabel()])->toArray(), PluginCategory::Plugin->value); $category = $this->option('category') ?? $this->choice('Category', collect(PluginCategory::cases())->mapWithKeys(fn (PluginCategory $category) => [$category->value => $category->getLabel()])->toArray(), PluginCategory::Plugin->value);
@ -65,25 +65,32 @@ class MakePluginCommand extends Command
return; return;
} }
$url = $this->option('url') ?? $this->ask('URL'); $url = $this->option('url') ?? $this->ask('URL (can be empty)');
$updateUrl = $this->option('updateUrl') ?? $this->ask('Update URL'); $updateUrl = $this->option('updateUrl') ?? $this->ask('Update URL (can be empty)');
$panels = $this->option('panels') ?? $this->choice('Panels', [
$panels = $this->option('panels') ?? $this->choice('Panels (leave empty for "all panels", otherwise comma separated list)', [
'admin' => 'Admin Area', 'admin' => 'Admin Area',
'server' => 'Client Area', 'server' => 'Client Area',
'app' => 'Server List', 'app' => 'Server List',
], 'admin,server', multiple: true); ], multiple: true);
$composerPackages = $this->option('composerPackages') ?? $this->ask('Composer Packages');
$panelVersion = $this->option('panelVersion');
if (!$panelVersion) {
$panelVersion = $this->ask('Required panel version (leave empty for no constraint)', config('app.version') === 'canary' ? null : config('app.version'));
if ($panelVersion && $this->confirm("Should the version constraint be minimal instead of strict? ($panelVersion or higher instead of only $panelVersion)")) {
$panelVersion = "^$panelVersion";
}
}
$composerPackages = null;
// TODO: ask for composer packages?
// Create base directory // Create base directory
$this->filesystem->makeDirectory(plugin_path($id)); $this->filesystem->makeDirectory(plugin_path($id));
// Write plugin.json // Write plugin.json
$this->filesystem->put(plugin_path($id, 'plugin.json'), json_encode([ $this->filesystem->put(plugin_path($id, 'plugin.json'), json_encode([
'meta' => [
'status' => PluginStatus::Enabled,
'status_message' => null,
'load_order' => 0,
],
'id' => $id, 'id' => $id,
'name' => $name, 'name' => $name,
'author' => $author, 'author' => $author,
@ -95,8 +102,12 @@ class MakePluginCommand extends Command
'namespace' => $namespace, 'namespace' => $namespace,
'class' => $class, 'class' => $class,
'panels' => is_string($panels) ? explode(',', $panels) : $panels, 'panels' => is_string($panels) ? explode(',', $panels) : $panels,
'panel_version' => config('app.version') === 'canary' ? null : config('app.version'), 'panel_version' => $panelVersion,
'composer_packages' => is_string($composerPackages) ? explode(',', $composerPackages) : $composerPackages, 'composer_packages' => $composerPackages,
'meta' => [
'status' => PluginStatus::Enabled,
'status_message' => null,
],
], JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); ], JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
// Create src directory and create main class // Create src directory and create main class