From ef3341a9c0fc50b93af86065b39087e016126596 Mon Sep 17 00:00:00 2001 From: Syntafin Date: Mon, 6 Jun 2022 16:22:20 +0200 Subject: [PATCH 1/9] Change Command Name and fix Typo Changed the Name for the Command to ``make:presenter`` to follow the usual Laravel make commands. --- src/Console/PresenterMakeCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/PresenterMakeCommand.php b/src/Console/PresenterMakeCommand.php index df0ad88..99186ca 100644 --- a/src/Console/PresenterMakeCommand.php +++ b/src/Console/PresenterMakeCommand.php @@ -6,9 +6,9 @@ class PresenterMakeCommand extends GeneratorCommand { - public $name = 'presenter:make'; + public $name = 'make:presenter'; - public $description = 'create a new presenter class'; + public $description = 'Create a new presenter class'; /** * The type of class being generated. From 4a8c56bd4314c64e80a9fab1b1856b2abf5120c0 Mon Sep 17 00:00:00 2001 From: Syntafin Date: Sat, 13 Aug 2022 03:36:39 +0200 Subject: [PATCH 2/9] Create an alias command and mark the old style as deprecated for future major release. --- src/Console/OldPresenterMakeCommand.php | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/Console/OldPresenterMakeCommand.php diff --git a/src/Console/OldPresenterMakeCommand.php b/src/Console/OldPresenterMakeCommand.php new file mode 100644 index 0000000..3e4becd --- /dev/null +++ b/src/Console/OldPresenterMakeCommand.php @@ -0,0 +1,69 @@ +files->exists($this->getPath($this->qualifyClass($rawName))); + } + + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + return $this->resolveStubPath('/stubs/presenter.stub'); + } + + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__ . $stub; + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + $configNamespace = config('laravel-presenter.presenter_namespace'); + + return is_null($configNamespace) + ? $rootNamespace . '\Presenters' + : $configNamespace; + } +} From 51f79638bcd4cd4dff43e772c554ef8bdb7e56f7 Mon Sep 17 00:00:00 2001 From: Syntafin Date: Sat, 13 Aug 2022 03:37:46 +0200 Subject: [PATCH 3/9] Fix Classname for PSR-4 Autoload --- src/Console/OldPresenterMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/OldPresenterMakeCommand.php b/src/Console/OldPresenterMakeCommand.php index 3e4becd..e1b771c 100644 --- a/src/Console/OldPresenterMakeCommand.php +++ b/src/Console/OldPresenterMakeCommand.php @@ -4,7 +4,7 @@ use Illuminate\Console\GeneratorCommand; -class PresenterMakeCommand extends GeneratorCommand +class OldPresenterMakeCommand extends GeneratorCommand { public $name = 'presenter:make'; From 168eaf556d6fa5af7a21e4e88978f4dda2dbd27b Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 21:47:28 +0100 Subject: [PATCH 4/9] Rename PresenterMakeCommand.php to MakePresenterCommand.php --- .../{PresenterMakeCommand.php => MakePresenterCommand.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Console/{PresenterMakeCommand.php => MakePresenterCommand.php} (100%) diff --git a/src/Console/PresenterMakeCommand.php b/src/Console/MakePresenterCommand.php similarity index 100% rename from src/Console/PresenterMakeCommand.php rename to src/Console/MakePresenterCommand.php From 8b8e43fae4421fcdc35abe89d6b913a0789b2876 Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 21:48:46 +0100 Subject: [PATCH 5/9] Update MakePresenterCommand.php --- src/Console/MakePresenterCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/MakePresenterCommand.php b/src/Console/MakePresenterCommand.php index 99186ca..fe1211c 100644 --- a/src/Console/MakePresenterCommand.php +++ b/src/Console/MakePresenterCommand.php @@ -4,7 +4,7 @@ use Illuminate\Console\GeneratorCommand; -class PresenterMakeCommand extends GeneratorCommand +class MakePresenterCommand extends GeneratorCommand { public $name = 'make:presenter'; From 33e6db7fd7dd277faeaec95f7e881e9c03c221bc Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 21:54:12 +0100 Subject: [PATCH 6/9] Update and rename OldPresenterMakeCommand.php to PresenterMakeCommand.php --- src/Console/OldPresenterMakeCommand.php | 69 ------------------------- src/Console/PresenterMakeCommand.php | 16 ++++++ 2 files changed, 16 insertions(+), 69 deletions(-) delete mode 100644 src/Console/OldPresenterMakeCommand.php create mode 100644 src/Console/PresenterMakeCommand.php diff --git a/src/Console/OldPresenterMakeCommand.php b/src/Console/OldPresenterMakeCommand.php deleted file mode 100644 index e1b771c..0000000 --- a/src/Console/OldPresenterMakeCommand.php +++ /dev/null @@ -1,69 +0,0 @@ -files->exists($this->getPath($this->qualifyClass($rawName))); - } - - /** - * Get the stub file for the generator. - * - * @return string - */ - protected function getStub() - { - return $this->resolveStubPath('/stubs/presenter.stub'); - } - - /** - * Resolve the fully-qualified path to the stub. - * - * @param string $stub - * @return string - */ - protected function resolveStubPath($stub) - { - return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) - ? $customPath - : __DIR__ . $stub; - } - - /** - * Get the default namespace for the class. - * - * @param string $rootNamespace - * @return string - */ - protected function getDefaultNamespace($rootNamespace) - { - $configNamespace = config('laravel-presenter.presenter_namespace'); - - return is_null($configNamespace) - ? $rootNamespace . '\Presenters' - : $configNamespace; - } -} diff --git a/src/Console/PresenterMakeCommand.php b/src/Console/PresenterMakeCommand.php new file mode 100644 index 0000000..0ce722a --- /dev/null +++ b/src/Console/PresenterMakeCommand.php @@ -0,0 +1,16 @@ +setHidden(true); + } + +} From c9daf619cfc8d65ee3579c7962a439578a0295ea Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 21:58:13 +0100 Subject: [PATCH 7/9] Update LaravelPresenterServiceProvider.php --- src/LaravelPresenterServiceProvider.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LaravelPresenterServiceProvider.php b/src/LaravelPresenterServiceProvider.php index e9582a4..91efd84 100644 --- a/src/LaravelPresenterServiceProvider.php +++ b/src/LaravelPresenterServiceProvider.php @@ -2,7 +2,10 @@ namespace Coderflex\LaravelPresenter; -use Coderflex\LaravelPresenter\Console\PresenterMakeCommand; +use Coderflex\LaravelPresenter\Console\{ + PresenterMakeCommand, + MakePresenterCommand +}; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -18,6 +21,7 @@ public function configurePackage(Package $package): void $package ->name('laravel-presenter') ->hasConfigFile('laravel-presenter') + ->hasCommand(MakePresenterCommand::class) ->hasCommand(PresenterMakeCommand::class); } } From cfc576e66e0ed6508829564ed8d1351b4d62384e Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 21:59:55 +0100 Subject: [PATCH 8/9] Update PresentersTest.php --- tests/PresentersTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/PresentersTest.php b/tests/PresentersTest.php index ef60cec..61c82b2 100644 --- a/tests/PresentersTest.php +++ b/tests/PresentersTest.php @@ -16,6 +16,12 @@ ->assertExitCode(0); })->group('Presenter Command'); + +it('can create new presenter class with the alias command', function () { + $this->artisan('make:presenter UserPresenter') + ->assertExitCode(0); +})->group('Presenter Command'); + it('presents user full name', function () { $user = new User([ 'first_name' => 'John', From d97aa97a6943b2187955cbb03c2dce5799cffe7f Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 14 Aug 2022 22:06:52 +0100 Subject: [PATCH 9/9] Update composer.json --- composer.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f857860..cff6e9a 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,14 @@ "test-coverage": "vendor/bin/pest --coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin-laravel": true, + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true, + "phpstan/phpstan-deprecation-rules": true, + "phpstan/phpstan-phpunit": true + } }, "extra": { "laravel": {