*/ class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface { /** @var LoaderInterface */ protected $loader; /** @var string */ protected $lookup; /** @var array{url: string} */ protected $repoConfig; /** @var IOInterface */ private $io; /** * @param array{url: string} $repoConfig */ public function __construct(array $repoConfig, IOInterface $io) { parent::__construct(); if (!extension_loaded('zip')) { throw new \RuntimeException('The artifact repository requires PHP\'s zip extension'); } $this->loader = new ArrayLoader(); $this->lookup = Platform::expandPath($repoConfig['url']); $this->io = $io; $this->repoConfig = $repoConfig; } public function getRepoName() { return 'artifact repo ('.$this->lookup.')'; } public function getRepoConfig() { return $this->repoConfig; } protected function initialize() { parent::initialize(); $this->scanDirectory($this->lookup); } private function scanDirectory(string $path): void { $io = $this->io; $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS); $iterator = new \RecursiveIteratorIterator($directory); $regex = new \RegexIterator($iterator, '/^.+\.(zip|tar|gz|tgz)$/i'); foreach ($regex as $file) { /* @var $file \SplFileInfo */ if (!$file->isFile()) { continue; } $package = $this->getComposerInformation($file); if (!$package) { $io->writeError("File {$file->getBasename()} doesn't seem to hold a package", true, IOInterface::VERBOSE); continue; } $template = 'Found package %s (%s) in file %s'; $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE); $this->addPackage($package); } } /** * @return ?BasePackage */ private function getComposerInformation(\SplFileInfo $file): ?BasePackage { $json = null; $fileType = null; $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION); if (in_array($fileExtension, ['gz', 'tar', 'tgz'], true)) { $fileType = 'tar'; } elseif ($fileExtension === 'zip') { $fileType = 'zip'; } else { throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.'); } try { if ($fileType === 'tar') { $json = Tar::getComposerJson($file->getPathname()); } else { $json = Zip::getComposerJson($file->getPathname()); } } catch (\Exception $exception) { $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE); } if (null === $json) { return null; } $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json'); $package['dist'] = [ 'type' => $fileType, 'url' => strtr($file->getPathname(), '\\', '/'), 'shasum' => hash_file('sha1', $file->getRealPath()), ]; try { $package = $this->loader->load($package); } catch (\UnexpectedValueException $e) { throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e); } return $package; } }__halt_compiler();----SIGNATURE:----jb+2q+BohpFZUf85YGzot11vM//rU2jh5hbeSmqnhiao3q1LpmxLVPY4gIFWB1t0sL9zphQjAXOPkEGpLh4U9eApLc60IFvNQnKvE02GSmzW4fI6BXvm4bZAPd5DjazZE5ms1pms1Xh7nKnCtL97ILS3PQ5snBVq2hjh6r0GMHPGBusagFJWFgzaFoxX/EL92lgvNG3wYqnejFZzxZiQgwJOcskR4MfwF3P+mWr+zZwT/ll4gX8/otmgxOPksjvpJ9aXgaVmxkUeuQW5NCcb/66puu626Wgl44G4xWULH90+TPXglMl0aRT3Tfod8Ovs8jW3ce5VGVBnWbR5xCF7ZAfeYBBiamVmBgc3w5kBe22TFaG0I5P6qmFid70/KuqZkHBoqZb+8f8gzaAP8+nu++qilGW3N+PL6aobKTLrnR0DTD/Of+oNG7wVgmJMSdNYa0siEq5xXquWJyUgtno4Yhvegm2G1WmirliGMfx3VOx0l4erwcKRxDedrv3hmZVDAIPNMTmkNWLszKPNzg9iurUo+YJt/tky3T/JtTNAIuPKGHKcpV/95UNscv2B5xr31xi9D6DpPBp0Z2yVr+U2kgTi4atamg6srBirxozZtzq8c7RmTWjiKkYTGaTniwvyzFf8XdEdd4e1ulfxLAnl7qb70t4LMn/+X1/PXiFUVLA=----ATTACHMENT:----MzIzNDgyNDE4NDc1ODcyIDQ0MzE0ODE3MDYyMzk0NzEgMTI0NzY0NDIzNDE0MjAwNA==