- 新增部署脚本 `build-deploy-bundle.mjs`,用于构建和部署 web 和 server 目录。 - 新增样式文件 `index-acd65452.css`,包含基础样式和响应式设计。 - 新增脚本 `repro-import-text.mjs`,用于测试文本导入 API。 - 新增测试文件 `db-migration-score-zero.test.ts`,验证历史数据库中 questions.score 约束的迁移逻辑。 - 更新数据库初始化逻辑,允许插入 score=0 的问题。
2.5 KiB
2.5 KiB
OpenSpec Instructions
These instructions are for AI assistants working in this project.
Always open @/openspec/AGENTS.md when the request:
- Mentions planning or proposals (words like proposal, spec, change, plan)
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
- Sounds ambiguous and you need the authoritative spec before coding
Use @/openspec/AGENTS.md to learn:
- How to create and apply change proposals
- Spec format and conventions
- Project structure and guidelines
Keep this managed block so 'openspec update' can refresh the instructions.
项目约束:发布/打包流程(强制)
以后只要涉及“发布 / 打包 / 上线 / 部署”,默认目标产物必须生成到 deploy_bundle/(无需用户再次强调)。
一键口径
- 发布前:
npm ci→npm run check→npm test - 构建:
npm run build(包含:vite build+scripts/build-api.mjs+postbuild复制init.sql) - 产物:同步到
deploy_bundle/(见下方“产物映射”)
产物映射(从仓库根目录执行)
构建完成后,仓库根目录的 dist/ 同时包含:
- 前端静态资源:
dist/index.html、dist/assets/、dist/favicon.svg等 - 后端产物:
dist/api/server.js、dist/api/server.js.map、dist/api/database/init.sql
发布时必须把它们整理为:
deploy_bundle/web/:放“前端静态资源”(复制dist/下除api/之外的所有内容)deploy_bundle/server/:放“后端可运行目录”deploy_bundle/server/dist/api/:复制整个dist/api/deploy_bundle/server/package.json、deploy_bundle/server/package-lock.json:与根目录依赖保持同步deploy_bundle/server/ecosystem.config.cjs:PM2 配置(通常无需改动,按环境变量/路径调整)
服务器侧部署(默认 PM2)
- 将
deploy_bundle/server/上传/同步到服务器运行目录(由ecosystem.config.cjs的cwd决定) - 在服务器运行目录执行:
npm ci --omit=dev - 启动/重启:
pm2 start ecosystem.config.cjs或pm2 reload ecosystem.config.cjs
发布注意事项(必须检查)
- Node 版本与构建目标一致(当前后端构建目标:Node 20)
- 数据库文件是外置持久化(由
DB_PATH指定),发布不覆盖 DB 文件 - 构建后确认
deploy_bundle/server/dist/api/database/init.sql存在(用于首次初始化/新环境)