Download src/Plugin/Infrastructure/Helpers/ComposerHelper.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Plugin/Infrastructure/Helpers/ComposerHelper.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Plugin/Infrastructure/Helpers/ComposerHelper.php
-
curl -L -o ComposerHelper.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Plugin/Infrastructure/Helpers/ComposerHelper.php
1.97 kB
| declare(strict_types=1); | |
| namespace Plugin\Infrastructure\Helpers; | |
| use Composer\Console\Application; | |
| use Exception; | |
| use Symfony\Component\Console\Input\ArrayInput; | |
| use Symfony\Component\Console\Input\InputInterface; | |
| use Symfony\Component\Console\Output\OutputInterface; | |
| class ComposerHelper | |
| { | |
| public function __construct( | |
| private Application $composer, | |
| ) { | |
| $this->composer->setAutoExit(false); | |
| } | |
| /** | |
| * @param string|string[] $packages | |
| * @throws Exception | |
| */ | |
| public function require( | |
| string|array $packages, | |
| ?OutputInterface $output = null | |
| ): int { | |
| $input = new ArrayInput([ | |
| 'command' => 'require', | |
| 'packages' => is_string($packages) ? [$packages] : $packages, | |
| '--with-all-dependencies' => null | |
| ]); | |
| return $this->run($input, $output); | |
| } | |
| /** | |
| * @param string|string[] $packages | |
| * @throws Exception | |
| */ | |
| public function reinstall( | |
| string|array $packages, | |
| ?OutputInterface $output = null | |
| ): int { | |
| $input = new ArrayInput([ | |
| 'command' => 'reinstall', | |
| 'packages' => is_string($packages) ? [$packages] : $packages | |
| ]); | |
| return $this->run($input, $output); | |
| } | |
| /** | |
| * @param string|string[] $packages | |
| * @throws Exception | |
| */ | |
| public function remove( | |
| string|array $packages, | |
| ?OutputInterface $output = null | |
| ): int { | |
| $input = new ArrayInput([ | |
| 'command' => 'remove', | |
| 'packages' => is_string($packages) ? [$packages] : $packages | |
| ]); | |
| return $this->run($input, $output); | |
| } | |
| /** | |
| * @param string|string[] $packages | |
| * @throws Exception | |
| */ | |
| private function run( | |
| InputInterface $input, | |
| ?OutputInterface $output = null | |
| ): int { | |
| $code = $this->composer->run($input, $output); | |
| return $code; | |
| } | |
| } | |