Skip to content

Commit

Permalink
Merge pull request #16 from Filefabrik/v1.0.7
Browse files Browse the repository at this point in the history
V1.0.7
  • Loading branch information
Filefabrik authored Aug 20, 2024
2 parents 0c9ee2f + 08134ad commit d4c3a89
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
exclude_patterns:
- ".github/"
- ".idea/"
- "stubs/**"
- "stubs/"
- "*.stub"
- "tests/"
- "**/vendor/"
- "**/node_modules/"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/Admin/Inputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/Console/Commands/Admin/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
17 changes: 11 additions & 6 deletions src/Console/Commands/Make/MakePackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MakePackage extends Command
*/
public function handle(): int
{
/** @var callable $method */
foreach (['stageArguments',
'stageVendorPackage',
'stageStubsConfig',
Expand Down Expand Up @@ -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) {
Expand All @@ -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(
Expand Down Expand Up @@ -125,15 +130,15 @@ protected function stageVendorPackage()
return true;
}

protected function stageStubsConfig()
protected function stageStubsConfig(): FromConfig
{
/**
* Semi-Validation
*/
return $this->stageVars['stubsConfig'] = new FromConfig($this->stageVars['selectedStubsSet']);
}

protected function stageStubs()
protected function stageStubs(): ?true
{
$stubs = $this->stageVars['stubsConfig']->stubs();

Expand All @@ -154,7 +159,7 @@ protected function stageStubs()
return true;
}

protected function stageStubsDirectory()
protected function stageStubsDirectory(): ?true
{
$stubsDirectory = $this->stageVars['stubsConfig']->directory();

Expand All @@ -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'],
Expand Down
8 changes: 6 additions & 2 deletions src/Console/Commands/Make/MakePackageStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,26 @@ 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('<kbd>php artisan vendor:publish --tag=paxsy-config</kbd>');

$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)
;

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;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/PaxsyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/Support/Stubs/StubsWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <info>{$destinationPath}</info> (already exists)");
$this->line(sprintf(' - Skipping <info>%s</info> (already exists)', $destinationPath));

return false;
}
Expand All @@ -97,7 +97,7 @@ public function writeFile(string $destinationPath, $stubPath): bool
$this->filesystem->ensureDirectoryExists($out);
$this->filesystem->put($filename, $output);

$this->line(" — Wrote to <info>{$destinationPath}</info>");
$this->line(sprintf(' — Wrote file <info>%s</info> into %s', $destinationPath, $out));

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/VendorPackageNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class VendorPackageNames
{
/**
* From config('stack_name') /app-modules/
* From config('stack_name') /app-paxsy/
*
* @var string|null
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/Datasets/MainMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
30 changes: 14 additions & 16 deletions tests/Unit/Console/Commands/PaxsyCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
;
},
Expand All @@ -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)
;
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
;
Expand All @@ -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)
;
},
Expand Down

0 comments on commit d4c3a89

Please # to comment.