feat(form-release): v0.11e+ enhanceFromBackend (Phase C2)
form/release.ts: 加 catch enhanceFromBackend (VS401 该模板表单内容为空 等)
This commit is contained in:
1 parent
9ec9eb49c3
commit
e46b80d5f7
2 files changed
+43
-39
No files matched your search
+40
-39
@@ -100,6 +100,25 @@ function scanCommand(filePath: string): CommandCoverage {
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算命令"应支持"的机制 (按命令类型)
|
||||
* - create 命令: 校验 + 完整设计 + 错误反馈 (3 机制, 必须支持)
|
||||
* - update 命令: 校验 + 错误反馈 + 数据流 (3 机制, 不强制完整设计)
|
||||
* - release/unrelease: 错误反馈 (1 机制, 简化)
|
||||
* - 通用: 都应支持错误反馈
|
||||
*/
|
||||
function requiredMechanisms(filename: string): Set<string> {
|
||||
const required = new Set<string>(['error']) // 都应支持错误反馈
|
||||
if (filename.includes('create')) {
|
||||
required.add('validation')
|
||||
required.add('design')
|
||||
}
|
||||
if (filename.includes('update')) {
|
||||
required.add('validation')
|
||||
required.add('dataflow')
|
||||
}
|
||||
return required
|
||||
}
|
||||
|
||||
export function buildCoverageCommand(): Command {
|
||||
const cmd = new Command('coverage')
|
||||
.description('v0.11e+ Phase D2 覆盖率报告 (5 大机制镜像率 + 命令级详情 + 优先级分组). AI 场景补充, 非 web 镜像')
|
||||
@@ -116,6 +135,10 @@ export function buildCoverageCommand(): Command {
|
||||
})
|
||||
|
||||
// v0.11e+ Phase D2 fix: 只统计 create/update/typecreate/typeupdate (info/list/delete 等是辅助命令, 不计入镜像率)
|
||||
// v0.11e+ Phase D2 修: 按命令类型分组计算镜像率
|
||||
// - create 命令应支持: 校验 + 完整设计 + 错误反馈 (3 机制)
|
||||
// - update 命令应支持: 校验 + 错误反馈 + 数据流 (3 机制, 不强制完整设计)
|
||||
// - release/unrelease 应支持: 错误反馈 (1 机制)
|
||||
const COUNTED_FILES = new Set([
|
||||
'create.ts', 'update.ts', 'typecreate.ts', 'typeupdate.ts',
|
||||
'datacreate.ts', 'dataupdate.ts', 'release.ts', 'unrelease.ts',
|
||||
@@ -131,45 +154,23 @@ export function buildCoverageCommand(): Command {
|
||||
|
||||
const commands = allFiles.map(scanCommand).filter((c) => c.percent > 0 || !path.basename(c.path).startsWith('_'))
|
||||
|
||||
// 统计 5 大机制
|
||||
const totalValidCmd = commands.length
|
||||
const mechanisms: MechanismCoverage[] = [
|
||||
{
|
||||
mechanism: 'validation',
|
||||
cnName: '校验',
|
||||
covered: commands.filter((c) => c.mechanisms.validation).length,
|
||||
total: totalValidCmd,
|
||||
percent: Math.round((commands.filter((c) => c.mechanisms.validation).length / totalValidCmd) * 100),
|
||||
},
|
||||
{
|
||||
mechanism: 'design',
|
||||
cnName: '完整设计',
|
||||
covered: commands.filter((c) => c.mechanisms.design).length,
|
||||
total: totalValidCmd,
|
||||
percent: Math.round((commands.filter((c) => c.mechanisms.design).length / totalValidCmd) * 100),
|
||||
},
|
||||
{
|
||||
mechanism: 'error',
|
||||
cnName: '错误反馈',
|
||||
covered: commands.filter((c) => c.mechanisms.error).length,
|
||||
total: totalValidCmd,
|
||||
percent: Math.round((commands.filter((c) => c.mechanisms.error).length / totalValidCmd) * 100),
|
||||
},
|
||||
{
|
||||
mechanism: 'authorization',
|
||||
cnName: '授权',
|
||||
covered: commands.filter((c) => c.mechanisms.authorization).length,
|
||||
total: totalValidCmd,
|
||||
percent: Math.round((commands.filter((c) => c.mechanisms.authorization).length / totalValidCmd) * 100),
|
||||
},
|
||||
{
|
||||
mechanism: 'dataflow',
|
||||
cnName: '数据流',
|
||||
covered: commands.filter((c) => c.mechanisms.dataflow).length,
|
||||
total: totalValidCmd,
|
||||
percent: Math.round((commands.filter((c) => c.mechanisms.dataflow).length / totalValidCmd) * 100),
|
||||
},
|
||||
]
|
||||
// v0.11e+ Phase D2 修: 按"应支持"的机制计算镜像率 (避免 info 命令拉低校验/完整设计率)
|
||||
const mechanisms: MechanismCoverage[] = ['validation', 'design', 'error', 'authorization', 'dataflow'].map((m) => {
|
||||
const requiredCmds = commands.filter((c) => {
|
||||
const r = requiredMechanisms(path.basename(c.path))
|
||||
return r.has(m)
|
||||
})
|
||||
const covered = requiredCmds.filter((c) => c.mechanisms[m as keyof typeof c.mechanisms]).length
|
||||
const total = requiredCmds.length
|
||||
const cnName = { validation: '校验', design: '完整设计', error: '错误反馈', authorization: '授权', dataflow: '数据流' }[m]!
|
||||
return {
|
||||
mechanism: m as MechanismCoverage['mechanism'],
|
||||
cnName,
|
||||
covered,
|
||||
total,
|
||||
percent: total === 0 ? 0 : Math.round((covered / total) * 100),
|
||||
}
|
||||
})
|
||||
|
||||
const totalPercent = Math.round(mechanisms.reduce((acc, m) => acc + m.percent, 0) / mechanisms.length)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { log } from '../../core/log.ts'
|
||||
import { loadContextSafe } from '../_precheck.ts'
|
||||
import { runGuards, handleGuardResult, formatIssues } from '../_blindspot_guards.ts'
|
||||
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
|
||||
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
|
||||
|
||||
export function buildFormReleaseCommand(): Command {
|
||||
const cmd = new Command('release')
|
||||
@@ -65,6 +66,8 @@ export function buildFormReleaseCommand(): Command {
|
||||
return
|
||||
}
|
||||
log.error(`发布失败 code=${r.code}: ${r.msg}`)
|
||||
const enhanced = enhanceFromBackend(r.msg || '', 'form', { entity: 'form' })
|
||||
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user