feat(dacli): P1 dm/drop TTY 拦截 + workflow shim 清理 (11 文件)

P1 (0.5h):
  - dm/drop.ts 加 TTY 拦截 — 镜像 form/delete.ts:25 + print/delete.ts:46 +
    report/delete.ts:39 已稳定的 pattern: `if (!opts.yes && process.stdin.isTTY)` 时
    warn + exit 1; 非 TTY 模式 (CI/脚本) 静默 --yes 走即可. 同步 DOC 注释 + 移除 TODO.
  - storage/info.ts:38 DacliError 分叉 — 验证**实际不存在** (`class DacliError`
    仅 src/core/types.ts:57 一处定义, 已被 storage/_helpers.ts:21 正确 import).
    ADR 0015 §2.2 早期记述有误, 修订清空.

shim 清理 (0.5h):
  - 11 个 workflow 子命令 (approve/create/decision/delete/info/launch/list/
    selector/syncForm/tasks/update) 把 `import { ... } from './_output.ts'`
    改成 `from '../_output_filter.ts'` (1 行 sed × 11 文件).
  - 删除 src/commands/workflow/_output.ts shim 文件 (D 掉), 减少 1 个间接层.
  - 不影响 L1 输出过滤 / L3 CommandLog 落盘, 因接口签名不变.

验证:
  - TS compile: 56 errors baseline 不变, 0 新错误
  - 68/68 单元测试 PASS (含 tests/unit/workflow/create_stale_retry)
  - 端到端: dacli dm drop --help + dacli workflow info --help 完整
This commit is contained in:
ssw committed 2026-07-21 17:35:09 +08:00
1 parent 72766bc629
commit 5ead157903
14 files changed
+32 -46

No files matched your search

