Node updated. Some todos.
This commit is contained in:
30
Scripts/node_modules/puppeteer/src/node/cli.ts
generated
vendored
30
Scripts/node_modules/puppeteer/src/node/cli.ts
generated
vendored
@ -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,
|
||||
@ -25,8 +22,27 @@ void new CLI({
|
||||
},
|
||||
allowCachePathOverride: false,
|
||||
pinnedBrowsers: {
|
||||
[Browser.CHROME]: PUPPETEER_REVISIONS.chrome,
|
||||
[Browser.FIREFOX]: PUPPETEER_REVISIONS.firefox,
|
||||
[Browser.CHROMEHEADLESSSHELL]: PUPPETEER_REVISIONS['chrome-headless-shell'],
|
||||
[Browser.CHROME]: {
|
||||
buildId:
|
||||
puppeteer.configuration.chrome?.version ||
|
||||
PUPPETEER_REVISIONS['chrome'] ||
|
||||
'latest',
|
||||
skipDownload: puppeteer.configuration.chrome?.skipDownload ?? false,
|
||||
},
|
||||
[Browser.FIREFOX]: {
|
||||
buildId:
|
||||
puppeteer.configuration.firefox?.version ||
|
||||
PUPPETEER_REVISIONS['firefox'] ||
|
||||
'latest',
|
||||
skipDownload: puppeteer.configuration.firefox?.skipDownload ?? true,
|
||||
},
|
||||
[Browser.CHROMEHEADLESSSHELL]: {
|
||||
buildId:
|
||||
puppeteer.configuration['chrome-headless-shell']?.version ||
|
||||
PUPPETEER_REVISIONS['chrome-headless-shell'] ||
|
||||
'latest',
|
||||
skipDownload:
|
||||
puppeteer.configuration['chrome-headless-shell']?.skipDownload ?? false,
|
||||
},
|
||||
},
|
||||
}).run(process.argv);
|
||||
|
||||
197
Scripts/node_modules/puppeteer/src/node/install.ts
generated
vendored
197
Scripts/node_modules/puppeteer/src/node/install.ts
generated
vendored
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type {BrowserPlatform} from '@puppeteer/browsers';
|
||||
import {
|
||||
install,
|
||||
Browser,
|
||||
@ -11,126 +12,120 @@ import {
|
||||
makeProgressCallback,
|
||||
detectBrowserPlatform,
|
||||
} from '@puppeteer/browsers';
|
||||
import type {Product} from 'puppeteer-core';
|
||||
import type {
|
||||
ChromeHeadlessShellSettings,
|
||||
ChromeSettings,
|
||||
FirefoxSettings,
|
||||
} from 'puppeteer-core';
|
||||
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
||||
|
||||
import {getConfiguration} from '../getConfiguration.js';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const supportedProducts = {
|
||||
chrome: 'Chrome',
|
||||
firefox: 'Firefox Nightly',
|
||||
} as const;
|
||||
async function downloadBrowser({
|
||||
browser,
|
||||
configuration,
|
||||
cacheDir,
|
||||
platform,
|
||||
}: {
|
||||
browser: Extract<
|
||||
Browser,
|
||||
Browser.CHROME | Browser.CHROMEHEADLESSSHELL | Browser.FIREFOX
|
||||
>;
|
||||
configuration: ChromeSettings | ChromeHeadlessShellSettings | FirefoxSettings;
|
||||
platform: BrowserPlatform;
|
||||
cacheDir: string;
|
||||
}) {
|
||||
const unresolvedBuildId =
|
||||
configuration?.version || PUPPETEER_REVISIONS[browser] || 'latest';
|
||||
const baseUrl = configuration?.downloadBaseUrl;
|
||||
const buildId = await resolveBuildId(browser, platform, unresolvedBuildId);
|
||||
|
||||
try {
|
||||
const result = await install({
|
||||
browser,
|
||||
cacheDir,
|
||||
platform,
|
||||
buildId,
|
||||
downloadProgressCallback: makeProgressCallback(browser, buildId),
|
||||
baseUrl,
|
||||
buildIdAlias:
|
||||
buildId !== unresolvedBuildId ? unresolvedBuildId : undefined,
|
||||
});
|
||||
logPolitely(`${browser} (${result.buildId}) downloaded to ${result.path}`);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`ERROR: Failed to set up ${browser} v${buildId}! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.`,
|
||||
{
|
||||
cause: error,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export async function downloadBrowser(): Promise<void> {
|
||||
export async function downloadBrowsers(): Promise<void> {
|
||||
overrideProxy();
|
||||
|
||||
const configuration = getConfiguration();
|
||||
if (configuration.skipDownload) {
|
||||
logPolitely('**INFO** Skipping browser download as instructed.');
|
||||
logPolitely('**INFO** Skipping downloading browsers as instructed.');
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadBaseUrl = configuration.downloadBaseUrl;
|
||||
|
||||
const platform = detectBrowserPlatform();
|
||||
if (!platform) {
|
||||
throw new Error('The current platform is not supported.');
|
||||
}
|
||||
const cacheDir = configuration.cacheDirectory!;
|
||||
|
||||
const product = configuration.defaultProduct!;
|
||||
const browser = productToBrowser(product);
|
||||
const installationJobs = [];
|
||||
if (configuration.chrome?.skipDownload) {
|
||||
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
||||
} else {
|
||||
const browser = Browser.CHROME;
|
||||
installationJobs.push(
|
||||
downloadBrowser({
|
||||
browser,
|
||||
configuration: configuration[browser] ?? {},
|
||||
cacheDir,
|
||||
platform,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
const unresolvedBuildId =
|
||||
configuration.browserRevision || PUPPETEER_REVISIONS[product] || 'latest';
|
||||
const unresolvedShellBuildId =
|
||||
configuration.browserRevision ||
|
||||
PUPPETEER_REVISIONS['chrome-headless-shell'] ||
|
||||
'latest';
|
||||
if (configuration['chrome-headless-shell']?.skipDownload) {
|
||||
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
||||
} else {
|
||||
const browser = Browser.CHROMEHEADLESSSHELL;
|
||||
|
||||
// TODO: deprecate downloadPath in favour of cacheDirectory.
|
||||
const cacheDir = configuration.downloadPath ?? configuration.cacheDirectory!;
|
||||
installationJobs.push(
|
||||
downloadBrowser({
|
||||
browser,
|
||||
configuration: configuration[browser] ?? {},
|
||||
cacheDir,
|
||||
platform,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (configuration.firefox?.skipDownload) {
|
||||
logPolitely('**INFO** Skipping Firefox download as instructed.');
|
||||
} else {
|
||||
const browser = Browser.FIREFOX;
|
||||
|
||||
installationJobs.push(
|
||||
downloadBrowser({
|
||||
browser,
|
||||
configuration: configuration[browser] ?? {},
|
||||
cacheDir,
|
||||
platform,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const installationJobs = [];
|
||||
|
||||
if (configuration.skipChromeDownload) {
|
||||
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
||||
} else {
|
||||
const buildId = await resolveBuildId(
|
||||
browser,
|
||||
platform,
|
||||
unresolvedBuildId
|
||||
);
|
||||
installationJobs.push(
|
||||
install({
|
||||
browser,
|
||||
cacheDir,
|
||||
platform,
|
||||
buildId,
|
||||
downloadProgressCallback: makeProgressCallback(browser, buildId),
|
||||
baseUrl: downloadBaseUrl,
|
||||
})
|
||||
.then(result => {
|
||||
logPolitely(
|
||||
`${supportedProducts[product]} (${result.buildId}) downloaded to ${result.path}`
|
||||
);
|
||||
})
|
||||
.catch(error => {
|
||||
throw new Error(
|
||||
`ERROR: Failed to set up ${supportedProducts[product]} v${buildId}! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.`,
|
||||
{
|
||||
cause: error,
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (browser === Browser.CHROME) {
|
||||
if (configuration.skipChromeHeadlessShellDownload) {
|
||||
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
||||
} else {
|
||||
const shellBuildId = await resolveBuildId(
|
||||
browser,
|
||||
platform,
|
||||
unresolvedShellBuildId
|
||||
);
|
||||
|
||||
installationJobs.push(
|
||||
install({
|
||||
browser: Browser.CHROMEHEADLESSSHELL,
|
||||
cacheDir,
|
||||
platform,
|
||||
buildId: shellBuildId,
|
||||
downloadProgressCallback: makeProgressCallback(
|
||||
browser,
|
||||
shellBuildId
|
||||
),
|
||||
baseUrl: downloadBaseUrl,
|
||||
})
|
||||
.then(result => {
|
||||
logPolitely(
|
||||
`${Browser.CHROMEHEADLESSSHELL} (${result.buildId}) downloaded to ${result.path}`
|
||||
);
|
||||
})
|
||||
.catch(error => {
|
||||
throw new Error(
|
||||
`ERROR: Failed to set up ${Browser.CHROMEHEADLESSSHELL} v${shellBuildId}! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.`,
|
||||
{
|
||||
cause: error,
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(installationJobs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -138,16 +133,6 @@ export async function downloadBrowser(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function productToBrowser(product?: Product) {
|
||||
switch (product) {
|
||||
case 'chrome':
|
||||
return Browser.CHROME;
|
||||
case 'firefox':
|
||||
return Browser.FIREFOX;
|
||||
}
|
||||
return Browser.CHROME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user