From 5e298c783e2465f2c4f1f51d1b740bd8701506c5 Mon Sep 17 00:00:00 2001 From: Jonas Regner Date: Thu, 9 Feb 2023 12:39:52 +0100 Subject: [PATCH 1/2] feat: make laravel 10 compatible --- composer.json | 5 ++-- src/Commands/BaseCommand.php | 45 +++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 8b4d060..cde0714 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,10 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "illuminate/support": "^9.0|^10.0", "illuminate/console": "^9.0|^10.0", - "illuminate/filesystem": "^9.0|^10.0", - "regnerisch/laravel-command-hooks": "^2.0" + "illuminate/filesystem": "^9.0|^10.0" }, "extra": { "laravel": { diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 354615e..8bb73ce 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -3,7 +3,10 @@ namespace AkrilliA\LaravelBeyond\Commands; use AkrilliA\LaravelBeyond\Contracts\Composer as ComposerContract; -use Regnerisch\LaravelCommandHooks\Command; +use Illuminate\Console\Command; +use Illuminate\Contracts\Console\Isolatable; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; abstract class BaseCommand extends Command { @@ -65,6 +68,46 @@ protected function checkVersionId(): int return 0; } + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($this instanceof Isolatable && $this->option('isolated') !== false && + ! $this->commandIsolationMutex()->create($this)) { + $this->comment(sprintf( + 'The [%s] command is already running.', $this->getName() + )); + + return (int) (is_numeric($this->option('isolated')) + ? $this->option('isolated') + : self::SUCCESS); + } + + $code = null; + + if (method_exists($this, 'before')) { + $code = $this->before(); + + if ($code) { + return (int) $code; + } + } + + $method = method_exists($this, 'handle') ? 'handle' : '__invoke'; + + try { + $originalCode = (int) $this->laravel->call([$this, $method]); + + if (method_exists($this, 'after')) { + $code = $this->after($originalCode); + } + + return is_null($code) ? $originalCode : (int) $code; + } finally { + if ($this instanceof Isolatable && $this->option('isolated') !== false) { + $this->commandIsolationMutex()->forget($this); + } + } + } + protected function getMissingPackages(): array { $composer = $this->getLaravel()->get(ComposerContract::class); From 3e18269fcc5172611168f3d17aa5a28b25a3e95b Mon Sep 17 00:00:00 2001 From: Jonas Regner Date: Thu, 9 Feb 2023 12:40:43 +0100 Subject: [PATCH 2/2] fix: test action --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b105ea0..2e9b102 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: ['8.0', '8.1', '8.2'] + php: ['8.1', '8.2'] steps: - name: Checkout