ESLint 升级到 recommended-type-checked + stylistic-type-checked, 引入 perfectionist 导入排序和 import 插件导入验证。 Prettier 显式声明全部格式化参数,消除跨环境差异。 TypeScript 启用 noUnusedLocals 和 noPropertyAccessFromIndexSignature。 完善 ignore 列表,排除 .agents/、bun.lock、data/ 等。 引入 husky + lint-staged(pre-commit)+ commitlint(commit-msg)。 更新 DEVELOPMENT.md 代码质量章节。 修复所有新增规则检测到的类型和风格违规。
58 lines
1.1 KiB
TypeScript
58 lines
1.1 KiB
TypeScript
interface ChildProcessInfo {
|
|
name: string;
|
|
process: Bun.Subprocess;
|
|
}
|
|
|
|
const configPath = process.argv[2];
|
|
|
|
const env = {
|
|
...process.env,
|
|
BACKEND_PORT: process.env["PORT"] ?? "3000",
|
|
};
|
|
|
|
const children: ChildProcessInfo[] = [
|
|
{
|
|
name: "server",
|
|
process: Bun.spawn(["bun", "run", "dev:server", ...(configPath ? [configPath] : [])], {
|
|
env,
|
|
stderr: "inherit",
|
|
stdout: "inherit",
|
|
}),
|
|
},
|
|
{
|
|
name: "web",
|
|
process: Bun.spawn(["bun", "run", "dev:web"], {
|
|
env,
|
|
stderr: "inherit",
|
|
stdout: "inherit",
|
|
}),
|
|
},
|
|
];
|
|
|
|
const stopChildren = () => {
|
|
for (const child of children) {
|
|
child.process.kill();
|
|
}
|
|
};
|
|
|
|
process.on("SIGINT", () => {
|
|
stopChildren();
|
|
process.exit(130);
|
|
});
|
|
|
|
process.on("SIGTERM", () => {
|
|
stopChildren();
|
|
process.exit(143);
|
|
});
|
|
|
|
const firstExit = await Promise.race(
|
|
children.map(async (child) => ({ code: await child.process.exited, name: child.name })),
|
|
);
|
|
|
|
stopChildren();
|
|
|
|
if (firstExit.code !== 0) {
|
|
console.error(`${firstExit.name} exited with code ${firstExit.code}`);
|
|
process.exit(firstExit.code ?? 1);
|
|
}
|