mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: rename PUPPETEER_DOWNLOAD_HOST to PUPPETEER_DOWNLOAD_BASE_URL (#10130)
This commit is contained in:
parent
9e21d30f75
commit
9758cae029
@ -21,10 +21,10 @@ 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><cache>/<product></code> where <code><cache></code> is Puppeteer's cache directory and <code><product></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. | |
|
||||
| logLevel | <code>optional</code> | 'silent' \| 'error' \| 'warn' | <p>Tells Puppeteer to log at the given level.</p><p>At the moment, any option silences logging.</p> | <code>undefined</code> |
|
||||
| logLevel | <code>optional</code> | 'silent' \| 'error' \| 'warn' | Tells Puppeteer to log at the given level. | <code>warn</code> |
|
||||
| skipDownload | <code>optional</code> | boolean | <p>Tells Puppeteer to not download during installation.</p><p>Can be overridden by <code>PUPPETEER_SKIP_DOWNLOAD</code>.</p> | |
|
||||
| temporaryDirectory | <code>optional</code> | string | <p>Defines the directory to be used by Puppeteer for creating temporary files.</p><p>Can be overridden by <code>PUPPETEER_TMP_DIR</code>.</p> | <code>os.tmpdir()</code> |
|
||||
|
@ -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) => 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) => 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> |
|
||||
|
@ -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
|
||||
*
|
||||
*/
|
||||
|
@ -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.
|
||||
*
|
||||
@ -109,9 +109,7 @@ export interface Configuration {
|
||||
/**
|
||||
* Tells Puppeteer to log at the given level.
|
||||
*
|
||||
* At the moment, any option silences logging.
|
||||
*
|
||||
* @defaultValue `undefined`
|
||||
* @defaultValue `warn`
|
||||
*/
|
||||
logLevel?: 'silent' | 'error' | 'warn';
|
||||
/**
|
||||
|
@ -48,8 +48,7 @@ export class ChromeLauncher extends ProductLauncher {
|
||||
const headless = options.headless ?? true;
|
||||
if (
|
||||
headless === true &&
|
||||
(!this.puppeteer.configuration.logLevel ||
|
||||
this.puppeteer.configuration.logLevel === 'warn') &&
|
||||
this.puppeteer.configuration.logLevel === 'warn' &&
|
||||
!Boolean(process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'])
|
||||
) {
|
||||
console.warn(
|
||||
|
@ -24,6 +24,12 @@ export const getConfiguration = (): Configuration => {
|
||||
const result = cosmiconfigSync('puppeteer').search();
|
||||
const configuration: Configuration = result ? result.config : {};
|
||||
|
||||
configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
|
||||
process.env['npm_config_LOGLEVEL'] ??
|
||||
process.env['npm_package_config_LOGLEVEL'] ??
|
||||
configuration.logLevel ??
|
||||
'warn') as 'silent' | 'error' | 'warn';
|
||||
|
||||
// Merging environment variables.
|
||||
configuration.defaultProduct = (process.env['PUPPETEER_PRODUCT'] ??
|
||||
process.env['npm_config_puppeteer_product'] ??
|
||||
@ -57,11 +63,25 @@ export const getConfiguration = (): Configuration => {
|
||||
process.env['npm_config_puppeteer_browser_revision'] ??
|
||||
process.env['npm_package_config_puppeteer_browser_revision'] ??
|
||||
configuration.browserRevision;
|
||||
configuration.downloadHost =
|
||||
|
||||
const downloadHost =
|
||||
process.env['PUPPETEER_DOWNLOAD_HOST'] ??
|
||||
process.env['npm_config_puppeteer_download_host'] ??
|
||||
process.env['npm_package_config_puppeteer_download_host'] ??
|
||||
configuration.downloadHost;
|
||||
process.env['npm_package_config_puppeteer_download_host'];
|
||||
|
||||
if (downloadHost && configuration.logLevel === 'warn') {
|
||||
console.warn(
|
||||
`PUPPETEER_DOWNLOAD_HOST is deprecated. Use PUPPETEER_DOWNLOAD_BASE_URL instead.`
|
||||
);
|
||||
}
|
||||
|
||||
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 ??
|
||||
downloadHost;
|
||||
|
||||
configuration.downloadPath =
|
||||
process.env['PUPPETEER_DOWNLOAD_PATH'] ??
|
||||
process.env['npm_config_puppeteer_download_path'] ??
|
||||
@ -83,11 +103,6 @@ export const getConfiguration = (): Configuration => {
|
||||
|
||||
configuration.experiments ??= {};
|
||||
|
||||
configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
|
||||
process.env['npm_config_LOGLEVEL'] ??
|
||||
process.env['npm_package_config_LOGLEVEL'] ??
|
||||
configuration.logLevel) as 'silent' | 'error' | 'warn';
|
||||
|
||||
// Validate configuration.
|
||||
if (!isSupportedProduct(configuration.defaultProduct)) {
|
||||
throw new Error(`Unsupported product ${configuration.defaultProduct}`);
|
||||
|
@ -46,7 +46,7 @@ export async function downloadBrowser(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadHost = configuration.downloadHost;
|
||||
const downloadBaseUrl = configuration.downloadBaseUrl;
|
||||
|
||||
const platform = detectBrowserPlatform();
|
||||
if (!platform) {
|
||||
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user