Skip to content

Commit

Permalink
feat!: remove PUPPETEER_DOWNLOAD_PATH in favor of PUPPETEER_CACHE_DIR (
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Feb 2, 2024
1 parent 9cb1fde commit 4677281
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 49 deletions.
1 change: 0 additions & 1 deletion docs/api/puppeteer.configuration.md
Expand Up @@ -22,7 +22,6 @@ export interface Configuration
| 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> |
| 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;cacheDirectory&gt;</code> |
| 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' | Tells Puppeteer to log at the given level. | <code>warn</code> |
Expand Down
8 changes: 0 additions & 8 deletions packages/puppeteer-core/src/common/Configuration.ts
Expand Up @@ -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 `<cacheDirectory>`
*/
downloadPath?: string;
/**
* Specifies an executable path to be used in
* {@link PuppeteerNode.launch | puppeteer.launch}.
Expand Down
5 changes: 2 additions & 3 deletions packages/puppeteer-core/src/node/PuppeteerNode.ts
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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,
});
Expand Down
6 changes: 0 additions & 6 deletions packages/puppeteer/src/getConfiguration.ts
Expand Up @@ -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 =
Expand Down
5 changes: 1 addition & 4 deletions packages/puppeteer/src/node/cli.ts
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions packages/puppeteer/src/node/install.ts
Expand Up @@ -53,8 +53,7 @@ export async function downloadBrowser(): Promise<void> {
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 = [];
Expand Down
25 changes: 0 additions & 25 deletions test/installation/src/puppeteer.spec.ts
Expand Up @@ -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',
Expand Down

0 comments on commit 4677281

Please sign in to comment.