Skip to content

Commit

Permalink
Merge branch '1.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Jul 21, 2023
2 parents 4cbcec6 + eb854df commit 8b90e16
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}]");
}
Expand Down
10 changes: 5 additions & 5 deletions src/Concerns/DetectsChromeVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
));
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Orchestra\DuskUpdater;

use Exception;
use RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8b90e16

Please sign in to comment.