From c6b7fe8729534fe4b4fbb067df831d2eb54f2555 Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 21 Jul 2026 17:56:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(dacli):=20P5=20=E5=85=A8=E9=87=8F=20?= =?UTF-8?q?=E2=80=94=20portal/create=20+=20bigscreen/construct=20throw=20?= =?UTF-8?q?=E2=86=92=20DacliError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 剩 2 命令路径文件 (其他 9 个用 P5 sample script 已改): - portal/create.ts:76,93 (2 throw) — businessType 字典为空 input 校验 - bigscreen/construct.ts:269 (1 throw) — validProps empty 剩 throw new Error 全在 SDK/test/helper (跳过): - form/{_ai,_buildformdata,_browser_verify}.ts (SDK 边界) - _ssw_retry.ts (网络重试 helper) - apis/_cache.ts (缓存 helper) - test/{run,render,generate}.ts (test 预期 throws) - menu/_helpers.ts (utility) 验证: TS compile 56 baseline, 0 新错误; portal create --help 正常输出 --- src/commands/bigscreen/construct.ts | 5 ++++- src/commands/portal/create.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/commands/bigscreen/construct.ts b/src/commands/bigscreen/construct.ts index b02b364..a2d4f86 100644 --- a/src/commands/bigscreen/construct.ts +++ b/src/commands/bigscreen/construct.ts @@ -1,6 +1,8 @@ /** * commands/bigscreen/construct.ts — 大屏构造 (v0.13+ §8.2.4 阶段 5) * + * 修改 P5 全量 (2026-07-21): throw new Error → DacliError 提升 L2 catch 分类. + * * 用途: 一键创建带组件的大屏. 支持: * - --template=base: 内置空大屏模板 (9 组件 demo) * - --from-template=: 官方模板 (Phase 5+ 扩展, 暂等同 --template=base) @@ -33,6 +35,7 @@ import { installHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import { initWebapi, loadVisualData } from '../../webapi/visualdata.ts' import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts' // v2.1+ (2026-07-21): 输出过滤 + CommandLog 落盘 +import { DacliError } from '../../core/types.ts' // P5 (2026-07-21): 提升 L2 catch 分类 import { runCommandAutoFix, fetchExistingLists } from '../_auto_fix.ts' // v2.1+ (2026-07-21): 跨命令 auto-fix pipeline import { getBaseConfig, @@ -266,7 +269,7 @@ async function runConstruct(opts: ConstructOpts): Promise<{ id?: string; enCode: let validProps: string[] try { validProps = getValidProps() - if (validProps.length === 0) throw new Error('empty') + if (validProps.length === 0) throw new DacliError('empty') } catch { validProps = listComponentProps() } diff --git a/src/commands/portal/create.ts b/src/commands/portal/create.ts index 3d4fc95..6febb15 100644 --- a/src/commands/portal/create.ts +++ b/src/commands/portal/create.ts @@ -28,6 +28,7 @@ import { import { initWebapi as initDictWebapi, loadDict } from '../../webapi/dict.ts' import { runCommandAutoFix, fetchExistingLists } from '../_auto_fix.ts' // v2.1+ (2026-07-21): 跨命令 auto-fix pipeline import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts' // v2.1+ (2026-07-21): 输出过滤 + CommandLog 落盘 +import { DacliError } from '../../core/types.ts' // P5 (2026-07-21): 提升 L2 catch 分类 interface CreateOpts { fullName: string @@ -73,7 +74,7 @@ async function resolvePortalCategory( (it: any) => ({ id: it.id, enCode: it.enCode, fullName: it.fullName }), ) if (items.length === 0) { - throw new Error( + throw new DacliError( 'businessType 字典为空 (JNPF 平台至少应有 13 项业务分类). 检查 web 端表单设计器是否初始化.', ) } @@ -90,7 +91,7 @@ async function resolvePortalCategory( String(it.fullName).includes(String(opts.category)), ) if (byCode) return { id: byCode.id, name: byCode.fullName, matched: 'explicit' } - throw new Error( + throw new DacliError( `--category "${opts.category}" 在字典 businessType 里找不到. 合法项: ${items .map((i) => `${i.fullName}(${i.id})`) .join(', ').slice(0, 200)}`,