diff --git a/.codeclimate.yml b/.codeclimate.yml index bc3b7b1..b656050 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,7 +1,8 @@ exclude_patterns: - ".github/" - ".idea/" - - "stubs/**" + - "stubs/" + - "*.stub" - "tests/" - "**/vendor/" - "**/node_modules/" diff --git a/composer.json b/composer.json index 60df987..d536491 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "filefabrik/paxsy", "description": "Software-Packaging your Laravel apps from https://paxsy.filefabrik.com", - "version": "v1.0.6", + "version": "v1.0.7", "keywords": [ "laravel", "laravel 11", diff --git a/src/Console/Commands/Admin/Inputs.php b/src/Console/Commands/Admin/Inputs.php index fb553b9..2dab410 100644 --- a/src/Console/Commands/Admin/Inputs.php +++ b/src/Console/Commands/Admin/Inputs.php @@ -55,7 +55,7 @@ public static function suggestComposerVendors(...$params): int|string } return suggest( - label : '"your-vendor-name" of the Package', + label : '"your-vendor-name" of the package', options: fn($value) => (new Collection($opts)) ->filter(fn($title) => str_contains(Str::lower($title), Str::lower($value))) ->all(), diff --git a/src/Console/Commands/Admin/Menus.php b/src/Console/Commands/Admin/Menus.php index d274895..90dcd15 100644 --- a/src/Console/Commands/Admin/Menus.php +++ b/src/Console/Commands/Admin/Menus.php @@ -17,9 +17,9 @@ class Menus * @var array[] */ public static array $mainMenu = [ - ['label' => 'Package components', 'method' => 'handle_package'], - ['label' => 'create Package', 'method' => 'create_package'], - ['label' => 'list Packages', 'method' => 'list_packages'], + ['label' => 'add components', 'method' => 'handle_package'], + ['label' => 'new laravel composer package', 'method' => 'create_package'], + ['label' => 'list packages', 'method' => 'list_packages'], // Handle composer Package into the Laravel-Host ['label' => 'add VendorPackage with there Repository (Laravel Host Composer )', 'method' => 'composer_add_repository_vendor_package'], ['label' => 'remove VendorPackage with there Repository (Laravel Host Composer)', 'method' => 'composer_remove_repository_vendor_package'], diff --git a/src/Console/Commands/Make/MakePackage.php b/src/Console/Commands/Make/MakePackage.php index 6f195d8..d3f2e36 100644 --- a/src/Console/Commands/Make/MakePackage.php +++ b/src/Console/Commands/Make/MakePackage.php @@ -42,6 +42,7 @@ class MakePackage extends Command */ public function handle(): int { + /** @var callable $method */ foreach (['stageArguments', 'stageVendorPackage', 'stageStubsConfig', @@ -74,7 +75,7 @@ public function handle(): int return self::SUCCESS; } - protected function stageArguments() + protected function stageArguments(): ?true { [$vendor, $package, $selectedStubsSet] = $this->inputArguments(); if (! $vendor || ! $package || ! $selectedStubsSet) { @@ -95,7 +96,11 @@ protected function stageArguments() return true; } - protected function stageVendorPackage() + /** + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + protected function stageVendorPackage(): bool { // todo must have the Package context, which has the Package Stack $newPackage = new VendorPackageNames( @@ -125,7 +130,7 @@ protected function stageVendorPackage() return true; } - protected function stageStubsConfig() + protected function stageStubsConfig(): FromConfig { /** * Semi-Validation @@ -133,7 +138,7 @@ protected function stageStubsConfig() return $this->stageVars['stubsConfig'] = new FromConfig($this->stageVars['selectedStubsSet']); } - protected function stageStubs() + protected function stageStubs(): ?true { $stubs = $this->stageVars['stubsConfig']->stubs(); @@ -154,7 +159,7 @@ protected function stageStubs() return true; } - protected function stageStubsDirectory() + protected function stageStubsDirectory(): ?true { $stubsDirectory = $this->stageVars['stubsConfig']->directory(); @@ -174,7 +179,7 @@ protected function stageStubsDirectory() return true; } - protected function stageReplaceableVars() + protected function stageReplaceableVars(): array { return $this->stageVars['replaceableVars'] = Facade::variables( vendorPackageNames: $this->stageVars['newPackage'], diff --git a/src/Console/Commands/Make/MakePackageStack.php b/src/Console/Commands/Make/MakePackageStack.php index 40aa229..94d3aff 100644 --- a/src/Console/Commands/Make/MakePackageStack.php +++ b/src/Console/Commands/Make/MakePackageStack.php @@ -22,13 +22,16 @@ public function handle(): int { $packageStack = StackApp::get(); + $stackName = $packageStack->getStackName(); + $stackBasePath = $packageStack->getStackBasePath(); + if (! $packageStack->exists()) { $packageStack->ensureStackDirectoryExists(); // todo would you like to publish configs before. so you can customize some stuff if need $this->line('php artisan vendor:publish --tag=paxsy-config'); - $successfully = 'Package Stack "'.$packageStack->getStackName().'" created successfully in your laravel: "'.$packageStack->getStackBasePath().'"!'; + $successfully = sprintf('Package Stack "%s" created successfully in your laravel: "%s"!', $stackName, $stackBasePath); $this->getOutput() ->title($successfully) @@ -36,8 +39,9 @@ public function handle(): int return self::SUCCESS; } + $msg = sprintf('Package Stack "%s" already exists in your laravel: "%s"!', $stackName, $stackBasePath); $this->getOutput() - ->title('Package Stack "'.$packageStack->getStackName().'" already exists in your laravel: "'.$packageStack->getStackBasePath().'"!') + ->title($msg) ; return self::SUCCESS; diff --git a/src/Console/Commands/PaxsyCommand.php b/src/Console/Commands/PaxsyCommand.php index 9875616..b02639e 100644 --- a/src/Console/Commands/PaxsyCommand.php +++ b/src/Console/Commands/PaxsyCommand.php @@ -280,7 +280,7 @@ protected function nest_in_package(string $vendor_package_name): int|string ->getPackage() ->toName() ; - $label = 'Choose the "make" command for your "'.$vendor_package_name.'" Package?'; + $label = sprintf('Choose the "make" command for your "%s" package?', $vendor_package_name); $command = Inputs::suggestMakeCommands($label); diff --git a/src/Support/Stubs/StubsWriter.php b/src/Support/Stubs/StubsWriter.php index c7b07be..c0b6a00 100644 --- a/src/Support/Stubs/StubsWriter.php +++ b/src/Support/Stubs/StubsWriter.php @@ -87,7 +87,7 @@ public function writeFile(string $destinationPath, $stubPath): bool // todo perhaps flag force or re-create all files if ($this->filesystem->exists($filename)) { - $this->line(" - Skipping {$destinationPath} (already exists)"); + $this->line(sprintf(' - Skipping %s (already exists)', $destinationPath)); return false; } @@ -97,7 +97,7 @@ public function writeFile(string $destinationPath, $stubPath): bool $this->filesystem->ensureDirectoryExists($out); $this->filesystem->put($filename, $output); - $this->line(" — Wrote to {$destinationPath}"); + $this->line(sprintf(' — Wrote file %s into %s', $destinationPath, $out)); return true; } diff --git a/src/Support/VendorPackageNames.php b/src/Support/VendorPackageNames.php index abb6e22..3d532fe 100644 --- a/src/Support/VendorPackageNames.php +++ b/src/Support/VendorPackageNames.php @@ -22,7 +22,7 @@ class VendorPackageNames { /** - * From config('stack_name') /app-modules/ + * From config('stack_name') /app-paxsy/ * * @var string|null */ diff --git a/tests/Datasets/MainMenu.php b/tests/Datasets/MainMenu.php index c0b9682..733f374 100644 --- a/tests/Datasets/MainMenu.php +++ b/tests/Datasets/MainMenu.php @@ -6,9 +6,9 @@ dataset( 'main menu', [ - ['label' => 'Package components', 'method' => 'handle_package'], - ['label' => 'create Package', 'method' => 'create_package'], - ['label' => 'list Packages', 'method' => 'list_packages'], + ['label' => 'add components', 'method' => 'handle_package'], + ['label' => 'new laravel composer package', 'method' => 'create_package'], + ['label' => 'list packages', 'method' => 'list_packages'], // Handle composer Package into the Laravel-Host ['label' => 'add VendorPackage with there Repository (Laravel Host Composer )', 'method' => 'composer_add_repository_vendor_package'], ['label' => 'remove VendorPackage with there Repository (Laravel Host Composer)', 'method' => 'composer_remove_repository_vendor_package'], diff --git a/tests/Unit/Console/Commands/PaxsyCommandTest.php b/tests/Unit/Console/Commands/PaxsyCommandTest.php index 5297447..34563fe 100644 --- a/tests/Unit/Console/Commands/PaxsyCommandTest.php +++ b/tests/Unit/Console/Commands/PaxsyCommandTest.php @@ -6,12 +6,11 @@ /** @copyright-header * */ use Filefabrik\Paxsy\Console\Commands\PaxsyCommand; -use Filefabrik\Paxsy\Paxsy; /** @copyright-header * */ beforeEach(function() { // todo all reset for make:package into function ... - + currentStackName(); removePackageStack(); rerouteStubsDirectory(); @@ -43,7 +42,7 @@ function() { $this->artisan('paxsy') ->expectsQuestion('Paxsy Menu', 'create_package') - ->expectsQuestion('"your-vendor-name" of the Package', '') + ->expectsQuestion('"your-vendor-name" of the package', '') ->assertExitCode(1) ; }, @@ -56,7 +55,7 @@ function() { $this->artisan('paxsy') ->expectsQuestion('Paxsy Menu', 'create_package') - ->expectsQuestion('"your-vendor-name" of the Package', 'testVendor') + ->expectsQuestion('"your-vendor-name" of the package', 'testVendor') ->expectsQuestion('Name of your package?', '') ->assertExitCode(1) ; @@ -83,16 +82,16 @@ function() { useShellDisabled(); $this->artisan('paxsy') - ->expectsQuestion('Paxsy Menu', 'create Package') - ->expectsQuestion('"your-vendor-name" of the Package', 'PaxsyVendorName') + ->expectsQuestion('Paxsy Menu', 'new laravel composer package') + ->expectsQuestion('"your-vendor-name" of the package', 'PaxsyVendorName') ->expectsQuestion('Name of your package?', 'PackEdgeName') ->expectsQuestion( - 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" Package?', + 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" package?', 'make:model', ) ->expectsQuestion('What should the model be named?', 'EdgyMododoodel') ->expectsQuestion( - 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" Package?', + 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" package?', PaxsyCommand::QUIT, ) ->expectsQuestion('Paxsy Menu', PaxsyCommand::QUIT) @@ -139,7 +138,7 @@ function() { ->expectsQuestion('Paxsy Menu', 'handle_package') ->expectsQuestion('package to call a make: command', $defaultPackage->vendorPackageName()) ->expectsQuestion( - 'Choose the "make" command for your "'.$defaultPackage->vendorPackageName().'" Package?', + 'Choose the "make" command for your "'.$defaultPackage->vendorPackageName().'" package?', PaxsyCommand::QUIT, ) ->expectsQuestion('Paxsy Menu', PaxsyCommand::QUIT) @@ -211,9 +210,9 @@ function() { config()->set('paxsy.ui_default_vendor'); $this->artisan('paxsy') ->expectsQuestion('Paxsy Menu', 'create_package') - ->expectsQuestion('"your-vendor-name" of the Package', 't') + ->expectsQuestion('"your-vendor-name" of the package', 't') ->expectsQuestion('Name of your package?', 't') - ->expectsQuestion('Choose the "make" command for your "t/t" Package?', PaxsyCommand::QUIT) + ->expectsQuestion('Choose the "make" command for your "t/t" package?', PaxsyCommand::QUIT) ->expectsQuestion('Paxsy Menu', PaxsyCommand::QUIT) ->assertExitCode(0) ; @@ -226,21 +225,20 @@ function() { config()->set( 'paxsy.stub_sets', - ['set1' => $defStubsSet, 'set2' => $defStubsSet, 'set3' => $defStubsSet] + ['set1' => $defStubsSet, 'set2' => $defStubsSet, 'set3' => $defStubsSet], ); // prevent from composer update useShellDisabled(); $this->artisan('paxsy') - ->expectsQuestion('Paxsy Menu', 'create Package') - ->expectsQuestion('"your-vendor-name" of the Package', 'PaxsyVendorName') + ->expectsQuestion('Paxsy Menu', 'new laravel composer package') + ->expectsQuestion('"your-vendor-name" of the package', 'PaxsyVendorName') ->expectsQuestion('Name of your package?', 'PackEdgeName') ->expectsQuestion('Which preconfigured Stub-Set?', 'set2') ->expectsQuestion( - 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" Package?', + 'Choose the "make" command for your "paxsy-vendor-name/pack-edge-name" package?', PaxsyCommand::QUIT, ) - ->expectsQuestion('Paxsy Menu', PaxsyCommand::QUIT) ; },