2c5bceb826
端到端验证时发现 4 处细节,一起补上:
1. bin.ts 漏了 default: 'serve'——CMD ["./server"] 会直接吐 help 而
不是起服务(在 compose 里 app 立刻 exit)。citty 原生支持 default
2. Dockerfile 在 bun install 之前就要 COPY patches/,否则 package.json
的 patchedDependencies 找不到补丁文件,install 失败
3. drizzle/ 目录在仓库里必须存在(带 .gitkeep),否则 Dockerfile 末尾
COPY drizzle/ 到运行镜像会失败
4. migrate.ts 之前只检查 ./drizzle 目录是否存在就跳过——空目录时仍会
进到 drizzle 的 readMigrationFiles,报 Can't find meta/_journal.json。
改成检查 meta/_journal.json 是否存在,更准确地区分"还没生成过迁移"
与"有迁移待应用"
验证路径:
- docker compose up -d --build → migrate 完成退出 → app 健康
- curl /api/spec.json → 200,OpenAPI 文档含 todo.{list,create,update,remove}
22 lines
748 B
TypeScript
22 lines
748 B
TypeScript
import { defineCommand, runMain } from 'citty'
|
|
import { name, version } from './package.json' with { type: 'json' }
|
|
|
|
// IMPORTANT: keep this file's static imports minimal. Nitro's bun preset
|
|
// emits `.output/server/index.mjs` with a top-level `serve(...)` call, so any
|
|
// eager (transitive) import of it would start the HTTP server even for
|
|
// `migrate` or `--help`. All subcommands are lazy-loaded via citty.
|
|
const main = defineCommand({
|
|
meta: {
|
|
name,
|
|
version,
|
|
description: 'Fullstack server binary (default subcommand: serve)',
|
|
},
|
|
default: 'serve',
|
|
subCommands: {
|
|
serve: () => import('./src/cli/serve').then((m) => m.default),
|
|
migrate: () => import('./src/cli/migrate').then((m) => m.default),
|
|
},
|
|
})
|
|
|
|
runMain(main)
|