@puppeteer/browsers
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -112,3 +112,2 @@ "use strict"; | ||
'browser.safebrowsing.malware.enabled': false, | ||
'browser.safebrowsing.passwords.enabled': false, | ||
'browser.safebrowsing.phishing.enabled': false, | ||
@@ -184,6 +183,2 @@ // Disable updates to search engines. | ||
'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`, | ||
// Temporarily force disable BFCache in parent (https://bit.ly/bug-1732263) | ||
'fission.bfcacheInParent': false, | ||
// Force all web content to use a single content process | ||
'fission.webContentIsolationStrategy': 0, | ||
// Allow the application to have focus even it runs in the background | ||
@@ -190,0 +185,0 @@ 'focusmanager.testmode': true, |
@@ -29,3 +29,3 @@ /** | ||
/** | ||
* Platform names used to identify a OS platfrom x architecture combination in the way | ||
* Platform names used to identify a OS platform x architecture combination in the way | ||
* that is relevant for the browser download. | ||
@@ -32,0 +32,0 @@ * |
@@ -33,3 +33,3 @@ "use strict"; | ||
/** | ||
* Platform names used to identify a OS platfrom x architecture combination in the way | ||
* Platform names used to identify a OS platform x architecture combination in the way | ||
* that is relevant for the browser download. | ||
@@ -36,0 +36,0 @@ * |
@@ -24,3 +24,14 @@ /** | ||
#private; | ||
constructor(cachePath?: string, rl?: readline.Interface); | ||
constructor(opts?: string | { | ||
cachePath?: string; | ||
scriptName?: string; | ||
prefixCommand?: { | ||
cmd: string; | ||
description: string; | ||
}; | ||
allowCachePathOverride?: boolean; | ||
pinnedBrowsers?: Partial<{ | ||
[key in Browser]: string; | ||
}>; | ||
}, rl?: readline.Interface); | ||
run(argv: string[]): Promise<void>; | ||
@@ -27,0 +38,0 @@ } |
@@ -61,5 +61,21 @@ "use strict"; | ||
#rl; | ||
constructor(cachePath = process.cwd(), rl) { | ||
this.#cachePath = cachePath; | ||
#scriptName = ''; | ||
#allowCachePathOverride = true; | ||
#pinnedBrowsers; | ||
#prefixCommand; | ||
constructor(opts, rl) { | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
if (typeof opts === 'string') { | ||
opts = { | ||
cachePath: opts, | ||
}; | ||
} | ||
this.#cachePath = opts.cachePath ?? process.cwd(); | ||
this.#rl = rl; | ||
this.#scriptName = opts.scriptName ?? '@puppeteer/browsers'; | ||
this.#allowCachePathOverride = opts.allowCachePathOverride ?? true; | ||
this.#pinnedBrowsers = opts.pinnedBrowsers; | ||
this.#prefixCommand = opts.prefixCommand; | ||
} | ||
@@ -87,2 +103,5 @@ #defineBrowserParameter(yargs) { | ||
#definePathParameter(yargs, required = false) { | ||
if (!this.#allowCachePathOverride) { | ||
return; | ||
} | ||
yargs.option('path', { | ||
@@ -100,4 +119,20 @@ type: 'string', | ||
const yargsInstance = (0, yargs_1.default)((0, helpers_1.hideBin)(argv)); | ||
await yargsInstance | ||
.scriptName('@puppeteer/browsers') | ||
let target = yargsInstance.scriptName(this.#scriptName); | ||
if (this.#prefixCommand) { | ||
target = target.command(this.#prefixCommand.cmd, this.#prefixCommand.description, yargs => { | ||
return this.#build(yargs); | ||
}); | ||
} | ||
else { | ||
target = this.#build(target); | ||
} | ||
await target | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
} | ||
#build(yargs) { | ||
const latestOrPinned = this.#pinnedBrowsers ? 'pinned' : 'latest'; | ||
return yargs | ||
.command('install <browser>', 'Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (format: <browser>@<buildID> <path>).', yargs => { | ||
@@ -111,3 +146,3 @@ this.#defineBrowserParameter(yargs); | ||
}); | ||
yargs.example('$0 install chrome', 'Install the latest available build of the Chrome browser.'); | ||
yargs.example('$0 install chrome', `Install the ${latestOrPinned} available build of the Chrome browser.`); | ||
yargs.example('$0 install chrome@latest', 'Install the latest available build for the Chrome browser.'); | ||
@@ -125,3 +160,5 @@ yargs.example('$0 install chrome@canary', 'Install the latest available build for the Chrome Canary browser.'); | ||
yargs.example('$0 install firefox --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.'); | ||
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.'); | ||
if (this.#allowCachePathOverride) { | ||
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.'); | ||
} | ||
}, async (argv) => { | ||
@@ -133,2 +170,9 @@ const args = argv; | ||
} | ||
if (args.browser.buildId === 'pinned') { | ||
const pinnedVersion = this.#pinnedBrowsers?.[args.browser.name]; | ||
if (!pinnedVersion) { | ||
throw new Error(`No pinned version found for ${args.browser.name}`); | ||
} | ||
args.browser.buildId = pinnedVersion; | ||
} | ||
args.browser.buildId = await (0, browser_data_js_1.resolveBuildId)(args.browser.name, args.platform, args.browser.buildId); | ||
@@ -188,3 +232,5 @@ await (0, install_js_1.install)({ | ||
}) | ||
.command('clear', 'Removes all installed browsers from the specified cache directory', yargs => { | ||
.command('clear', this.#allowCachePathOverride | ||
? 'Removes all installed browsers from the specified cache directory' | ||
: `Removes all installed browsers from ${this.#cachePath}`, yargs => { | ||
this.#definePathParameter(yargs, true); | ||
@@ -207,5 +253,3 @@ }, async (argv) => { | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
.help(); | ||
} | ||
@@ -217,3 +261,7 @@ #parseBrowser(version) { | ||
const parts = version.split('@'); | ||
return parts.length === 2 ? parts[1] : 'latest'; | ||
return parts.length === 2 | ||
? parts[1] | ||
: this.#pinnedBrowsers | ||
? 'pinned' | ||
: 'latest'; | ||
} | ||
@@ -220,0 +268,0 @@ } |
@@ -102,5 +102,11 @@ "use strict"; | ||
}); | ||
const env = opts.env || {}; | ||
debugLaunch(`Launching ${this.#executablePath} ${this.#args.join(' ')}`, { | ||
detached: opts.detached, | ||
env: opts.env, | ||
env: Object.keys(env).reduce((res, key) => { | ||
if (key.toLowerCase().startsWith('puppeteer_')) { | ||
res[key] = env[key]; | ||
} | ||
return res; | ||
}, {}), | ||
stdio, | ||
@@ -110,3 +116,3 @@ }); | ||
detached: opts.detached, | ||
env: opts.env, | ||
env, | ||
stdio, | ||
@@ -113,0 +119,0 @@ }); |
@@ -101,3 +101,2 @@ /** | ||
'browser.safebrowsing.malware.enabled': false, | ||
'browser.safebrowsing.passwords.enabled': false, | ||
'browser.safebrowsing.phishing.enabled': false, | ||
@@ -173,6 +172,2 @@ // Disable updates to search engines. | ||
'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`, | ||
// Temporarily force disable BFCache in parent (https://bit.ly/bug-1732263) | ||
'fission.bfcacheInParent': false, | ||
// Force all web content to use a single content process | ||
'fission.webContentIsolationStrategy': 0, | ||
// Allow the application to have focus even it runs in the background | ||
@@ -179,0 +174,0 @@ 'focusmanager.testmode': true, |
@@ -29,3 +29,3 @@ /** | ||
/** | ||
* Platform names used to identify a OS platfrom x architecture combination in the way | ||
* Platform names used to identify a OS platform x architecture combination in the way | ||
* that is relevant for the browser download. | ||
@@ -32,0 +32,0 @@ * |
@@ -30,3 +30,3 @@ /** | ||
/** | ||
* Platform names used to identify a OS platfrom x architecture combination in the way | ||
* Platform names used to identify a OS platform x architecture combination in the way | ||
* that is relevant for the browser download. | ||
@@ -33,0 +33,0 @@ * |
@@ -24,3 +24,14 @@ /** | ||
#private; | ||
constructor(cachePath?: string, rl?: readline.Interface); | ||
constructor(opts?: string | { | ||
cachePath?: string; | ||
scriptName?: string; | ||
prefixCommand?: { | ||
cmd: string; | ||
description: string; | ||
}; | ||
allowCachePathOverride?: boolean; | ||
pinnedBrowsers?: Partial<{ | ||
[key in Browser]: string; | ||
}>; | ||
}, rl?: readline.Interface); | ||
run(argv: string[]): Promise<void>; | ||
@@ -27,0 +38,0 @@ } |
@@ -32,5 +32,21 @@ /** | ||
#rl; | ||
constructor(cachePath = process.cwd(), rl) { | ||
this.#cachePath = cachePath; | ||
#scriptName = ''; | ||
#allowCachePathOverride = true; | ||
#pinnedBrowsers; | ||
#prefixCommand; | ||
constructor(opts, rl) { | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
if (typeof opts === 'string') { | ||
opts = { | ||
cachePath: opts, | ||
}; | ||
} | ||
this.#cachePath = opts.cachePath ?? process.cwd(); | ||
this.#rl = rl; | ||
this.#scriptName = opts.scriptName ?? '@puppeteer/browsers'; | ||
this.#allowCachePathOverride = opts.allowCachePathOverride ?? true; | ||
this.#pinnedBrowsers = opts.pinnedBrowsers; | ||
this.#prefixCommand = opts.prefixCommand; | ||
} | ||
@@ -58,2 +74,5 @@ #defineBrowserParameter(yargs) { | ||
#definePathParameter(yargs, required = false) { | ||
if (!this.#allowCachePathOverride) { | ||
return; | ||
} | ||
yargs.option('path', { | ||
@@ -71,4 +90,20 @@ type: 'string', | ||
const yargsInstance = yargs(hideBin(argv)); | ||
await yargsInstance | ||
.scriptName('@puppeteer/browsers') | ||
let target = yargsInstance.scriptName(this.#scriptName); | ||
if (this.#prefixCommand) { | ||
target = target.command(this.#prefixCommand.cmd, this.#prefixCommand.description, yargs => { | ||
return this.#build(yargs); | ||
}); | ||
} | ||
else { | ||
target = this.#build(target); | ||
} | ||
await target | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
} | ||
#build(yargs) { | ||
const latestOrPinned = this.#pinnedBrowsers ? 'pinned' : 'latest'; | ||
return yargs | ||
.command('install <browser>', 'Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (format: <browser>@<buildID> <path>).', yargs => { | ||
@@ -82,3 +117,3 @@ this.#defineBrowserParameter(yargs); | ||
}); | ||
yargs.example('$0 install chrome', 'Install the latest available build of the Chrome browser.'); | ||
yargs.example('$0 install chrome', `Install the ${latestOrPinned} available build of the Chrome browser.`); | ||
yargs.example('$0 install chrome@latest', 'Install the latest available build for the Chrome browser.'); | ||
@@ -96,3 +131,5 @@ yargs.example('$0 install chrome@canary', 'Install the latest available build for the Chrome Canary browser.'); | ||
yargs.example('$0 install firefox --platform mac', 'Install the latest Mac (Intel) build of the Firefox browser.'); | ||
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.'); | ||
if (this.#allowCachePathOverride) { | ||
yargs.example('$0 install firefox --path /tmp/my-browser-cache', 'Install to the specified cache directory.'); | ||
} | ||
}, async (argv) => { | ||
@@ -104,2 +141,9 @@ const args = argv; | ||
} | ||
if (args.browser.buildId === 'pinned') { | ||
const pinnedVersion = this.#pinnedBrowsers?.[args.browser.name]; | ||
if (!pinnedVersion) { | ||
throw new Error(`No pinned version found for ${args.browser.name}`); | ||
} | ||
args.browser.buildId = pinnedVersion; | ||
} | ||
args.browser.buildId = await resolveBuildId(args.browser.name, args.platform, args.browser.buildId); | ||
@@ -159,3 +203,5 @@ await install({ | ||
}) | ||
.command('clear', 'Removes all installed browsers from the specified cache directory', yargs => { | ||
.command('clear', this.#allowCachePathOverride | ||
? 'Removes all installed browsers from the specified cache directory' | ||
: `Removes all installed browsers from ${this.#cachePath}`, yargs => { | ||
this.#definePathParameter(yargs, true); | ||
@@ -178,5 +224,3 @@ }, async (argv) => { | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
.help(); | ||
} | ||
@@ -188,3 +232,7 @@ #parseBrowser(version) { | ||
const parts = version.split('@'); | ||
return parts.length === 2 ? parts[1] : 'latest'; | ||
return parts.length === 2 | ||
? parts[1] | ||
: this.#pinnedBrowsers | ||
? 'pinned' | ||
: 'latest'; | ||
} | ||
@@ -191,0 +239,0 @@ } |
@@ -93,5 +93,11 @@ /** | ||
}); | ||
const env = opts.env || {}; | ||
debugLaunch(`Launching ${this.#executablePath} ${this.#args.join(' ')}`, { | ||
detached: opts.detached, | ||
env: opts.env, | ||
env: Object.keys(env).reduce((res, key) => { | ||
if (key.toLowerCase().startsWith('puppeteer_')) { | ||
res[key] = env[key]; | ||
} | ||
return res; | ||
}, {}), | ||
stdio, | ||
@@ -101,3 +107,3 @@ }); | ||
detached: opts.detached, | ||
env: opts.env, | ||
env, | ||
stdio, | ||
@@ -104,0 +110,0 @@ }); |
{ | ||
"name": "@puppeteer/browsers", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Download and launch browsers", | ||
@@ -104,3 +104,10 @@ "scripts": { | ||
"yargs": "17.7.2" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "4.1.12", | ||
"@types/progress": "2.0.7", | ||
"@types/tar-fs": "2.0.4", | ||
"@types/unbzip2-stream": "1.4.3", | ||
"@types/yargs": "17.0.32" | ||
} | ||
} |
@@ -133,3 +133,2 @@ /** | ||
'browser.safebrowsing.malware.enabled': false, | ||
'browser.safebrowsing.passwords.enabled': false, | ||
'browser.safebrowsing.phishing.enabled': false, | ||
@@ -225,8 +224,2 @@ | ||
// Temporarily force disable BFCache in parent (https://bit.ly/bug-1732263) | ||
'fission.bfcacheInParent': false, | ||
// Force all web content to use a single content process | ||
'fission.webContentIsolationStrategy': 0, | ||
// Allow the application to have focus even it runs in the background | ||
@@ -233,0 +226,0 @@ 'focusmanager.testmode': true, |
@@ -31,3 +31,3 @@ /** | ||
/** | ||
* Platform names used to identify a OS platfrom x architecture combination in the way | ||
* Platform names used to identify a OS platform x architecture combination in the way | ||
* that is relevant for the browser download. | ||
@@ -34,0 +34,0 @@ * |
@@ -71,6 +71,33 @@ /** | ||
#rl?: readline.Interface; | ||
#scriptName = ''; | ||
#allowCachePathOverride = true; | ||
#pinnedBrowsers?: Partial<{[key in Browser]: string}>; | ||
#prefixCommand?: {cmd: string; description: string}; | ||
constructor(cachePath = process.cwd(), rl?: readline.Interface) { | ||
this.#cachePath = cachePath; | ||
constructor( | ||
opts?: | ||
| string | ||
| { | ||
cachePath?: string; | ||
scriptName?: string; | ||
prefixCommand?: {cmd: string; description: string}; | ||
allowCachePathOverride?: boolean; | ||
pinnedBrowsers?: Partial<{[key in Browser]: string}>; | ||
}, | ||
rl?: readline.Interface | ||
) { | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
if (typeof opts === 'string') { | ||
opts = { | ||
cachePath: opts, | ||
}; | ||
} | ||
this.#cachePath = opts.cachePath ?? process.cwd(); | ||
this.#rl = rl; | ||
this.#scriptName = opts.scriptName ?? '@puppeteer/browsers'; | ||
this.#allowCachePathOverride = opts.allowCachePathOverride ?? true; | ||
this.#pinnedBrowsers = opts.pinnedBrowsers; | ||
this.#prefixCommand = opts.prefixCommand; | ||
} | ||
@@ -102,2 +129,5 @@ | ||
#definePathParameter(yargs: Yargs.Argv<unknown>, required = false): void { | ||
if (!this.#allowCachePathOverride) { | ||
return; | ||
} | ||
yargs.option('path', { | ||
@@ -116,4 +146,24 @@ type: 'string', | ||
const yargsInstance = yargs(hideBin(argv)); | ||
await yargsInstance | ||
.scriptName('@puppeteer/browsers') | ||
let target = yargsInstance.scriptName(this.#scriptName); | ||
if (this.#prefixCommand) { | ||
target = target.command( | ||
this.#prefixCommand.cmd, | ||
this.#prefixCommand.description, | ||
yargs => { | ||
return this.#build(yargs); | ||
} | ||
); | ||
} else { | ||
target = this.#build(target); | ||
} | ||
await target | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
} | ||
#build(yargs: Yargs.Argv<unknown>): Yargs.Argv<unknown> { | ||
const latestOrPinned = this.#pinnedBrowsers ? 'pinned' : 'latest'; | ||
return yargs | ||
.command( | ||
@@ -132,3 +182,3 @@ 'install <browser>', | ||
'$0 install chrome', | ||
'Install the latest available build of the Chrome browser.' | ||
`Install the ${latestOrPinned} available build of the Chrome browser.` | ||
); | ||
@@ -183,6 +233,8 @@ yargs.example( | ||
); | ||
yargs.example( | ||
'$0 install firefox --path /tmp/my-browser-cache', | ||
'Install to the specified cache directory.' | ||
); | ||
if (this.#allowCachePathOverride) { | ||
yargs.example( | ||
'$0 install firefox --path /tmp/my-browser-cache', | ||
'Install to the specified cache directory.' | ||
); | ||
} | ||
}, | ||
@@ -195,2 +247,11 @@ async argv => { | ||
} | ||
if (args.browser.buildId === 'pinned') { | ||
const pinnedVersion = this.#pinnedBrowsers?.[args.browser.name]; | ||
if (!pinnedVersion) { | ||
throw new Error( | ||
`No pinned version found for ${args.browser.name}` | ||
); | ||
} | ||
args.browser.buildId = pinnedVersion; | ||
} | ||
args.browser.buildId = await resolveBuildId( | ||
@@ -281,3 +342,5 @@ args.browser.name, | ||
'clear', | ||
'Removes all installed browsers from the specified cache directory', | ||
this.#allowCachePathOverride | ||
? 'Removes all installed browsers from the specified cache directory' | ||
: `Removes all installed browsers from ${this.#cachePath}`, | ||
yargs => { | ||
@@ -306,5 +369,3 @@ this.#definePathParameter(yargs, true); | ||
.demandCommand(1) | ||
.help() | ||
.wrap(Math.min(120, yargsInstance.terminalWidth())) | ||
.parse(); | ||
.help(); | ||
} | ||
@@ -318,3 +379,7 @@ | ||
const parts = version.split('@'); | ||
return parts.length === 2 ? parts[1]! : 'latest'; | ||
return parts.length === 2 | ||
? parts[1]! | ||
: this.#pinnedBrowsers | ||
? 'pinned' | ||
: 'latest'; | ||
} | ||
@@ -321,0 +386,0 @@ } |
@@ -183,5 +183,15 @@ /** | ||
const env = opts.env || {}; | ||
debugLaunch(`Launching ${this.#executablePath} ${this.#args.join(' ')}`, { | ||
detached: opts.detached, | ||
env: opts.env, | ||
env: Object.keys(env).reduce<Record<string, string | undefined>>( | ||
(res, key) => { | ||
if (key.toLowerCase().startsWith('puppeteer_')) { | ||
res[key] = env[key]; | ||
} | ||
return res; | ||
}, | ||
{} | ||
), | ||
stdio, | ||
@@ -195,3 +205,3 @@ }); | ||
detached: opts.detached, | ||
env: opts.env, | ||
env, | ||
stdio, | ||
@@ -198,0 +208,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
441432
8205
5