chore(tooling): 对齐协作规范与 Playwright 运行配置
统一设备配置和浏览器启动入口,加入窗口焦点守卫,并按运行隔离报告和追踪文件。
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { preview } from 'vite';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { positiveInteger } from './playwright-runtime.mjs';
|
||||
import { verifyBuild } from './verify-build.mjs';
|
||||
|
||||
const directory =
|
||||
process.env.PW_DIST_DIR ||
|
||||
fileURLToPath(new URL('../dist/', import.meta.url));
|
||||
const portIndex = process.argv.indexOf('--port');
|
||||
const port = positiveInteger(
|
||||
portIndex === -1 ? 4176 : process.argv[portIndex + 1],
|
||||
'port',
|
||||
);
|
||||
if (port > 65535) throw new Error('port must be <= 65535');
|
||||
await verifyBuild(directory);
|
||||
const server = await preview({
|
||||
build: { outDir: directory },
|
||||
preview: { host: '127.0.0.1', port, strictPort: true },
|
||||
});
|
||||
server.printUrls();
|
||||
for (const signal of ['SIGTERM', 'SIGINT'])
|
||||
process.on(signal, () => server.httpServer.close());
|
||||
Reference in New Issue
Block a user