+12 -7
View File
@@ -64,14 +64,18 @@ wrapCommand({
**端到端验证**: `datasource list/test --json`, `--help`, validation fail 路径
(bscode 含 `!` + dbType=MySQL 缺 serviceName) → exit 1 + 错误 log 完整保留.
### 2.2 P1: 已知 baseline 坑 (2 类, 各 1 文件)
### 2.2 P1: 已知 baseline 坑 (1 类, 1 文件)
| 文件 | 问题 | 修法 |
|------|------|------|
| `dacli/src/commands/dm/drop.ts` | 缺 TTY 拦截, 跑在 CI 会无确认删表 | 加 `if (!opts.yes && process.stdin.isTTY)` 同 datasource/delete |
| `dacli/src/commands/storage/info.ts:38` | 同文件内 `DacliError` 类分叉 (vs `src/core/types.ts` 统一) | 统一 import `'../../core/types.ts'` |
| 文件 | 问题 | 修法 | 状态 |
|------|------|------|------|
| `dacli/src/commands/dm/drop.ts` | 缺 TTY 拦截, 跑在 CI 会无确认删表 | 加 `if (!opts.yes && process.stdin.isTTY)` 同 form/delete.ts:25 / print/delete.ts:46 / report/delete.ts:39 | ✅ done (本 session) |
**工作量**: 0.5h, 1 文件 P0-1, 1 文件 import 修改.
**storage/info.ts:38 DacliError 分叉 (ADR 早期记的)**: **实际不存在**.
8 维度扫 (本 session) 确认 `class DacliError` 仅 `src/core/types.ts:57` 一处定义,
`storage/_helpers.ts` 已正确 `import { DacliError } from '../../core/types.ts'`.
ADR 0015 早期记述有误, 现清空.
**工作量**: 0.5h, 1 文件.
### 2.3 P2: 25+ 高严重度文件批量改造 (validator 模式)
@@ -128,7 +132,8 @@ wrapCommand({
|---|--------|------|------|-------------------|
| **P0** | 1h | 极高 | ✅ **DONE** | c637a58 (wrapCommand helper + 6 文件迁移 + 17 单测) |
| **P3** | 1h | 中 | ✅ **DONE** | 715fcb9 (18 `_validate.ts` 删本地说法, 改 `import { ValidationError } from '../_error_codes.ts'`, 净减 113 行) |
| **P1** | 0.5h | 高 | 待 | `dacli/src/commands/dm/drop.ts` + `dacli/src/commands/storage/info.ts:38` |
| **P1** | 0.5h | 高 | ✅ **DONE** | dm/drop.ts TTY 拦截 (镜像 form/delete.ts:25); storage/info.ts:38 DacliError 分叉**实际不存在** (ADR §2.2 修订) |
| **shim** | 0.5h | 低 | (本 session) | workflow/_output.ts 11 import 改写 + 删 shim |
| P2 | 2-3h | 高 | 待 | form/create.ts 子模块验证函数审查清单 |
| P3 | 1h | 中 | 待 | 18 个 `**/_validate.ts` 改错误码 import |
| P4 | 1h | 中 | 待 | `addOutputOptions` 已加, stdout 文案不统一 → 走 log.flush |
+9 -5
View File
@@ -4,7 +4,10 @@
* v0.11+ Phase 2 (2026-06-25): 改用 webapi 镜像 (loadDataModel.delDataModel)
* 替代 v0.10 直接 c.del('/system/DataModel/{dbLinkId}/Table/{table}')
*
* ⚠️ 危险操作, 表数据不可恢复. 真实执行需双重人工确认 (TODO: 加 TTY 拦截)
* ⚠️ 危险操作, 表数据不可恢复.
* P1 修复 (2026-07-21): 加 TTY 拦截 — TTY 模式无 --yes 主动 exit 1 引导用户
* 确认; 非 TTY 模式 (CI / 脚本) 静默执行 (脚本需自己传 --yes). 镜像
* form/delete.ts:25 + print/delete.ts:46 + report/delete.ts:39 同款 pattern.
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
@@ -25,10 +28,11 @@ export function buildDmDropCommand(): Command {
.option('--dbLinkId <id>', '业务库 id')
.option('--yes', '跳过确认', false)
.action(async (opts: DropOpts) => {
if (!opts.yes) {
log.warn(`即将删除表: ${opts.table}`)
log.warn('传 --yes 确认 (数据不可恢复)')
process.exit(2)
// P1 修复 (2026-07-21): TTY 拦截 — 交互模式无 --yes 引导确认; 脚本模式照常执行 (跳过提示).
// 镜像 form/delete.ts:25 同款. command 不发起 AP I, 仅校验 + UX, 不落 CommandLog.
if (!opts.yes && process.stdin.isTTY) {
log.warn(`即将删除表: ${opts.table}, 加 --yes 跳过提示`)
process.exit(1)
}
const c = await JnpfClient.fromToken()
// BS-48 fix: '--dbLinkId=default' 字面量 → token.dbLinkId
-23
View File
@@ -1,23 +0,0 @@
/**
* commands/workflow/_output.ts — workflow 命令输出过滤 shim (2026-07-21)
*
* ⚠️ 真实实现已迁移到 commands/_output_filter.ts (跨命令通用 helper, v2.1+).
* 保留此文件仅为向后兼容现有 import 路径:
* - commands/workflow/{info,approve,create,tasks,syncForm,decision,list,launch,delete,update,selector}.ts
* 共 11 个 workflow 文件 import from './_output.ts'.
*
* 迁移要点 (2026-07-21):
* - printCommandEnd 签名变了 — 旧 (opts, command, summary) → 新 printCommandEnd({ command, appCode, summary, fixes, ... })
* 旧签名的 1 个调用方 (workflow/create.ts:383) 需更新; 本 shim 不再转发旧签名.
* - setupOutputFilter / addOutputOptions 签名不变, 11 个调用方无需修改.
* - printCommandEndSimple 已删除 (dead code, 全 codebase 0 调用方).
*
* 新代码请直接 import from '../_output_filter.ts'.
*/
// L1 输出过滤 + 选项 (11 个 workflow 命令使用, 签名不变)
export { setupOutputFilter, addOutputOptions } from '../_output_filter.ts'
// L3 CommandLog 落盘 (仅 workflow/create.ts:383 使用, 签名已变 — 调用方需同步更新)
export { printCommandEnd } from '../_output_filter.ts'
export type { PrintCommandEndArgs, OutputOpts } from '../_output_filter.ts'
+1 -1
View File
@@ -7,7 +7,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
interface Opts {
operatorId: string
+1 -1
View File
@@ -23,7 +23,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHookWithPatterns } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter, printCommandEnd } from './_output.ts'
import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts'
import { callAiWorkflow, detectTrivialFlowXml } from '../form/_ai.ts'
import { buildFlowNodes, validateFlowNodeStructure } from './_webapi_helpers.ts'
import { autoLayoutFlowXml, isLayoutNeeded } from './_autoLayout.ts'
+1 -1
View File
@@ -14,7 +14,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
interface DecisionOpts {
list?: boolean
+1 -1
View File
@@ -8,7 +8,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
import { initWebapi, loadWorkflow } from '../../webapi/workflow.ts'
interface Opts { id: string; yes?: boolean; verbose?: boolean; json?: boolean }
+1 -1
View File
@@ -11,7 +11,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
import { initWebapi, loadWorkflow } from '../../webapi/workflow.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
+1 -1
View File
@@ -13,7 +13,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
interface Opts {
flowId: string
+1 -1
View File
@@ -9,7 +9,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter, printCommandEnd } from './_output.ts'
import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts'
interface ListOpts {
category?: string
+1 -1
View File
@@ -11,7 +11,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
import { initWebapi, loadWorkflow } from '../../webapi/workflow.ts'
interface Opts {
+1 -1
View File
@@ -21,7 +21,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
interface SyncFormOpts {
flowId: string
+1 -1
View File
@@ -13,7 +13,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
interface Opts {
category?: string
+1 -1
View File
@@ -8,7 +8,7 @@ import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { setupOutputFilter } from './_output.ts'
import { setupOutputFilter } from '../_output_filter.ts'
import { initWebapi, loadWorkflow } from '../../webapi/workflow.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
import { dirtyCheck, dirtyCheckFailAndExit } from '../_dirty_check.ts'