diff --git a/src/AppStore/src/Plugin.php b/src/AppStore/src/Plugin.php index 7f655fb..4420c57 100644 --- a/src/AppStore/src/Plugin.php +++ b/src/AppStore/src/Plugin.php @@ -190,7 +190,7 @@ public static function install(string $path): void throw new \RuntimeException(sprintf('Composer command error, details:%s', $checkCmd['output'] ?? '--')); } - $execList[] = sprintf('cd %s &&', BASE_PATH); + $execList[] = sprintf('cd %s', BASE_PATH); $packageList = []; foreach ($requires as $package => $version) { if (! InstalledVersions::isInstalled($package)) { @@ -209,6 +209,11 @@ public static function install(string $path): void } } + if (! empty($info['composer']['installScript']) && class_exists($installScript = $info['composer']['installScript'])) { + $installScript = ApplicationContext::getContainer()->make($installScript); + $installScript(); + } + // run script if (! empty($info['composer']['script'])) { $scripts = $info['composer']['script']; @@ -231,11 +236,6 @@ public static function install(string $path): void $frontDirectory = self::getConfig('front_directory', BASE_PATH . '/web'); - if (! empty($info['installScript']) && class_exists($info['installScript'])) { - $installScript = ApplicationContext::getContainer()->make($info['installScript']); - $installScript(); - } - // Handling front-end dependency information if (! empty($info['package']['dependencies'])) { $frontBin = self::getConfig('front-tool'); @@ -306,10 +306,6 @@ public static function uninstall(string $path): void 'No installation behavior was detected for this plugin, and uninstallation could not be performed' ); } - if (! empty($info['uninstallScript']) && class_exists($info['uninstallScript'])) { - $uninstallScript = ApplicationContext::getContainer()->make($info['uninstallScript']); - $uninstallScript(); - } if (! empty($info['composer']['require'])) { $requires = $info['composer']['require']; $composerBin = self::getConfig('composer.bin', 'composer'); @@ -317,20 +313,27 @@ public static function uninstall(string $path): void if (($checkCmd['code'] ?? 0) !== 0) { throw new \RuntimeException(sprintf('Composer command error, details:%s', $checkCmd['output'] ?? '--')); } - $cmdBody = sprintf('cd %s &&', BASE_PATH); - $cmdBody .= sprintf('%s remove ', $composerBin); + $execList = []; + $execList[] = sprintf('cd %s', BASE_PATH); foreach ($requires as $package => $version) { if (InstalledVersions::isInstalled($package)) { - $cmdBody .= sprintf('%s:%s ', $package, $version); + $execList[] = sprintf('%s remove %s ', $composerBin, $package); } } - $cmdBody .= sprintf('-vvv'); - $result = System::exec($cmdBody); - if ($result['code'] !== 0 && ! empty($result['ouput'])) { - throw new \RuntimeException(sprintf('Failed to execute composer require command, details:%s', $result['output'] ?? '--')); + + foreach ($execList as $exec) { + $result = System::exec($exec); + if ($result['code'] !== 0 && ! empty($result['ouput'])) { + throw new \RuntimeException(sprintf('Failed to execute composer require command, details:%s', $result['output'] ?? '--')); + } } } + if (! empty($info['composer']['uninstallScript']) && class_exists($info['composer']['uninstallScript'])) { + $uninstallScript = ApplicationContext::getContainer()->make($info['composer']['uninstallScript']); + $uninstallScript(); + } + $frontDirectory = self::getConfig('front_directory', BASE_PATH . '/web'); // Handling front-end dependency information