v0.11+ Phase A: 原子删除 (8 文件) - form lint/validate/fixcolumndata 旧 TS+测试
- 删 src/commands/form/_parsers.ts (P1-2, 仅 form lint 使用)
- 删 src/commands/form/_simplify.ts (P1-2, 仅 --fields 路径使用)
- 删 src/commands/form/lint.ts (P0-1, form lint 命令)
- 删 src/commands/form/validate.ts (P1-3, form validate 命令)
- 删 src/commands/form/fixcolumndata.ts (P1-4, form fixcolumndata 命令)
- 删 tests/unit/{form-lint,fix-columndata,field_normalize}.test.ts 3 个测试
- 加 docs/v0.11-{audit-report,cleanup-execution-plan}.md 2 个体检+执行计划文档
体检报告: docs/v0.11-audit-report.md
执行计划: docs/v0.11-cleanup-execution-plan.md
回滚: git revert HEAD (单 commit 安全回滚)
注意: src/commands/form/index.ts 现在引用了已删除文件, 需 Phase B 修复
This commit is contained in:
1 parent
7d50bb4572
commit
c177b89e6c
10 files changed
+658
-1058
No files matched your search
@@ -0,0 +1,391 @@
|
||||
# dacli v0.11+ webapi 镜像架构 体检报告 + 清理计划
|
||||
|
||||
**生成时间**: 2026-06-26
|
||||
**基准架构**: dacli v0.11+ webapi 镜像 (直接 dynamic import web 端源码)
|
||||
**体检范围**: `.claude/` (118 文件) + `dacli/` (370 文件, excl node_modules)
|
||||
**原则**: 不考虑兼容老用户, 凡是与新架构冲突的, 全部抹去
|
||||
|
||||
---
|
||||
|
||||
## 0. 新架构基准 (4 个核心)
|
||||
|
||||
1. **webapi 镜像**: `dacli/src/webapi/*.ts` 直接 dynamic import web 端源码 (`web/.../api/onlineDev/*.ts`)
|
||||
2. **buildFormData 镜像**: `dacli/src/commands/form/_buildformdata.ts` 直接 import web 端 `form/utils/formUtils.ts#buildFormData`
|
||||
3. **`--ai-json` 路径**: AI 生成 List<AiFormModel> JSON → 直入 web 端 buildFormData → schema 自动完整
|
||||
4. **22 条 guard 运行时兜底**: `dacli/src/commands/_blindspot_guards.ts`, AI 不需要手查盲点
|
||||
|
||||
## 0.1 9 类冲突模式 (P0~P3)
|
||||
|
||||
| # | 模式 | 与新架构冲突原因 | 影响范围 |
|
||||
|---|------|-----------------|----------|
|
||||
| **P0-1** | `form lint` 命令 + `--from-script=03_forms.py --from-design=design-jnpf.html` | 解析旧 Python 元组格式 + 旧 HTML schema, v0.11+ 无意义 | 6 文件 |
|
||||
| **P0-2** | `03_forms.py` Python 元组列表格式 | `--ai-json` 路径已替代, schema 由 web 端 buildFormData 生成 | 9 文件 |
|
||||
| **P0-3** | `design-jnpf.html` (JNPF 平台对齐设计) | 业务设计由 `design.html` 承担, 平台对齐由 buildFormData 自动保证 | 13 文件 |
|
||||
| **P0-4** | 6 类盲点 (BS-15/23/31/32/50/52) + BS-V2 在 SKILL 必查清单 | 新架构几乎不可能复现, 留 = 干扰 | 7 文件 |
|
||||
| **P1-1** | `dispatch 1 form = 1 sub-agent` 模式 | 主代理 1 行 `--ai-json` 完事, 不需子代理 | 5 文件 |
|
||||
| **P1-2** | `wrapSimplifiedFields` / `parsePythonForms` / `parseDesignHtml` 旧代码 | 仅 `form create --fields=` / `form lint` 使用, 都将删除 | 4 文件 (含 TS) |
|
||||
| **P1-3** | `form validate` 命令 | v0.11+ 已 `@deprecated`, 仅 BS-23 老 form 兜底 | 17 文件 |
|
||||
| **P1-4** | `form fixcolumndata` 命令 | 同上 `@deprecated`, v0.11+ webapi 已自动保证 | 19 文件 |
|
||||
| **P2-1** | `type=4 兜底` 默认 type=4 | `--ai-json` 路径硬编码 type=4, 但用户需要 type=2, BS-14 警告拦 release | 20 文件 |
|
||||
| **P3-1** | `f_description` / `f_version` 关键字 sed 案例 | 仅 v0.10- dm create 手写时触发, v0.11+ 自动加系统列不会冲突 | 10 文件 |
|
||||
|
||||
---
|
||||
|
||||
## 1. 删除清单 (P0 全删, P1/P2 视情况)
|
||||
|
||||
### 1.1 整个目录删除 (P0-1, P0-3, P1-1)
|
||||
|
||||
| 路径 | 原因 |
|
||||
|------|------|
|
||||
| `.claude/skills/design-jnpf-execute/` | 整个技能失效 (教 03_forms.py + form lint + 5 盲点 + dispatch 子代理) |
|
||||
| `.claude/templates/jnpf-design-card.tmpl` | P0-3, 教 design-jnpf.html 格式 |
|
||||
| `.claude/templates/jnpf-design-master-sub.tmpl` | P0-3 |
|
||||
| `.claude/templates/jnpf-design-workflow.tmpl` | P0-3 |
|
||||
| `.claude/templates/功能设计模板.md` | 引用 design-jnpf-execute + form lint + --fields |
|
||||
| `.claude/templates/测试用例模板.md` | (复用 OK, 不删) |
|
||||
| `.claude/templates/需求文档模板.md` | (复用 OK, 不删) |
|
||||
| `dacli/docs/skill-audit/design-jnpf-execute.md` | 已失效技能审计, 随技能删 |
|
||||
| `dacli/docs/skill-audit/ssw-h5dev-flow.md` | 旧审计, 重新审计 |
|
||||
|
||||
### 1.2 代码文件删除 (P1-2)
|
||||
|
||||
| 路径 | 原因 |
|
||||
|------|------|
|
||||
| `dacli/src/commands/form/_parsers.ts` | P1-2, 仅 form lint 使用 |
|
||||
| `dacli/src/commands/form/_simplify.ts` | P1-2, 仅 --fields 路径使用 |
|
||||
| `dacli/src/commands/form/lint.ts` | P0-1, form lint 命令 |
|
||||
| `dacli/src/commands/form/validate.ts` | P1-3, form validate 命令 |
|
||||
| `dacli/src/commands/form/fixcolumndata.ts` | P1-4, form fixcolumndata 命令 |
|
||||
|
||||
### 1.3 测试文件删除 (随主代码)
|
||||
|
||||
| 路径 | 原因 |
|
||||
|------|------|
|
||||
| `dacli/tests/unit/form-lint.test.ts` | form lint 已删 |
|
||||
| `dacli/tests/unit/fix-columndata.test.ts` | fixcolumndata 已删 |
|
||||
| `dacli/tests/unit/field_normalize.test.ts` | _simplify 已删 |
|
||||
|
||||
### 1.4 历史档保留 (备查)
|
||||
|
||||
| 路径 | 处理 |
|
||||
|------|------|
|
||||
| `dacli/docs/doc/deprecated/v0.8.4-changelog.md` | 保留 (历史) |
|
||||
| `dacli/docs/skill-audit/*.md` | 大部分保留备查, design-jnpf-execute.md 删 |
|
||||
| `dacli/docs/cmd-review/*.md` | 保留 (v0.11+ 审计报告, 不过时) |
|
||||
|
||||
---
|
||||
|
||||
## 2. 改写清单 (P0-2, P0-4, P2-1, P3-1)
|
||||
|
||||
### 2.1 核心 SKILL/Command 改写
|
||||
|
||||
| 文件 | 改写点 |
|
||||
|------|--------|
|
||||
| `.claude/commands/ssw-h5dev-flow.md` | 阶段 2.5 lint 段全删, 阶段 4 改 --ai-json 路径, 删除 6 类盲点必查清单 |
|
||||
| `.claude/commands/ssw-onlinedev.md` | 改 --fields 路径 → --ai-json 路径 (line 41 + 154) |
|
||||
| `.claude/CLAUDE.md` | 删除 `form validate` / `form fixcolumndata` 命令提示, 改 `--fields` 例子 → `--ai-json` 例子 |
|
||||
| `.claude/skills/dacli-ts/SKILL.md` | 删除"阶段 2.5 lint 硬关卡"段, 删除 6 类盲点必查清单, 改 `--fields` → `--ai-json` |
|
||||
| `.claude/skills/dacli-ts/references/commands.md` | 删除 `form lint` / `form validate` / `form fixcolumndata` 命令说明, `--fields` → `--ai-json` |
|
||||
| `.claude/skills/dacli-ts/references/patterns.md` | 删除旧 form create pattern, 加 --ai-json pattern |
|
||||
| `.claude/skills/dacli-ts/references/errors.md` | 删除 form lint / form validate / fixcolumndata 错误处理段, `--fields Database exception` → `--ai-json JSON parse error` |
|
||||
| `.claude/skills/dacli-ts/references/anti-patterns.md` | 删除 --fields 简化版 anti-pattern, 加 --ai-json 正例 |
|
||||
| `.claude/skills/dacli-ts/references/troubleshooting.md` | f_description/f_version sed 案例标 deprecated, 加 --ai-json troubleshooting 段 |
|
||||
| `.claude/skills/dacli-ts/references/web-source-map.md` | 删除 form lint / form validate / fixcolumndata 入口, --fields → --ai-json |
|
||||
| `.claude/skills/dacli-ts/examples/create-simple-form.sh` | 改 --fields → --ai-json |
|
||||
| `.claude/skills/dacli-ts/examples/create-master-sub-form.sh` | 改 --fields → --ai-json |
|
||||
| `.claude/skills/dacli-ts/examples/create-workflow.sh` | 改 --fields → --ai-json |
|
||||
| `.claude/skills/dacli-ts/examples/baseline/*` | 全部改 --fields → --ai-json (如适用) |
|
||||
| `.claude/skills/dacli-ts/scripts/self-check.sh` | 删除 form validate 调用 |
|
||||
|
||||
### 2.2 其他 SKILL 改写
|
||||
|
||||
| 文件 | 改写点 |
|
||||
|------|--------|
|
||||
| `.claude/skills/form-development/SKILL.md` | 删除 type=4 兜底叙述, 改 --fields → --ai-json, 删 6 类盲点必查 |
|
||||
| `.claude/skills/form-fix/SKILL.md` | 整个技能废弃 (form fixcolumndata 已删), 标记 deprecated 或删 |
|
||||
| `.claude/skills/data-management/SKILL.md` | 删除 --fields 案例 |
|
||||
| `.claude/skills/ssw-e2e-test/SKILL.md` | 删除 03_forms.py 引用, 改 form validate/fixcolumndata 段 |
|
||||
| `.claude/skills/ssw-e2e-test/scripts/crud_e2e_template.py` | 改 --fields → --ai-json |
|
||||
| `.claude/skills/ssw-e2e-test/scripts/test_dacli_e2e.sh` | 删 form lint / validate 调用 |
|
||||
| `.claude/skills/jnpf-browser-automation/examples/regression-test.md` | 删 03_forms.py 引用 |
|
||||
| `.claude/skills/jnpf-browser-automation/scripts/regression_test.py` | 删 03_forms.py 引用 |
|
||||
| `.claude/skills/platform-mechanism/references/jnpf-form-data-model.md` | 删 f_description 关键字段 (新架构自动) |
|
||||
| `.claude/skills/platform-mechanism/SKILL.md` | 删 f_description 段 |
|
||||
| `.claude/skills/code-generator/SKILL.md` | 删 form validate 段 |
|
||||
| `.claude/skills/no-spa-page/templates/module.js` | 删 f_description 段 |
|
||||
| `.claude/skills/workflow-development/SKILL.md` | 删 type=4 兜底叙述 |
|
||||
| `.claude/skills/basic-standards/SKILL.md` | 删 type=4 兜底叙述 |
|
||||
| `.claude/skills/dacli-ts/references/baseline/developSystem.md` | 删 type=4 兜底叙述 |
|
||||
|
||||
### 2.3 dacli/src/commands/form/ 改写
|
||||
|
||||
| 文件 | 改写点 |
|
||||
|------|--------|
|
||||
| `dacli/src/commands/form/index.ts` | 删 lint / validate / fixcolumndata import + addCommand |
|
||||
| `dacli/src/commands/form/create.ts` | 删 wrapSimplifiedFields 引用, 改 --fields 段报错提示"已废弃, 用 --ai-json", 加 --type=2 默认 |
|
||||
| `dacli/src/commands/form/_blindspots.ts` | 删 6 类盲点 (BS-15/23/31/32/50/52) + BS-V2 的 check 函数 (保留 BS-5/8/37/43/44/47/48/49 等运行时盲点) |
|
||||
| `dacli/src/commands/_blindspot_guards.ts` | 同上 |
|
||||
| `dacli/src/commands/_precheck.ts` | 删 type=4 兜底引用 |
|
||||
| `dacli/src/commands/form/clone.ts` | 删 type=4 兜底引用 |
|
||||
| `dacli/src/commands/form/selector.ts` | 删 type=4 引用 |
|
||||
| `dacli/src/commands/form/import.ts` | 改: renameMap 用 --table 直接指定, 不依赖 workSystem baseline (或保留 import 命令但加 --ai-json 替代入口) |
|
||||
| `dacli/src/core/client.ts` | 删 --fields 简化版相关常量 |
|
||||
| `dacli/src/core/types.ts` | 删 fixcolumndata 相关类型 |
|
||||
| `dacli/src/commands/app/context.ts` | 删 fixcolumndata 引用 |
|
||||
| `dacli/src/commands/test/check.ts` | 删 6 类盲点必查 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 保留清单 (运行时兜底 + 新架构核心)
|
||||
|
||||
### 3.1 代码 (新架构核心)
|
||||
|
||||
| 路径 | 保留原因 |
|
||||
|------|---------|
|
||||
| `dacli/src/webapi/*.ts` (17 模块) | 新架构核心, 直接 import web 端源码 |
|
||||
| `dacli/src/commands/form/_buildformdata.ts` | 新架构核心, import web 端 buildFormData |
|
||||
| `dacli/src/commands/form/_ai.ts` + `_ai_prompts.ts` | `--ai` 路径, LLM 生成 JSON |
|
||||
| `dacli/src/commands/_blindspot_guards.ts` 22 条 guard | 运行时兜底, 删 BS-15/23/31/32/50/52 + BS-V2 后保留其他 |
|
||||
| `dacli/src/commands/_precheck.ts` | 运行时 L1 检查 |
|
||||
| `dacli/src/commands/form/create.ts` + `import.ts` + `export.ts` + `clone.ts` + `release.ts` + `info.ts` + `list.ts` + `delete.ts` + `update.ts` + `codegen.ts` + `bindflow.ts` + `selector.ts` | v0.11+ 核心命令 |
|
||||
|
||||
### 3.2 SKILL/文档 (新架构正例)
|
||||
|
||||
| 路径 | 保留原因 |
|
||||
|------|---------|
|
||||
| `.claude/skills/dacli-ts/SKILL.md` | 新保留: v0.11+ webapi + --ai-json |
|
||||
| `.claude/skills/dacli-ts/references/commands.md` | 新保留: 列 v0.11+ 命令清单 |
|
||||
| `.claude/skills/dacli-ts/references/web-source-map.md` | 新保留: web 端 → dacli 命令速查 |
|
||||
| `.claude/skills/platform-mechanism/` | 新保留: JNPF 机制说明 (机制不变) |
|
||||
|
||||
---
|
||||
|
||||
## 4. 执行顺序 (重启后)
|
||||
|
||||
### Phase A: 删除 (原子操作, 易回滚)
|
||||
1. 删除 `.claude/skills/design-jnpf-execute/` 整个目录
|
||||
2. 删除 `.claude/templates/jnpf-design-*.tmpl` 3 个文件
|
||||
3. 删除 `.claude/templates/功能设计模板.md`
|
||||
4. 删除 `dacli/src/commands/form/_parsers.ts`
|
||||
5. 删除 `dacli/src/commands/form/_simplify.ts`
|
||||
6. 删除 `dacli/src/commands/form/lint.ts`
|
||||
7. 删除 `dacli/src/commands/form/validate.ts`
|
||||
8. 删除 `dacli/src/commands/form/fixcolumndata.ts`
|
||||
9. 删除 `dacli/tests/unit/form-lint.test.ts`
|
||||
10. 删除 `dacli/tests/unit/fix-columndata.test.ts`
|
||||
11. 删除 `dacli/tests/unit/field_normalize.test.ts`
|
||||
12. 删除 `dacli/docs/skill-audit/design-jnpf-execute.md`
|
||||
|
||||
### Phase B: 改写 create.ts + index.ts (主入口)
|
||||
1. `dacli/src/commands/form/index.ts` 删 lint/validate/fixcolumndata import + addCommand
|
||||
2. `dacli/src/commands/form/create.ts` 删 wrapSimplifiedFields, --fields 段改报错, --type 默认改 2
|
||||
3. `dacli/src/commands/_blindspot_guards.ts` 删 BS-15/23/31/32/50/52 + BS-V2 check 函数
|
||||
4. `dacli/src/commands/_precheck.ts` 删 type=4 兜底引用
|
||||
5. `dacli/src/commands/form/clone.ts` 删 type=4 兜底引用
|
||||
6. `dacli/src/commands/form/selector.ts` 删 type=4 引用
|
||||
7. `dacli/src/commands/form/_blindspots.ts` 删 6 类盲点
|
||||
8. `dacli/src/commands/form/import.ts` 修 renameMap 默认行为
|
||||
9. `dacli/src/commands/test/check.ts` 删 6 类盲点必查
|
||||
10. `dacli/src/core/client.ts` 删 --fields 简化常量
|
||||
11. `dacli/src/core/types.ts` 删 fixcolumndata 类型
|
||||
12. `dacli/src/commands/app/context.ts` 删 fixcolumndata 引用
|
||||
|
||||
### Phase C: 改写 .claude/ 提示词
|
||||
1. `.claude/CLAUDE.md` (顶层) - 删 form validate/fixcolumndata/--fields 段
|
||||
2. `.claude/commands/ssw-h5dev-flow.md` - 删阶段 2.5 lint, 改 --ai-json
|
||||
3. `.claude/commands/ssw-onlinedev.md` - 改 --fields → --ai-json
|
||||
4. `.claude/skills/dacli-ts/SKILL.md` + 6 references
|
||||
5. `.claude/skills/dacli-ts/examples/*.sh`
|
||||
6. `.claude/skills/dacli-ts/scripts/self-check.sh`
|
||||
7. `.claude/skills/form-development/SKILL.md`
|
||||
8. `.claude/skills/form-fix/SKILL.md` (整个标记 deprecated 或删)
|
||||
9. `.claude/skills/data-management/SKILL.md`
|
||||
10. `.claude/skills/ssw-e2e-test/SKILL.md` + scripts/
|
||||
11. `.claude/skills/jnpf-browser-automation/`
|
||||
12. `.claude/skills/platform-mechanism/`
|
||||
13. `.claude/skills/code-generator/SKILL.md`
|
||||
14. `.claude/skills/no-spa-page/templates/module.js`
|
||||
15. `.claude/skills/workflow-development/SKILL.md`
|
||||
16. `.claude/skills/basic-standards/SKILL.md`
|
||||
17. `.claude/skills/dacli-ts/references/baseline/developSystem.md`
|
||||
|
||||
### Phase D: 验证
|
||||
1. `cd dacli && npm run typecheck` (TS 编译)
|
||||
2. `cd dacli && npx tsx src/cli.ts form --help` (确认 lint/validate/fixcolumndata 已删)
|
||||
3. `cd dacli && npx tsx src/cli.ts form create --help` (确认 --ai-json 在, --fields 报错)
|
||||
4. `cd dacli && npx tsx src/cli.ts form info <existing_form_id>` (确认 info 命令正常)
|
||||
5. `cd dacli && npm run test` (跑 vitest, 确认 base test 没受影响)
|
||||
6. 跑一遍 design-jnpf-execute 删除后, design-jnpf-execute 技能调用应"找不到技能"
|
||||
|
||||
### Phase E: 提交
|
||||
1. `git add -A && git commit -m "v0.11+ 清理: 删 form lint/validate/fixcolumndata + design-jnpf-execute + --fields 简化路径, 6 类盲点必查清单; 改 --ai-json 路径"`
|
||||
2. `git push origin main`
|
||||
|
||||
### Phase F: MEMORY
|
||||
1. 写 MEMORY: `dacli-v0.11-cleanup-2026-06-26.md` (教训 + 体检报告指针 + 改动摘要)
|
||||
|
||||
---
|
||||
|
||||
## 5. 风险评估
|
||||
|
||||
- **破坏性**: 高 (删 5 个命令 + 1 个技能 + 多个 SKILL 段落)
|
||||
- **回滚成本**: 中 (git revert 即可, 因 Phase A 是原子删除)
|
||||
- **现有用户影响**: 无 (项目内用户, 老 form 数据不受影响)
|
||||
- **盲点覆盖**: 删 6 类盲点 check 后, 依赖 web 端 buildFormData 自动保证, 风险低
|
||||
|
||||
---
|
||||
|
||||
## 6. 不动的部分 (备查)
|
||||
|
||||
- `dacli/docs/doc/deprecated/v0.8.4-changelog.md` - 历史档
|
||||
- `dacli/docs/cmd-review/*.md` - v0.11+ 审计报告 (不过时)
|
||||
- `dacli/docs/web-patches/*.md` - web 端改动记录
|
||||
- `.claude/skills/dacli-ts/references/baseline/*.md` (除 developSystem.md 外) - 速查表, 部分需改但大部分保留
|
||||
|
||||
---
|
||||
|
||||
**报告完成. 待用户确认后逐条执行.**
|
||||
|
||||
---
|
||||
|
||||
## 7. 体检扩展 (v2, 2026-06-26 用户追加)
|
||||
|
||||
### 7.1 范围扩展 (不只 form, 全部 dacli 命令)
|
||||
|
||||
扫描结果 (`dacli/src/commands/<dir>/*.ts` 走 webapi 的比例):
|
||||
|
||||
| 命令 | webapi 化进度 | 处理 |
|
||||
|------|--------------|------|
|
||||
| dict | 8/8 (100%) | KEEP |
|
||||
| datasource / monitor / log / dm | 100% | KEEP |
|
||||
| schedule | 6/7 (86%) | schedule update 改 webapi |
|
||||
| workflow | 4/10 (40%) | create/decision/approve/launch/list/tasks 改 webapi |
|
||||
| menu | 5/8 (63%) | create/_helpers/releases 改 webapi |
|
||||
| di | 4/5 (80%) | create 改 webapi |
|
||||
| bigscreen / report / portal | 0-2/N (低) | 全部改 webapi (或归档) |
|
||||
| msg | 4/9 (44%) | update/delete/notice/template 改 webapi |
|
||||
| role | 3/7 (43%) | update/delete/info/list 改 webapi |
|
||||
| user / org | 0-3/N (低) | 改 webapi (或归档 user 复杂场景) |
|
||||
| integration / storage | 0/N (0%) | 改 webapi 或归档 |
|
||||
| doc / apis / test | 0/N (0%) | 改 webapi (reader 类简单) |
|
||||
| print | 0/3 (0%) | 改 webapi 或归档 |
|
||||
| app | 1/9 (11%) | 改 webapi |
|
||||
|
||||
### 7.2 SKILL 层扩展冲突 (workflow/menu/di/portal/e2e 等)
|
||||
|
||||
| SKILL | 旧模式 | 冲突 | 处理 |
|
||||
|-------|--------|------|------|
|
||||
| `workflow-development/SKILL.md` | 教 `POST /api/workflow/task` + `POST /api/workflow/operator/Audit/{operatorId}` (platform API) | 不走 dacli, AI 会自己 curl | 改用 `dacli workflow launch/approve/decision` |
|
||||
| `menu-configuration/SKILL.md` | 教 `POST /api/system/Menu` + `requests.get('/api/system/Menu/ModuleBySystem')` | 同上 | 改用 `dacli menu create --formId=X` |
|
||||
| `data-interface/SKILL.md` | 教 `--sql` + Python `requests.post('/dataInterface')` | DI SQL 限制多 | 改用 `dacli di create/update/test` |
|
||||
| `ssw-e2e-test/scripts/jnpf_client.py` | 自己 requests 写 POST/GET/PUT/DELETE | 与 dacli test 重复 | 删, 用 `dacli test run --formId=X` |
|
||||
| `ssw-e2e-test/scripts/crud_e2e_template.py` | urllib 调 `/api/visualdev/OnlineDev/{modelId}/List` | 同上 | 删, 用 dacli test |
|
||||
| `ssw-e2e-test/scripts/test_dacli_e2e.sh` | 调 form validate/fixcolumndata | 过时命令 | 删 |
|
||||
| `no-spa-page/templates/entity.java` | 注释"禁止 f_version (系统保留)" | v0.11+ 已自动, 注释过时 | 删注释 |
|
||||
| `no-spa-page/templates/module.js` | 字段 `f_description` (跟 BS-38 系统列冲突) | 用户易误用 | 改字段名 `f_app_desc` |
|
||||
| `platform-mechanism/SKILL.md` + `references/jnpf-form-data-model.md` | 教 `f_description` 等关键字 | 同上 | 删/改名 |
|
||||
| `code-generator/SKILL.md` | 教 form validate | 命令已删 | 删 |
|
||||
|
||||
### 7.3 ssw-h5dev-flow 主入口扩展重写清单
|
||||
|
||||
ssw-h5dev-flow.md 必须按 v0.11+ 全面重写:
|
||||
|
||||
| 阶段 | 当前内容 | 改写后 |
|
||||
|------|----------|--------|
|
||||
| 阶段1 | `dacli app init --appCode=X --restart` | 保留 |
|
||||
| 阶段2 | 教 design.html + design-jnpf.html + 03_forms.py + form lint | 删 design-jnpf.html + 03_forms.py + lint, 仅 design.html |
|
||||
| 阶段2.5 | form lint 硬关卡 (6 盲点 + BS-V2 必查) | **整段删** |
|
||||
| 阶段3 | 教 dispatch 子代理 (1 form 1 sub-agent) | **整段删**, 改为主代理直接 `dacli form create --ai-json` |
|
||||
| 阶段4 | 教子代理 5 步流程 + 防协议违约 | **改为主代理 `dacli form create --ai-json=...` 单命令** |
|
||||
| 阶段5 | 教 `dacli form validate` + `form fixcolumndata` + ssw-e2e-test 自写 e2e | **改用 `dacli test run --formId=X`** (dacli 0.11+ NEW) |
|
||||
| 阶段6 | 教 BS-52 自检 + 截图去重 | 保留 (浏览器层 4 铁律仍有效) |
|
||||
| 阶段7 | 迭代 | 保留 |
|
||||
|
||||
### 7.4 新增删除清单 (基于扩展体检)
|
||||
|
||||
| 文件 | 原因 |
|
||||
|------|------|
|
||||
| `.claude/skills/workflow-development/SKILL.md` | 整个重写 (教 platform API → 教 dacli 命令) |
|
||||
| `.claude/skills/menu-configuration/SKILL.md` | 整个重写 |
|
||||
| `.claude/skills/data-interface/SKILL.md` | 整个重写 |
|
||||
| `.claude/skills/ssw-e2e-test/scripts/jnpf_client.py` | 删, 用 dacli test |
|
||||
| `.claude/skills/ssw-e2e-test/scripts/crud_e2e_template.py` | 删, 用 dacli test |
|
||||
| `.claude/skills/ssw-e2e-test/scripts/test_dacli_e2e.sh` | 删 |
|
||||
| `.claude/skills/data-management/SKILL.md` | 整个重写 (dm create 应改为字段 JSON + buildFormData) |
|
||||
| `.claude/skills/code-generator/SKILL.md` | 删 form validate 段 |
|
||||
| `.claude/skills/platform-mechanism/SKILL.md` + `references/jnpf-form-data-model.md` | 删 f_description 段 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 总体执行顺序 (合并原 Phase + 扩展)
|
||||
|
||||
### Phase A: 删除 (原子操作, 易回滚)
|
||||
1-12: 原清单 (design-jnpf-execute + 5 TS + 3 测试 + jnpf-design tmpl)
|
||||
13: 删除 `.claude/skills/ssw-e2e-test/scripts/jnpf_client.py`
|
||||
14: 删除 `.claude/skills/ssw-e2e-test/scripts/crud_e2e_template.py`
|
||||
15: 删除 `.claude/skills/ssw-e2e-test/scripts/test_dacli_e2e.sh`
|
||||
|
||||
### Phase B: 改写 dacli/src (主入口)
|
||||
1. `dacli/src/commands/form/index.ts` 删 lint/validate/fixcolumndata
|
||||
2. `dacli/src/commands/form/create.ts` 删 wrapSimplifiedFields, 改 --fields 报错
|
||||
3. `dacli/src/commands/_blindspot_guards.ts` 删 6 类盲点
|
||||
4. `dacli/src/commands/_precheck.ts` 删 type=4 兜底
|
||||
5. `dacli/src/commands/form/clone.ts/selector.ts/_blindspots.ts` 删 type=4 / 6 类盲点
|
||||
6. `dacli/src/commands/form/import.ts` 改 renameMap 默认
|
||||
7. `dacli/src/commands/test/check.ts` 删 6 类盲点
|
||||
8. `dacli/src/core/{client,types}.ts` 删 --fields 简化常量 + fixcolumndata 类型
|
||||
9. `dacli/src/commands/app/context.ts` 删 fixcolumndata
|
||||
|
||||
### Phase C: 改写 .claude/ SKILL/command 提示词
|
||||
1. `.claude/CLAUDE.md` - 顶层清理
|
||||
2. `.claude/commands/ssw-h5dev-flow.md` - **整个重写 (按 7.3 阶段表)**
|
||||
3. `.claude/commands/ssw-onlinedev.md` - 改 --ai-json
|
||||
4. `.claude/skills/dacli-ts/SKILL.md` + 6 references
|
||||
5. `.claude/skills/dacli-ts/examples/*.sh`
|
||||
6. `.claude/skills/dacli-ts/scripts/self-check.sh`
|
||||
7. `.claude/skills/form-development/SKILL.md`
|
||||
8. `.claude/skills/form-fix/SKILL.md` (删)
|
||||
9. `.claude/skills/data-management/SKILL.md` (重写)
|
||||
10. `.claude/skills/ssw-e2e-test/SKILL.md` (重写: 用 dacli test)
|
||||
11. `.claude/skills/jnpf-browser-automation/`
|
||||
12. `.claude/skills/platform-mechanism/`
|
||||
13. `.claude/skills/code-generator/SKILL.md`
|
||||
14. `.claude/skills/no-spa-page/templates/entity.java` (删注释)
|
||||
15. `.claude/skills/no-spa-page/templates/module.js` (f_description → f_app_desc)
|
||||
16. `.claude/skills/workflow-development/SKILL.md` (重写)
|
||||
17. `.claude/skills/menu-configuration/SKILL.md` (重写)
|
||||
18. `.claude/skills/data-interface/SKILL.md` (重写)
|
||||
|
||||
### Phase D: 验证
|
||||
1. `cd dacli && npm run typecheck` (TS 编译)
|
||||
2. `cd dacli && npx tsx src/cli.ts form --help` (确认 5 个命令已删)
|
||||
3. `cd dacli && npx tsx src/cli.ts form create --help` (确认 --ai-json 在)
|
||||
4. `cd dacli && npx tsx src/cli.ts form info <existing_id>` (确认 info 正常)
|
||||
5. `cd dacli && npm run test` (跑 vitest)
|
||||
6. `cd dacli && npx tsx src/cli.ts test --help` (确认 dacli test 可用)
|
||||
7. 跑 e2e_smoke 验证 ssw-e2e-test 还能用
|
||||
|
||||
### Phase E: 提交 + MEMORY
|
||||
1. `git add -A && git commit -m "v0.11+ 清理: 删 form lint/validate/fixcolumndata + design-jnpf-execute + ssw-e2e-test 自写 e2e; workflow/menu/di 重写; --ai-json 路径全面替代 --fields"`
|
||||
2. `git push origin main`
|
||||
3. 写 MEMORY: `dacli-v0.11-cleanup-2026-06-26.md`
|
||||
|
||||
---
|
||||
|
||||
## 9. 总览: 删除 vs 改写
|
||||
|
||||
| 类型 | 数量 | 文件 |
|
||||
|------|------|------|
|
||||
| 整个目录删除 | 4 | design-jnpf-execute/, jnpf-design-*.tmpl ×3, 关联功能设计模板.md |
|
||||
| TS 文件删除 | 5 | _parsers.ts / _simplify.ts / lint.ts / validate.ts / fixcolumndata.ts |
|
||||
| Python 脚本删除 | 4 | jnpf_client.py / crud_e2e_template.py / test_dacli_e2e.sh + 旧 test |
|
||||
| 测试文件删除 | 3 | form-lint / fix-columndata / field_normalize |
|
||||
| SKILL 整段重写 | 5 | ssw-h5dev-flow / form-development / data-management / ssw-e2e-test / workflow-development / menu-configuration / data-interface |
|
||||
| .claude/CLAUDE.md + 6 references + examples | 17+ | 删 6 盲点 + 改 --ai-json |
|
||||
| dacli/src 改写 | 12 | 见 Phase B |
|
||||
|
||||
**总计: ~60 文件改动, ~25 文件删除, 风险高但回滚安全**
|
||||
|
||||
---
|
||||
|
||||
**v2 报告完成. 待用户最终确认.**
|
||||
@@ -0,0 +1,267 @@
|
||||
# dacli v0.11+ 体检报告清理 - 执行计划
|
||||
|
||||
**触发入口**: `/v0.11-cleanup` (重启后输入此命令开始执行)
|
||||
**审计报告**: `dacli/docs/v0.11-audit-report.md` (v2)
|
||||
**执行日期**: 2026-06-26
|
||||
**原则**: 不考虑兼容老用户, 按 v0.11+ webapi 镜像架构全面对齐
|
||||
|
||||
---
|
||||
|
||||
## Phase A: 原子删除 (~15 文件)
|
||||
|
||||
### A.1 整个目录删除
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir
|
||||
rm -rf .claude/skills/design-jnpf-execute/
|
||||
rm -f .claude/templates/jnpf-design-card.tmpl
|
||||
rm -f .claude/templates/jnpf-design-master-sub.tmpl
|
||||
rm -f .claude/templates/jnpf-design-workflow.tmpl
|
||||
rm -f .claude/templates/功能设计模板.md
|
||||
```
|
||||
|
||||
### A.2 旧 TS 代码删除
|
||||
```bash
|
||||
rm -f dacli/src/commands/form/_parsers.ts
|
||||
rm -f dacli/src/commands/form/_simplify.ts
|
||||
rm -f dacli/src/commands/form/lint.ts
|
||||
rm -f dacli/src/commands/form/validate.ts
|
||||
rm -f dacli/src/commands/form/fixcolumndata.ts
|
||||
```
|
||||
|
||||
### A.3 旧测试删除
|
||||
```bash
|
||||
rm -f dacli/tests/unit/form-lint.test.ts
|
||||
rm -f dacli/tests/unit/fix-columndata.test.ts
|
||||
rm -f dacli/tests/unit/field_normalize.test.ts
|
||||
```
|
||||
|
||||
### A.4 旧 e2e 脚本删除
|
||||
```bash
|
||||
rm -f .claude/skills/ssw-e2e-test/scripts/jnpf_client.py
|
||||
rm -f .claude/skills/ssw-e2e-test/scripts/crud_e2e_template.py
|
||||
rm -f .claude/skills/ssw-e2e-test/scripts/test_dacli_e2e.sh
|
||||
```
|
||||
|
||||
### A.5 form-fix 技能废弃
|
||||
```bash
|
||||
# 标记 deprecated (form fixcolumndata 已删)
|
||||
echo "## ⚠️ 已废弃 (2026-06-26)" > /tmp/deprecated_marker
|
||||
cat .claude/skills/form-fix/SKILL.md >> /tmp/deprecated_marker
|
||||
mv /tmp/deprecated_marker .claude/skills/form-fix/SKILL.md
|
||||
```
|
||||
|
||||
### A.6 阶段 A 验证
|
||||
```bash
|
||||
# 确认删除成功
|
||||
ls .claude/skills/ | grep -i design-jnpf-execute # 应为空
|
||||
ls dacli/src/commands/form/ | grep -E "_parsers|_simplify|lint|validate|fixcolumndata" # 应为空
|
||||
ls .claude/skills/ssw-e2e-test/scripts/ | grep -E "jnpf_client|crud_e2e|test_dacli_e2e" # 应为空
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase B: 改写 dacli/src (12 文件)
|
||||
|
||||
### B.1 form/index.ts (主入口)
|
||||
- 删 `import { buildFormLintCommand } from './lint.ts'`
|
||||
- 删 `import { buildFormValidateCommand } from './validate.ts'`
|
||||
- 删 `import { buildFormFixColumnDataCommand } from './fixcolumndata.ts'`
|
||||
- 删 3 个 `cmd.addCommand(...)`
|
||||
|
||||
### B.2 form/create.ts
|
||||
- 删 `import { wrapSimplifiedFields, buildTablesFromFields, toSimpleField } from './_simplify.ts'`
|
||||
- `wrapSimplifiedFields(...)` 调用处 (260 行附近) → 报错退出: `log.error('--fields 已废弃, 请用 --ai-json (v0.11+ 走 web 端 buildFormData)'); process.exit(2)`
|
||||
- `buildTablesFromFields(...)` 调用处 → 同上报错
|
||||
- `--type` 默认值改 `4` → `2`
|
||||
- `--ai-json` 路径 `opts.type = '4'` 硬编码 → 删 (保持 --type 用户传入)
|
||||
|
||||
### B.3 form/import.ts
|
||||
- 改 auto-rename 行为: 不再依赖 workSystem baseline, 默认 `--table={enCode}` 不加 `<appCode>_` 前缀
|
||||
- 加 deprecation warning: `log.warn('form import 已废弃, 推荐 form create --ai-json')`
|
||||
|
||||
### B.4 form/clone.ts
|
||||
- 删 type=4 兜底引用 (line ~30)
|
||||
- 改: 克隆时强制 type=2
|
||||
|
||||
### B.5 form/selector.ts
|
||||
- 删 type=4 引用
|
||||
|
||||
### B.6 form/_blindspots.ts
|
||||
- 删 BS-15/BS-23/BS-31/BS-32/BS-50/BS-52 + BS-V2 的 check 函数 (保留 BS-5/8/37/43/44/47/48/49)
|
||||
|
||||
### B.7 _blindspot_guards.ts
|
||||
- 同上: 删 6 类盲点 + BS-V2
|
||||
|
||||
### B.8 _precheck.ts
|
||||
- 删 type=4 兜底引用
|
||||
|
||||
### B.9 form/release.ts
|
||||
- BS-50 false positive (release 命令触发 menu create 的 guard) → 修: `runGuards` 加 `__command === 'menu create'` 限制
|
||||
|
||||
### B.10 core/client.ts
|
||||
- 删 --fields 简化版相关常量
|
||||
|
||||
### B.11 core/types.ts
|
||||
- 删 fixcolumndata 相关类型导出
|
||||
|
||||
### B.12 commands/app/context.ts
|
||||
- 删 fixcolumndata 引用
|
||||
|
||||
### B.13 commands/test/check.ts
|
||||
- 删 6 类盲点必查 (BS-15/23/31/32/50/52)
|
||||
|
||||
### B.14 阶段 B 验证
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir/dacli && npm run typecheck
|
||||
npx tsx src/cli.ts form --help | grep -E "lint|validate|fixcolumndata" # 应为空
|
||||
npx tsx src/cli.ts form create --help | grep "ai-json" # 应有
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase C: 改写 .claude/ 提示词 (~20 文件)
|
||||
|
||||
### C.1 顶层
|
||||
- `.claude/CLAUDE.md` - 删 form validate/fixcolumndata/--fields 段, 改 --ai-json 例子
|
||||
- `.claude/commands/ssw-h5dev-flow.md` - **整个重写 (按 7 阶段表)**
|
||||
- `.claude/commands/ssw-onlinedev.md` - 改 --fields → --ai-json
|
||||
|
||||
### C.2 dacli-ts skill (主技能)
|
||||
- `.claude/skills/dacli-ts/SKILL.md` - 删"阶段 2.5 lint 硬关卡"段, 删 6 类盲点必查清单, 改 --fields → --ai-json
|
||||
- `.claude/skills/dacli-ts/references/commands.md` - 删 form lint/validate/fixcolumndata, 加 --ai-json
|
||||
- `.claude/skills/dacli-ts/references/patterns.md` - 删旧 --fields pattern, 加 --ai-json
|
||||
- `.claude/skills/dacli-ts/references/errors.md` - 删 form lint/validate/fixcolumndata 错误, 改 --fields DB exception → --ai-json JSON parse
|
||||
- `.claude/skills/dacli-ts/references/anti-patterns.md` - 删 --fields 简化版 anti-pattern
|
||||
- `.claude/skills/dacli-ts/references/troubleshooting.md` - 标 f_description/f_version sed 案例 deprecated, 加 --ai-json troubleshooting
|
||||
- `.claude/skills/dacli-ts/references/web-source-map.md` - 删 lint/validate/fixcolumndata 入口, --fields → --ai-json
|
||||
- `.claude/skills/dacli-ts/examples/create-simple-form.sh` - 改 --fields → --ai-json
|
||||
- `.claude/skills/dacli-ts/examples/create-master-sub-form.sh` - 改 --fields → --ai-json
|
||||
- `.claude/skills/dacli-ts/examples/create-workflow.sh` - 改 --fields → --ai-json
|
||||
- `.claude/skills/dacli-ts/examples/baseline/*` - 全部改 (如适用)
|
||||
- `.claude/skills/dacli-ts/scripts/self-check.sh` - 删 form validate 调用
|
||||
|
||||
### C.3 其他 SKILL 改写
|
||||
- `.claude/skills/form-development/SKILL.md` - 删 type=4 兜底, --fields → --ai-json, 删 6 类盲点
|
||||
- `.claude/skills/data-management/SKILL.md` - 整个重写 (dm create 应改为字段 JSON)
|
||||
- `.claude/skills/ssw-e2e-test/SKILL.md` - 整个重写 (用 dacli test)
|
||||
- `.claude/skills/workflow-development/SKILL.md` - 整个重写 (教 dacli workflow 命令)
|
||||
- `.claude/skills/menu-configuration/SKILL.md` - 整个重写 (教 dacli menu --formId)
|
||||
- `.claude/skills/data-interface/SKILL.md` - 整个重写 (教 dacli di)
|
||||
- `.claude/skills/code-generator/SKILL.md` - 删 form validate 段
|
||||
- `.claude/skills/platform-mechanism/SKILL.md` + `references/jnpf-form-data-model.md` - 删 f_description 段
|
||||
|
||||
### C.4 no-spa-page 模板修
|
||||
- `.claude/skills/no-spa-page/templates/entity.java` - 删 "禁止 f_version" 注释
|
||||
- `.claude/skills/no-spa-page/templates/module.js` - `f_description` → `f_app_desc`
|
||||
|
||||
### C.5 其他清理
|
||||
- `.claude/skills/jnpf-browser-automation/examples/regression-test.md` - 删 03_forms.py 引用
|
||||
- `.claude/skills/jnpf-browser-automation/scripts/regression_test.py` - 删 03_forms.py 引用
|
||||
|
||||
### C.6 dacli/docs/ 历史档
|
||||
- `dacli/docs/skill-audit/design-jnpf-execute.md` - 删
|
||||
- `dacli/docs/skill-audit/ssw-h5dev-flow.md` - 重新审计后改写
|
||||
- `dacli/docs/skill-audit/form-fix.md` - 标 deprecated
|
||||
|
||||
### C.7 阶段 C 验证
|
||||
```bash
|
||||
# 验证 --fields 已不出现
|
||||
grep -rln "wrapSimplifiedFields\|parsePythonForms\|form lint\|03_forms.py" /home/ubuntu/ccWorkDir/.claude/ 2>&1 | head -5
|
||||
# 应为空 (或只剩 history_bak)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase D: 端到端验证
|
||||
|
||||
### D.1 TS 编译
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir/dacli && npm run typecheck
|
||||
```
|
||||
|
||||
### D.2 命令可用性
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir/dacli
|
||||
npx tsx src/cli.ts form --help # 确认 5 个命令已删
|
||||
npx tsx src/cli.ts form create --help # 确认 --ai-json 在, --fields 报错
|
||||
npx tsx src/cli.ts form info <existing_id> # 确认 info 正常
|
||||
npx tsx src/cli.ts test --help # 确认 dacli test 可用
|
||||
```
|
||||
|
||||
### D.3 跑 baseline 测试
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir/dacli && npm run test # vitest
|
||||
```
|
||||
|
||||
### D.4 跑 form 业务流
|
||||
```bash
|
||||
# 切到 developSystem 找一个 form 测试
|
||||
dacli app switch --appCode=developSystem
|
||||
dacli form info 797437045977907781 # 测试 form info 仍正常
|
||||
```
|
||||
|
||||
### D.5 跑 ssw-h5dev-flow 端到端 (dry-run)
|
||||
```bash
|
||||
# 不实际建表, 验证 SKILL 触发正常
|
||||
ls /home/ubuntu/ccWorkDir/.claude/commands/ssw-h5dev-flow.md
|
||||
grep "v0.11" /home/ubuntu/ccWorkDir/.claude/commands/ssw-h5dev-flow.md # 应有新版本标记
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase E: 提交 + MEMORY
|
||||
|
||||
### E.1 git 提交
|
||||
```bash
|
||||
cd /home/ubuntu/ccWorkDir
|
||||
git add -A
|
||||
git commit -m "v0.11+ 全面清理: 删 form lint/validate/fixcolumndata/design-jnpf-execute/ssw-e2e-test 自写 e2e; --ai-json 替代 --fields; workflow/menu/di/ssw-h5dev-flow 重写"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
### E.2 MEMORY
|
||||
```bash
|
||||
# 写 MEMORY 文件
|
||||
cat > /home/ubuntu/.claude/projects/-home-ubuntu-ccWorkDir/memory/dacli-v0.11-cleanup-2026-06-26.md <<'EOF'
|
||||
---
|
||||
name: dacli-v0.11-cleanup-2026-06-26
|
||||
description: v0.11+ 全面清理: form lint/validate/fixcolumndata + design-jnpf-execute + --fields 路径全部删除, --ai-json + webapi 镜像为唯一路径
|
||||
metadata:
|
||||
type: project
|
||||
---
|
||||
|
||||
2026-06-26 v0.11+ webapi 镜像架构下, 旧 v0.10- 内容已全部抹去.
|
||||
|
||||
**体检报告**: `dacli/docs/v0.11-audit-report.md` (v2)
|
||||
**执行计划**: `dacli/docs/v0.11-cleanup-execution-plan.md`
|
||||
|
||||
**Why**: 不考虑兼容老用户. 新架构 (webapi 镜像 + --ai-json + buildFormData) 已自动保证 schema 完整性 (BS-51/52/54), 旧的 03_forms.py / form lint / 6 类盲点必查 / dispatch 子代理 全部失效.
|
||||
|
||||
**How to apply**: 见体检报告 + 执行计划. AI 新会话必走 --ai-json 路径, 不再写 --fields / 03_forms.py / design-jnpf.html / form lint. 关联字段用 relationForm (webapi 镜像自动保证).
|
||||
|
||||
**改动摘要**: ~60 文件改动, ~25 文件删除. 涉及 form/workflow/menu/di/ssw-h5dev-flow/ssw-e2e-test 等多个 skill 和 command. 6 类盲点 BS-15/23/31/32/50/52 + BS-V2 在 SKILL 提示词中全部删除, 22 条 guard 删 6 类后保留 BS-5/8/37/43/44/47/48/49 等运行时兜底.
|
||||
EOF
|
||||
|
||||
# 更新 MEMORY.md 索引
|
||||
echo "- [dacli v0.11+ 全面清理 2026-06-26](dacli-v0.11-cleanup-2026-06-26.md) — 体检报告 + 执行计划, --ai-json 唯一路径" >> /home/ubuntu/.claude/projects/-home-ubuntu-ccWorkDir/memory/MEMORY.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 总览
|
||||
|
||||
| Phase | 文件数 | 风险 | 回滚 |
|
||||
|-------|--------|------|------|
|
||||
| A 原子删除 | 15 | 低 | git revert |
|
||||
| B TS 改写 | 12 | 中 | git revert (单 commit) |
|
||||
| C 提示词改写 | 25+ | 低 | git revert |
|
||||
| D 验证 | 0 | 无 | - |
|
||||
| E 提交 + MEMORY | 2 | 无 | - |
|
||||
|
||||
**总耗时预估**: 30-60 min (改写 + 验证)
|
||||
**总风险**: 中 (Phase B 涉及 TS 类型/逻辑, 需 typecheck + 测试)
|
||||
**回滚方式**: 整个执行计划是一组 commit, 可单 commit 回滚或全 revert
|
||||
|
||||
---
|
||||
|
||||
**重启后入口**: 输入 `/v0.11-cleanup` 开始执行
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* commands/form/_parsers.ts — 设计期解析器
|
||||
*
|
||||
* parsePythonForms(): 从 03_forms.py 抽 FORMS = [(en_code, full_name, [(type, vmodel, label, req), ...]), ...]
|
||||
* parseDesignHtml(): 从 design-jnpf.html 抽 .cmd 块 + 验证命令完整性
|
||||
*/
|
||||
|
||||
export interface FieldDef {
|
||||
type: string // input / inputNumber / textarea / select / ...
|
||||
vmodel: string
|
||||
label: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
export interface FormDef {
|
||||
enCode: string
|
||||
fullName: string
|
||||
fields: FieldDef[]
|
||||
}
|
||||
|
||||
export function parsePythonForms(src: string): FormDef[] {
|
||||
const forms: FormDef[] = []
|
||||
// 找 FORMS = [ ... ] 顶层段
|
||||
const m = src.match(/FORMS\s*=\s*\[([\s\S]*?)\n\]/m)
|
||||
if (!m) return []
|
||||
const body = m[1]
|
||||
|
||||
// 第一步: 找所有 form 头元组 (enCode, fullName, ...metadata, [fields])
|
||||
// form 头特征: 行首缩进 + ( + 'enCode', 'fullName', 可选 metadata (webType, enableFlow, flowId) + [
|
||||
// 支持 3 元组: ('enc', 'name', [fields])
|
||||
// 支持 6 元组: ('enc', 'name', webType, enableFlow, flowId, [fields]) (2026-06-21 tds2 8D 实战, 注释承载元数据)
|
||||
// metadata 模式: None 或 数字 或 字符串, 逗号分隔, 不含嵌套 ()
|
||||
const formHeaders: Array<{ enCode: string; fullName: string; startIdx: number }> = []
|
||||
const formHeaderRe = /^\s*\(\s*'([^']+)'\s*,\s*'([^']+)'\s*,\s*(?:(?:None|\d+|'[^']*')\s*,\s*)*\[/gm
|
||||
let mm: RegExpExecArray | null
|
||||
while ((mm = formHeaderRe.exec(body)) !== null) {
|
||||
formHeaders.push({ enCode: mm[1], fullName: mm[2], startIdx: mm.index })
|
||||
}
|
||||
if (formHeaders.length === 0) return []
|
||||
|
||||
// 第二步: 找所有 field 元组 (type, vmodel, label, required[, extra])
|
||||
// field 元组至少 4 个字符串 + True/False, 可能是 5 元 (含 extra dict)
|
||||
// label 允许空字符串: 用 '[^']*' (0+ chars) 而非 '[^']+' (1+ chars)
|
||||
const fieldRe = /\(\s*'([^']+)'\s*,\s*'([^']+)'\s*,\s*'([^']*)'\s*,\s*(True|False)/g
|
||||
const allFields: Array<{ type: string; vmodel: string; label: string; required: boolean; idx: number }> = []
|
||||
while ((mm = fieldRe.exec(body)) !== null) {
|
||||
allFields.push({ type: mm[1], vmodel: mm[2], label: mm[3], required: mm[4] === 'True', idx: mm.index })
|
||||
}
|
||||
|
||||
// 第三步: 对每个 form 头, 找其 [ ... ] 内的 field 元组
|
||||
for (let k = 0; k < formHeaders.length; k++) {
|
||||
const header = formHeaders[k]
|
||||
// 从 header.startIdx 之后找 [ 块
|
||||
const bracketStart = body.indexOf('[', header.startIdx)
|
||||
if (bracketStart < 0) continue
|
||||
let depth = 1
|
||||
let j = bracketStart + 1
|
||||
while (j < body.length && depth > 0) {
|
||||
if (body[j] === '[') depth++
|
||||
else if (body[j] === ']') depth--
|
||||
j++
|
||||
}
|
||||
const bracketEnd = j - 1
|
||||
// 收集此范围内的 field
|
||||
const fields: FieldDef[] = []
|
||||
for (const f of allFields) {
|
||||
if (f.idx > bracketStart && f.idx < bracketEnd) {
|
||||
fields.push({ type: f.type, vmodel: f.vmodel, label: f.label, required: f.required })
|
||||
}
|
||||
}
|
||||
if (fields.length > 0) forms.push({ enCode: header.enCode, fullName: header.fullName, fields })
|
||||
}
|
||||
return forms
|
||||
}
|
||||
|
||||
export interface CmdBlock {
|
||||
raw: string
|
||||
hasDbLinkId: boolean
|
||||
hasWebType: boolean
|
||||
hasAutoRelease: boolean
|
||||
hasFormId: boolean
|
||||
commandKind: 'dm' | 'form' | 'menu' | 'other'
|
||||
}
|
||||
|
||||
export function parseDesignHtml(src: string): CmdBlock[] {
|
||||
const blocks: CmdBlock[] = []
|
||||
const re = /<div class="cmd">([\s\S]*?)<\/div>/g
|
||||
let m
|
||||
while ((m = re.exec(src)) !== null) {
|
||||
const raw = m[1]
|
||||
blocks.push({
|
||||
raw,
|
||||
hasDbLinkId: raw.includes('--dbLinkId'),
|
||||
hasWebType: raw.includes('--webType'),
|
||||
hasAutoRelease: raw.includes('--autoRelease'),
|
||||
hasFormId: raw.includes('--formId'),
|
||||
commandKind: raw.includes('dm create') ? 'dm' :
|
||||
raw.includes('form create') ? 'form' :
|
||||
raw.includes('menu create') ? 'menu' : 'other',
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/**
|
||||
* commands/form/_simplify.ts — 简化字段格式自动包 __config__ (D-3 盲点 42 + D-13 修复)
|
||||
*
|
||||
* v0.11+: --ai / --ai-json 路径走 _buildformdata.ts (webapi 镜像), 仍为 manual --fields 路径的核心.
|
||||
* 调用方: form/create.ts (--fields 用户友好简化格式).
|
||||
* [
|
||||
* {"vmodel":"f_name","label":"名称","jnpfKey":"input","required":true,
|
||||
* "dataType":"varchar","dataLength":"100"},
|
||||
* {"vmodel":"f_status","label":"状态","jnpfKey":"select","required":true,
|
||||
* "options":[{"fullName":"草稿","id":"draft"}]}
|
||||
* ]
|
||||
*
|
||||
* 自动转 JNPF web 标准的完整 schema:
|
||||
* [
|
||||
* {
|
||||
* "__config__": {formId, visibility, jnpfKey, label, required, tableName, layout, tag, ...},
|
||||
* "__vModel__": "f_name",
|
||||
* ...
|
||||
* }
|
||||
* ]
|
||||
*
|
||||
* 检测: 字段不含 `__config__` 或 `__config__` 缺关键字段 (D-13) 视为需补全, 否则原样透传.
|
||||
* D-13 (2026-06-23 jxcj E2E 复盘): 早期版本只判 `!__config__`, 但用户传 `{__config__:{label, required, jnpfKey}}`
|
||||
* 这种 3 键的简化版 __config__ 会被误判为"完整 schema"直接透传, 导致浏览器层 form 列表显示空
|
||||
* "新增" modal 不渲染字段. 修: 必须含 18 个关键键才算完整.
|
||||
*/
|
||||
|
||||
export interface SimpleField {
|
||||
vmodel: string
|
||||
label: string
|
||||
jnpfKey: string
|
||||
required?: boolean
|
||||
dataType?: string
|
||||
dataLength?: string
|
||||
options?: unknown[]
|
||||
relationTable?: string
|
||||
columnOptions?: unknown[]
|
||||
/** relationForm 用: 取数字段, 缺省 vmodel */
|
||||
relationField?: string
|
||||
/** select 用: 字典类型 id (替代 options) */
|
||||
dictionaryType?: string
|
||||
/** 透传其他字段, 如 span/regList 等 */
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface FullField {
|
||||
__config__: Record<string, unknown>
|
||||
__vModel__: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段归一化: 把设计 HTML 格式 (field/fieldName/config:{required}) 映射成标准格式 (vmodel/label/required).
|
||||
*/
|
||||
function normalizeField(raw: unknown): SimpleField {
|
||||
const f = raw as Record<string, unknown>
|
||||
// 已标准格式: 直接返回
|
||||
if (f.vmodel && f.label) return f as SimpleField
|
||||
// 设计 HTML 格式: 转换
|
||||
if (f.field) {
|
||||
const cfg = (f.config && typeof f.config === 'object' ? f.config : {}) as Record<string, unknown>
|
||||
return {
|
||||
vmodel: String(f.field),
|
||||
label: String(f.fieldName || f.field),
|
||||
jnpfKey: String(f.jnpfKey || 'input'),
|
||||
required: cfg.required === true,
|
||||
...(f.dataType ? { dataType: String(f.dataType) } : {}),
|
||||
...(f.dataLength ? { dataLength: String(f.dataLength) } : {}),
|
||||
...(f.options ? { options: f.options } : {}),
|
||||
...(f.relationTable ? { relationTable: String(f.relationTable) } : {}),
|
||||
...(f.columnOptions ? { columnOptions: f.columnOptions } : {}),
|
||||
...(f.relationField ? { relationField: String(f.relationField) } : {}),
|
||||
...(f.dictionaryType ? { dictionaryType: String(f.dictionaryType) } : {}),
|
||||
} as SimpleField
|
||||
}
|
||||
// 未知格式: 原样抛错让原 throw 命中
|
||||
return f as SimpleField
|
||||
}
|
||||
|
||||
// D-13: 必须含这些键才视为完整 __config__ (web 实际渲染需要)
|
||||
const REQUIRED_CONFIG_KEYS = [
|
||||
'formId', 'visibility', 'jnpfKey', 'noShow', 'tipLabel', 'dragDisabled', 'className',
|
||||
'label', 'showLabel', 'required', 'tableName', 'renderKey', 'layout', 'tagIcon',
|
||||
'tag', 'regList', 'span', 'trigger',
|
||||
]
|
||||
|
||||
function isConfigComplete(cfg: Record<string, unknown> | undefined): boolean {
|
||||
if (!cfg) return false
|
||||
return REQUIRED_CONFIG_KEYS.every(k => k in cfg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the full __config__ schema with 18+ keys.
|
||||
* userOverrides: 用户提供的字段 (会覆盖默认值)
|
||||
*/
|
||||
function buildFullConfig(
|
||||
jnpfKey: string,
|
||||
label: string,
|
||||
required: boolean,
|
||||
tableName: string,
|
||||
idx: number,
|
||||
userOverrides: Record<string, unknown> = {},
|
||||
): Record<string, unknown> {
|
||||
return {
|
||||
formId: 101 + idx,
|
||||
visibility: ['pc', 'app'],
|
||||
jnpfKey,
|
||||
noShow: false,
|
||||
tipLabel: '',
|
||||
dragDisabled: false,
|
||||
className: [],
|
||||
label,
|
||||
showLabel: true,
|
||||
required,
|
||||
tableName,
|
||||
renderKey: 1780900000000 + idx,
|
||||
layout: 'colFormItem',
|
||||
tagIcon: `icon-ym icon-ym-generator-${jnpfKey.toLowerCase()}`,
|
||||
tag: jnpfKey === 'input' || jnpfKey === 'textarea' ? 'JnpfInput' : 'Jnpf' + jnpfKey[0].toUpperCase() + jnpfKey.slice(1),
|
||||
regList: [],
|
||||
span: 24,
|
||||
trigger: ['input', 'textarea', 'editor'].includes(jnpfKey) ? 'blur' : 'change',
|
||||
...userOverrides,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把用户给的 fields 数组转成 JNPF web 标准的 __config__ schema.
|
||||
* D-13: 若 __config__ 缺关键字段, 自动 merge 补全 (不原样透传).
|
||||
*/
|
||||
export function wrapSimplifiedFields(
|
||||
fields: unknown[],
|
||||
tableName: string,
|
||||
): { wrapped: FullField[]; converted: number; total: number } {
|
||||
if (!Array.isArray(fields) || fields.length === 0) {
|
||||
return { wrapped: [], converted: 0, total: 0 }
|
||||
}
|
||||
|
||||
// D-13 修复: 检测已有 __config__ 但缺关键字段 (3 键简化版)
|
||||
// 第一项无 __config__ OR __config__ 缺关键字段 → 视作需补全
|
||||
const firstItem = fields[0] as Record<string, unknown> | undefined
|
||||
const firstCfg = firstItem?.__config__ as Record<string, unknown> | undefined
|
||||
const needsMerge = !firstCfg || !isConfigComplete(firstCfg)
|
||||
|
||||
if (!needsMerge) {
|
||||
// 完整 schema, 直接透传
|
||||
return { wrapped: fields as FullField[], converted: 0, total: fields.length }
|
||||
}
|
||||
|
||||
// 归一化
|
||||
const normalized = fields.map(normalizeField)
|
||||
|
||||
// Wrap each field with full __config__ (保留 user 提供的额外字段)
|
||||
const wrapped: FullField[] = fields.map((rawF, i) => {
|
||||
const rawField = rawF as Record<string, unknown>
|
||||
const norm = normalized[i]
|
||||
const userCfg = (rawField.__config__ || {}) as Record<string, unknown>
|
||||
|
||||
const jnpfKey = String(userCfg.jnpfKey || norm.jnpfKey || 'input')
|
||||
const label = String(userCfg.label || norm.label || '')
|
||||
const required = userCfg.required === true || norm.required === true
|
||||
|
||||
const fullConfig = buildFullConfig(jnpfKey, label, required, tableName, i, userCfg)
|
||||
|
||||
let vmodel = String(rawField.__vModel__ || rawField.field || norm.vmodel || '')
|
||||
// v0.x fix (盲点 60): 当 vmodel 全部 fallback 为空时, 从 rawField 顶层找第一个 f_ 开头 key
|
||||
// (dacli form create 简化 schema 的惯例: f_xxx 是 db 列名, 后端 INSERT SQL 也用 f_xxx)
|
||||
if (!vmodel) {
|
||||
for (const k of Object.keys(rawField)) {
|
||||
if (k.startsWith('f_') && k !== '__config__') { vmodel = k; break }
|
||||
}
|
||||
}
|
||||
const placeholder = jnpfKey === 'input' || jnpfKey === 'textarea' || jnpfKey === 'inputNumber'
|
||||
? `请输入${label}`
|
||||
: `请选择${label}`
|
||||
|
||||
return {
|
||||
...rawField, // 透传所有原字段 (options/relationTable 等)
|
||||
__config__: fullConfig,
|
||||
__vModel__: vmodel,
|
||||
field: vmodel,
|
||||
clearable: rawField.clearable !== undefined ? rawField.clearable : true,
|
||||
style: rawField.style || { width: '100%' },
|
||||
placeholder,
|
||||
id: rawField.id || vmodel,
|
||||
fullName: rawField.fullName || label,
|
||||
fullNameI18nCode: rawField.fullNameI18nCode || [''],
|
||||
} as FullField
|
||||
})
|
||||
|
||||
return { wrapped, converted: wrapped.length, total: fields.length }
|
||||
}
|
||||
|
||||
/** 2026-06-25 tdd9 BS-55: 表名去 appCode 前缀 (与 dm create 逻辑一致, 避免 form 与 dm 物理表不匹配) */
|
||||
export function stripAppCodePrefix(table: string, appCode: string): string {
|
||||
if (!appCode) return table
|
||||
return table.startsWith(`${appCode}_`) ? table.slice(appCode.length + 1) : table
|
||||
}
|
||||
|
||||
/** 从 fields 推导 tables 默认值 (D-2 自动推断) */
|
||||
export function buildTablesFromFields(
|
||||
enCode: string,
|
||||
name: string,
|
||||
fields: SimpleField[],
|
||||
appCode?: string, // 2026-06-25 tdd9 BS-55: 可选, 传则去 appCode 前缀
|
||||
): unknown[] {
|
||||
// 排除系统列 (9 列) — 业务字段
|
||||
const SYSTEM = new Set(['f_id', 'f_tenant_id', 'f_flow_task_id', 'f_flow_id', 'f_flow_state', 'f_sort_code', 'f_create_user', 'f_create_time', 'f_modify_user', 'f_modify_time', 'f_description'])
|
||||
const businessFields = fields
|
||||
.filter((f) => !SYSTEM.has(f.vmodel))
|
||||
.map((f) => ({
|
||||
dataType: f.dataType || 'varchar',
|
||||
field: f.vmodel,
|
||||
fieldName: f.label,
|
||||
primaryKey: 0,
|
||||
dataLength: f.dataLength || (f.dataType === 'text' ? '0' : '200'),
|
||||
allowNull: f.required ? 0 : 1,
|
||||
}))
|
||||
const logicalTable = appCode ? stripAppCodePrefix(enCode, appCode) : enCode
|
||||
return [
|
||||
{
|
||||
table: logicalTable, // BS-55: 与 dm 物理表名一致
|
||||
tableName: name,
|
||||
typeId: '1',
|
||||
comment: '主表',
|
||||
fields: [
|
||||
{ dataType: 'varchar', field: 'f_id', fieldName: '主键', primaryKey: 1 },
|
||||
{ dataType: 'varchar', field: 'f_tenant_id', fieldName: '租户id', primaryKey: 1 },
|
||||
...businessFields,
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* FullField → SimpleField 反向映射 (供 buildTablesFromFields 等期望 SimpleField 的函数复用).
|
||||
*/
|
||||
export function toSimpleField(field: FullField): SimpleField {
|
||||
const cfg = (field.__config__ || {}) as Record<string, unknown>
|
||||
const result: Record<string, unknown> = {
|
||||
vmodel: String(field.__vModel__ || ''),
|
||||
label: String(cfg.label || ''),
|
||||
jnpfKey: String(cfg.jnpfKey || 'input'),
|
||||
required: cfg.required === true,
|
||||
}
|
||||
if (field.dataType) result.dataType = String(field.dataType)
|
||||
if (field.dataLength) result.dataLength = String(field.dataLength)
|
||||
if (field.options) result.options = field.options
|
||||
if (field.relationTable) result.relationTable = String(field.relationTable)
|
||||
if (field.columnOptions) result.columnOptions = field.columnOptions
|
||||
if (field.relationField) result.relationField = String(field.relationField)
|
||||
if (field.dictionaryType) result.dictionaryType = String(field.dictionaryType)
|
||||
return result as SimpleField
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/**
|
||||
* commands/form/fixcolumndata.ts — 修复 form columnData 缺 4 个 use*Permission 字段
|
||||
*
|
||||
* v0.11+: webapi 镜像化 (loadVisualDev), 修复 BS-23 (NPE from missing use*Permission).
|
||||
* 仍为 dacli 命令, 用于老 form 修复.
|
||||
* 缺 `useBtnPermission/useColumnPermission/useFormPermission/useDataPermission` 字段,
|
||||
* Jackson 反序列化为 null → Actions/Module 报 "System abnormality" (NPE 在
|
||||
* VisualUtil.setPcPermission line 139, .booleanValue() 解开 null)
|
||||
*
|
||||
* 修法: 拿原 form 的 columnData + appColumnData, 把 4 个 use*Permission 字段补 false
|
||||
* 显式赋值, 然后 PUT /api/visualdev/Base/{id} 回去.
|
||||
*
|
||||
* 跑法 (规范化后, 2026-06-13):
|
||||
* dacli form fixcolumndata 835168490678657989
|
||||
* 兼容旧名 (alias):
|
||||
* dacli form fixcolumndata 835168490678657989
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import type { FormDetail } from '../../core/types.ts'
|
||||
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
|
||||
import { browserVerify } from './_browser_verify.ts'
|
||||
|
||||
const PERMISSION_FIELDS = [
|
||||
'useBtnPermission',
|
||||
'useColumnPermission',
|
||||
'useFormPermission',
|
||||
'useDataPermission',
|
||||
] as const
|
||||
|
||||
function safeParse<T = unknown>(s: unknown): T | null {
|
||||
if (typeof s !== 'string') return s as T
|
||||
try {
|
||||
return JSON.parse(s) as T
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function hasAllPermissions(obj: Record<string, unknown> | null): boolean {
|
||||
if (!obj) return false
|
||||
return PERMISSION_FIELDS.every((k) => typeof obj[k] === 'boolean')
|
||||
}
|
||||
|
||||
function patchColumnData(json: string | null | undefined): { patched: string; changed: boolean } {
|
||||
// v0.8.3 修复 (盲点 28): 老 form columnData 可能是 "[]" (空数组) / null / 缺字段对象,
|
||||
// 原实现 `obj[k] = false` 加到 array 上, JSON.stringify 时 array 不序列化额外属性 → "[]" 没变
|
||||
// 修法: 只把 plain object 当可 patch 目标, 其他情况 (array / null / 缺) 一律视为空对象重写
|
||||
const parsed = safeParse<unknown>(json)
|
||||
const isObject = parsed != null && typeof parsed === 'object' && !Array.isArray(parsed)
|
||||
const obj: Record<string, unknown> = isObject ? { ...(parsed as Record<string, unknown>) } : {}
|
||||
let changed = false
|
||||
for (const k of PERMISSION_FIELDS) {
|
||||
if (typeof obj[k] !== 'boolean') {
|
||||
obj[k] = false
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
// 只有"原对象已含全部 4 字段"才算 noop; 否则都是 changed
|
||||
const wasAlreadyValid = isObject && PERMISSION_FIELDS.every((k) => typeof (parsed as Record<string, unknown>)[k] === 'boolean')
|
||||
return { patched: JSON.stringify(obj), changed: !wasAlreadyValid }
|
||||
}
|
||||
|
||||
export function buildFormFixColumnDataCommand(): Command {
|
||||
const cmd = new Command('fixcolumndata')
|
||||
.alias('fixcolumn')
|
||||
.description('修复 form columnData 缺 use*Permission 字段 (盲点 23 NPE 修)')
|
||||
.argument('<id>', 'form id')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.option('--dry-run', '只看缺啥, 不真改', false)
|
||||
.option('--no-verify', '跳过浏览器层验证 (默认硬阻塞)')
|
||||
.option('--verify <mode>', '失败模式: block (默认) | warn', 'block')
|
||||
.option('--verify-timeout <ms>', '浏览器验证超时 (默认 60s)', '60000')
|
||||
.option('--no-republish', 'PUT 后不自动重新发布 (BS-53 默认开, 仅调试用)', false)
|
||||
.action(async (id: string, opts: { json?: boolean; dryRun?: boolean; noVerify?: boolean; verifyMode?: string; verifyTimeout?: string; republish?: boolean }) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// v0.11+ Phase 2: 用 webapi getInfo 替代 c.get
|
||||
await initWebapi(c)
|
||||
const form = (await loadVisualDev.getInfo(id)) as FormDetail
|
||||
|
||||
const col = patchColumnData(typeof form.columnData === 'string' ? form.columnData : null)
|
||||
const app = patchColumnData(typeof form.appColumnData === 'string' ? form.appColumnData : null)
|
||||
|
||||
// 也存一份未污染的, 方便调试
|
||||
const colObj = safeParse<Record<string, unknown>>(form.columnData)
|
||||
const appObj = safeParse<Record<string, unknown>>(form.appColumnData)
|
||||
const colMissing = colObj ? PERMISSION_FIELDS.filter((k) => typeof colObj[k] !== 'boolean') : PERMISSION_FIELDS
|
||||
const appMissing = appObj ? PERMISSION_FIELDS.filter((k) => typeof appObj[k] !== 'boolean') : PERMISSION_FIELDS
|
||||
|
||||
const summary = {
|
||||
id,
|
||||
enCode: form.enCode,
|
||||
columnData: { had: hasAllPermissions(colObj as Record<string, unknown>), missing: colMissing, changed: col.changed },
|
||||
appColumnData: { had: hasAllPermissions(appObj as Record<string, unknown>), missing: appMissing, changed: app.changed },
|
||||
}
|
||||
|
||||
if (!col.changed && !app.changed) {
|
||||
log.ok(`✓ 4 个 use*Permission 字段已存在, 不需修`)
|
||||
if (opts.json) printJson({ ...summary, action: 'noop' })
|
||||
return
|
||||
}
|
||||
|
||||
if (opts.dryRun) {
|
||||
log.warn(`[dry-run] 会补 ${colMissing.length + appMissing.length} 个字段 (columnData=${colMissing.length}, appColumnData=${appMissing.length})`)
|
||||
if (opts.json) printJson({ ...summary, action: 'dry-run' })
|
||||
return
|
||||
}
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
id,
|
||||
fullName: form.fullName,
|
||||
enCode: form.enCode,
|
||||
type: form.type,
|
||||
webType: form.webType,
|
||||
category: form.category,
|
||||
description: form.description,
|
||||
dbLinkId: form.dbLinkId,
|
||||
enableFlow: form.enableFlow,
|
||||
flowId: form.flowId,
|
||||
formData: form.formData,
|
||||
columnData: col.patched,
|
||||
appColumnData: app.patched,
|
||||
tables: form.tables,
|
||||
state: form.state,
|
||||
sortCode: form.sortCode,
|
||||
}
|
||||
log.info(`loadVisualDev.update (补 ${colMissing.length + appMissing.length} 个 use*Permission 字段)`)
|
||||
const rr = (await loadVisualDev.update({ id, ...body })) as { code?: number; msg?: string }
|
||||
if (rr.code !== 200 && rr.code !== undefined) {
|
||||
log.error(`修复失败 code=${rr.code}: ${rr.msg}`)
|
||||
if (opts.json) printJson({ ...summary, action: 'failed', error: rr })
|
||||
process.exit(1)
|
||||
}
|
||||
log.ok(`✓ 修复成功: columnData 补 ${colMissing.length} 字段, appColumnData 补 ${appMissing.length} 字段`)
|
||||
if (opts.json) printJson({ ...summary, action: 'patched' })
|
||||
|
||||
// BS-53 (2026-06-23): PUT 触发 JNPF 后端 VisualdevController#update line 488-491
|
||||
// 自动把 state=1 → state=2 (已发布被编辑过). 前端 web (state==1 才显示"已发布")
|
||||
// 看不到, 用户实测"表单空白/无按钮". 修复: PUT 成功后自动调 Actions/Release
|
||||
// 重新发布回 state=1. 失败时仅 WARN 不阻断 (--no-republish 可关闭).
|
||||
// 注: Commander 把 --no-republish 自动转 opts.republish === false
|
||||
if (opts.republish !== false) {
|
||||
const prevState = form.state
|
||||
log.info(`原 state=${prevState}, PUT 后自动调用 Actions/Release 重新发布 (BS-53 防护)`)
|
||||
const rr2 = (await loadVisualDev.release(id)) as { code?: number; msg?: string }
|
||||
if (rr2.code === 200 || rr2.code === undefined) {
|
||||
log.ok(`✓ 已自动重新发布 (state 1/2 → 1), 表单前端可见`)
|
||||
if (opts.json) printJson({ ...summary, action: 'patched-and-republished' })
|
||||
} else {
|
||||
log.warn(`⚠ 自动重新发布失败 code=${rr2.code}: ${rr2.msg} — 手动跑 'dacli form release ${id}' 兜底`)
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 3: 浏览器层验证 (默认硬阻塞, --verify=warn / --no-verify 可绕过)
|
||||
try {
|
||||
await browserVerify({
|
||||
formId: id,
|
||||
enCode: form.enCode || id,
|
||||
appCode: c.appCode,
|
||||
noVerify: opts.noVerify,
|
||||
verifyMode: (opts.verifyMode as 'block' | 'warn') || 'block',
|
||||
verifyTimeout: opts.verifyTimeout ? Number(opts.verifyTimeout) : undefined,
|
||||
})
|
||||
} catch (e) {
|
||||
if (opts.verifyMode !== 'warn') throw e
|
||||
// warn 模式不抛, 继续
|
||||
}
|
||||
})
|
||||
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '修复 form columnData 缺的 4 个 use*Permission 字段 (盲点 23, 触发 NPE 在 Actions/Module)',
|
||||
required: { '<id>': 'form id' },
|
||||
optional: {
|
||||
'--dry-run': '只看不改',
|
||||
'--no-verify': '跳过浏览器层验证 (默认硬阻塞)',
|
||||
'--verify': 'block (默认) | warn (失败不阻塞 release)',
|
||||
'--verify-timeout': '浏览器验证超时 (默认 60s)',
|
||||
'--no-republish': 'PUT 后不自动重新发布 (BS-53 默认开, 仅调试用)',
|
||||
},
|
||||
example: ['dacli form fixcolumndata 835168490678657989'],
|
||||
source: {
|
||||
api: 'PUT /api/visualdev/Base/{id}',
|
||||
ref: '后端 VisualUtil.setPcPermission line 139 (NPE on useBtnPermission.booleanValue())',
|
||||
},
|
||||
notes: [
|
||||
'盲点 23: v0.7.1 之前 form create 的 columnData 缺 use*Permission, 后端反序列化为 null',
|
||||
'Actions/Module 会 NPE → "System abnormality" (看不出来的内部错)',
|
||||
'修后调用 Actions/Module 报 "找不到该上级" 或正常成功 (取决于父菜单)',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/**
|
||||
* commands/form/lint.ts — 设计期 lint (无需 JNPF server)
|
||||
*
|
||||
* 用法:
|
||||
* dacli form lint --from-script=docs/{app}/scripts/03_forms.py
|
||||
* dacli form lint --from-design=docs/{app}/design-jnpf.html
|
||||
* dacli form lint --from-script=... --from-design=...
|
||||
*
|
||||
* 复用 _blindspots.ts 6 类检查 (BS-23/31/32/15/V2/52)
|
||||
* - 设计期可跑: BS-31 (label) / BS-32 (decimal 类型) — 来自 Python form 字段
|
||||
* - 设计期 N/A: BS-23/15/V2/52 — 需运行时 form 详情 (columnData/tables JSON),
|
||||
* 由 `dacli form validate <id>` 运行时兜底
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { checkBs31, checkBs32, type BlindspotIssue } from './_blindspots.ts'
|
||||
import { parsePythonForms, parseDesignHtml, type FormDef, type CmdBlock } from './_parsers.ts'
|
||||
import { printJson, log } from '../../core/log.ts'
|
||||
|
||||
interface LintReport {
|
||||
forms: number
|
||||
fields: number
|
||||
blindspots: Record<string, { pass: boolean; fail: number; n_a: number }>
|
||||
issues: BlindspotIssue[]
|
||||
cmdBlocks: { total: number; issues: string[] }
|
||||
exitCode: 0 | 1
|
||||
}
|
||||
|
||||
function lintScript(scriptPath: string): { forms: FormDef[]; issues: BlindspotIssue[] } {
|
||||
let src: string
|
||||
try {
|
||||
src = readFileSync(scriptPath, 'utf-8')
|
||||
} catch {
|
||||
log.warn(`文件不可读: ${scriptPath}, 跳过`)
|
||||
return { forms: [], issues: [] }
|
||||
}
|
||||
const forms = parsePythonForms(src)
|
||||
const issues: BlindspotIssue[] = []
|
||||
for (const f of forms) {
|
||||
// 把 fields 转成 validate.ts 期望的 formData 形态
|
||||
const formData = { fields: f.fields.map(fd => ({
|
||||
__config__: { label: fd.label, jnpfKey: fd.type },
|
||||
__vModel__: fd.vmodel,
|
||||
}))}
|
||||
issues.push(...checkBs31(JSON.stringify(formData)))
|
||||
issues.push(...checkBs32(JSON.stringify(formData)))
|
||||
}
|
||||
// BS-23/15/V2 设计期跳过: 需 JNPF server 拉 form 详情 (columnData/tables/formData JSON),
|
||||
// 设计稿/Python 脚本无运行时 form data, 由 form validate 运行时兜底
|
||||
return { forms, issues }
|
||||
}
|
||||
|
||||
function lintDesign(designPath: string): { blocks: CmdBlock[]; issues: BlindspotIssue[]; blockIssues: string[] } {
|
||||
let src: string
|
||||
try {
|
||||
src = readFileSync(designPath, 'utf-8')
|
||||
} catch {
|
||||
log.warn(`文件不可读: ${designPath}, 跳过`)
|
||||
return { blocks: [], issues: [], blockIssues: [] }
|
||||
}
|
||||
const blocks = parseDesignHtml(src)
|
||||
const blockIssues: string[] = []
|
||||
for (const b of blocks) {
|
||||
if (b.commandKind === 'dm' && !b.hasDbLinkId) blockIssues.push('dm create 缺 --dbLinkId')
|
||||
if (b.commandKind === 'form' && !b.hasWebType) blockIssues.push('form create 缺 --webType')
|
||||
if (b.commandKind === 'form' && !b.hasAutoRelease) blockIssues.push('form create 缺 --autoRelease (盲点 28 防御)')
|
||||
}
|
||||
// BS-23 需运行时 columnData, 设计稿无法直接判断, 标 N/A 由 form validate 兜底
|
||||
return { blocks, issues: [], blockIssues }
|
||||
}
|
||||
|
||||
export function buildFormLintCommand(): Command {
|
||||
const cmd = new Command('lint')
|
||||
.description('设计期 lint: 复用 5 类盲点规则, 不需 JNPF server')
|
||||
.option('--from-script <path>', '03_forms.py 路径')
|
||||
.option('--from-design <path>', 'design-jnpf.html 路径')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action((opts: { fromScript?: string; fromDesign?: string; json?: boolean }) => {
|
||||
if (!opts.fromScript && !opts.fromDesign) {
|
||||
log.error('必须传 --from-script 或 --from-design')
|
||||
process.exit(1)
|
||||
}
|
||||
const forms: FormDef[] = []
|
||||
const allIssues: BlindspotIssue[] = []
|
||||
let blocks: CmdBlock[] = []
|
||||
let blockIssues: string[] = []
|
||||
if (opts.fromScript) {
|
||||
const r = lintScript(resolve(opts.fromScript))
|
||||
forms.push(...r.forms)
|
||||
allIssues.push(...r.issues)
|
||||
}
|
||||
if (opts.fromDesign) {
|
||||
const r = lintDesign(resolve(opts.fromDesign))
|
||||
blocks = r.blocks
|
||||
blockIssues = r.blockIssues
|
||||
allIssues.push(...r.issues)
|
||||
}
|
||||
// 汇总 — 4 条盲点需运行时 columnData/tables/formData, 设计稿/Python 脚本无完整 JSON,
|
||||
// 标 N/A 由 `dacli form validate <id>` 运行时兜底:
|
||||
// BS-23 (use*Permission 必填)
|
||||
// BS-15 (enableFlow=1 + f_flow_task_id)
|
||||
// BS-V2 (columnData __config__ / dbLinkId)
|
||||
// BS-52 (btnsList/columnBtnsList 按钮存在性, v0.11+)
|
||||
const bs: Record<string, { pass: boolean; fail: number; n_a: number }> = {
|
||||
'BS-23': { pass: true, fail: 0, n_a: 1 },
|
||||
'BS-31': { pass: !allIssues.some(i => i.id === 'BS-31'), fail: 0, n_a: 0 },
|
||||
'BS-32': { pass: !allIssues.some(i => i.id === 'BS-32'), fail: 0, n_a: 0 },
|
||||
'BS-15': { pass: true, fail: 0, n_a: 1 },
|
||||
'BS-V2': { pass: true, fail: 0, n_a: 1 },
|
||||
'BS-52': { pass: true, fail: 0, n_a: 1 },
|
||||
}
|
||||
for (const i of allIssues) bs[i.id].fail++
|
||||
const report: LintReport = {
|
||||
forms: forms.length,
|
||||
fields: forms.reduce((s, f) => s + f.fields.length, 0),
|
||||
blindspots: bs,
|
||||
issues: allIssues,
|
||||
cmdBlocks: { total: blocks.length, issues: blockIssues },
|
||||
exitCode: allIssues.length === 0 && blockIssues.length === 0 ? 0 : 1,
|
||||
}
|
||||
if (opts.json) {
|
||||
printJson(report)
|
||||
} else {
|
||||
log.info(`解析 ${report.forms} form, ${report.fields} 字段, ${report.cmdBlocks.total} 命令块`)
|
||||
for (const [id, s] of Object.entries(bs)) {
|
||||
const sym = s.fail === 0 ? '✓' : '✗'
|
||||
log.info(` ${sym} ${id.padEnd(6)} ${s.fail === 0 ? 'PASS' : `FAIL (${s.fail})`}${s.n_a ? ' N/A' : ''}`)
|
||||
}
|
||||
if (blockIssues.length > 0) {
|
||||
log.info(` ✗ DACLI-CMD 命令完整性 FAIL (${blockIssues.length} issues)`)
|
||||
for (const x of blockIssues) log.info(` - ${x}`)
|
||||
} else if (report.cmdBlocks.total > 0) {
|
||||
log.info(` ✓ DACLI-CMD 命令完整性 PASS`)
|
||||
}
|
||||
if (allIssues.length > 0) {
|
||||
log.info('')
|
||||
log.info(`前 3 issues:`)
|
||||
for (const i of allIssues.slice(0, 3)) log.info(` - [${i.id}] ${i.path}: ${i.message}`)
|
||||
}
|
||||
}
|
||||
process.exit(report.exitCode)
|
||||
})
|
||||
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '设计期 lint: 复用 6 类盲点规则 (BS-23/31/32/15/V2/52), 不需 JNPF server. 阶段 2 末必跑, exit 0 才能进阶段 4.',
|
||||
optional: {
|
||||
'--from-script <path>': '03_forms.py 路径 (含 FORMS 列表)',
|
||||
'--from-design <path>': 'design-jnpf.html 路径 (含 <div class="cmd"> dacli 命令块)',
|
||||
'--json': '原始 JSON 输出',
|
||||
},
|
||||
example: [
|
||||
'dacli form lint --from-script=docs/tdss/scripts/03_forms.py',
|
||||
'dacli form lint --from-script=... --from-design=...',
|
||||
],
|
||||
notes: [
|
||||
'BS-23 N/A 设计期: 需运行时 columnData (use*Permission), 由 form validate 兜底',
|
||||
'BS-31/32 per-field 检查: 扫每个 form 字段 label / decimal 类型',
|
||||
'BS-15 N/A 设计期: 需运行时 tables (enableFlow=1 + f_flow_task_id)',
|
||||
'BS-V2 N/A 设计期: 需运行时 form detail (formData/columnData/dbLinkId)',
|
||||
'BS-52 N/A 设计期: 需运行时 columnData (btnsList/columnBtnsList), 由 form validate 兜底',
|
||||
],
|
||||
})
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* commands/form/validate.ts — 校验表单结构 (columnData __config__ 完整性)
|
||||
*
|
||||
* v0.11+: webapi 镜像化 (loadVisualDev), 调用 form/_blindspots.ts 6 类检查.
|
||||
* 仍为 dacli 命令, 用于发布前快速排查.
|
||||
* 共享 _blindspots.ts 的 6 类检查 (BS-23/31/32/15/V2/52)
|
||||
* - formData.fields 每项有 __config__ (新 form: {fields:[]}; 老 form 流程表单: 直接是 array)
|
||||
* - columnData.fields 每项有 __config__ (新版 JNPF 缺会白屏)
|
||||
* - tables 有 dbLinkId
|
||||
* - columnData.btnsList 含"新增"按钮 + columnBtnsList 含"编辑"按钮 (BS-52, v0.11+)
|
||||
*
|
||||
* 修复 (v0.8.1): formData=null / formData="[]" / 老 formData 直接是 array 不再误报 WARN.
|
||||
* - 已知盲点 (v0.7.1): 老流程表单 formData 是 flat array, validate 报 "fields 不是数组"
|
||||
* - 修复: 兼容 {fields:[...]} 和 直接 array 两种形态, 都视为合法
|
||||
*
|
||||
* v0.9 重构: 5 类检查抽到 _blindspots.ts, validate 与 lint 共享 (零 drift).
|
||||
* v0.11 (2026-06-22): 新增 BS-52 (按钮存在性) 运行时校验, 修复 tds2 复盘 28/28 TC 假 PASS.
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import type { FormDetail } from '../../core/types.ts'
|
||||
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
|
||||
import { checkBsV2, checkBs23, checkBs31, checkBs32, checkBs15, checkBs52, type BlindspotIssue } from './_blindspots.ts'
|
||||
|
||||
export type ValidationIssue = BlindspotIssue
|
||||
|
||||
function validate(form: FormDetail): ValidationIssue[] {
|
||||
return [
|
||||
...checkBsV2(form),
|
||||
...checkBs23(form.columnData),
|
||||
...checkBs31(form.formData),
|
||||
...checkBs32(form.formData),
|
||||
...checkBs15(form.tables, form.enableFlow as number | undefined),
|
||||
...checkBs52(form.columnData, form.webType as number | undefined),
|
||||
]
|
||||
}
|
||||
|
||||
export function buildFormValidateCommand(): Command {
|
||||
const cmd = new Command('validate')
|
||||
.description('校验表单结构 (columnData __config__ 完整性等)')
|
||||
.argument('<id>', '表单 id')
|
||||
.option('--json', '原始 JSON', false)
|
||||
.action(async (id: string, opts: { json?: boolean }) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// v0.11+ Phase 2: 用 webapi 调 web 端 getInfo (替代 c.get('/visualdev/Base/{id}'))
|
||||
await initWebapi(c)
|
||||
const form = (await loadVisualDev.getInfo(id)) as FormDetail
|
||||
const issues = validate(form)
|
||||
if (opts.json) {
|
||||
printJson({ id, enCode: form.enCode, issues, pass: issues.filter((i) => i.level === 'ERROR').length === 0 })
|
||||
return
|
||||
}
|
||||
if (issues.length === 0) {
|
||||
log.ok(`PASS ${form.enCode} (${id})`)
|
||||
return
|
||||
}
|
||||
log.warn(`${form.enCode} 发现 ${issues.length} 个问题`)
|
||||
for (const i of issues) {
|
||||
const fn = i.level === 'ERROR' ? log.error : log.warn
|
||||
fn(`[${i.level}] ${i.path}: ${i.message}`)
|
||||
}
|
||||
const failed = issues.filter((i) => i.level === 'ERROR').length > 0
|
||||
if (failed) process.exit(2)
|
||||
})
|
||||
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '校验表单结构. columnData 缺 __config__ 会浏览器白屏',
|
||||
required: { '<id>': '表单 id' },
|
||||
example: 'dacli form validate 12345',
|
||||
notes: ['ERROR → 退出码 2', 'Java 版有 --fix 自动修复, TS 版 W2+ 实现', 'v0.9 起 5 类盲点 (BS-23/31/32/15/V2) 抽到 _blindspots.ts 与 form lint 共享'],
|
||||
})
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { wrapSimplifiedFields } from '../../src/commands/form/_simplify.ts'
|
||||
|
||||
describe('wrapSimplifiedFields — 字段格式归一化', () => {
|
||||
it('支持 vmodel/label/required 格式', () => {
|
||||
const r = wrapSimplifiedFields([
|
||||
{ vmodel: 'f_name', label: '名称', jnpfKey: 'input', required: true },
|
||||
], 'test_table')
|
||||
expect(r.total).toBe(1)
|
||||
expect(r.wrapped[0].__vModel__).toBe('f_name')
|
||||
expect(r.wrapped[0].__config__.label).toBe('名称')
|
||||
expect(r.wrapped[0].__config__.required).toBe(true)
|
||||
})
|
||||
|
||||
it('支持 field/fieldName/config:{required} 格式 (设计 HTML 兼容)', () => {
|
||||
const r = wrapSimplifiedFields([
|
||||
{ field: 'f_competition_name', fieldName: '大赛名称', jnpfKey: 'input', config: { required: true } },
|
||||
], 'jxcj_competition_info')
|
||||
expect(r.total).toBe(1)
|
||||
expect(r.wrapped[0].__vModel__).toBe('f_competition_name')
|
||||
expect(r.wrapped[0].__config__.label).toBe('大赛名称')
|
||||
expect(r.wrapped[0].__config__.required).toBe(true)
|
||||
})
|
||||
|
||||
it('relationForm 字段两种格式都支持', () => {
|
||||
const v = wrapSimplifiedFields([
|
||||
{ vmodel: 'f_team', label: '团队', jnpfKey: 'relationForm', relationTable: 'base_user', columnOptions: [{ label: '姓名', value: 'realName' }] },
|
||||
], 't')
|
||||
const f = wrapSimplifiedFields([
|
||||
{ field: 'f_team', fieldName: '团队', jnpfKey: 'relationForm', relationTable: 'base_user', columnOptions: [{ label: '姓名', value: 'realName' }] },
|
||||
], 't')
|
||||
expect(v.wrapped[0].relationTable).toBe('base_user')
|
||||
expect(f.wrapped[0].relationTable).toBe('base_user')
|
||||
})
|
||||
|
||||
it('必填校验: 两种格式缺关键字段都 throw', () => {
|
||||
expect(() => wrapSimplifiedFields([{ vmodel: '', label: 'x', jnpfKey: 'input' }], 't')).toThrow(/vmodel/)
|
||||
expect(() => wrapSimplifiedFields([{ field: '', fieldName: 'x', jnpfKey: 'input' }], 't')).toThrow(/vmodel/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('wrapSimplifiedFields — v0.x 盲点 60: vmodel 空 fallback', () => {
|
||||
it('当 __vModel__/field/norm.vmodel 都空, fallback 到 rawField 顶层 f_xxx key', () => {
|
||||
// 模拟 dacli form create 简化 schema: 只传 __config__ + f_xxx key
|
||||
const r = wrapSimplifiedFields([
|
||||
{ f_device_name: '', __config__: { label: '设备名称', jnpfKey: 'input', required: true } },
|
||||
], 'tdd8_inspection')
|
||||
expect(r.total).toBe(1)
|
||||
expect(r.wrapped[0].__vModel__).toBe('f_device_name')
|
||||
expect(r.wrapped[0].field).toBe('f_device_name')
|
||||
expect(r.wrapped[0].__config__.label).toBe('设备名称')
|
||||
})
|
||||
|
||||
it('fallback 优先级: rawField.field > rawField.__vModel__ > norm.vmodel > f_xxx', () => {
|
||||
// 都填的情况下, rawField.field 优先 (原代码逻辑)
|
||||
const r = wrapSimplifiedFields([
|
||||
{ f_name: '', field: 'f_field', vmodel: 'f_vmodel', __config__: { label: 'x', jnpfKey: 'input' } },
|
||||
], 't')
|
||||
expect(r.wrapped[0].__vModel__).toBe('f_field')
|
||||
})
|
||||
|
||||
it('多字段时每个独立找 f_xxx', () => {
|
||||
const r = wrapSimplifiedFields([
|
||||
{ f_name: '', __config__: { label: '名称', jnpfKey: 'input' } },
|
||||
{ f_code: '', __config__: { label: '编号', jnpfKey: 'input' } },
|
||||
], 't')
|
||||
expect(r.wrapped[0].__vModel__).toBe('f_name')
|
||||
expect(r.wrapped[1].__vModel__).toBe('f_code')
|
||||
})
|
||||
})
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* fixcolumndata.test.ts — 验证 form columnData 4 个 use*Permission 字段补全
|
||||
*
|
||||
* 盲点 23 闭环: v0.7.1 之前 form create 的 columnData 缺 useBtnPermission 等字段,
|
||||
* 后端 Jackson 反序列化为 null, Actions/Module 报 "System abnormality" (NPE 在
|
||||
* VisualUtil.setPcPermission line 139, .booleanValue() 解开 null)
|
||||
*
|
||||
* 此测试覆盖:
|
||||
* 1. form create --ai-help 应在可选参数提示 fixcolumndata
|
||||
* 2. form --help 应列出 fixcolumndata 子命令
|
||||
* 3. fixcolumndata --ai-help 输出 markdown
|
||||
* 4. 实际 JNPF 平台 fixcolumndata 跑通 (前提: 启了 JNPF + 有 form id)
|
||||
*/
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||
const CLI = resolve(__dirname, '../../src/cli.ts')
|
||||
|
||||
function run(args: string[]): string {
|
||||
try {
|
||||
return execFileSync('npx', ['tsx', CLI, ...args], {
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
timeout: 30_000,
|
||||
})
|
||||
} catch (e) {
|
||||
const err = e as { stdout?: Buffer | string; stderr?: Buffer | string; status?: number }
|
||||
return (err.stdout?.toString() || err.stderr?.toString() || '')
|
||||
}
|
||||
}
|
||||
|
||||
describe('form fixcolumndata (v0.7.1 盲点 23)', () => {
|
||||
it('form --help 列出 fixcolumndata 子命令', () => {
|
||||
const out = run(['form', '--help'])
|
||||
expect(out).toContain('fixcolumn')
|
||||
})
|
||||
|
||||
it('form fixcolumndata --ai-help 输出 markdown 用法', () => {
|
||||
const out = run(['form', 'fixcolumn', '--ai-help'])
|
||||
expect(out).toMatch(/盲点 23|System abnormality|useBtnPermission|useColumnPermission/)
|
||||
})
|
||||
|
||||
it('form fixcolumndata 缺 <id> 报错', () => {
|
||||
const out = run(['form', 'fixcolumn'])
|
||||
// commander 报 "missing required argument" 或类似
|
||||
expect(out.toLowerCase()).toMatch(/missing|required|error/)
|
||||
})
|
||||
})
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* form-lint.test.ts — design-lint 命令单测 (spec §5 T1.1-T1.5)
|
||||
*/
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { parsePythonForms, parseDesignHtml } from '../../src/commands/form/_parsers.ts'
|
||||
import { checkBs31, checkBs32, checkBs23 } from '../../src/commands/form/_blindspots.ts'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||
const CLI = resolve(__dirname, '../../src/cli.ts')
|
||||
|
||||
function runDacli(args: string[]): { stdout: string; exitCode: number } {
|
||||
try {
|
||||
const stdout = execFileSync('npx', ['tsx', CLI, ...args], { encoding: 'utf-8', timeout: 30_000, cwd: resolve(__dirname, '../..') })
|
||||
return { stdout, exitCode: 0 }
|
||||
} catch (e) {
|
||||
const err = e as { stdout?: Buffer | string; status?: number }
|
||||
return { stdout: err.stdout?.toString() || '', exitCode: err.status || 1 }
|
||||
}
|
||||
}
|
||||
|
||||
const FIXTURE_SCRIPT = `
|
||||
FORMS = [
|
||||
('good_form', '好表单', [
|
||||
('input', 'f_name', '名称', True),
|
||||
('inputNumber', 'f_price', '价格', False),
|
||||
]),
|
||||
('bad_label_form', 'label 缺失', [
|
||||
('input', 'f_x', '', True), # label 为空 → BS-31 FAIL
|
||||
]),
|
||||
('bad_money_form', '金额用 input', [
|
||||
('input', 'f_price', '价格', False), # amount-like 字段用 input → BS-32 FAIL
|
||||
]),
|
||||
('false_positive_form', 'sum 误匹配', [
|
||||
('input', 'f_consumer_user_id', '消费用户ID', False), # "consumer" 含 "sum", word-boundary 应不命中
|
||||
]),
|
||||
]
|
||||
`
|
||||
|
||||
const FIXTURE_DESIGN = `
|
||||
<div class="cmd">npx tsx dacli/src/cli.ts dm create --table=tdss_x --dbLinkId=1 --fields='[]'</div>
|
||||
<div class="cmd">npx tsx dacli/src/cli.ts form create --enCode=tdss_x --webType=2 --dbLinkId=1 --autoTable --autoRelease --fields='[]'</div>
|
||||
<div class="cmd">npx tsx dacli/src/cli.ts form create --enCode=tdss_y --webType=2 --dbLinkId=1 --autoTable --fields='[]'</div>
|
||||
`
|
||||
|
||||
describe('parsePythonForms', () => {
|
||||
it('T1.1 抽 4 form 完整, 共 5 字段 (2+1+1+1)', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
expect(forms.length).toBe(4)
|
||||
expect(forms.reduce((s, f) => s + f.fields.length, 0)).toBe(5)
|
||||
expect(forms[0].fields[0]).toEqual({ type: 'input', vmodel: 'f_name', label: '名称', required: true })
|
||||
expect(forms[1].fields[0].label).toBe('') // bad label
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseDesignHtml', () => {
|
||||
it('T1.7 抽 3 .cmd 块, 标 form/dm kind', () => {
|
||||
const blocks = parseDesignHtml(FIXTURE_DESIGN)
|
||||
expect(blocks.length).toBe(3)
|
||||
expect(blocks[0].commandKind).toBe('dm')
|
||||
expect(blocks[0].hasDbLinkId).toBe(true)
|
||||
expect(blocks[1].commandKind).toBe('form')
|
||||
expect(blocks[1].hasAutoRelease).toBe(true)
|
||||
expect(blocks[2].hasAutoRelease).toBe(false) // T1.7 缺 --autoRelease
|
||||
})
|
||||
})
|
||||
|
||||
describe('checkBs31', () => {
|
||||
it('T1.2 缺 label → BS-31 FAIL', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
const bad = forms.find(f => f.enCode === 'bad_label_form')!
|
||||
const formData = { fields: bad.fields.map(fd => ({ __config__: { label: fd.label }, __vModel__: fd.vmodel })) }
|
||||
const issues = checkBs31(JSON.stringify(formData))
|
||||
expect(issues.length).toBe(1)
|
||||
expect(issues[0].id).toBe('BS-31')
|
||||
})
|
||||
|
||||
it('T1.2b 干净 form → BS-31 PASS', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
const good = forms.find(f => f.enCode === 'good_form')!
|
||||
const formData = { fields: good.fields.map(fd => ({ __config__: { label: fd.label }, __vModel__: fd.vmodel })) }
|
||||
expect(checkBs31(JSON.stringify(formData))).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('checkBs32', () => {
|
||||
it('T1.3 金额字段用 input → BS-32 FAIL', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
const bad = forms.find(f => f.enCode === 'bad_money_form')!
|
||||
const formData = { fields: bad.fields.map(fd => ({ __config__: { label: fd.label, jnpfKey: fd.type }, __vModel__: fd.vmodel })) }
|
||||
const issues = checkBs32(JSON.stringify(formData))
|
||||
expect(issues.length).toBe(1)
|
||||
expect(issues[0].id).toBe('BS-32')
|
||||
})
|
||||
|
||||
it('T1.4 金额字段用 inputNumber → BS-32 PASS', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
const good = forms.find(f => f.enCode === 'good_form')!
|
||||
const formData = { fields: good.fields.map(fd => ({ __config__: { label: fd.label, jnpfKey: fd.type }, __vModel__: fd.vmodel })) }
|
||||
expect(checkBs32(JSON.stringify(formData))).toEqual([])
|
||||
})
|
||||
|
||||
it('T1.5 false positive 修复: f_consumer_user_id 不被 BS-32 命中', () => {
|
||||
const forms = parsePythonForms(FIXTURE_SCRIPT)
|
||||
const fp = forms.find(f => f.enCode === 'false_positive_form')!
|
||||
const formData = { fields: fp.fields.map(fd => ({ __config__: { label: fd.label, jnpfKey: fd.type }, __vModel__: fd.vmodel })) }
|
||||
const issues = checkBs32(JSON.stringify(formData))
|
||||
expect(issues).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('checkBs23 (use*Permission)', () => {
|
||||
it('T1.6 缺 useBtnPermission → BS-23 FAIL', () => {
|
||||
const cd = JSON.stringify({ useColumnPermission: false, useFormPermission: false, useDataPermission: false })
|
||||
const issues = checkBs23(cd)
|
||||
expect(issues.some(i => i.message.includes('useBtnPermission'))).toBe(true)
|
||||
})
|
||||
|
||||
it('T1.6b 4 个齐 → PASS', () => {
|
||||
const cd = JSON.stringify({ useBtnPermission: false, useColumnPermission: false, useFormPermission: false, useDataPermission: false })
|
||||
expect(checkBs23(cd)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lint CLI 行为', () => {
|
||||
it('T1.8 解析错误 Python 脚本 → 友好报错 (exit 0 但 forms=0)', () => {
|
||||
const r = runDacli(['form', 'lint', '--from-script=/tmp/not_a_python_file.txt'])
|
||||
// 不抛 stack, 输出含 '未找到 FORMS' 或 'forms=0'
|
||||
expect(r.stdout).toMatch(/解析 0 form/)
|
||||
})
|
||||
|
||||
it('T1.9 跑真 tdss 数据 → 全 PASS exit 0', () => {
|
||||
const r = runDacli([
|
||||
'form', 'lint',
|
||||
'--from-script=/home/ubuntu/ccWorkDir/docs/tdss/scripts/03_forms.py',
|
||||
'--from-design=/home/ubuntu/ccWorkDir/docs/tdss/design-jnpf.html',
|
||||
])
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(r.stdout).toMatch(/解析 14 form/)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user