From 48c619c33e7739f1d242262cc23360bf17fa728b Mon Sep 17 00:00:00 2001 From: Jarvis Date: Sun, 27 Nov 2022 02:20:51 +0800 Subject: [PATCH] feat: add composer-update --- src/Commands/PluginComposerUpdateCommand.php | 31 ++++++++++++++++++++ src/Commands/PluginInstallCommand.php | 13 ++++---- src/Commands/PluginUninstallCommand.php | 9 +++--- 3 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/Commands/PluginComposerUpdateCommand.php diff --git a/src/Commands/PluginComposerUpdateCommand.php b/src/Commands/PluginComposerUpdateCommand.php new file mode 100644 index 0000000..9fe8375 --- /dev/null +++ b/src/Commands/PluginComposerUpdateCommand.php @@ -0,0 +1,31 @@ +output); + if (!$process->isSuccessful()) { + $this->error('Failed to install packages, calc composer.json hash value fail'); + + return Command::FAILURE; + } + + return 0; + } +} diff --git a/src/Commands/PluginInstallCommand.php b/src/Commands/PluginInstallCommand.php index a3fdcdc..c1edf7a 100644 --- a/src/Commands/PluginInstallCommand.php +++ b/src/Commands/PluginInstallCommand.php @@ -10,7 +10,6 @@ use Fresns\PluginManager\Plugin; use Fresns\PluginManager\Support\Json; -use Fresns\PluginManager\Support\Process; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Cache; @@ -45,14 +44,14 @@ public function handle() if (! $unikey) { info('Failed to unzip, couldn\'t get the plugin unikey'); - return -1; + return Command::FAILURE; } $plugin = new Plugin($unikey); if (! $plugin->isValidPlugin()) { $this->error('plugin is invalid'); - return -1; + return Command::FAILURE; } $plugin->manualAddNamespace(); @@ -68,11 +67,11 @@ public function handle() // Triggers top-level computation of composer.json hash values and installation of extension packages // @see https://getcomposer.org/doc/03-cli.md#process-exit-codes if (count($require) || count($requireDev)) { - $process = Process::run('composer update', $this->output); - if (! $process->isSuccessful()) { - $this->error('Failed to install packages, calc composer.json hash value fail'); + $exitCode = $this->call('plugin:composer-update'); + if ($exitCode) { + $this->error("Failed to update plugin dependency"); - return -1; + return Command::FAILURE; } } diff --git a/src/Commands/PluginUninstallCommand.php b/src/Commands/PluginUninstallCommand.php index 1ac9f29..f98f19a 100644 --- a/src/Commands/PluginUninstallCommand.php +++ b/src/Commands/PluginUninstallCommand.php @@ -10,7 +10,6 @@ use Fresns\PluginManager\Plugin; use Fresns\PluginManager\Support\Json; -use Fresns\PluginManager\Support\Process; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Facades\File; @@ -59,11 +58,11 @@ public function handle() // Triggers top-level computation of composer.json hash values and installation of extension packages if (count($require) || count($requireDev)) { - $process = Process::run('composer update', $this->output); - if (! $process->isSuccessful()) { - $this->error('Failed to uninstall packages, calc composer.json hash value fail'); + $exitCode = $this->call('plugin:composer-update'); + if ($exitCode) { + $this->error("Failed to update plugin dependency"); - return -1; + return Command::FAILURE; } }