auto(14b5ea1b9bd9): session end @ 2026-07-25T16:21:35 (+5f)
This commit is contained in:
1 parent
54989b9ef1
commit
6fc262f8c0
5 files changed
+116
-15
No files matched your search
@@ -303,9 +303,13 @@ export function printCommandEnd(args: PrintCommandEndArgs): void {
|
||||
log.info(` 详情: dacli log last`)
|
||||
} else {
|
||||
log.discard()
|
||||
// P1-4 fix (2026-07-25): 默认 quiet 模式把状态行走 stderr,
|
||||
// 避免污染 stdout (调用方的 printJson() 输出的 JSON 才能被 python3 json.load 解析).
|
||||
// 修前: process.stdout.write 状态行 → 与 printJson 输出混杂, JSON.parse 报 "Extra data"
|
||||
// 修后: 状态行走 stderr, stdout 留给调用方业务 JSON.
|
||||
const oneLine = formatOneLineSummary(cmdLog)
|
||||
process.stdout.write(`\n${oneLine}\n`)
|
||||
process.stdout.write(` 详情: dacli log last\n`)
|
||||
process.stderr.write(`\n${oneLine}\n`)
|
||||
process.stderr.write(` 详情: dacli log last\n`)
|
||||
}
|
||||
} catch {
|
||||
// 日志写入失败不阻塞主流程, 但 stdout 仍要打印 (兜底)
|
||||
@@ -322,10 +326,11 @@ export function printCommandEnd(args: PrintCommandEndArgs): void {
|
||||
const lines = Object.entries(summary)
|
||||
.map(([k, v]) => ` ${k}: ${v}`)
|
||||
.join('\n')
|
||||
process.stdout.write(`\n${lines}\n`)
|
||||
// P1-4 fix (2026-07-25): 错误分支也走 stderr, 保持 stdout 干净
|
||||
process.stderr.write(`\n${lines}\n`)
|
||||
}
|
||||
if (error) process.stdout.write(` 错误: ${error}\n`)
|
||||
process.stdout.write(` 详情: dacli log last\n`)
|
||||
if (error) process.stderr.write(` 错误: ${error}\n`)
|
||||
process.stderr.write(` 详情: dacli log last\n`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -343,10 +348,11 @@ export function printCommandEnd(args: PrintCommandEndArgs): void {
|
||||
const lines = Object.entries(summary)
|
||||
.map(([k, v]) => ` ${k}: ${v}`)
|
||||
.join('\n')
|
||||
process.stdout.write(`\n${lines}\n`)
|
||||
// P1-4 fix (2026-07-25): 无 appCode 路径也走 stderr
|
||||
process.stderr.write(`\n${lines}\n`)
|
||||
}
|
||||
if (error) process.stdout.write(` 错误: ${error}\n`)
|
||||
process.stdout.write(` 详情: dacli log last\n`)
|
||||
if (error) process.stderr.write(` 错误: ${error}\n`)
|
||||
process.stderr.write(` 详情: dacli log last\n`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,13 +75,35 @@ export function buildRoleAssignCommand(): Command {
|
||||
}
|
||||
}
|
||||
await initRoleRelationWebapi(c)
|
||||
const fn = opts.action === 'add' ? loadRoleRelation.addRoles : loadRoleRelation.removeRoles
|
||||
// P0-1 fix (2026-07-25): 后端 AddRolesForm 期望 {type, objectId, ids},
|
||||
// 不是 dacli 之前传的 {roleId, userIds}. web 端 role/Form.vue 走的是
|
||||
// organize.addRoles({objectId, ids, type}) 模式, type ∈ {user, organize, position}.
|
||||
// dacli role assign 语义是 "给角色赋用户" (roleId + userIds[]),
|
||||
// 镜像成后端契约: 每个 userId 一次 addRoles({type:'user', objectId:uid, ids:[roleId]}).
|
||||
// 这样 RoleRelationEntity 才会真持久化 (tdd3 阶段 4 子代理发现: 旧 {roleId,userIds} 后端静默接受, DB 无 relation)
|
||||
if (opts.action === 'add') {
|
||||
const fn = loadRoleRelation.addRoles
|
||||
let successCount = 0
|
||||
for (const uid of userIds) {
|
||||
const r = (await fn({ type: 'user', objectId: uid, ids: [opts.roleId] })) as { code?: number; msg?: string }
|
||||
if (r.code !== 200 && r.code !== undefined) {
|
||||
log.error(` ↳ userId=${uid} 失败: ${r.msg}`)
|
||||
return ctx.fail(`role assign 失败 (userId=${uid}): ${r.msg}`, { roleId: opts.roleId, userId: uid })
|
||||
}
|
||||
successCount++
|
||||
}
|
||||
log.info(`✓ 角色 id=${opts.roleId} add ${successCount} 个用户 OK (P0-1: 镜像后端 AddRolesForm 契约)`)
|
||||
ctx.success({ roleId: opts.roleId, action: 'add', count: successCount })
|
||||
return
|
||||
}
|
||||
// remove 路径暂保留旧契约, 需后续 P0-1 follow-up
|
||||
const fn = loadRoleRelation.removeRoles
|
||||
const r = (await fn({ roleId: opts.roleId, userIds })) as { code?: number; msg?: string }
|
||||
if (r.code !== 200) {
|
||||
return ctx.fail(`role assign 失败: ${r.msg}`, { roleId: opts.roleId })
|
||||
}
|
||||
log.info(`✓ 角色 id=${opts.roleId} ${opts.action} ${userIds.length} 个用户 OK`)
|
||||
ctx.success({ roleId: opts.roleId, action: opts.action, count: userIds.length })
|
||||
log.info(`✓ 角色 id=${opts.roleId} remove ${userIds.length} 个用户 OK (TODO: P0-1 follow-up remove 路径也镜像后端契约)`)
|
||||
ctx.success({ roleId: opts.roleId, action: 'remove', count: userIds.length })
|
||||
} catch (e) {
|
||||
ctx.fail(`role assign 失败: ${(e as Error).message?.slice(0, 200)}`, { roleId: opts.roleId })
|
||||
}
|
||||
|
||||
@@ -769,6 +769,7 @@ interface BrowserOpts {
|
||||
baseUrl?: string
|
||||
noSnapshot?: boolean
|
||||
json?: boolean
|
||||
verbose?: boolean
|
||||
}
|
||||
|
||||
export function buildTestBrowserCommand(): Command {
|
||||
@@ -792,7 +793,7 @@ Prerequisites (workflow module):
|
||||
确保待办数据: bash scripts/ensure-tc-b-todo.sh [appCode]
|
||||
testspace 默认有 3 个 admin 待办 (来自 vehicleRefuelRecord 流程), workSystem/developSystem baseline 0 待办.
|
||||
`)
|
||||
.option('--appCode <app>', '应用 code (默认 workSystem, testspace 也可)', 'workSystem')
|
||||
.option('--appCode <app>', '应用 code (默认从 token 读, 防 BS-新10 workSystem 假登录)', '')
|
||||
.option('--baseUrl <url>', '后端 base URL', 'http://nginx')
|
||||
.option('--no-snapshot', '不存储 storage snapshot (每次重新 login)', false)
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
@@ -822,10 +823,17 @@ Prerequisites (workflow module):
|
||||
})
|
||||
const ctx = JSON.parse(tokenRaw)
|
||||
|
||||
// P2-8 fix (2026-07-25): --appCode 不传时从 token 读 appCode,
|
||||
// 避免硬编码 workSystem 假登录 (BS-新10 复现)
|
||||
const effectiveAppCode = opts.appCode || ctx.appCode || 'workSystem'
|
||||
if (!opts.appCode && opts.verbose) {
|
||||
log.dim(`[appCode 默认值] 从 token 读 → ${effectiveAppCode}`)
|
||||
}
|
||||
|
||||
const r = await runBrowserTest({
|
||||
module: opts.module,
|
||||
id: id!,
|
||||
appCode: opts.appCode!,
|
||||
appCode: effectiveAppCode,
|
||||
baseUrl: opts.baseUrl!,
|
||||
noSnapshot: opts.noSnapshot,
|
||||
})
|
||||
|
||||
@@ -98,9 +98,13 @@ export function buildUserCreateCommand(): Command {
|
||||
enabledMark: opts.enabledMark || '1',
|
||||
sortCode: parseInt(opts.sortCode || '0', 10),
|
||||
}
|
||||
if (opts.organizeId) body.organizeId = opts.organizeId
|
||||
if (opts.description) body.description = opts.description
|
||||
if (opts.roleId) body.roleId = opts.roleId.split(',')
|
||||
// P0-2 fix (2026-07-25): 不再在 createUser body 塞 roleId/organizeId,
|
||||
// 后端 UserCrForm 不收 (jnpf-permission-controller/.../UserController.java:404-417).
|
||||
// 改在 createUser 成功后, 走专门 relation 端点:
|
||||
// --roleId → roleRelation.addRoles({type:'user', objectId:userId, ids:[roleId]})
|
||||
// --organizeId → userRelation.addUserRelation({objectId:organizeId, userIds:[userId], objectType:'position'})
|
||||
// web 端 organize/index.vue:434 真实契约
|
||||
log.info(`loadUser.createUser (account=${opts.account})`)
|
||||
const r = (await loadUser.createUser(body)) as { id?: string; code?: number; msg?: string; data?: { id?: string } }
|
||||
if (r.code !== 200 && r.code !== undefined) {
|
||||
@@ -117,6 +121,59 @@ export function buildUserCreateCommand(): Command {
|
||||
id = found?.id
|
||||
}
|
||||
log.info(`✓ 用户创建成功 id=${id}`)
|
||||
|
||||
// P0-3 fix (2026-07-25): 后端 UserServiceImpl:537 强制用 sysInfo.getNewUserDefaultPassword()
|
||||
// 覆盖入参 --password, 用户用 123456 登不上. 兜底: createUser 成功后, 若 --password 显式传,
|
||||
// 调 loadUser.resetUserPassword 走 web ResetPassword.vue 路径, 显式覆盖成用户期望值.
|
||||
if (opts.password && id) {
|
||||
const md5Pwd = encryptByMd5(opts.password)
|
||||
try {
|
||||
await loadUser.resetUserPassword({ id, userPassword: md5Pwd, validatePassword: md5Pwd })
|
||||
log.info(`✓ 密码已重置为用户入参值 (id=${id})`)
|
||||
} catch (e) {
|
||||
log.warn(`P0-3: 密码重置失败 (${(e as Error).message?.slice(0, 100)}), 用户可能需用默认密码登录`)
|
||||
}
|
||||
}
|
||||
|
||||
// P0-2 fix part 2 (2026-07-25): createUser 成功后, 走 relation 端点绑 role/organize
|
||||
if (id) {
|
||||
// --roleId (单/多) → roleRelation.addRoles (走 web 端契约, P0-1 已修 addRoles 路径)
|
||||
if (opts.roleId) {
|
||||
try {
|
||||
const roleIds = opts.roleId.split(',').map((s) => s.trim()).filter(Boolean)
|
||||
const { initWebapi: initRoleRelationWebapi, loadRoleRelation } = await import('../../webapi/roleRelation.ts')
|
||||
await initRoleRelationWebapi(c)
|
||||
for (const rid of roleIds) {
|
||||
const rr = await loadRoleRelation.addRoles({ type: 'user', objectId: id, ids: [rid] })
|
||||
if (rr?.code !== 200 && rr?.code !== undefined) {
|
||||
log.warn(`P0-2: 绑 roleId=${rid} 失败 (${rr?.msg || 'unknown'})`)
|
||||
} else {
|
||||
log.info(`✓ 绑 roleId=${rid} OK`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
log.warn(`P0-2: roleId 绑定流程异常 (${(e as Error).message?.slice(0, 100)})`)
|
||||
}
|
||||
}
|
||||
// --organizeId → userRelation.addUserRelation (web 端 organize/index.vue:434 契约)
|
||||
if (opts.organizeId) {
|
||||
try {
|
||||
const ur = await c.postJson('/permission/UserRelation', {
|
||||
objectId: opts.organizeId,
|
||||
userIds: [id],
|
||||
objectType: 'position',
|
||||
}) as { code?: number; msg?: string }
|
||||
if (ur.code !== 200 && ur.code !== undefined) {
|
||||
log.warn(`P0-2: 绑 organizeId=${opts.organizeId} 失败 (${ur.msg || 'unknown'})`)
|
||||
} else {
|
||||
log.info(`✓ 绑 organizeId=${opts.organizeId} OK`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.warn(`P0-2: organizeId 绑定流程异常 (${(e as Error).message?.slice(0, 100)})`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.json) printJson({ ...(r.data as object || r), id })
|
||||
ctx.success({ id, account: opts.account, realName: opts.realName })
|
||||
} catch (e) {
|
||||
|
||||
@@ -176,6 +176,14 @@ export function buildWorkflowCreateCommand(): Command {
|
||||
// ========== 1. 解析 flowXml 来源 (AI 或 直传) ==========
|
||||
let flowXml: string | undefined = opts.flowXml
|
||||
if (!flowXml && opts.ai) {
|
||||
// P1-6 fix (2026-07-25): --ai 路径加载 web FlowProcess 全模块 + 5 节点递归, 默认 256MB 不够
|
||||
// 检测 NODE_OPTIONS 是否设置, 缺则 WARN 提示重跑 (dacli 进程已启动, 不能 retroactively 设)
|
||||
if (!process.env.NODE_OPTIONS || !/max-old-space-size/.test(process.env.NODE_OPTIONS)) {
|
||||
log.warn(`P1-6: --ai 路径会 load web FlowProcess 全模块, 256MB 默认值不够, 易 OOM`)
|
||||
log.warn(` 建议重跑: NODE_OPTIONS="--max-old-space-size=4096" dacli workflow create --ai "..." ...`)
|
||||
log.warn(` (或传 --flowXml 跳过 AI 路径, 已知 tdd3 workflow --ai 实测 4GB 也爆)`)
|
||||
}
|
||||
|
||||
log.info(`[step 1/6] --ai "${opts.ai.slice(0, 50)}${opts.ai.length > 50 ? '...' : ''}" — 调 web 端 getAiInfo`)
|
||||
const data = await callAiWorkflow(opts.ai)
|
||||
if (!data.flowXml) {
|
||||
|
||||
Reference in new issue
Block a user