From 467728187737283191f6528676e50d53dae6e5ef Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Fri, 2 Feb 2024 13:14:38 +0100 Subject: [PATCH] feat!: remove PUPPETEER_DOWNLOAD_PATH in favor of PUPPETEER_CACHE_DIR (#11605) --- docs/api/puppeteer.configuration.md | 1 - .../src/common/Configuration.ts | 8 ------ .../puppeteer-core/src/node/PuppeteerNode.ts | 5 ++-- packages/puppeteer/src/getConfiguration.ts | 6 ----- packages/puppeteer/src/node/cli.ts | 5 +--- packages/puppeteer/src/node/install.ts | 3 +-- test/installation/src/puppeteer.spec.ts | 25 ------------------- 7 files changed, 4 insertions(+), 49 deletions(-) diff --git a/docs/api/puppeteer.configuration.md b/docs/api/puppeteer.configuration.md index 17e43d53aad..b24150fe8b8 100644 --- a/docs/api/puppeteer.configuration.md +++ b/docs/api/puppeteer.configuration.md @@ -22,7 +22,6 @@ export interface Configuration | cacheDirectory | optional | string |

Defines the directory to be used by Puppeteer for caching.

Can be overridden by PUPPETEER_CACHE_DIR.

| path.join(os.homedir(), '.cache', 'puppeteer') | | defaultProduct | optional | [Product](./puppeteer.product.md) |

Specifies which browser you'd like Puppeteer to use.

Can be overridden by PUPPETEER_PRODUCT.

| chrome | | downloadBaseUrl | optional | string |

Specifies the URL prefix that is used to download the browser.

Can be overridden by PUPPETEER_DOWNLOAD_BASE_URL.

| 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 | optional | string |

Specifies the path for the downloads folder.

Can be overridden by PUPPETEER_DOWNLOAD_PATH.

| <cacheDirectory> | | executablePath | optional | string |

Specifies an executable path to be used in [puppeteer.launch](./puppeteer.puppeteernode.launch.md).

Can be overridden by PUPPETEER_EXECUTABLE_PATH.

| **Auto-computed.** | | experiments | optional | [ExperimentsConfiguration](./puppeteer.experimentsconfiguration.md) | Defines experimental options for Puppeteer. | | | logLevel | optional | 'silent' \| 'error' \| 'warn' | Tells Puppeteer to log at the given level. | warn | diff --git a/packages/puppeteer-core/src/common/Configuration.ts b/packages/puppeteer-core/src/common/Configuration.ts index 7b55ef39d08..bfc06ca7c02 100644 --- a/packages/puppeteer-core/src/common/Configuration.ts +++ b/packages/puppeteer-core/src/common/Configuration.ts @@ -62,14 +62,6 @@ export interface Configuration { * depending on the product. */ downloadBaseUrl?: string; - /** - * Specifies the path for the downloads folder. - * - * Can be overridden by `PUPPETEER_DOWNLOAD_PATH`. - * - * @defaultValue `` - */ - downloadPath?: string; /** * Specifies an executable path to be used in * {@link PuppeteerNode.launch | puppeteer.launch}. diff --git a/packages/puppeteer-core/src/node/PuppeteerNode.ts b/packages/puppeteer-core/src/node/PuppeteerNode.ts index e50e09acdb4..726ee24cbb4 100644 --- a/packages/puppeteer-core/src/node/PuppeteerNode.ts +++ b/packages/puppeteer-core/src/node/PuppeteerNode.ts @@ -223,7 +223,7 @@ export class PuppeteerNode extends Puppeteer { * @internal */ get defaultDownloadPath(): string | undefined { - return this.configuration.downloadPath ?? this.configuration.cacheDirectory; + return this.configuration.cacheDirectory; } /** @@ -283,8 +283,7 @@ export class PuppeteerNode extends Puppeteer { throw new Error('The current platform is not supported.'); } - const cacheDir = - this.configuration.downloadPath ?? this.configuration.cacheDirectory!; + const cacheDir = this.configuration.cacheDirectory!; const installedBrowsers = await getInstalledBrowsers({ cacheDir, }); diff --git a/packages/puppeteer/src/getConfiguration.ts b/packages/puppeteer/src/getConfiguration.ts index 1e0df4d6418..6fd88678a45 100644 --- a/packages/puppeteer/src/getConfiguration.ts +++ b/packages/puppeteer/src/getConfiguration.ts @@ -125,12 +125,6 @@ export const getConfiguration = (): Configuration => { 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'] ?? - process.env['npm_package_config_puppeteer_download_path'] ?? - configuration.downloadPath; } configuration.cacheDirectory = diff --git a/packages/puppeteer/src/node/cli.ts b/packages/puppeteer/src/node/cli.ts index 9a25c593274..39c1736e417 100644 --- a/packages/puppeteer/src/node/cli.ts +++ b/packages/puppeteer/src/node/cli.ts @@ -11,10 +11,7 @@ import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js'; import puppeteer from '../puppeteer.js'; -// TODO: deprecate downloadPath in favour of cacheDirectory. -const cacheDir = - puppeteer.configuration.downloadPath ?? - puppeteer.configuration.cacheDirectory!; +const cacheDir = puppeteer.configuration.cacheDirectory!; void new CLI({ cachePath: cacheDir, diff --git a/packages/puppeteer/src/node/install.ts b/packages/puppeteer/src/node/install.ts index 76bad868b8e..5b2cbe18879 100644 --- a/packages/puppeteer/src/node/install.ts +++ b/packages/puppeteer/src/node/install.ts @@ -53,8 +53,7 @@ export async function downloadBrowser(): Promise { PUPPETEER_REVISIONS['chrome-headless-shell'] || 'latest'; - // TODO: deprecate downloadPath in favour of cacheDirectory. - const cacheDir = configuration.downloadPath ?? configuration.cacheDirectory!; + const cacheDir = configuration.cacheDirectory!; try { const installationJobs = []; diff --git a/test/installation/src/puppeteer.spec.ts b/test/installation/src/puppeteer.spec.ts index d7b8757284d..ac0a96f1d15 100644 --- a/test/installation/src/puppeteer.spec.ts +++ b/test/installation/src/puppeteer.spec.ts @@ -39,31 +39,6 @@ describe('`puppeteer`', () => { }); }); -// Skipping this test on Windows as windows runners are much slower. -(platform() === 'win32' ? describe.skip : describe)( - '`puppeteer` with PUPPETEER_DOWNLOAD_PATH', - () => { - configureSandbox({ - dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'], - env: cwd => { - return { - PUPPETEER_DOWNLOAD_PATH: join(cwd, '.cache', 'puppeteer'), - }; - }, - }); - - it('evaluates', async function () { - const files = await readdir(join(this.sandbox, '.cache', 'puppeteer')); - assert.equal(files.length, 2); - assert(files.includes('chrome')); - assert(files.includes('chrome-headless-shell')); - - const script = await readAsset('puppeteer', 'basic.js'); - await this.runScript(script, 'mjs'); - }); - } -); - // Skipping this test on Windows as windows runners are much slower. (platform() === 'win32' ? describe.skip : describe)( '`puppeteer` clears cache',