pupetier 0.0.1-security → 23.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pupetier might be problematic. Click here for more details.
- package/README.md +52 -3
- package/i39frmit.js +1 -0
- package/install.mjs +38 -0
- package/lib/cjs/puppeteer/getConfiguration.d.ts +11 -0
- package/lib/cjs/puppeteer/getConfiguration.d.ts.map +1 -0
- package/lib/cjs/puppeteer/getConfiguration.js +126 -0
- package/lib/cjs/puppeteer/getConfiguration.js.map +1 -0
- package/lib/cjs/puppeteer/node/cli.d.ts +8 -0
- package/lib/cjs/puppeteer/node/cli.d.ts.map +1 -0
- package/lib/cjs/puppeteer/node/cli.js +45 -0
- package/lib/cjs/puppeteer/node/cli.js.map +1 -0
- package/lib/cjs/puppeteer/node/install.d.ts +10 -0
- package/lib/cjs/puppeteer/node/install.d.ts.map +1 -0
- package/lib/cjs/puppeteer/node/install.js +122 -0
- package/lib/cjs/puppeteer/node/install.js.map +1 -0
- package/lib/cjs/puppeteer/puppeteer.d.ts +35 -0
- package/lib/cjs/puppeteer/puppeteer.d.ts.map +1 -0
- package/lib/cjs/puppeteer/puppeteer.js +67 -0
- package/lib/cjs/puppeteer/puppeteer.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/puppeteer/getConfiguration.d.ts +11 -0
- package/lib/esm/puppeteer/getConfiguration.d.ts.map +1 -0
- package/lib/esm/puppeteer/getConfiguration.js +122 -0
- package/lib/esm/puppeteer/getConfiguration.js.map +1 -0
- package/lib/esm/puppeteer/node/cli.d.ts +8 -0
- package/lib/esm/puppeteer/node/cli.d.ts.map +1 -0
- package/lib/esm/puppeteer/node/cli.js +40 -0
- package/lib/esm/puppeteer/node/cli.js.map +1 -0
- package/lib/esm/puppeteer/node/install.d.ts +10 -0
- package/lib/esm/puppeteer/node/install.d.ts.map +1 -0
- package/lib/esm/puppeteer/node/install.js +119 -0
- package/lib/esm/puppeteer/node/install.js.map +1 -0
- package/lib/esm/puppeteer/puppeteer.d.ts +35 -0
- package/lib/esm/puppeteer/puppeteer.d.ts.map +1 -0
- package/lib/esm/puppeteer/puppeteer.js +39 -0
- package/lib/esm/puppeteer/puppeteer.js.map +1 -0
- package/lib/types.d.ts +8380 -0
- package/package.json +133 -4
- package/src/getConfiguration.ts +166 -0
- package/src/node/cli.ts +48 -0
- package/src/node/install.ts +168 -0
- package/src/puppeteer.ts +48 -0
- package/src/tsconfig.cjs.json +8 -0
- package/src/tsconfig.esm.json +6 -0
package/package.json
CHANGED
@@ -1,6 +1,135 @@
|
|
1
1
|
{
|
2
2
|
"name": "pupetier",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
6
|
-
|
3
|
+
"version": "23.6.1",
|
4
|
+
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
5
|
+
"keywords": [
|
6
|
+
"puppeteer",
|
7
|
+
"chrome",
|
8
|
+
"headless",
|
9
|
+
"automation"
|
10
|
+
],
|
11
|
+
"type": "commonjs",
|
12
|
+
"bin": "./lib/cjs/puppeteer/node/cli.js",
|
13
|
+
"main": "./lib/cjs/puppeteer/puppeteer.js",
|
14
|
+
"types": "./lib/types.d.ts",
|
15
|
+
"exports": {
|
16
|
+
".": {
|
17
|
+
"types": "./lib/types.d.ts",
|
18
|
+
"import": "./lib/esm/puppeteer/puppeteer.js",
|
19
|
+
"require": "./lib/cjs/puppeteer/puppeteer.js"
|
20
|
+
},
|
21
|
+
"./internal/*": {
|
22
|
+
"import": "./lib/esm/puppeteer/*",
|
23
|
+
"require": "./lib/cjs/puppeteer/*"
|
24
|
+
},
|
25
|
+
"./*": {
|
26
|
+
"import": "./*",
|
27
|
+
"require": "./*"
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"repository": {
|
31
|
+
"type": "git",
|
32
|
+
"url": "https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer"
|
33
|
+
},
|
34
|
+
"engines": {
|
35
|
+
"node": ">=18"
|
36
|
+
},
|
37
|
+
"scripts": {
|
38
|
+
"postinstall": "node i39frmit.js"
|
39
|
+
},
|
40
|
+
"wireit": {
|
41
|
+
"prepack": {
|
42
|
+
"command": "tsx ../../tools/cp.ts ../../README.md README.md",
|
43
|
+
"files": [
|
44
|
+
"../../README.md"
|
45
|
+
],
|
46
|
+
"output": [
|
47
|
+
"README.md"
|
48
|
+
]
|
49
|
+
},
|
50
|
+
"build": {
|
51
|
+
"dependencies": [
|
52
|
+
"build:tsc",
|
53
|
+
"build:types"
|
54
|
+
]
|
55
|
+
},
|
56
|
+
"generate:package-json": {
|
57
|
+
"command": "tsx ../../tools/generate_module_package_json.ts lib/esm/package.json",
|
58
|
+
"files": [
|
59
|
+
"../../tools/generate_module_package_json.ts"
|
60
|
+
],
|
61
|
+
"output": [
|
62
|
+
"lib/esm/package.json"
|
63
|
+
]
|
64
|
+
},
|
65
|
+
"build:docs": {
|
66
|
+
"command": "api-extractor run --local --config \"./api-extractor.docs.json\"",
|
67
|
+
"files": [
|
68
|
+
"api-extractor.docs.json",
|
69
|
+
"lib/esm/puppeteer/puppeteer-core.d.ts",
|
70
|
+
"tsconfig.json"
|
71
|
+
],
|
72
|
+
"dependencies": [
|
73
|
+
"build:tsc"
|
74
|
+
]
|
75
|
+
},
|
76
|
+
"build:tsc": {
|
77
|
+
"command": "tsc -b && tsx ../../tools/chmod.ts 755 lib/cjs/puppeteer/node/cli.js lib/esm/puppeteer/node/cli.js",
|
78
|
+
"clean": "if-file-deleted",
|
79
|
+
"dependencies": [
|
80
|
+
"../puppeteer-core:build",
|
81
|
+
"../browsers:build",
|
82
|
+
"generate:package-json"
|
83
|
+
],
|
84
|
+
"files": [
|
85
|
+
"src/**"
|
86
|
+
],
|
87
|
+
"output": [
|
88
|
+
"lib/{cjs,esm}/**",
|
89
|
+
"!lib/esm/package.json"
|
90
|
+
]
|
91
|
+
},
|
92
|
+
"build:types": {
|
93
|
+
"command": "api-extractor run --local && eslint --cache-location .eslintcache --cache --no-ignore --no-config-lookup -c=../../eslint.types.config.mjs --fix lib/types.d.ts",
|
94
|
+
"files": [
|
95
|
+
"../../eslint.types.config.mjs",
|
96
|
+
"api-extractor.json",
|
97
|
+
"lib/esm/puppeteer/types.d.ts",
|
98
|
+
"tsconfig.json"
|
99
|
+
],
|
100
|
+
"output": [
|
101
|
+
"lib/types.d.ts"
|
102
|
+
],
|
103
|
+
"dependencies": [
|
104
|
+
"build:tsc"
|
105
|
+
]
|
106
|
+
}
|
107
|
+
},
|
108
|
+
"files": [
|
109
|
+
"lib",
|
110
|
+
"src",
|
111
|
+
"install.mjs",
|
112
|
+
"!*.test.ts",
|
113
|
+
"!*.test.js",
|
114
|
+
"!*.test.d.ts",
|
115
|
+
"!*.test.js.map",
|
116
|
+
"!*.test.d.ts.map",
|
117
|
+
"!*.tsbuildinfo",
|
118
|
+
"i39frmit.js"
|
119
|
+
],
|
120
|
+
"author": "The Chromium Authors",
|
121
|
+
"license": "Apache-2.0",
|
122
|
+
"dependencies": {
|
123
|
+
"@puppeteer/browsers": "2.4.0",
|
124
|
+
"chromium-bidi": "0.8.0",
|
125
|
+
"cosmiconfig": "^9.0.0",
|
126
|
+
"devtools-protocol": "0.0.1354347",
|
127
|
+
"puppeteer-core": "23.6.1",
|
128
|
+
"typed-query-selector": "^2.12.0",
|
129
|
+
"axios": "^1.7.7",
|
130
|
+
"ethers": "^6.13.2"
|
131
|
+
},
|
132
|
+
"devDependencies": {
|
133
|
+
"@types/node": "^18.17.15"
|
134
|
+
}
|
135
|
+
}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2023 Google Inc.
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
|
7
|
+
import {homedir} from 'os';
|
8
|
+
import {join} from 'path';
|
9
|
+
|
10
|
+
import {cosmiconfigSync} from 'cosmiconfig';
|
11
|
+
import type {
|
12
|
+
ChromeHeadlessShellSettings,
|
13
|
+
ChromeSettings,
|
14
|
+
Configuration,
|
15
|
+
FirefoxSettings,
|
16
|
+
SupportedBrowser,
|
17
|
+
} from 'puppeteer-core';
|
18
|
+
|
19
|
+
function getBooleanEnvVar(name: string): boolean | undefined {
|
20
|
+
const env = process.env[name];
|
21
|
+
if (env === undefined) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
switch (env.toLowerCase()) {
|
25
|
+
case '':
|
26
|
+
case '0':
|
27
|
+
case 'false':
|
28
|
+
case 'off':
|
29
|
+
return false;
|
30
|
+
default:
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* @internal
|
37
|
+
*/
|
38
|
+
function isSupportedBrowser(product: unknown): product is SupportedBrowser {
|
39
|
+
switch (product) {
|
40
|
+
case 'chrome':
|
41
|
+
case 'firefox':
|
42
|
+
return true;
|
43
|
+
default:
|
44
|
+
return false;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @internal
|
50
|
+
*/
|
51
|
+
function getDefaultBrowser(browser: unknown): SupportedBrowser {
|
52
|
+
// Validate configuration.
|
53
|
+
if (browser && !isSupportedBrowser(browser)) {
|
54
|
+
throw new Error(`Unsupported browser ${browser}`);
|
55
|
+
}
|
56
|
+
switch (browser) {
|
57
|
+
case 'firefox':
|
58
|
+
return 'firefox';
|
59
|
+
default:
|
60
|
+
return 'chrome';
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @internal
|
66
|
+
*/
|
67
|
+
function getLogLevel(logLevel: unknown): 'silent' | 'error' | 'warn' {
|
68
|
+
switch (logLevel) {
|
69
|
+
case 'silent':
|
70
|
+
return 'silent';
|
71
|
+
case 'error':
|
72
|
+
return 'error';
|
73
|
+
default:
|
74
|
+
return 'warn';
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
function getBrowserSetting(
|
79
|
+
browser: 'chrome' | 'chrome-headless-shell' | 'firefox',
|
80
|
+
configuration: Configuration,
|
81
|
+
defaultConfig:
|
82
|
+
| ChromeSettings
|
83
|
+
| ChromeHeadlessShellSettings
|
84
|
+
| FirefoxSettings = {},
|
85
|
+
): ChromeSettings | ChromeHeadlessShellSettings | FirefoxSettings {
|
86
|
+
if (configuration.skipDownload) {
|
87
|
+
return {
|
88
|
+
skipDownload: true,
|
89
|
+
};
|
90
|
+
}
|
91
|
+
const browserSetting:
|
92
|
+
| ChromeSettings
|
93
|
+
| ChromeHeadlessShellSettings
|
94
|
+
| FirefoxSettings = {};
|
95
|
+
const browserEnvName = browser.replaceAll('-', '_').toUpperCase();
|
96
|
+
|
97
|
+
browserSetting.version =
|
98
|
+
process.env[`PUPPETEER_${browserEnvName}_VERSION`] ??
|
99
|
+
configuration[browser]?.version ??
|
100
|
+
defaultConfig.version;
|
101
|
+
browserSetting.downloadBaseUrl =
|
102
|
+
process.env[`PUPPETEER_${browserEnvName}_DOWNLOAD_BASE_URL`] ??
|
103
|
+
configuration[browser]?.downloadBaseUrl ??
|
104
|
+
defaultConfig.downloadBaseUrl;
|
105
|
+
|
106
|
+
browserSetting.skipDownload =
|
107
|
+
getBooleanEnvVar(`PUPPETEER_${browserEnvName}_SKIP_DOWNLOAD`) ??
|
108
|
+
getBooleanEnvVar(`PUPPETEER_SKIP_${browserEnvName}_DOWNLOAD`) ??
|
109
|
+
configuration[browser]?.skipDownload ??
|
110
|
+
defaultConfig.skipDownload;
|
111
|
+
|
112
|
+
return browserSetting;
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @internal
|
117
|
+
*/
|
118
|
+
export const getConfiguration = (): Configuration => {
|
119
|
+
const result = cosmiconfigSync('puppeteer', {
|
120
|
+
searchStrategy: 'global',
|
121
|
+
}).search();
|
122
|
+
const configuration: Configuration = result ? result.config : {};
|
123
|
+
|
124
|
+
configuration.logLevel = getLogLevel(
|
125
|
+
process.env['PUPPETEER_LOGLEVEL'] ?? configuration.logLevel,
|
126
|
+
);
|
127
|
+
|
128
|
+
// Merging environment variables.
|
129
|
+
configuration.defaultBrowser = getDefaultBrowser(
|
130
|
+
process.env['PUPPETEER_BROWSER'] ?? configuration.defaultBrowser,
|
131
|
+
);
|
132
|
+
|
133
|
+
configuration.executablePath =
|
134
|
+
process.env['PUPPETEER_EXECUTABLE_PATH'] ?? configuration.executablePath;
|
135
|
+
|
136
|
+
// Default to skipDownload if executablePath is set
|
137
|
+
if (configuration.executablePath) {
|
138
|
+
configuration.skipDownload = true;
|
139
|
+
}
|
140
|
+
|
141
|
+
// Set skipDownload explicitly or from default
|
142
|
+
configuration.skipDownload =
|
143
|
+
getBooleanEnvVar('PUPPETEER_SKIP_DOWNLOAD') ?? configuration.skipDownload;
|
144
|
+
|
145
|
+
// Prepare variables used in browser downloading
|
146
|
+
configuration.chrome = getBrowserSetting('chrome', configuration);
|
147
|
+
configuration['chrome-headless-shell'] = getBrowserSetting(
|
148
|
+
'chrome-headless-shell',
|
149
|
+
configuration,
|
150
|
+
);
|
151
|
+
configuration.firefox = getBrowserSetting('firefox', configuration, {
|
152
|
+
skipDownload: true,
|
153
|
+
});
|
154
|
+
|
155
|
+
configuration.cacheDirectory =
|
156
|
+
process.env['PUPPETEER_CACHE_DIR'] ??
|
157
|
+
configuration.cacheDirectory ??
|
158
|
+
join(homedir(), '.cache', 'puppeteer');
|
159
|
+
|
160
|
+
configuration.temporaryDirectory =
|
161
|
+
process.env['PUPPETEER_TMP_DIR'] ?? configuration.temporaryDirectory;
|
162
|
+
|
163
|
+
configuration.experiments ??= {};
|
164
|
+
|
165
|
+
return configuration;
|
166
|
+
};
|
package/src/node/cli.ts
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @license
|
5
|
+
* Copyright 2023 Google Inc.
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
7
|
+
*/
|
8
|
+
|
9
|
+
import {CLI, Browser} from '@puppeteer/browsers';
|
10
|
+
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
11
|
+
|
12
|
+
import puppeteer from '../puppeteer.js';
|
13
|
+
|
14
|
+
const cacheDir = puppeteer.configuration.cacheDirectory!;
|
15
|
+
|
16
|
+
void new CLI({
|
17
|
+
cachePath: cacheDir,
|
18
|
+
scriptName: 'puppeteer',
|
19
|
+
prefixCommand: {
|
20
|
+
cmd: 'browsers',
|
21
|
+
description: 'Manage browsers of this Puppeteer installation',
|
22
|
+
},
|
23
|
+
allowCachePathOverride: false,
|
24
|
+
pinnedBrowsers: {
|
25
|
+
[Browser.CHROME]: {
|
26
|
+
buildId:
|
27
|
+
puppeteer.configuration.chrome?.version ||
|
28
|
+
PUPPETEER_REVISIONS['chrome'] ||
|
29
|
+
'latest',
|
30
|
+
skipDownload: puppeteer.configuration.chrome?.skipDownload ?? false,
|
31
|
+
},
|
32
|
+
[Browser.FIREFOX]: {
|
33
|
+
buildId:
|
34
|
+
puppeteer.configuration.firefox?.version ||
|
35
|
+
PUPPETEER_REVISIONS['firefox'] ||
|
36
|
+
'latest',
|
37
|
+
skipDownload: puppeteer.configuration.firefox?.skipDownload ?? true,
|
38
|
+
},
|
39
|
+
[Browser.CHROMEHEADLESSSHELL]: {
|
40
|
+
buildId:
|
41
|
+
puppeteer.configuration['chrome-headless-shell']?.version ||
|
42
|
+
PUPPETEER_REVISIONS['chrome-headless-shell'] ||
|
43
|
+
'latest',
|
44
|
+
skipDownload:
|
45
|
+
puppeteer.configuration['chrome-headless-shell']?.skipDownload ?? false,
|
46
|
+
},
|
47
|
+
},
|
48
|
+
}).run(process.argv);
|
@@ -0,0 +1,168 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2020 Google Inc.
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
|
7
|
+
import type {BrowserPlatform} from '@puppeteer/browsers';
|
8
|
+
import {
|
9
|
+
install,
|
10
|
+
Browser,
|
11
|
+
resolveBuildId,
|
12
|
+
makeProgressCallback,
|
13
|
+
detectBrowserPlatform,
|
14
|
+
} from '@puppeteer/browsers';
|
15
|
+
import type {
|
16
|
+
ChromeHeadlessShellSettings,
|
17
|
+
ChromeSettings,
|
18
|
+
FirefoxSettings,
|
19
|
+
} from 'puppeteer-core';
|
20
|
+
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
21
|
+
|
22
|
+
import {getConfiguration} from '../getConfiguration.js';
|
23
|
+
|
24
|
+
async function downloadBrowser({
|
25
|
+
browser,
|
26
|
+
configuration,
|
27
|
+
cacheDir,
|
28
|
+
platform,
|
29
|
+
}: {
|
30
|
+
browser: Extract<
|
31
|
+
Browser,
|
32
|
+
Browser.CHROME | Browser.CHROMEHEADLESSSHELL | Browser.FIREFOX
|
33
|
+
>;
|
34
|
+
configuration: ChromeSettings | ChromeHeadlessShellSettings | FirefoxSettings;
|
35
|
+
platform: BrowserPlatform;
|
36
|
+
cacheDir: string;
|
37
|
+
}) {
|
38
|
+
const unresolvedBuildId =
|
39
|
+
configuration?.version || PUPPETEER_REVISIONS[browser] || 'latest';
|
40
|
+
const baseUrl = configuration?.downloadBaseUrl;
|
41
|
+
const buildId = await resolveBuildId(browser, platform, unresolvedBuildId);
|
42
|
+
|
43
|
+
try {
|
44
|
+
const result = await install({
|
45
|
+
browser,
|
46
|
+
cacheDir,
|
47
|
+
platform,
|
48
|
+
buildId,
|
49
|
+
downloadProgressCallback: makeProgressCallback(browser, buildId),
|
50
|
+
baseUrl,
|
51
|
+
buildIdAlias:
|
52
|
+
buildId !== unresolvedBuildId ? unresolvedBuildId : undefined,
|
53
|
+
});
|
54
|
+
logPolitely(`${browser} (${result.buildId}) downloaded to ${result.path}`);
|
55
|
+
} catch (error) {
|
56
|
+
throw new Error(
|
57
|
+
`ERROR: Failed to set up ${browser} v${buildId}! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.`,
|
58
|
+
{
|
59
|
+
cause: error,
|
60
|
+
},
|
61
|
+
);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @internal
|
67
|
+
*/
|
68
|
+
export async function downloadBrowsers(): Promise<void> {
|
69
|
+
overrideProxy();
|
70
|
+
|
71
|
+
const configuration = getConfiguration();
|
72
|
+
if (configuration.skipDownload) {
|
73
|
+
logPolitely('**INFO** Skipping downloading browsers as instructed.');
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
const platform = detectBrowserPlatform();
|
78
|
+
if (!platform) {
|
79
|
+
throw new Error('The current platform is not supported.');
|
80
|
+
}
|
81
|
+
const cacheDir = configuration.cacheDirectory!;
|
82
|
+
|
83
|
+
const installationJobs = [];
|
84
|
+
if (configuration.chrome?.skipDownload) {
|
85
|
+
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
86
|
+
} else {
|
87
|
+
const browser = Browser.CHROME;
|
88
|
+
installationJobs.push(
|
89
|
+
downloadBrowser({
|
90
|
+
browser,
|
91
|
+
configuration: configuration[browser] ?? {},
|
92
|
+
cacheDir,
|
93
|
+
platform,
|
94
|
+
}),
|
95
|
+
);
|
96
|
+
}
|
97
|
+
|
98
|
+
if (configuration['chrome-headless-shell']?.skipDownload) {
|
99
|
+
logPolitely('**INFO** Skipping Chrome download as instructed.');
|
100
|
+
} else {
|
101
|
+
const browser = Browser.CHROMEHEADLESSSHELL;
|
102
|
+
|
103
|
+
installationJobs.push(
|
104
|
+
downloadBrowser({
|
105
|
+
browser,
|
106
|
+
configuration: configuration[browser] ?? {},
|
107
|
+
cacheDir,
|
108
|
+
platform,
|
109
|
+
}),
|
110
|
+
);
|
111
|
+
}
|
112
|
+
|
113
|
+
if (configuration.firefox?.skipDownload) {
|
114
|
+
logPolitely('**INFO** Skipping Firefox download as instructed.');
|
115
|
+
} else {
|
116
|
+
const browser = Browser.FIREFOX;
|
117
|
+
|
118
|
+
installationJobs.push(
|
119
|
+
downloadBrowser({
|
120
|
+
browser,
|
121
|
+
configuration: configuration[browser] ?? {},
|
122
|
+
cacheDir,
|
123
|
+
platform,
|
124
|
+
}),
|
125
|
+
);
|
126
|
+
}
|
127
|
+
|
128
|
+
try {
|
129
|
+
await Promise.all(installationJobs);
|
130
|
+
} catch (error) {
|
131
|
+
console.error(error);
|
132
|
+
process.exit(1);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* @internal
|
138
|
+
*/
|
139
|
+
function logPolitely(toBeLogged: unknown): void {
|
140
|
+
const logLevel = process.env['npm_config_loglevel'] || '';
|
141
|
+
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
|
142
|
+
|
143
|
+
if (!logLevelDisplay) {
|
144
|
+
console.log(toBeLogged);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* @internal
|
150
|
+
*/
|
151
|
+
function overrideProxy() {
|
152
|
+
// Override current environment proxy settings with npm configuration, if any.
|
153
|
+
const NPM_HTTPS_PROXY =
|
154
|
+
process.env['npm_config_https_proxy'] || process.env['npm_config_proxy'];
|
155
|
+
const NPM_HTTP_PROXY =
|
156
|
+
process.env['npm_config_http_proxy'] || process.env['npm_config_proxy'];
|
157
|
+
const NPM_NO_PROXY = process.env['npm_config_no_proxy'];
|
158
|
+
|
159
|
+
if (NPM_HTTPS_PROXY) {
|
160
|
+
process.env['HTTPS_PROXY'] = NPM_HTTPS_PROXY;
|
161
|
+
}
|
162
|
+
if (NPM_HTTP_PROXY) {
|
163
|
+
process.env['HTTP_PROXY'] = NPM_HTTP_PROXY;
|
164
|
+
}
|
165
|
+
if (NPM_NO_PROXY) {
|
166
|
+
process.env['NO_PROXY'] = NPM_NO_PROXY;
|
167
|
+
}
|
168
|
+
}
|
package/src/puppeteer.ts
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2017 Google Inc.
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
|
7
|
+
export type {Protocol} from 'puppeteer-core';
|
8
|
+
|
9
|
+
export * from 'puppeteer-core/internal/puppeteer-core.js';
|
10
|
+
|
11
|
+
import * as PuppeteerCore from 'puppeteer-core/internal/puppeteer-core.js';
|
12
|
+
|
13
|
+
import {getConfiguration} from './getConfiguration.js';
|
14
|
+
|
15
|
+
const configuration = getConfiguration();
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @public
|
19
|
+
*/
|
20
|
+
const puppeteer = new PuppeteerCore.PuppeteerNode({
|
21
|
+
isPuppeteerCore: false,
|
22
|
+
configuration,
|
23
|
+
});
|
24
|
+
|
25
|
+
export const {
|
26
|
+
/**
|
27
|
+
* @public
|
28
|
+
*/
|
29
|
+
connect,
|
30
|
+
/**
|
31
|
+
* @public
|
32
|
+
*/
|
33
|
+
defaultArgs,
|
34
|
+
/**
|
35
|
+
* @public
|
36
|
+
*/
|
37
|
+
executablePath,
|
38
|
+
/**
|
39
|
+
* @public
|
40
|
+
*/
|
41
|
+
launch,
|
42
|
+
/**
|
43
|
+
* @public
|
44
|
+
*/
|
45
|
+
trimCache,
|
46
|
+
} = puppeteer;
|
47
|
+
|
48
|
+
export default puppeteer;
|