diff --git a/CHANGELOG-1.x.md b/CHANGELOG-1.x.md index 8dfeb45..0bf7be5 100644 --- a/CHANGELOG-1.x.md +++ b/CHANGELOG-1.x.md @@ -2,6 +2,14 @@ This changelog references the relevant changes (bug and security fixes) done to `orchestra/dusk-updater`. +## 1.6.1 + +Released: 2023-07-21 + +### Fixes + +* Retrieve ChromeDriver archive using `--proxy` and `--ssl-no-verify` options. + ## 1.6.0 Released: 2023-07-21 diff --git a/src/Command.php b/src/Command.php index dd636a7..c50bdc0 100644 --- a/src/Command.php +++ b/src/Command.php @@ -83,7 +83,7 @@ protected function fetchUrl(string $url): string $streamOptions['http'] = ['proxy' => $this->httpProxy, 'request_fulluri' => true]; } - $contents = file_get_contents($url, false, stream_context_create($streamOptions)); + $contents = @file_get_contents($url, false, stream_context_create($streamOptions)); return \is_string($contents) ? $contents : throw new Exception("Unable to fetch contents from [{$url}]"); } diff --git a/src/Concerns/DetectsChromeVersion.php b/src/Concerns/DetectsChromeVersion.php index ff9d81b..60797ef 100644 --- a/src/Concerns/DetectsChromeVersion.php +++ b/src/Concerns/DetectsChromeVersion.php @@ -95,9 +95,7 @@ protected function findVersionUrl(?string $version): string if ($version < 70) { return $this->legacyVersions[$version]; } elseif ($version < 115) { - return $this->fetchChromeVersionFromUrl( - sprintf('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_%d', $version) - ); + return $this->fetchChromeVersionFromUrl($version); } $milestones = $this->resolveChromeVersionsPerMilestone(); @@ -218,9 +216,11 @@ protected function installedChromeDriverVersion(string $os, ?string $driverDirec /** * Get the chrome version from URL. */ - protected function fetchChromeVersionFromUrl(string $url): string + protected function fetchChromeVersionFromUrl(int $version): string { - return trim((string) $this->fetchUrl($url)); + return trim((string) $this->fetchUrl( + sprintf('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_%d', $version) + )); } /** diff --git a/src/UpdateCommand.php b/src/UpdateCommand.php index 5ea1d16..511aa39 100644 --- a/src/UpdateCommand.php +++ b/src/UpdateCommand.php @@ -2,6 +2,7 @@ namespace Orchestra\DuskUpdater; +use Exception; use RuntimeException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -84,15 +85,13 @@ protected function download(string $version, string $slug): string { $url = $this->resolveDownloadUrl($version, $slug); - file_put_contents( - $archive = $this->directory.'chromedriver.zip', - $resource = @fopen($url, 'r') - ); - - if (! \is_resource($resource) || ! file_exists($archive)) { + try { + file_put_contents( + $archive = $this->directory.'chromedriver.zip', + $this->fetchUrl($url) + ); + } catch (Exception $e) { throw new RuntimeException("Unable to retrieve ChromeDriver [{$version}]."); - } else { - fclose($resource); } return $archive;