mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat!: remove PUPPETEER_DOWNLOAD_PATH in favor of PUPPETEER_CACHE_DIR (#11605)
This commit is contained in:
parent
9cb1fde589
commit
4677281877
@ -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><cacheDirectory></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> |
|
||||
|
@ -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}.
|
||||
|
@ -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,
|
||||
});
|
||||
|
@ -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 =
|
||||
|
@ -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,
|
||||
|
@ -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 = [];
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user