Files
wrong-notebook/scripts/seed-chinese-primary.ts
margrop 5691c864d5 fix: 恢复 Docker 与安装包种子脚本的独立编译
标签种子模块移动后,Dockerfile 仍复制已不存在的 src/lib/seed-chinese-tags.ts,
且 seed-chinese-tags.ts 改用了 @/ 别名导入;Docker 与安装包构建用 tsc 单独
编译种子脚本、不读取路径别名,会导致镜像构建失败或启动时语文标签同步失败。

- seed-chinese-tags.ts 恢复相对路径导入并注明原因
- 种子脚本直接导入具体模块,不经过 tags/seed 汇总入口(避免带入 cnm-tags 等无关依赖)
- Dockerfile 更新复制路径
- 新增测试:两个种子脚本的导入链只使用相对路径、且不含 server-only 模块
2026-11-04 10:21:09 +08:00

27 lines
965 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 增量补齐小学、初中和高中语文系统标签,不删除已有标签。
* 源码运行:npx ts-node --compiler-options '{"module":"CommonJS"}' scripts/seed-chinese-primary.ts
* Docker 和安装包运行:node dist-scripts/scripts/seed-chinese-primary.js
*/
import { PrismaClient } from '@prisma/client';
import { getErrorMessage } from '../src/lib/error-message';
import { createLogger } from '../src/lib/logger';
import { seedChineseTags } from '../src/lib/tags/seed/seed-chinese-tags';
const logger = createLogger('seed-chinese-tags');
async function main() {
const prisma = new PrismaClient();
try {
const result = await seedChineseTags(prisma);
logger.info(result, '语文系统标签同步完成');
} finally {
await prisma.$disconnect();
}
}
main().catch((error: unknown) => {
logger.error({ error: getErrorMessage(error) }, '语文系统标签同步失败');
process.exitCode = 1;
});