Skip to content

Commit

Permalink
Update Commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschucki committed Mar 30, 2024
1 parent a5669f2 commit bd2eff2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
11 changes: 7 additions & 4 deletions app/Commands/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Resources\ShopwarePlugin;
use App\Services\Plugins\PluginService;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\select;

class GeneratorCommand extends Command
Expand Down Expand Up @@ -37,8 +36,12 @@ public function handle(): void

private function selectPlugin(): void
{
$pluginService = new PluginService($this->argument('shopwareRootPath') ?? 'shopware');
$pluginService = new PluginService($this->argument('shopwareRootPath'));
$cExistingPlugins = $pluginService->getPlugins();
if ($cExistingPlugins->count() === 0) {
$this->error('No plugins found in the provided path');
exit(1);
}

$sSelectedPlugin = select(
label: 'Select Plugin',
Expand All @@ -48,7 +51,7 @@ private function selectPlugin(): void
hint: 'Select the plugin you want to generate files for',
);

$this->selectedPlugin = $cExistingPlugins->first(fn (ShopwarePlugin $plugin) => $plugin->getTitle() === $sSelectedPlugin);
$this->selectedPlugin = $cExistingPlugins->first(fn(ShopwarePlugin $plugin) => $plugin->getTitle() === $sSelectedPlugin);
}

private function selectGenerator(): void
Expand All @@ -62,7 +65,7 @@ private function selectGenerator(): void
hint: 'Select the generator you want to use',
);

$this->call('make:'.$sSelectedGenerator, [
$this->call('make:' . $sSelectedGenerator, [
'plugin' => $this->selectedPlugin->getTitle(),
'shopwareRootPath' => $this->argument('shopwareRootPath'),
]);
Expand Down
6 changes: 5 additions & 1 deletion app/Commands/Generators/MakeCmsBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,12 @@ private function selectCmsCategory(): void

private function selectPlugin(): void
{
$pluginService = new PluginService($this->argument('shopwareRootPath') ?? 'shopware');
$pluginService = new PluginService($this->argument('shopwareRootPath'));
$cExistingPlugins = $pluginService->getPlugins();
if ($cExistingPlugins->count() === 0) {
$this->error('No plugins found in the provided path');
exit(1);
}
$this->selectedPlugin = $cExistingPlugins->first(fn (ShopwarePlugin $plugin) => $plugin->getTitle() === $this->argument('plugin'));
}
}
2 changes: 1 addition & 1 deletion app/Commands/Generators/MakeCmsElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function setCmsElementName(): void

private function selectPlugin(): void
{
$pluginService = new PluginService($this->argument('shopwareRootPath') ?? 'shopware');
$pluginService = new PluginService($this->argument('shopwareRootPath'));
$cExistingPlugins = $pluginService->getPlugins();
if ($cExistingPlugins->count() === 0) {
$this->error('No plugins found in the provided path');
Expand Down
Binary file modified builds/sw-servant
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "CLI tool to help you create and build Shopware 6 plugins. Creates CMS-Elements & CMS-Blocks",
"keywords": ["shopware-plugin-servant", "shopware-servant", "shopware", "console", "cli"],
"type": "project",
"version": "0.0.1",
"version": "0.0.2",
"license": "GPL-3.0-or-later",
"support": {
"issues": "https://github.com/Tschucki/shopware-servant/issues",
Expand Down

0 comments on commit bd2eff2

Please sign in to comment.