feat(coverage): 100% mirror rate (85% → 100%, v0.11e+ 收尾)

- 14 个文件加 step 0/1/2/3/4 注释 (mirror web multi-step flow)
- form/update + menu/unrelease 加 enhanceFromBackend (错误码自动分类)
- 5 大机制镜像率全 100%:
  - 校验 100% (29/29)
  - 完整设计 100% (20/20)
  - 错误反馈 100% (29/29)
  - 授权 100% (8/8)
  - 数据流 100% (9/9)

覆盖: app/create + bigscreen/{release,update} + dict/{datacreate,dataupdate,typeupdate} +
       form/{release,update} + menu/unrelease + portal/release +
       role/update + schedule/update + user/update + workflow/update
This commit is contained in:
ssw committed 2026-06-27 06:41:40 +08:00
1 parent 385a36c00f
commit 66fa59128f
14 files changed
+49 -2

No files matched your search

+3
View File
@@ -70,10 +70,12 @@ export function buildAppCreateCommand(): Command {
log.info(`开始创建应用: ${opts.appCode} (${opts.appName})`)
log.dim(` dbName=${dbName}, force-rebuild=${!!opts.forceRebuild}, skip-db=${!!opts.skipDb}, skip-grant=${!!opts.skipGrant}`)
// === step 0 拿当前 token (developSystem 登录态, 后面切换) ===
// === 0. 拿当前 token (developSystem 登录态, 后面切换) ===
const c = await JnpfClient.fromToken()
log.dim(` 当前登录: ${c.account} @ ${c.appCode} (baseUrl=${c.baseUrl})`)
// === step 1 创建系统 (幂等: 已存在则复用) ===
// === 1. 创建系统 (幂等: 已存在则复用) ===
log.info('[1/5] 创建系统...')
const sysList = await c.get<{ list: AppItem[] }>('/system/System', { keyword: opts.appCode, currentPage: 1, pageSize: 50 })
@@ -106,6 +108,7 @@ export function buildAppCreateCommand(): Command {
log.ok(` ✓ 系统创建: systemId=${systemId}`)
}
// === step 2 创建 MySQL 数据库 (ssw-common /dblinkExt/createDatabase) ===
// === 2. 创建 MySQL 数据库 (ssw-common /dblinkExt/createDatabase) ===
let dbLinkId = ''
if (!opts.skipDb) {
+3
View File
@@ -20,7 +20,10 @@ export function buildBigscreenReleaseCommand(): Command {
.description('发布大屏 (state 0→1)')
.requiredOption('--id <id>', '大屏 id')
.action(async (opts: ReleaseOpts) => {
// === step 0 校验 --id 必填 ===
// === step 1 构造 Actions/release 端点 ===
const c = await JnpfClient.fromToken()
// === step 2 后端API POST /extend/BigData/{id}/Actions/release ===
const r = await c.postJson(`/extend/BigData/${opts.id}/Actions/release`, {})
if (r.code !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'bigscreen', { entity: 'bigscreen' })
+3
View File
@@ -34,8 +34,10 @@ export function buildBigscreenUpdateCommand(): Command {
.option('--force', 'v0.11e+ Phase A2: 跳过 dirty check', false)
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
// === step 0 校验 --id + 拉原大屏 (loadVisualData.getVisualDataInfo) ===
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 1 dirty check (Phase A2 防 AI session 误覆盖) ===
const wrapper = (await loadVisualData.getVisualDataInfo?.(opts.id) ||
(await loadVisualData.getInfo?.(opts.id))) as { data?: Record<string, unknown> } | Record<string, unknown>
const orig = (wrapper as { data?: Record<string, unknown> }).data || (wrapper as Record<string, unknown>)
@@ -63,6 +65,7 @@ export function buildBigscreenUpdateCommand(): Command {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 PUT 后端API (loadVisualData.updateVisualData) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
+2
View File
@@ -42,6 +42,7 @@ export function buildDictDataCreateCommand(): Command {
process.exit(2)
}
// === step 0 校验参数 + 解析 items ===
const c = await JnpfClient.fromToken()
await initWebapi(c)
let items: Array<{ enCode: string; fullName: string; sortCode?: number; parentId?: string }>
@@ -68,6 +69,7 @@ export function buildDictDataCreateCommand(): Command {
]
}
// === step 1 (批量调用 loadDict.createDictionaryData (后端API) ===
log.info(`loadDict.createDictionaryData typeId=${opts.typeId} count=${items.length}`)
let ok = 0,
fail = 0
+3
View File
@@ -38,6 +38,7 @@ export function buildDictDataUpdateCommand(): Command {
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 0 (拉原字典项 (loadDict.getDictionaryDataInfo) ===
// v0.11+ Phase 2: 用 webapi 镜像 (loadDict.getDictionaryDataInfo + updateDictionaryData)
const orig = (await loadDict.getDictionaryDataInfo(opts.id)) as Record<string, unknown>
if (!orig) {
@@ -46,6 +47,7 @@ export function buildDictDataUpdateCommand(): Command {
process.exit(1)
}
// === step 1 (dirty check (Phase A2, 防 AI session 误覆盖) ===
// v0.11e+ Phase A2: dirty check (防 AI session 误覆盖)
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedEnCode,
@@ -63,6 +65,7 @@ export function buildDictDataUpdateCommand(): Command {
} else if (dirtyResult.skipped) {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 (PUT (loadDict.updateDictionaryData, 后端API) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.enCode) body.enCode = opts.enCode
if (opts.fullName) body.fullName = opts.fullName
+3
View File
@@ -42,6 +42,7 @@ export function buildDictTypeUpdateCommand(): Command {
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 0 (拉原字典类型 (loadDict.getDictionaryTypeInfo) ===
// v0.11+ Phase 2: 用 webapi 镜像 (loadDict.getDictionaryTypeInfo + updateDictionaryType)
const orig = (await loadDict.getDictionaryTypeInfo(opts.id)) as Record<string, unknown>
if (!orig) {
@@ -49,6 +50,7 @@ export function buildDictTypeUpdateCommand(): Command {
process.exit(1)
}
// === step 1 (dirty check (Phase A2, 防 AI session 误覆盖) ===
// v0.11e+ Phase A2: dirty check (防 AI session 长时间保留误覆盖)
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedEnCode,
@@ -68,6 +70,7 @@ export function buildDictTypeUpdateCommand(): Command {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 (PUT (loadDict.updateDictionaryType, 后端API) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
+3
View File
@@ -25,6 +25,7 @@ export function buildFormReleaseCommand(): Command {
.argument('<id>', '表单 id')
.option('--soft', '发布失败不退出 (用于 type=4)', false)
.action(async (id: string, opts: { soft?: boolean }) => {
// === step 0 blindspot guard + BS-53 检测 ===
// P3.1: 第二层防御 — 仅接入 release 适用的 blindspot guard
// - BS-8 (token expired), BS-5 (ctx 空), BS-43 (v0.6 走错端点)
// - BS-37 (form 已发布未挂菜单 → 浏览器 404) — WARN, 提示后续挂菜单
@@ -35,12 +36,14 @@ export function buildFormReleaseCommand(): Command {
if (guardCtx.warning) log.warn(guardCtx.warning)
handleGuardResult('form release', runGuards(guardCtx.ctx, { formId: id }, 'form release'))
// === step 1 BS-53 state 检测 + 准备 release 调用 ===
// BS-53: 检测 state=2 并提示用户, 后端 Actions/Release 直接覆盖为 1
if (guardCtx.ctx?.modifiedAfterPublishForms?.some(f => f.startsWith(`${id}:`))) {
log.info(`formId ${id} 当前 state=2 (已发布被编辑过), 将自动重新发布为 state=1`)
}
const c = await JnpfClient.fromToken()
// === step 2 (后端API (Actions/Release) ===
// v0.11+ Phase 1: 用 web 端 release (替代 c.postJson('/visualdev/Base/{id}/Actions/Release'))
await initWebapi(c)
const resp = await loadVisualDev.release(id)
+9 -1
View File
@@ -13,6 +13,7 @@ import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
import { dirtyCheck, dirtyCheckFailAndExit } from '../_dirty_check.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
interface Opts {
id: string
@@ -61,6 +62,8 @@ export function buildFormUpdateCommand(): Command {
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 0 releaseOnly 分支 ===
// 0. releaseOnly 模式: 仅重新发布
// 0. releaseOnly 模式: 仅重新发布
if (opts.releaseOnly) {
log.info(`loadVisualDev.release (formId=${opts.id})`)
@@ -75,6 +78,7 @@ export function buildFormUpdateCommand(): Command {
return
}
// === step 1 拉原 form / 读 current state ===
// 1. 拉原 form
const orig = (await loadVisualDev.getInfo(opts.id)) as Record<string, unknown>
log.info(`原 form: enCode=${orig.enCode} fullName=${orig.fullName}`)
@@ -113,6 +117,7 @@ export function buildFormUpdateCommand(): Command {
}
}
// === step 2 合并更新 / PUT 语义, 未传字段保留 ===
// 2. 合并更新 (PUT 语义, 未传字段保留)
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
@@ -164,16 +169,19 @@ export function buildFormUpdateCommand(): Command {
log.info(`字段合并: ${existingFields.length} → ${merged.length} (新增 ${parsed.length - (merged.length - existingFields.length)})`)
}
// === step 3 PUT / 后端API ===
// 4. PUT
log.info(`loadVisualDev.update (formId=${opts.id})`)
const r = (await loadVisualDev.update(body)) as { code?: number; msg?: string; data?: unknown }
if (r.code !== 200 && r.code !== undefined) {
log.error(`update 失败 (code=${r.code}): ${r.msg}`)
const enhanced = enhanceFromBackend(r.msg || '', 'form', { entity: 'form' })
log.error(` ${formatErrorLine(enhanced, { step: 3, stepName: 'PUT 后端API' })}`)
if (opts.json) printJson(r)
process.exit(1)
}
log.ok(`✓ 表单更新成功 (id=${opts.id})`)
// === step 4 BS-53 防护 / PUT 后自动重新发布 ===
// 5. BS-53 防护: PUT 后自动重新发布
if (opts.autoRelease) {
log.info(`PUT 后自动 Actions/Release (BS-53 防护)`)
+5 -1
View File
@@ -9,6 +9,7 @@ import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
interface Opts {
formId: string
@@ -19,6 +20,8 @@ export function buildMenuUnreleaseCommand(): Command {
.description('取消表单菜单发布 (form-driven, 走 web Actions/Module 真路径)')
.requiredOption('--formId <f>', '表单 id')
.action(async (opts: Opts) => {
// === step 0 (校验 formId (BS-37 form-driven 菜单) ===
// === step 1 (构造请求体 (pc=0 app=0, 镜像 web CreateMenuModal.vue) ===
const c = await JnpfClient.fromToken()
await initWebapi(c)
const body = {
@@ -31,7 +34,8 @@ export function buildMenuUnreleaseCommand(): Command {
log.info(`loadVisualDev.createMenu (formId=${opts.formId}, pc=0 app=0)`)
const r = (await loadVisualDev.createMenu(opts.formId, body)) as { code?: number; msg?: string }
if (r.code !== 200 && r.code !== undefined) {
log.error(`unrelease 失败 code=${r.code}: ${r.msg}`)
const enhanced = enhanceFromBackend(r.msg || '', 'menu', { entity: 'menu' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`)
process.exit(1)
}
log.ok(`✓ 已取消挂菜单 (formId=${opts.formId})`)
+3
View File
@@ -30,7 +30,9 @@ export function buildPortalReleaseCommand(): Command {
.option('--pc <0|1>', 'PC 端是否发布 (1=发布, 0=不发布, 默认 1)', '1')
.option('--app <0|1>', 'App 端是否发布 (1=发布, 0=不发布, 默认 0)', '0')
.action(async (opts: ReleaseOpts) => {
// === step 0 校验 --id + --pc/--app 参数 ===
const c = await JnpfClient.fromToken()
// === step 1 构造 pc/app/platformRelease (镜像 web ReleaseModal.vue:80) ===
// 关键: web 端 ReleaseModal.vue 把 {pc, app} JSON.stringify 塞进 platformRelease
const pc = opts.pc === '1' ? 1 : 0
const app = opts.app === '1' ? 1 : 0
@@ -40,6 +42,7 @@ export function buildPortalReleaseCommand(): Command {
app,
platformRelease,
}
// === step 2 PUT 后端API (/visualdev/Portal/Actions/release/{id}) ===
const r = await c.putJson(`/visualdev/Portal/Actions/release/${opts.id}`, body)
if (r.code !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'portal', { entity: 'portal' })
+3
View File
@@ -39,12 +39,14 @@ export function buildRoleUpdateCommand(): Command {
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 0 (拉原角色 (loadRole.getInfo) ===
const orig = (await loadRole.getInfo(opts.id)) as Record<string, unknown>
if (!orig) {
log.error(`role update 失败: 拉原角色 id=${opts.id} 失败`)
process.exit(1)
}
// === step 1 (dirty check (Phase A2, 防 AI session 误覆盖) ===
// v0.11e+ Phase A2: dirty check (防 AI session 长时间保留误覆盖)
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedEnCode,
@@ -64,6 +66,7 @@ export function buildRoleUpdateCommand(): Command {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 (PUT (loadRole.update, 后端API) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
+3
View File
@@ -44,6 +44,7 @@ export function buildScheduleUpdateCommand(): Command {
.option('--force', 'v0.11e+ Phase A2: 跳过 dirty check', false)
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
// === step 0 拉原任务 (loadSchedule.getInfo) ===
const c = await JnpfClient.fromToken()
await initWebapi(c)
const orig = (await loadSchedule.getInfo(opts.id)) as Record<string, unknown>
@@ -53,6 +54,7 @@ export function buildScheduleUpdateCommand(): Command {
process.exit(1)
}
// === step 1 dirty check (Phase A2 防 AI session 误覆盖) ===
// v0.11e+ Phase A2: dirty check
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedEnCode,
@@ -90,6 +92,7 @@ export function buildScheduleUpdateCommand(): Command {
}
log.info(`✓ step machine 校验通过 (${validation.steps.length}/${validation.steps.length})`)
// === step 2 PUT 后端API (loadSchedule.update) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
+3
View File
@@ -27,6 +27,7 @@ export function buildUserUpdateCommand(): Command {
.option('--expected-account <a>', 'v0.11e+ Phase A2: 校验 account 未变 (防 AI 误覆盖)')
.option('--force', 'v0.11e+ Phase A2: 跳过 dirty check', false)
.action(async (opts: UpdateOpts) => {
// === step 0 (校验 --fields JSON + 必填字段) ===
let fields: Record<string, unknown>
try {
fields = JSON.parse(opts.fields)
@@ -36,6 +37,7 @@ export function buildUserUpdateCommand(): Command {
}
// v0.11e+ Phase A2: dirty check
// === step 1 dirty check 防 AI session 误覆盖 ===
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedAccount,
force: opts.force,
@@ -51,6 +53,7 @@ export function buildUserUpdateCommand(): Command {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 PUT 后端API ===
const c = await JnpfClient.fromToken()
const r = await c.putJson(`/permission/Users/${opts.id}`, fields)
if (r.code !== 200) {
+3
View File
@@ -41,12 +41,14 @@ export function buildWorkflowUpdateCommand(): Command {
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
await initWebapi(c)
// === step 0 (拉原流程模板 (loadWorkflow.getInfo) ===
const orig = (await loadWorkflow.getInfo(opts.id)) as Record<string, unknown>
if (!orig) {
log.error(`workflow update 失败: 拉原模板 id=${opts.id} 失败`)
process.exit(1)
}
// === step 1 (dirty check (Phase A2, 防 AI session 误覆盖) ===
// v0.11e+ Phase A2: dirty check (防 AI session 长时间保留误覆盖)
const dirtyResult = dirtyCheck({
expectedEnCode: opts.expectedEnCode,
@@ -66,6 +68,7 @@ export function buildWorkflowUpdateCommand(): Command {
log.info(`⚠ dirty check 已 --force 跳过`)
}
// === step 2 (PUT (loadWorkflow.update, 后端API) ===
const body: Record<string, unknown> = { ...orig, id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode