From d0155d90ee41ffcbcc402bd9cfa4bc29c9abdfbc Mon Sep 17 00:00:00 2001 From: ousid Date: Thu, 10 Feb 2022 13:51:07 +0100 Subject: [PATCH 1/3] add Laravel 9 support --- .github/workflows/run-tests.yml | 8 ++++---- composer.json | 11 +++++------ .../Concerns/InteractsWithConsoleCommands.php | 19 ++++++------------- tests/Commands/ModelMakeCommandTest.php | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 041bf5d..f3395c8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,12 +13,12 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.0] - laravel: [8.*] + php: [8.1, 8.0] + laravel: [9.*] stability: [prefer-lowest, prefer-stable] include: - - laravel: 8.* - testbench: ^6.23 + - laravel: 9.* + testbench: 7.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index b9ddae7..e6cf92f 100644 --- a/composer.json +++ b/composer.json @@ -18,19 +18,18 @@ "require": { "php": "^8.0", "spatie/laravel-package-tools": "^1.9.2", - "illuminate/contracts": "^8.73" + "illuminate/contracts": "^9.0" }, "require-dev": { - "nunomaduro/collision": "^5.10", + "nunomaduro/collision": "^6.0", "nunomaduro/larastan": "^1.0", - "orchestra/testbench": "^6.22", + "orchestra/testbench": "^7.0", "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.1", + "pestphp/pest-plugin-laravel": "^1.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5", - "spatie/laravel-ray": "^1.26" + "phpunit/phpunit": "^9.5.4" }, "autoload": { "psr-4": { diff --git a/src/Console/Concerns/InteractsWithConsoleCommands.php b/src/Console/Concerns/InteractsWithConsoleCommands.php index 80266b5..5177911 100644 --- a/src/Console/Concerns/InteractsWithConsoleCommands.php +++ b/src/Console/Concerns/InteractsWithConsoleCommands.php @@ -16,7 +16,12 @@ trait InteractsWithConsoleCommands */ public function loopThroughNameArgumentWith(string $command): bool { - collect($this->argument('name'))->each(function ($name, $key) use ($command) { + /** + * @var array $models + */ + $models = explode(' ', strval($this->argument('name'))); + + collect($models)->each(function ($name) use ($command) { $this->line("Generating {$name} class\n"); $this->call( @@ -37,18 +42,6 @@ public function loopThroughNameArgumentWith(string $command): bool return true; } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments(): array - { - return [ - ['name', InputArgument::IS_ARRAY, 'The name of the class'], - ]; - } - /** * Get the list of options * diff --git a/tests/Commands/ModelMakeCommandTest.php b/tests/Commands/ModelMakeCommandTest.php index 328dbfd..5d59d2d 100644 --- a/tests/Commands/ModelMakeCommandTest.php +++ b/tests/Commands/ModelMakeCommandTest.php @@ -1,5 +1,19 @@ artisan('laracommand:make-model', [ + 'name' => 'Category', + ]) + ->assertExitCode(0); +}); + +it('returns required error if the name was not provided', function () { + $this->artisan('laracommand:make-model', [ + 'name' => null, + ]) + ->assertExitCode(0); +}); + it('creates a new eloquent model class', function () { $this->artisan('laracommand:make-model', [ 'name' => 'Category Product', From b26ade5c0822a395e8305b07cf0d743425b48de1 Mon Sep 17 00:00:00 2001 From: ousid Date: Thu, 10 Feb 2022 12:51:35 +0000 Subject: [PATCH 2/3] Fix styling --- src/Console/Concerns/InteractsWithConsoleCommands.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Console/Concerns/InteractsWithConsoleCommands.php b/src/Console/Concerns/InteractsWithConsoleCommands.php index 5177911..4626485 100644 --- a/src/Console/Concerns/InteractsWithConsoleCommands.php +++ b/src/Console/Concerns/InteractsWithConsoleCommands.php @@ -2,8 +2,6 @@ namespace Coderflex\LaraCommand\Console\Concerns; -use Symfony\Component\Console\Input\InputArgument; - /** * Interact With Console Commands */ @@ -20,7 +18,7 @@ public function loopThroughNameArgumentWith(string $command): bool * @var array $models */ $models = explode(' ', strval($this->argument('name'))); - + collect($models)->each(function ($name) use ($command) { $this->line("Generating {$name} class\n"); From 36c07cd7cd6da1c21267a8c52a2adf4f5d657676 Mon Sep 17 00:00:00 2001 From: ousid Date: Thu, 10 Feb 2022 23:31:18 +0000 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 074588a..59047fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to `Laracommand` will be documented in this file. +## v2.0.1 - 2022-02-10 + +## What's Changed + +- V2 by @ousid in https://github.com/coderflexx/laracommand/pull/2 + +**Full Changelog**: https://github.com/coderflexx/laracommand/compare/v1.2.0...v2.0.1 + ## v2.0.0 - 2022-02-10 ## Add