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> |
|
| 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> |
|
| 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. |
|
| 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.** |
|
| 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. | |
|
| 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> |
|
| 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.
|
* depending on the product.
|
||||||
*/
|
*/
|
||||||
downloadBaseUrl?: string;
|
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
|
* Specifies an executable path to be used in
|
||||||
* {@link PuppeteerNode.launch | puppeteer.launch}.
|
* {@link PuppeteerNode.launch | puppeteer.launch}.
|
||||||
|
@ -223,7 +223,7 @@ export class PuppeteerNode extends Puppeteer {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
get defaultDownloadPath(): string | undefined {
|
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.');
|
throw new Error('The current platform is not supported.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheDir =
|
const cacheDir = this.configuration.cacheDirectory!;
|
||||||
this.configuration.downloadPath ?? this.configuration.cacheDirectory!;
|
|
||||||
const installedBrowsers = await getInstalledBrowsers({
|
const installedBrowsers = await getInstalledBrowsers({
|
||||||
cacheDir,
|
cacheDir,
|
||||||
});
|
});
|
||||||
|
@ -125,12 +125,6 @@ export const getConfiguration = (): Configuration => {
|
|||||||
process.env['npm_package_config_puppeteer_download_base_url'] ??
|
process.env['npm_package_config_puppeteer_download_base_url'] ??
|
||||||
configuration.downloadBaseUrl ??
|
configuration.downloadBaseUrl ??
|
||||||
downloadHost;
|
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 =
|
configuration.cacheDirectory =
|
||||||
|
@ -11,10 +11,7 @@ import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
|||||||
|
|
||||||
import puppeteer from '../puppeteer.js';
|
import puppeteer from '../puppeteer.js';
|
||||||
|
|
||||||
// TODO: deprecate downloadPath in favour of cacheDirectory.
|
const cacheDir = puppeteer.configuration.cacheDirectory!;
|
||||||
const cacheDir =
|
|
||||||
puppeteer.configuration.downloadPath ??
|
|
||||||
puppeteer.configuration.cacheDirectory!;
|
|
||||||
|
|
||||||
void new CLI({
|
void new CLI({
|
||||||
cachePath: cacheDir,
|
cachePath: cacheDir,
|
||||||
|
@ -53,8 +53,7 @@ export async function downloadBrowser(): Promise<void> {
|
|||||||
PUPPETEER_REVISIONS['chrome-headless-shell'] ||
|
PUPPETEER_REVISIONS['chrome-headless-shell'] ||
|
||||||
'latest';
|
'latest';
|
||||||
|
|
||||||
// TODO: deprecate downloadPath in favour of cacheDirectory.
|
const cacheDir = configuration.cacheDirectory!;
|
||||||
const cacheDir = configuration.downloadPath ?? configuration.cacheDirectory!;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const installationJobs = [];
|
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.
|
// Skipping this test on Windows as windows runners are much slower.
|
||||||
(platform() === 'win32' ? describe.skip : describe)(
|
(platform() === 'win32' ? describe.skip : describe)(
|
||||||
'`puppeteer` clears cache',
|
'`puppeteer` clears cache',
|
||||||
|
Loading…
Reference in New Issue
Block a user