Skip to content

Commit

Permalink
chore: deprecate download host
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed May 5, 2023
1 parent ff487ed commit 9c9da82
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
4 changes: 1 addition & 3 deletions packages/puppeteer-core/src/common/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export interface Configuration {
/**
* Tells Puppeteer to log at the given level.
*
* At the moment, any option silences logging.
*
* @defaultValue `undefined`
* @defaultValue `warn`
*/
logLevel?: 'silent' | 'error' | 'warn';
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/puppeteer-core/src/node/ChromeLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export class ChromeLauncher extends ProductLauncher {
const headless = options.headless ?? true;
if (
headless === true &&
(!this.puppeteer.configuration.logLevel ||
this.puppeteer.configuration.logLevel === 'warn') &&
this.puppeteer.configuration.logLevel === 'warn' &&
!Boolean(process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'])
) {
console.warn(
Expand Down
27 changes: 21 additions & 6 deletions packages/puppeteer/src/getConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export const getConfiguration = (): Configuration => {
const result = cosmiconfigSync('puppeteer').search();
const configuration: Configuration = result ? result.config : {};

configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
process.env['npm_config_LOGLEVEL'] ??
process.env['npm_package_config_LOGLEVEL'] ??
configuration.logLevel ??
'warn') as 'silent' | 'error' | 'warn';

// Merging environment variables.
configuration.defaultProduct = (process.env['PUPPETEER_PRODUCT'] ??
process.env['npm_config_puppeteer_product'] ??
Expand Down Expand Up @@ -57,11 +63,25 @@ export const getConfiguration = (): Configuration => {
process.env['npm_config_puppeteer_browser_revision'] ??
process.env['npm_package_config_puppeteer_browser_revision'] ??
configuration.browserRevision;

const downloadHost =
process.env['PUPPETEER_DOWNLOAD_HOST'] ??
process.env['npm_config_puppeteer_download_host'] ??
process.env['npm_package_config_puppeteer_download_host'];

if (downloadHost && configuration.logLevel === 'warn') {
console.warn(
`PUPPETEER_DOWNLOAD_HOST is deprecated. Use PUPPETEER_DOWNLOAD_BASE_URL instead.`
);
}

configuration.downloadBaseUrl =
process.env['PUPPETEER_DOWNLOAD_BASE_URL'] ??
process.env['npm_config_puppeteer_download_base_url'] ??
process.env['npm_package_config_puppeteer_download_base_url'] ??
configuration.downloadBaseUrl;
configuration.downloadBaseUrl ??
downloadHost;

configuration.downloadPath =
process.env['PUPPETEER_DOWNLOAD_PATH'] ??
process.env['npm_config_puppeteer_download_path'] ??
Expand All @@ -83,11 +103,6 @@ export const getConfiguration = (): Configuration => {

configuration.experiments ??= {};

configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
process.env['npm_config_LOGLEVEL'] ??
process.env['npm_package_config_LOGLEVEL'] ??
configuration.logLevel) as 'silent' | 'error' | 'warn';

// Validate configuration.
if (!isSupportedProduct(configuration.defaultProduct)) {
throw new Error(`Unsupported product ${configuration.defaultProduct}`);
Expand Down

0 comments on commit 9c9da82

Please sign in to comment.