/** * {@inheritDoc} */ protected function initialize() { $this->packages = array(); $this->packageName = isset($this->repoConfig['name']) ? Util::cleanPackageName($this->repoConfig['name']) : null; $driver = $this->initDriver(); $this->initLoader(); $this->initRootIdentifier($driver); $this->initRegistryVersions(); $this->initTags($driver); $this->initBranches($driver); $driver->cleanup(); if (!$this->getPackages()) { throw new InvalidRepositoryException('No valid ' . $this->assetType->getFilename() . ' was found in any branch or tag of ' . $this->url . ', could not load a package from it.'); } }
/** * {@inheritdoc} */ public function whatProvides(Pool $pool, $name, $bypassFilters = false) { if (null !== ($provides = $this->findWhatProvides($name))) { return $provides; } try { $repoName = Util::convertAliasName($name); $packageName = Util::cleanPackageName($repoName); $packageUrl = str_replace('%package%', $packageName, $this->lazyProvidersUrl); $cacheName = $packageName . '-' . sha1($packageName) . '-package.json'; $data = $this->fetchFile($packageUrl, $cacheName); $repo = $this->createVcsRepositoryConfig($data, Util::cleanPackageName($name)); $repo['vcs-package-filter'] = $this->packageFilter; $repo['vcs-driver-options'] = Util::getArrayValue($this->repoConfig, 'vcs-driver-options', array()); Util::addRepository($this->io, $this->rm, $this->repos, $name, $repo, $pool); $this->providers[$name] = array(); } catch (\Exception $ex) { $this->whatProvidesManageException($pool, $name, $ex); } return $this->providers[$name]; }
/** * {@inheritDoc} */ public function whatProvides(Pool $pool, $name) { if (null !== ($provides = $this->findWhatProvides($name))) { return $provides; } // no education $io = $this->io; $ioReflection = new \ReflectionObject($io); // no thought control $inputReflection = $ioReflection->getProperty('input'); $inputReflection->setAccessible(true); $inputPublic = $inputReflection->getValue($io); // no dark sarcasm $args = $inputPublic->getArguments(); $isAsset = isset($args['packages']) && (bool) count(array_filter($args['packages'], function ($el) { return strpos($el, 'bower-asset') !== false || strpos($el, 'npm-asset') !== false; })); // kids alone if (!$isAsset && $inputPublic->getOption('ansi') || $inputPublic->getOption('no-ansi')) { return array(); } try { $repoName = Util::convertAliasName($name); $packageName = Util::cleanPackageName($repoName); $packageUrl = str_replace('%package%', $packageName, $this->lazyProvidersUrl); $cacheName = $packageName . '-' . sha1($packageName) . '-package.json'; $data = $this->fetchFile($packageUrl, $cacheName); $repo = $this->createVcsRepositoryConfig($data, Util::cleanPackageName($name)); $repo['vcs-package-filter'] = $this->packageFilter; Util::addRepository($this->io, $this->rm, $this->repos, $name, $repo, $pool); $this->providers[$name] = array(); } catch (\Exception $ex) { $this->whatProvidesManageException($pool, $name, $ex); } return $this->providers[$name]; }
/** * {@inheritDoc} */ public function whatProvides(Pool $pool, $name) { if (null !== $provides = $this->findWhatProvides($name)) { return $provides; } try { $repoName = Util::convertAliasName($name); $packageName = Util::cleanPackageName($repoName); $packageUrl = str_replace('%package%', $packageName, $this->lazyProvidersUrl); $cacheName = $packageName . '-' . sha1($packageName) . '-package.json'; $data = $this->fetchFile($packageUrl, $cacheName); $repo = $this->createVcsRepositoryConfig($data, Util::cleanPackageName($name)); $repo['vcs-package-filter'] = $this->packageFilter; Util::addRepository($this->rm, $this->repos, $name, $repo, $pool); $this->providers[$name] = array(); } catch (TransportException $ex) { $this->fallbackWathProvides($pool, $name, $ex); } return $this->providers[$name]; }