新增 refactor-checker-cohesion 变更提案,包含 proposal、design、 specs 和 tasks,定义 checker 目录内聚结构规范。同时归档已完成的 历史变更记录。
57 lines
3.9 KiB
Markdown
57 lines
3.9 KiB
Markdown
## 1. 基础设施搭建
|
||
|
||
- [ ] 1.1 创建 `src/server/checker/utils.ts`,将 `size.ts` 的 `parseSize` 和 `config-loader.ts` 的 `parseDuration` 及 `DURATION_REGEX` 迁入
|
||
- [ ] 1.2 创建 `src/server/checker/expect/` 目录,创建 `expect/types.ts` 放置 `ExpectResult` 等共享类型
|
||
- [ ] 1.3 将 `runner/shared/operator.ts` 迁入为 `expect/operator.ts`
|
||
- [ ] 1.4 将 `runner/shared/failure.ts` 迁入为 `expect/failure.ts`
|
||
- [ ] 1.5 将 `runner/shared/duration.ts` 迁入为 `expect/duration.ts`(`ExpectResult` 类型提取到 `expect/types.ts`)
|
||
- [ ] 1.6 从 `runner/shared/validate.ts` 中提取 `validateOperatorObject`、`isJsonValue`、`validateOperatorValue`、`isPlainRecord` 到 `expect/validate-operator.ts`
|
||
|
||
## 2. Schema 目录重组
|
||
|
||
- [ ] 2.1 将 `config-contract/` 目录重命名为 `schema/`
|
||
- [ ] 2.2 将 `schema/schema.ts` 重命名为 `schema/builder.ts`
|
||
- [ ] 2.3 更新 `schema/` 内部文件的相互引用路径
|
||
- [ ] 2.4 更新外部对 `config-contract/` 的所有 import 路径(config-loader.ts、runner/shared/validate.ts 等)
|
||
|
||
## 3. 类型系统重构
|
||
|
||
- [ ] 3.1 在顶层 `types.ts` 中创建 `ResolvedTargetBase` 和 `RawTargetConfig` base interface
|
||
- [ ] 3.2 将 HTTP 专属类型(`HttpTargetConfig`、`ResolvedHttpTarget`、`HttpExpectConfig`、`HttpDefaultsConfig`、`ResolvedHttpConfig`、`BodyRule`、`CssRule`、`JsonRule`、`XpathRule`、`HeaderExpect`)迁入 `runner/http/types.ts`
|
||
- [ ] 3.3 将 Command 专属类型(`CommandTargetConfig`、`ResolvedCommandTarget`、`CommandExpectConfig`、`CommandDefaultsConfig`、`ResolvedCommandConfig`)迁入 `runner/command/types.ts`
|
||
- [ ] 3.4 删除顶层 `types.ts` 中的 `ResolvedTarget` 联合类型和 `TargetConfig` 联合类型,将 `TextRule` 迁入 command/types.ts
|
||
- [ ] 3.5 将 `DefaultsConfig` 改为宽松 base 形式(仅保留 `interval?`、`timeout?` + index signature),将 `CommandDefaultsConfig` 迁入 command/types.ts,将 `HttpDefaultsConfig` 迁入 http/types.ts
|
||
- [ ] 3.6 更新 `runner/types.ts` 中 `CheckerDefinition` 接口签名,使用 `RawTargetConfig` 和 `ResolvedTargetBase`
|
||
- [ ] 3.7 更新 `engine.ts`、`store.ts`、`config-loader.ts` 的类型引用为 `ResolvedTargetBase` 和 `RawTargetConfig`
|
||
|
||
## 4. HTTP Checker 内聚化
|
||
|
||
- [ ] 4.1 将 `runner/http/runner.ts` 重命名为 `runner/http/execute.ts`
|
||
- [ ] 4.2 将 `runner/http/contract.ts` 重命名为 `runner/http/schema.ts`
|
||
- [ ] 4.3 将 `runner/shared/body.ts` 迁入 `runner/http/body.ts`
|
||
- [ ] 4.4 将 `runner/shared/validate.ts` 中的 `validateBodyRules`、`validateCssRule`、`validateJsonRule`、`validateXpathRule`、`validateRegexRule`、`validateSingleBodyRule`、`validateJsonPath` 合并到 `runner/http/validate.ts`
|
||
- [ ] 4.5 创建 `runner/http/index.ts`,re-export `HttpChecker`
|
||
- [ ] 4.6 更新 `runner/http/` 内所有文件的 import 路径
|
||
|
||
## 5. Command Checker 内聚化
|
||
|
||
- [ ] 5.1 将 `runner/command/runner.ts` 重命名为 `runner/command/execute.ts`
|
||
- [ ] 5.2 将 `runner/command/contract.ts` 重命名为 `runner/command/schema.ts`
|
||
- [ ] 5.3 将 `runner/shared/text.ts` 迁入 `runner/command/text.ts`
|
||
- [ ] 5.4 将 `runner/shared/validate.ts` 中的 `validateTextRules` 合并到 `runner/command/validate.ts`
|
||
- [ ] 5.5 创建 `runner/command/index.ts`,re-export `CommandChecker`
|
||
- [ ] 5.6 更新 `runner/command/` 内所有文件的 import 路径
|
||
|
||
## 6. 注册入口改造
|
||
|
||
- [ ] 6.1 重写 `runner/index.ts` 为显式列表注册模式(import 列表 + checker 数组 + 循环注册)
|
||
- [ ] 6.2 删除 `runner/shared/` 目录(确认所有内容已迁移完毕)
|
||
- [ ] 6.3 删除 `src/server/checker/size.ts`(已迁入 utils.ts)
|
||
|
||
## 7. 测试与质量保障
|
||
|
||
- [ ] 7.1 更新所有测试文件的 import 路径
|
||
- [ ] 7.2 执行完整测试套件,确保所有测试通过
|
||
- [ ] 7.3 执行 lint 和格式检查,确保代码质量
|
||
- [ ] 7.4 更新 README.md 和 DEVELOPMENT.md 中涉及 checker 模块结构的描述
|