Skip to content

Commit

Permalink
feat!: rename PUPPETEER_DOWNLOAD_HOST to PUPPETEER_DOWNLOAD_BASE_URL
Browse files Browse the repository at this point in the history
Change to Chrome for Testing changed the servers we download binaries
from so PUPPETEER_DOWNLOAD_HOST would not work as it used to because
the rest of the file structure changed too. This change documents
the breaking change and removes the PUPPETEER_DOWNLOAD_HOST in
favour of PUPPETEER_DOWNLOAD_BASE_URL.
  • Loading branch information
OrKoN committed May 4, 2023
1 parent 8d08b2f commit 4bf1258
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/api/puppeteer.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Configuration
| browserRevision | <code>optional</code> | string | <p>Specifies a certain version of the browser you'd like Puppeteer to use.</p><p>Can be overridden by <code>PUPPETEER_BROWSER_REVISION</code>.</p><p>See [puppeteer.launch](./puppeteer.puppeteernode.launch.md) on how executable path is inferred.</p> | A compatible-revision of the browser. |
| cacheDirectory | <code>optional</code> | string | <p>Defines the directory to be used by Puppeteer for caching.</p><p>Can be overridden by <code>PUPPETEER_CACHE_DIR</code>.</p> | <code>path.join(os.homedir(), '.cache', 'puppeteer')</code> |
| defaultProduct | <code>optional</code> | [Product](./puppeteer.product.md) | <p>Specifies which browser you'd like Puppeteer to use.</p><p>Can be overridden by <code>PUPPETEER_PRODUCT</code>.</p> | <code>chrome</code> |
| downloadHost | <code>optional</code> | string | <p>Specifies the URL prefix that is used to download the browser.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_HOST</code>.</p> | Either https://storage.googleapis.com or https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central, depending on the product. |
| downloadBaseUrl | <code>optional</code> | string | <p>Specifies the URL prefix that is used to download the browser.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_BASE_URL</code>.</p> | Either https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central, depending on the product. |
| downloadPath | <code>optional</code> | string | <p>Specifies the path for the downloads folder.</p><p>Can be overridden by <code>PUPPETEER_DOWNLOAD_PATH</code>.</p> | <code>&lt;cache&gt;/&lt;product&gt;</code> where <code>&lt;cache&gt;</code> is Puppeteer's cache directory and <code>&lt;product&gt;</code> is the name of the browser. |
| executablePath | <code>optional</code> | string | <p>Specifies an executable path to be used in [puppeteer.launch](./puppeteer.puppeteernode.launch.md).</p><p>Can be overridden by <code>PUPPETEER_EXECUTABLE_PATH</code>.</p> | **Auto-computed.** |
| experiments | <code>optional</code> | [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) | Defines experimental options for Puppeteer. | |
Expand Down
18 changes: 9 additions & 9 deletions docs/browsers-api/browsers.installoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export interface InstallOptions

## Properties

| Property | Modifiers | Type | Description | Default |
| ------------------------ | --------------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| baseUrl | <code>optional</code> | string | Determines the host that will be used for downloading. | <p>Either</p><p>- https://storage.googleapis.com/chromium-browser-snapshots or - https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central</p> |
| browser | | [Browser](./browsers.browser.md) | Determines which browser to install. | |
| buildId | | string | Determines which buildId to dowloand. BuildId should uniquely identify binaries and they are used for caching. | |
| cacheDir | | string | Determines the path to download browsers to. | |
| downloadProgressCallback | <code>optional</code> | (downloadedBytes: number, totalBytes: number) =&gt; void | Provides information about the progress of the download. | |
| platform | <code>optional</code> | [BrowserPlatform](./browsers.browserplatform.md) | Determines which platform the browser will be suited for. | **Auto-detected.** |
| unpack | <code>optional</code> | boolean | Whether to unpack and install browser archives. | <code>true</code> |
| Property | Modifiers | Type | Description | Default |
| ------------------------ | --------------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| baseUrl | <code>optional</code> | string | Determines the host that will be used for downloading. | <p>Either</p><p>- https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or - https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central</p> |
| browser | | [Browser](./browsers.browser.md) | Determines which browser to install. | |
| buildId | | string | Determines which buildId to dowloand. BuildId should uniquely identify binaries and they are used for caching. | |
| cacheDir | | string | Determines the path to download browsers to. | |
| downloadProgressCallback | <code>optional</code> | (downloadedBytes: number, totalBytes: number) =&gt; void | Provides information about the progress of the download. | |
| platform | <code>optional</code> | [BrowserPlatform](./browsers.browserplatform.md) | Determines which platform the browser will be suited for. | **Auto-detected.** |
| unpack | <code>optional</code> | boolean | Whether to unpack and install browser archives. | <code>true</code> |
2 changes: 1 addition & 1 deletion packages/browsers/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface InstallOptions {
*
* @defaultValue Either
*
* - https://storage.googleapis.com/chromium-browser-snapshots or
* - https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or
* - https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central
*
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/puppeteer-core/src/common/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ export interface Configuration {
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_DOWNLOAD_HOST`.
* Can be overridden by `PUPPETEER_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
*
* @defaultValue Either https://storage.googleapis.com or
* @defaultValue Either https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing or
* https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central,
* depending on the product.
*/
downloadHost?: string;
downloadBaseUrl?: string;
/**
* Specifies the path for the downloads folder.
*
Expand Down
10 changes: 5 additions & 5 deletions packages/puppeteer/src/getConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export const getConfiguration = (): Configuration => {
process.env['npm_config_puppeteer_browser_revision'] ??
process.env['npm_package_config_puppeteer_browser_revision'] ??
configuration.browserRevision;
configuration.downloadHost =
process.env['PUPPETEER_DOWNLOAD_HOST'] ??
process.env['npm_config_puppeteer_download_host'] ??
process.env['npm_package_config_puppeteer_download_host'] ??
configuration.downloadHost;
configuration.downloadBaseUrl =
process.env['PUPPETEER_DOWNLOAD_BASE_URL'] ??
process.env['npm_config_puppeteer_download_base_url'] ??
process.env['npm_package_config_puppeteer_download_base_url'] ??
configuration.downloadBaseUrl;
configuration.downloadPath =
process.env['PUPPETEER_DOWNLOAD_PATH'] ??
process.env['npm_config_puppeteer_download_path'] ??
Expand Down
6 changes: 2 additions & 4 deletions packages/puppeteer/src/node/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function downloadBrowser(): Promise<void> {
return;
}

const downloadHost = configuration.downloadHost;
const downloadBaseUrl = configuration.downloadBaseUrl;

const platform = detectBrowserPlatform();
if (!platform) {
Expand All @@ -68,9 +68,7 @@ export async function downloadBrowser(): Promise<void> {
platform,
buildId,
downloadProgressCallback: makeProgressCallback(browser, buildId),
// TODO: remove downloadHost in favour of baseDownloadUrl. The "host" of
// Firefox is already a URL and not a host. This would be a breaking change.
baseUrl: downloadHost,
baseUrl: downloadBaseUrl,
});

logPolitely(
Expand Down

0 comments on commit 4bf1258

Please sign in to comment.