auto(09213057c521): session end @ 2026-06-22T11:30:37 (+5f)
This commit is contained in:
1 parent
7a0ee68ae7
commit
9dd1dc33e2
5 files changed
+71
-4
No files matched your search
@@ -15,6 +15,22 @@ description: Use when working with JNPF platform form/menu/workflow creation, da
|
||||
|
||||
---
|
||||
|
||||
## 🆕 v0.9 关键校准 (2026-06-22, AI 必读 — `dacli app clear` 移植)
|
||||
|
||||
| 校准项 | 旧 (v0.8.4) | 新 (v0.9) | 影响 |
|
||||
|--------|-----------|------------|------|
|
||||
| **`dacli app clear` (P0, 新)** | 不存在 (TS 版报 `unknown command 'clear'`), 仅 Java 归档版 `docs/dacli/ssw-dacli/` 有 | TS 版 `src/commands/app/clear.ts` (~580 行), mysql2/promise + yaml + readline/promises + TTY 强制 + 双重人工确认 | 完整保留 Java 版 6 阶段法 (文件 → pom → yml → DB Phase 1/2/3 → token → MANIFEST); AI 可 `--dry-run` 看清单, 真跑需用户**亲自键入** `appCode` + `DELETE` |
|
||||
| **`--no-restart` flag** | n/a | 默认 true (`--restart`), `dacli app create --appCode=X --appName=Y --force-rebuild` 子进程 inherit stdio | TS 版无 `dacli app init` 创建应用 (只有健康检查 + 重启), --restart 改为调 `app create` |
|
||||
| **`mysql2` 移到 `dependencies`** | devDep (仅 E2E 测试用) | dep (clear 命令直接连 MySQL 跑 RENAME / INSERT SELECT / DELETE) | `npm install` 一条到位, 不再需要 dev 模式 |
|
||||
| **TS 版无 `:app_code` 命名占位符** | n/a | `bindParams` 先 `.replace(/:app_code/g, '?')` 再按 `TABLES_PARAMS_BY_APP_CODE` 表决定填 systemId / appCode | mysql2 只支持位置占位符; Java 版 `:app_code` 是 JPA/Hibernate 语法必须先替换 |
|
||||
| **AI 严禁键入 DELETE 确认** | Java 版已强制 | TS 版同样强制: `process.stdin.isTTY && process.stdout.isTTY` 必须为 true, 否则 `process.exit(1)` | 管道 / Heredoc / 重定向 / AI Bash 工具全部拒绝; `--dry-run` 是唯一 AI 安全的入口 |
|
||||
|
||||
**为什么需要 clear 移植**:Java 版 `ClearAppCommand.java` 是破坏性工具的核心实现, 但 mvn 构建 + jar 启动慢 (~3s), TS 版 tsx 启动 <500ms, AI 操作员体验更好。
|
||||
|
||||
**详细实现**: `src/commands/app/clear.ts` (单文件, 6 阶段法), 复用 `core/{config,log,help}.ts` + `mysql2/promise` (从 devDeps 移到 deps) + `yaml` (已在 deps) + `readline/promises` (Node std)。
|
||||
|
||||
---
|
||||
|
||||
## 🆕 v0.8.4 关键校准 (2026-06-21, AI 必读 — apis/doc 4 新命令 + SQLite 持久化)
|
||||
|
||||
| 校准项 | 旧 (v0.8.3) | 新 (v0.8.4) | 影响 |
|
||||
|
||||
@@ -135,5 +135,6 @@ output (JSON / table / --ai-help markdown)
|
||||
| 49 | enCode 失败残留 | form create 失败后再用同 enCode → "Encoding cannot be repeated" | 三选一:加 `_v2` / `form delete` / `form clone` 重建 |
|
||||
| 50 | menu --formId + Actions/Module 失败 | form schema 缺主表信息 → "主表不存在" | 不传 --formId,走低级模式 `--type=3 --urlAddress=model/{enCode}` |
|
||||
| 51 | 浏览器层 list 白屏 | dacli 简化 columnList 缺完整 schema 字段 | `dacli form clone <workSystem_id>` 拿完整 schema,或用 no-spa-page 静态页兜底 |
|
||||
| 52 | `dacli app clear` mysql2 不支持 `:app_code` | 报 "syntax error near ':app_code'" | bindParams 先 `.replace(/:app_code/g, '?')` 再填 `?` |
|
||||
|
||||
详细反模式 + 完整代码示例见 `.claude/skills/dacli-ts/references/anti-patterns.md`。
|
||||
+1
-1
@@ -21,6 +21,7 @@
|
||||
"better-sqlite3": "^11.10.0",
|
||||
"commander": "^12.1.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"mysql2": "^3.22.5",
|
||||
"vue": "^3.5.0",
|
||||
"yaml": "^2.9.0"
|
||||
},
|
||||
@@ -29,7 +30,6 @@
|
||||
"@types/better-sqlite3": "^7.6.11",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/node": "^22.0.0",
|
||||
"mysql2": "^3.22.5",
|
||||
"pixelmatch": "^6.0.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.6.0",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* info 应用详情
|
||||
* create 真·创建 JNPF 应用
|
||||
* init 应用初始化 (健康检查 / 重启; 原 initapp)
|
||||
* clear 清除应用本地资源 + DB (破坏性, TTY + 双确认, 移植自 Java 版)
|
||||
* login 登录 JNPF (原顶层 login)
|
||||
* status 显示登录状态 (原顶层 status)
|
||||
* switch 切换当前应用 (原顶层 switchapp / switch-app)
|
||||
@@ -17,6 +18,7 @@ import { buildAppListCommand } from './list.ts'
|
||||
import { buildAppInfoCommand } from './info.ts'
|
||||
import { buildAppInitCommand } from './init.ts'
|
||||
import { buildAppCreateCommand } from './create.ts'
|
||||
import { buildAppClearCommand } from './clear.ts'
|
||||
import { buildAppLoginCommand } from './login.ts'
|
||||
import { buildAppStatusCommand } from './status.ts'
|
||||
import { buildAppSwitchCommand } from './switch.ts'
|
||||
@@ -27,6 +29,7 @@ export function buildAppCommand(): Command {
|
||||
cmd.addCommand(buildAppInfoCommand())
|
||||
cmd.addCommand(buildAppInitCommand())
|
||||
cmd.addCommand(buildAppCreateCommand())
|
||||
cmd.addCommand(buildAppClearCommand())
|
||||
cmd.addCommand(buildAppLoginCommand())
|
||||
cmd.addCommand(buildAppStatusCommand())
|
||||
cmd.addCommand(buildAppSwitchCommand())
|
||||
|
||||
+50
-3
@@ -17,18 +17,19 @@ function run(args: string[]): string {
|
||||
timeout: 30_000,
|
||||
})
|
||||
} catch (e) {
|
||||
const err = e as { stdout?: Buffer | string; status?: number }
|
||||
return (err.stdout?.toString() || '')
|
||||
const err = e as { stdout?: Buffer | string; stderr?: Buffer | string }
|
||||
return ((err.stdout?.toString() || '') + (err.stderr?.toString() || ''))
|
||||
}
|
||||
}
|
||||
|
||||
describe('app command tree (W9-D1)', () => {
|
||||
it('app --help 列出 7 个子命令 (v0.9: 归并 login/status/switch/init)', () => {
|
||||
it('app --help 列出 8 个子命令 (v0.9+: 归并 login/status/switch/init + clear)', () => {
|
||||
const out = run(['app', '--help'])
|
||||
expect(out).toContain('list')
|
||||
expect(out).toContain('info')
|
||||
expect(out).toContain('init')
|
||||
expect(out).toContain('create')
|
||||
expect(out).toContain('clear')
|
||||
expect(out).toContain('login')
|
||||
expect(out).toContain('status')
|
||||
expect(out).toContain('switch')
|
||||
@@ -55,3 +56,49 @@ describe('app command tree (W9-D1)', () => {
|
||||
expect(out).toContain('app')
|
||||
})
|
||||
})
|
||||
|
||||
describe('app clear (移植自 Java 版 ClearAppCommand.java)', () => {
|
||||
it('app clear --help 含 5 个 flag', () => {
|
||||
const out = run(['app', 'clear', '--help'])
|
||||
expect(out).toContain('--appCode')
|
||||
expect(out).toContain('--dry-run')
|
||||
expect(out).toContain('--skip-db')
|
||||
expect(out).toContain('--no-restart')
|
||||
expect(out).toContain('--workspace')
|
||||
})
|
||||
|
||||
it('app clear --ai-help 含完整 purpose/required/optional/example/source/notes', () => {
|
||||
const out = run(['app', 'clear', '--ai-help'])
|
||||
expect(out).toContain('## 用途')
|
||||
expect(out).toContain('## 必传参数')
|
||||
expect(out).toContain('## 可选参数')
|
||||
expect(out).toContain('## 来源')
|
||||
expect(out).toContain('## 例子')
|
||||
expect(out).toContain('## 注意')
|
||||
expect(out).toContain('history_bak')
|
||||
expect(out).toContain('Phase 1/2/3')
|
||||
expect(out).toContain('--appCode=tds2')
|
||||
})
|
||||
|
||||
it('app clear --appCode=BAD_CODE (大写) 报格式不合法 (regex fail)', () => {
|
||||
const out = run(['app', 'clear', '--appCode=BAD_CODE'])
|
||||
expect(out).toContain('app-code 格式不合法')
|
||||
expect(out).toContain('BAD_CODE')
|
||||
})
|
||||
|
||||
it('app clear --appCode=bad-code!@# (含特殊字符) 报格式不合法', () => {
|
||||
const out = run(['app', 'clear', '--appCode=bad-code!@#'])
|
||||
expect(out).toContain('app-code 格式不合法')
|
||||
})
|
||||
|
||||
it('app clear --appCode=neverexist --workspace=/tmp/nonexistent_xyz 报工程根目录不存在', () => {
|
||||
const out = run(['app', 'clear', '--appCode=neverexist', '--workspace=/tmp/nonexistent_xyz_2026'])
|
||||
expect(out).toContain('工程根目录不存在')
|
||||
})
|
||||
|
||||
it('app clear --appCode=neverexist --dry-run --workspace=<ccWorkDir> 不报错 (无任何资源时静默退出)', () => {
|
||||
// 实际跑在工程根目录, 但 appCode=neverexistxyz123 不存在 → 0 资源 → 静默
|
||||
const out = run(['app', 'clear', '--appCode=neverexistxyz123', '--dry-run'])
|
||||
expect(out).toContain('没有找到任何需要清理的资源')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user