feat: manage Chromium installation in engine
Engine CI / test (push) Waiting to run

This commit is contained in:
2026-08-30 18:51:35 +08:00
parent fef7459650
commit e3b0b2d576
17 changed files with 139 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
export interface BrowserInstallCommand {
command: string;
args: string[];
}
export declare function createBrowserInstallCommand(args: string[]): BrowserInstallCommand;
+23
View File
@@ -0,0 +1,23 @@
import { createRequire } from 'node:module';
import path from 'node:path';
const require = createRequire(import.meta.url);
export function createBrowserInstallCommand(args) {
const unsupported = args.filter(argument => argument !== '--with-deps');
const withDepsCount = args.filter(argument => argument === '--with-deps').length;
if (unsupported.length > 0)
throw new Error(`install-browser 不支持参数:${unsupported.join(' ')}`);
if (withDepsCount > 1)
throw new Error('install-browser 的 --with-deps 只能指定一次');
const packageJson = require.resolve('playwright-chromium/package.json');
const playwrightCli = path.join(path.dirname(packageJson), 'cli.js');
return {
command: process.execPath,
args: [
playwrightCli,
'install',
...(withDepsCount === 1 ? ['--with-deps'] : []),
'chromium',
],
};
}
//# sourceMappingURL=browser-install.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"browser-install.js","sourceRoot":"","sources":["../../scripts/lib/browser-install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAO9C,MAAM,UAAU,2BAA2B,CAAC,IAAc;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAA;IACvE,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,MAAM,CAAA;IAEhF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACnE,IAAI,aAAa,GAAG,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAEzD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAA;IACvE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAA;IAEpE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,QAAQ;QACzB,IAAI,EAAE;YACJ,aAAa;YACb,SAAS;YACT,GAAG,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/C,UAAU;SACX;KACF,CAAA;AACH,CAAC"}