From 15b3361f159f81cda68a3205072b444d77b13a26 Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 21 Jul 2026 18:38:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(dacli):=20P4=20v3=20batch=201=20=E2=80=94?= =?UTF-8?q?=203=20=E7=AE=80=E5=8D=95=20swap=20=E5=B7=B2=20wrapCommand=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20console.log=20=E8=A1=A8=20=E2=86=92=20prin?= =?UTF-8?q?tRawTable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - report/list.ts (4 列: ID/FULL_NAME/CATEGORY/ENCODE, 已有 wrapCommand) - storage/list.ts (6 列: TYPE/NAME/EN-STORE/EN-ACCESS/ACTIVE/YML-PATH, 已有 wrapCommand) - workflow/list.ts (5 列: ID/FLOW_ID/FULL_NAME/ENCODE/CATEGORY, 已有 wrapCommand) 每文件: - 替换 header console.log + '-' separator + for-loop padEnd 为单 log.printRawTable() 调用 - 列宽由 printRawTable 自动算 (maxColWidth=36 默认), 不再硬编码 95/120 等 - padEnd 字符串对齐逻辑下沉到 primitive, 输出列宽自适应 验证: - TS compile 0 新错误 (baseline 57 不变) - 73/73 单元测试 PASS (含 printRawTable 5 单测) 剩 22 REAL_TABLE 文件待迁 (需新 wrapCommand). 下批: apis/* (search + tags). --- src/commands/report/list.ts | 18 +++++++++--------- src/commands/storage/list.ts | 21 +++++++++++---------- src/commands/workflow/list.ts | 15 ++++++++++----- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/commands/report/list.ts b/src/commands/report/list.ts index c745dc9..00de913 100644 --- a/src/commands/report/list.ts +++ b/src/commands/report/list.ts @@ -111,15 +111,15 @@ export function buildReportListCommand(): Command { return ctx.success(summary) } log.info(`共 ${list.length} 张报表 (total=${total})`) - console.log('ID FULL_NAME CATEGORY ENCODE') - console.log('-'.repeat(95)) - for (const d of list) { - const id = String(d.id || '').padEnd(30) - const name = String(d.fullName || '').padEnd(23) - const cat = String(d.category || '').padEnd(23) - const code = String(d.enCode || '') - console.log(`${id}${name}${cat}${code}`) - } + log.printRawTable( + ['ID', 'FULL_NAME', 'CATEGORY', 'ENCODE'], + list.map((d) => [ + String(d.id || ''), + String(d.fullName || ''), + String(d.category || ''), + String(d.enCode || ''), + ]), + ) ctx.success(summary) } catch (e) { ctx.fail(`report list 失败: ${(e as Error).message?.slice(0, 200)}`) diff --git a/src/commands/storage/list.ts b/src/commands/storage/list.ts index d7f19dd..f447d26 100644 --- a/src/commands/storage/list.ts +++ b/src/commands/storage/list.ts @@ -58,16 +58,17 @@ export function buildStorageListCommand(): Command { log.info(`default-platform: ${cfg.defaultPlatform}`) log.info(`thumbnail-suffix: ${cfg.thumbnailSuffix}`) console.log('') - console.log('TYPE NAME EN-STORE EN-ACCESS ACTIVE YML-PATH') - console.log('-'.repeat(95)) - for (const p of cfg.platforms) { - const type = p.type.padEnd(16) - const name = p.name.padEnd(18) - const store = (p.enableStorage ? 'true ' : 'false').padEnd(10) - const access = (p.enableAccess ? 'true ' : 'false').padEnd(11) - const active = (p.name === cfg.defaultPlatform ? '✓' : ' ').padEnd(8) - console.log(`${type}${name}${store}${access}${active}${p.ymlPath}`) - } + log.printRawTable( + ['TYPE', 'NAME', 'EN-STORE', 'EN-ACCESS', 'ACTIVE', 'YML-PATH'], + cfg.platforms.map((p) => [ + p.type, + p.name, + p.enableStorage ? 'true' : 'false', + p.enableAccess ? 'true' : 'false', + p.name === cfg.defaultPlatform ? '✓' : '', + p.ymlPath, + ]), + ) if (cfg.platforms.length === 0) { log.warn('yml 中未发现任何已知后端 (7 种 backend-type 都没出现)') } diff --git a/src/commands/workflow/list.ts b/src/commands/workflow/list.ts index 4cc2378..e4815e5 100644 --- a/src/commands/workflow/list.ts +++ b/src/commands/workflow/list.ts @@ -62,11 +62,16 @@ export function buildWorkflowListCommand(): Command { log.info(`${path} 共 ${list.length} 条`) // v0.12+ jxcj-2026-06-29 fix: 多输出一列 FLOW_ID (TemplateJsonEntity.id = 最新 version id) // 作用: launchFlow / actionLaunchFlow 用 template=FLOW_ID, 不要用 ID (TemplateEntity.id) - console.log('ID FLOW_ID FULL_NAME ENCODE CATEGORY') - console.log('-'.repeat(120)) - for (const t of list) { - console.log(`${String(t.id || '').padEnd(36)}${String(t.flowId || '').padEnd(36)}${String(t.fullName || '').padEnd(22)}${String(t.enCode || '').padEnd(22)}${t.category || ''}`) - } + log.printRawTable( + ['ID', 'FLOW_ID', 'FULL_NAME', 'ENCODE', 'CATEGORY'], + list.map((t) => [ + String(t.id || ''), + String(t.flowId || ''), + String(t.fullName || ''), + String(t.enCode || ''), + String(t.category || ''), + ]), + ) if (list.some((t) => t.id !== t.flowId)) { log.info(` 💡 launchFlow / actionLaunchFlow 需用 FLOW_ID (≠ ID):`) log.info(` dacli workflow launch --id= ...`)