aws-runtime-bridge 1.9.104 → 1.9.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -26,6 +26,9 @@ const require = createRequire(import.meta.url);
|
|
|
26
26
|
/** 下载超时:Chromium 约 150MB,慢网络下允许 15 分钟。 */
|
|
27
27
|
const INSTALL_TIMEOUT_MS = 15 * 60 * 1000;
|
|
28
28
|
|
|
29
|
+
/** npmmirror 镜像,加速国内下载;用户已显式设置 PLAYWRIGHT_DOWNLOAD_HOST 时尊重用户选择。 */
|
|
30
|
+
const DEFAULT_PLAYWRIGHT_DOWNLOAD_HOST = "https://npmmirror.com/mirrors/playwright";
|
|
31
|
+
|
|
29
32
|
/** 定位 playwright 包的 CLI 入口(兼容 npm hoist 与嵌套安装两种布局)。 */
|
|
30
33
|
function resolvePlaywrightCliPath() {
|
|
31
34
|
try {
|
|
@@ -37,6 +40,11 @@ function resolvePlaywrightCliPath() {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
async function runInstall(cliPath, args) {
|
|
43
|
+
// 未显式设置 PLAYWRIGHT_DOWNLOAD_HOST 时,默认使用 npmmirror 镜像加速国内下载。
|
|
44
|
+
const env = { ...process.env };
|
|
45
|
+
if (!env.PLAYWRIGHT_DOWNLOAD_HOST) {
|
|
46
|
+
env.PLAYWRIGHT_DOWNLOAD_HOST = DEFAULT_PLAYWRIGHT_DOWNLOAD_HOST;
|
|
47
|
+
}
|
|
40
48
|
const { stdout, stderr } = await execFileAsync(
|
|
41
49
|
process.execPath,
|
|
42
50
|
[cliPath, ...args],
|
|
@@ -44,6 +52,7 @@ async function runInstall(cliPath, args) {
|
|
|
44
52
|
timeout: INSTALL_TIMEOUT_MS,
|
|
45
53
|
maxBuffer: 16 * 1024 * 1024,
|
|
46
54
|
windowsHide: true,
|
|
55
|
+
env,
|
|
47
56
|
},
|
|
48
57
|
);
|
|
49
58
|
return `${stdout ?? ""}${stderr ?? ""}`.trim();
|
|
@@ -76,8 +85,13 @@ async function main() {
|
|
|
76
85
|
const isRoot =
|
|
77
86
|
typeof process.getuid === "function" && process.getuid() === 0;
|
|
78
87
|
|
|
88
|
+
const downloadHost = process.env.PLAYWRIGHT_DOWNLOAD_HOST || DEFAULT_PLAYWRIGHT_DOWNLOAD_HOST;
|
|
89
|
+
const usingDefaultMirror = downloadHost === DEFAULT_PLAYWRIGHT_DOWNLOAD_HOST;
|
|
79
90
|
console.log(
|
|
80
|
-
|
|
91
|
+
`[aws-runtime-bridge] 正在准备 Playwright Chromium(首次安装需下载约 150MB,请耐心等待)...` +
|
|
92
|
+
(usingDefaultMirror
|
|
93
|
+
? `\n[aws-runtime-bridge] 下载源:${downloadHost}(npmmirror 镜像加速;如需切换可设 PLAYWRIGHT_DOWNLOAD_HOST)`
|
|
94
|
+
: ""),
|
|
81
95
|
);
|
|
82
96
|
|
|
83
97
|
// Linux + root:连系统依赖一起装(sudo npm install -g 场景一步到位)
|