2023-09-09 08:14:28 +08:00
|
|
|
import { execSync } from 'node:child_process';
|
2023-09-16 00:01:31 +08:00
|
|
|
import { PORT, commonConfig, runNocoBase } from './utils';
|
2023-09-09 08:14:28 +08:00
|
|
|
|
2023-09-16 00:01:31 +08:00
|
|
|
const run = async () => {
|
|
|
|
|
const { kill } = await runNocoBase();
|
|
|
|
|
|
|
|
|
|
// 等待服务成功启动
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
try {
|
|
|
|
|
execSync(
|
|
|
|
|
`npx playwright codegen --load-storage=playwright/.auth/codegen.auth.json http://localhost:${PORT} --save-storage=playwright/.auth/codegen.auth.json`,
|
|
|
|
|
commonConfig,
|
|
|
|
|
);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (err.message.includes('auth.json')) {
|
|
|
|
|
execSync(
|
|
|
|
|
`npx playwright codegen http://localhost:${PORT} --save-storage=playwright/.auth/codegen.auth.json`,
|
|
|
|
|
commonConfig,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
console.error(err);
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
kill?.('SIGKILL');
|
|
|
|
|
}
|
|
|
|
|
}, 5000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
run();
|