固定前端端口为 7380、后端端口为 7381,避开 3000/5173/8080 等常见开发端口,防止与同机其它工程互占。 - 更新根目录、backend、web 的 .env.example 与 README、Makefile 说明 - 同步 vite.config.ts、web/package.json、desktop/main.cjs 默认地址 - 同步 backend config.go 默认端口常量、Dockerfile 与 docker-compose 健康检查 - 同步 deploy/nginx.conf 监听与反代、Dockerfile.web 端口 - 后端新增 godotenv 加载 backend/.env,真实环境变量优先 - AGENTS.md 补充端口约定与按 PID 清理进程的强制规范 - 新增 preflight 脚本并在 pnpm dev 前执行
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
import { existsSync } from "node:fs";
|
||
import path from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
|
||
/**
|
||
* 启动前依赖自检。
|
||
* 目的:依赖缺失时给出明确指引,而不是让 `go run` / `vite` 抛出难以定位的报错。
|
||
*/
|
||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||
|
||
const CHECKS = [
|
||
{ label: "根目录开发工具 concurrently", target: "node_modules/concurrently" },
|
||
{ label: "前端依赖", target: "web/node_modules" },
|
||
{ label: "后端依赖", target: "backend/go.sum" },
|
||
];
|
||
|
||
const missing = CHECKS.filter((item) => !existsSync(path.join(root, item.target)));
|
||
|
||
if (missing.length > 0) {
|
||
console.error("\n依赖未就绪,已中止启动。\n");
|
||
for (const item of missing) {
|
||
console.error(` x ${item.label} (未找到 ${item.target})`);
|
||
}
|
||
console.error("\n请在项目根目录依次执行:\n");
|
||
console.error(" pnpm install # 安装 concurrently");
|
||
console.error(" pnpm setup # 安装 web / backend / desktop 依赖\n");
|
||
process.exit(1);
|
||
}
|