/** * @return string[] */ private function fetch() { $this->io->write(sprintf(' - Updating <info>%s</info> tag list', $this->package)); if (isset($_ENV['HRDNS_PHANTOMJS_VERSION']) && !empty($_ENV['HRDNS_PHANTOMJS_VERSION'])) { $this->cache = [$_ENV['HRDNS_PHANTOMJS_VERSION']]; } if ($this->cache === null) { $this->cache = []; $this->io->writeError(" Downloading: <comment>Connecting...</comment>", false); $repo = new VcsRepository(['url' => $this->url, 'type' => $this->type], $this->io, $this->config); $this->cache = array_keys($repo->getDriver()->getTags()); $this->io->overwriteError('', false); $this->io->overwriteError(sprintf("\r Found <comment>%d</comment> versions\n", count($this->cache))); } return $this->cache; }
/** * @return string[] */ private function fetch() { $this->io->write(sprintf(' - Updating <info>%s</info> tag list', $this->package)); if (isset($_ENV['HRDNS_SELENIUM_VERSION']) && !empty($_ENV['HRDNS_SELENIUM_VERSION'])) { $this->cache = [$_ENV['HRDNS_SELENIUM_VERSION']]; } if ($this->cache === null) { $this->cache = []; $this->io->writeError(" Downloading: <comment>Connecting...</comment>", false); $repo = new VcsRepository(['url' => $this->url, 'type' => $this->type], $this->io, $this->config); $this->cache = array_keys($repo->getDriver()->getTags()); $this->io->overwriteError(" Downloading: <comment>100%</comment>", false); $this->cache = array_filter($this->cache, function ($version) { return strpos($version, 'selenium-') === 0; }); array_walk($this->cache, function (&$value) { $value = substr($value, 9); }); $this->io->overwriteError(sprintf("\r Found <comment>%d</comment> versions\n", count($this->cache))); } return $this->cache; }
public function referencePackages(PackageSet $packageSet, IOInterface $io, $apiUrl = null) { if (!$apiUrl) { $apiUrl = 'https://php-bach.org'; } $apiUrlFormat = $apiUrl . '/p/%s.json'; //cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); /** @var Package $package */ foreach ($packageSet as $package) { $packageName = $package->getPackageName(); $versionName = $package->getVersion(); $url = sprintf($apiUrlFormat, $packageName); curl_setopt($ch, CURLOPT_URL, $url); $response = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $message = '<info>Checking:</info> ' . $packageName . ' (' . $versionName . ') ...'; $io->write($message); if ('200' === (string) $code) { $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); // ヘッダサイズ取得 $body = substr($response, $header_size); // bodyだけ切り出し if ($this->parseResponse($package, $body)) { $io->overwrite('<info>Done.</info>'); } else { $io->overwrite('<fg=white;bg=magenta>Version not found.</>'); } } elseif ('404' === (string) $code) { $io->overwrite('<fg=white;bg=magenta>Package not found.</>'); } else { $io->overwriteError($message . '<error>Connection error.</error>'); } } curl_close($ch); }