From 2a1fd000a65246e16f66b5d13b36fb3350f010c8 Mon Sep 17 00:00:00 2001 From: ssw Date: Tue, 21 Jul 2026 21:03:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(dacli):=20schedule/*=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=20wrapCommand=20=E8=BF=81=E7=A7=BB=20(create/delete/info/trigg?= =?UTF-8?q?er/update,=209=20exit=20=E6=94=B6=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit create 从旧 printCommandEnd 升级 (保留 auto-fix). trigger 从旧 printCommandEnd 升级. update 复用 DirtyCheckError catch + step machine → ctx.fail. delete/info process.exit → ctx.fail. schedule/ 模块 process.exit 归零. Co-Authored-By: Claude --- src/commands/schedule/create.ts | 125 +++++++++++-------------- src/commands/schedule/delete.ts | 42 ++++++--- src/commands/schedule/info.ts | 50 ++++++---- src/commands/schedule/trigger.ts | 42 ++++----- src/commands/schedule/update.ts | 156 ++++++++++++++++++------------- 5 files changed, 226 insertions(+), 189 deletions(-) diff --git a/src/commands/schedule/create.ts b/src/commands/schedule/create.ts index 1559898..430252e 100644 --- a/src/commands/schedule/create.ts +++ b/src/commands/schedule/create.ts @@ -18,7 +18,7 @@ import { initWebapi, loadSchedule } from '../../webapi/schedule.ts' import { validateScheduleCreate } from './_validate.ts' import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' import { runCommandAutoFix, fetchExistingLists } from '../_auto_fix.ts' // v2.1+ (2026-07-21): 跨命令 auto-fix -import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts' // v2.1+ (2026-07-21): stdout 三模式 + CommandLog 落盘 +import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ stdout 三模式 + CommandLog; v2.2+ wrapCommand 收口 5c interface CreateOpts { fullName: string @@ -44,8 +44,7 @@ export function buildScheduleCreateCommand(): Command { .option('--startTime ', 'v0.11e+ Phase C1: 开始时间 (ISO 格式, SYS131 校验)') .option('--endTime ', 'v0.11e+ Phase C1: 结束时间 (ISO 格式, SYS131 校验)') .option('--enabledMark ', 'v0.11e+ Phase C1: 0/1', '1') - .option('--verbose', '完整输出 (含 step machine、API 调用等过程日志)', false) - .option('--json', '原始 JSON 输出', false) + addOutputOptions(cmd) .action(async (opts: CreateOpts) => { // v2.1+ L1: stdout 三模式 setupOutputFilter(opts) @@ -60,79 +59,61 @@ export function buildScheduleCreateCommand(): Command { Object.assign(opts, cmdFix.opts) } - // v0.11e+ Phase C1: step machine 校验 (cron 格式 + SYS131 时间关系) - const validation = validateScheduleCreate({ - fullName: opts.fullName, - enCode: opts.enCode, - cron: opts.cron, - startTime: opts.startTime, - endTime: opts.endTime, - enabledMark: opts.enabledMark, - }) - if (!validation.ok) { - for (const s of validation.steps) { - for (const e of s.errors) { - log.error(` ${formatErrorLine(e, { step: s.step, stepName: s.stepName })}`) - } - } - // v2.1+ L3: 失败落 CommandLog (cron 格式 / SYS131 错误供 AI 查) - printCommandEnd({ - command: 'schedule create', - appCode: c.appCode, - result: 'failure', - summary: { enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }, - fixes: [...cmdFix.silent, ...cmdFix.assertive, ...cmdFix.suggestions], - error: validation.steps.flatMap(s => s.errors).map(e => e.message).join('; '), - duration_ms: Date.now() - startTime, - verbose: opts.verbose, - json: opts.json, - }) - process.exit(1) - } - log.info(`✓ step machine 校验通过 (${validation.steps.length}/${validation.steps.length})`) - // step 0 基础信息 (P0 镜像 web Form.vue schemas) - - const body: Record = { - fullName: opts.fullName, - enCode: opts.enCode, - executeType: opts.executeType, - executeContent: opts.executeContent, - enabledMark: 1, - sortCode: 0, - } - if (opts.cron) body.cron = opts.cron - log.info(`loadSchedule.create (enCode=${opts.enCode})`) - const r = (await loadSchedule.create(body)) as { id?: string; code?: number; msg?: string; data?: { id?: string } } - if (r.code !== 200 && r.code !== undefined) { - const enhanced = enhanceFromBackend(r.msg || '', 'schedule', { entity: 'schedule' }) - log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) - // v2.1+ L3: API 失败落 CommandLog - printCommandEnd({ - command: 'schedule create', - appCode: c.appCode, - result: 'failure', - summary: { enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }, - fixes: [...cmdFix.silent, ...cmdFix.assertive, ...cmdFix.suggestions], - error: r.msg || `code=${r.code}`, - duration_ms: Date.now() - startTime, - verbose: opts.verbose, - json: opts.json, - }) - process.exit(1) - } - const id = r.id || r.data?.id - log.ok(`✓ 定时任务创建成功 id=${id}`) - if (opts.json) printJson(r.data || r) - - // v2.1+ L3: 落 CommandLog - printCommandEnd({ + await wrapCommand({ command: 'schedule create', appCode: c.appCode, - summary: { id, enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }, - fixes: [...cmdFix.silent, ...cmdFix.assertive, ...cmdFix.suggestions], - duration_ms: Date.now() - startTime, + startTime, verbose: opts.verbose, json: opts.json, + fixes: [...cmdFix.silent, ...cmdFix.assertive, ...cmdFix.suggestions], + }, async (ctx) => { + try { + // v0.11e+ Phase C1: step machine 校验 (cron 格式 + SYS131 时间关系) + const validation = validateScheduleCreate({ + fullName: opts.fullName, + enCode: opts.enCode, + cron: opts.cron, + startTime: opts.startTime, + endTime: opts.endTime, + enabledMark: opts.enabledMark, + }) + if (!validation.ok) { + for (const s of validation.steps) { + for (const e of s.errors) { + log.error(` ${formatErrorLine(e, { step: s.step, stepName: s.stepName })}`) + } + } + return ctx.fail( + validation.steps.flatMap(s => s.errors).map(e => e.message).join('; '), + { enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }, + ) + } + log.info(`✓ step machine 校验通过 (${validation.steps.length}/${validation.steps.length})`) + // step 0 基础信息 (P0 镜像 web Form.vue schemas) + + const body: Record = { + fullName: opts.fullName, + enCode: opts.enCode, + executeType: opts.executeType, + executeContent: opts.executeContent, + enabledMark: 1, + sortCode: 0, + } + if (opts.cron) body.cron = opts.cron + log.info(`loadSchedule.create (enCode=${opts.enCode})`) + const r = (await loadSchedule.create(body)) as { id?: string; code?: number; msg?: string; data?: { id?: string } } + if (r.code !== 200 && r.code !== undefined) { + const enhanced = enhanceFromBackend(r.msg || '', 'schedule', { entity: 'schedule' }) + log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) + return ctx.fail(r.msg || `code=${r.code}`, { enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }) + } + const id = r.id || r.data?.id + log.ok(`✓ 定时任务创建成功 id=${id}`) + if (opts.json) printJson(r.data || r) + ctx.success({ id, enCode: opts.enCode, fullName: opts.fullName, cron: opts.cron }) + } catch (e) { + ctx.fail(`schedule create 失败: ${(e as Error).message?.slice(0, 200)}`) + } }) }) installHelpHook(cmd, { diff --git a/src/commands/schedule/delete.ts b/src/commands/schedule/delete.ts index d165738..6478ecb 100644 --- a/src/commands/schedule/delete.ts +++ b/src/commands/schedule/delete.ts @@ -9,28 +9,44 @@ import { JnpfClient } from '../../core/client.ts' import { installHelpHook } from '../../core/help.ts' import { log } from '../../core/log.ts' import { initWebapi, loadSchedule } from '../../webapi/schedule.ts' +import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ 输出过滤; v2.2+ wrapCommand 收口 5c -interface Opts { id: string; yes?: boolean } +interface Opts { id: string; yes?: boolean; json?: boolean; verbose?: boolean } export function buildScheduleDeleteCommand(): Command { const cmd = new Command('delete') .description('定时任务删除 (硬删, v0.11+ webapi)') .requiredOption('--id ', '任务 id') .option('--yes', '跳过确认', false) + addOutputOptions(cmd) .action(async (opts: Opts) => { - if (!opts.yes) { - log.warn(`即将删除定时任务 id=${opts.id}, 加 --yes 跳过确认`) - process.exit(2) - } + setupOutputFilter(opts) const c = await JnpfClient.fromToken() - await initWebapi(c) - log.info(`loadSchedule.delTask (id=${opts.id})`) - const r = (await loadSchedule.delTask(opts.id)) as { code?: number; msg?: string } - if (r.code !== 200 && r.code !== undefined) { - log.error(`schedule delete 失败: ${r.msg}`) - process.exit(1) - } - log.ok(`✓ 定时任务已删除 (id=${opts.id})`) + + await wrapCommand({ + command: 'schedule delete', + appCode: c.appCode, + startTime: Date.now(), + verbose: opts.verbose, + json: opts.json, + fixes: [], + }, async (ctx) => { + try { + if (!opts.yes) { + return ctx.fail(`即将删除定时任务 id=${opts.id}, 加 --yes 跳过确认`, { id: opts.id }) + } + await initWebapi(c) + log.info(`loadSchedule.delTask (id=${opts.id})`) + const r = (await loadSchedule.delTask(opts.id)) as { code?: number; msg?: string } + if (r.code !== 200 && r.code !== undefined) { + return ctx.fail(`schedule delete 失败: ${r.msg}`, { id: opts.id, code: r.code }) + } + log.ok(`✓ 定时任务已删除 (id=${opts.id})`) + ctx.success({ id: opts.id }) + } catch (e) { + ctx.fail(`schedule delete 失败: ${(e as Error).message?.slice(0, 200)}`) + } + }) }) installHelpHook(cmd, { purpose: '定时任务删除. 任务调度会停.', diff --git a/src/commands/schedule/info.ts b/src/commands/schedule/info.ts index 597ed92..59005b2 100644 --- a/src/commands/schedule/info.ts +++ b/src/commands/schedule/info.ts @@ -9,34 +9,52 @@ import { JnpfClient } from '../../core/client.ts' import { installHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import { initWebapi, loadSchedule } from '../../webapi/schedule.ts' +import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ 输出过滤; v2.2+ wrapCommand 收口 5c interface InfoOpts { id: string json?: boolean + /** v2.1+ (2026-07-21): --verbose, addOutputOptions 注入 */ + verbose?: boolean } export function buildScheduleInfoCommand(): Command { const cmd = new Command('info') .description('查看定时任务详情 (Quartz cron + 执行配置, v0.11+ webapi)') .requiredOption('--id ', '定时任务 id') - .option('--json', '原始 JSON 输出', false) + addOutputOptions(cmd) .action(async (opts: InfoOpts) => { + setupOutputFilter(opts) const c = await JnpfClient.fromToken() - await initWebapi(c) - const d = (await loadSchedule.getInfo(opts.id)) as Record - if (!d) { - log.error(`schedule id=${opts.id} 不存在`) - process.exit(1) - } - if (opts.json) { - printJson(d) - return - } - log.info(`定时任务 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`) - console.log(`cron: ${d.cron || '-'}`) - console.log(`executeType: ${d.executeType || '-'}`) - console.log(`executeContent: ${d.executeContent || '-'}`) - console.log(`enabledMark: ${d.enabledMark === 1 ? '启用' : '停用'}`) + + await wrapCommand({ + command: 'schedule info', + appCode: c.appCode, + startTime: Date.now(), + verbose: opts.verbose, + json: opts.json, + fixes: [], + }, async (ctx) => { + try { + await initWebapi(c) + const d = (await loadSchedule.getInfo(opts.id)) as Record + if (!d) { + return ctx.fail(`schedule id=${opts.id} 不存在`, { id: opts.id }) + } + if (opts.json) { + printJson(d) + return ctx.success({ id: opts.id }) + } + log.info(`定时任务 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`) + console.log(`cron: ${d.cron || '-'}`) + console.log(`executeType: ${d.executeType || '-'}`) + console.log(`executeContent: ${d.executeContent || '-'}`) + console.log(`enabledMark: ${d.enabledMark === 1 ? '启用' : '停用'}`) + ctx.success({ id: opts.id, enCode: d.enCode }) + } catch (e) { + ctx.fail(`schedule info 失败: ${(e as Error).message?.slice(0, 200)}`) + } + }) }) installHelpHook(cmd, { purpose: '查看定时任务详情 (Quartz cron + 执行配置)', diff --git a/src/commands/schedule/trigger.ts b/src/commands/schedule/trigger.ts index 5678e5f..65b1a0e 100644 --- a/src/commands/schedule/trigger.ts +++ b/src/commands/schedule/trigger.ts @@ -11,7 +11,7 @@ import { Command } from 'commander' import { JnpfClient } from '../../core/client.ts' import { installHelpHook } from '../../core/help.ts' import { log } from '../../core/log.ts' -import { setupOutputFilter, printCommandEnd } from '../_output_filter.ts' // v2.1+ (2026-07-21): stdout 三模式 + CommandLog 落盘 +import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ stdout 三模式 + CommandLog; v2.2+ wrapCommand 收口 5c interface TriggerOpts { id: string @@ -23,38 +23,30 @@ export function buildScheduleTriggerCommand(): Command { const cmd = new Command('trigger') .description('手动触发定时任务 (白名单, 不等 cron)') .requiredOption('--id ', '定时任务 id') - .option('--verbose', '完整输出 (含 step machine、API 调用等过程日志)', false) - .option('--json', '原始 JSON 输出', false) + addOutputOptions(cmd) .action(async (opts: TriggerOpts) => { // v2.1+ L1: stdout 三模式 setupOutputFilter(opts) const c = await JnpfClient.fromToken() - const startTime = Date.now() - const r = await c.postJson('/scheduletask/white/trigger', { id: opts.id }) - if (r.code !== 200) { - log.error(`schedule trigger 失败: ${r.msg}`) - // v2.1+ L3: 失败落 CommandLog - printCommandEnd({ - command: 'schedule trigger', - appCode: c.appCode, - result: 'failure', - summary: { id: opts.id }, - error: r.msg || `code=${r.code}`, - duration_ms: Date.now() - startTime, - verbose: opts.verbose, - json: opts.json, - }) - process.exit(1) - } - log.ok(`✓ 定时任务 id=${opts.id} 已触发`) - // v2.1+ L3: 成功落 CommandLog - printCommandEnd({ + + await wrapCommand({ command: 'schedule trigger', appCode: c.appCode, - summary: { id: opts.id }, - duration_ms: Date.now() - startTime, + startTime: Date.now(), verbose: opts.verbose, json: opts.json, + fixes: [], + }, async (ctx) => { + try { + const r = await c.postJson('/scheduletask/white/trigger', { id: opts.id }) + if (r.code !== 200) { + return ctx.fail(r.msg || `code=${r.code}`, { id: opts.id }) + } + log.ok(`✓ 定时任务 id=${opts.id} 已触发`) + ctx.success({ id: opts.id }) + } catch (e) { + ctx.fail(`schedule trigger 失败: ${(e as Error).message?.slice(0, 200)}`) + } }) }) installHelpHook(cmd, { diff --git a/src/commands/schedule/update.ts b/src/commands/schedule/update.ts index 27efb2b..1664436 100644 --- a/src/commands/schedule/update.ts +++ b/src/commands/schedule/update.ts @@ -11,9 +11,10 @@ import { JnpfClient } from '../../core/client.ts' import { installHelpHook } from '../../core/help.ts' import { log, printJson } from '../../core/log.ts' import { initWebapi, loadSchedule } from '../../webapi/schedule.ts' -import { dirtyCheck, dirtyCheckFailAndExit } from '../_dirty_check.ts' +import { dirtyCheck, dirtyCheckFailAndExit, DirtyCheckError } from '../_dirty_check.ts' import { validateScheduleUpdate } from './_validate.ts' import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' +import { setupOutputFilter, addOutputOptions, wrapCommand } from '../_output_filter.ts' // v2.1+ 输出过滤; v2.2+ wrapCommand 收口 5c interface Opts { id: string @@ -27,6 +28,8 @@ interface Opts { expectedEnCode?: string force?: boolean json?: boolean + /** v2.1+ (2026-07-21): --verbose, addOutputOptions 注入 */ + verbose?: boolean } export function buildScheduleUpdateCommand(): Command { @@ -42,73 +45,100 @@ export function buildScheduleUpdateCommand(): Command { .option('--enabledMark <0|1>', '启用/禁用 (JNPF 无独立 pause/resume API, 用此替代)') .option('--expected-enCode ', 'v0.11e+ Phase A2: 校验 enCode 未变') .option('--force', 'v0.11e+ Phase A2: 跳过 dirty check', false) - .option('--json', '原始 JSON 输出', false) + addOutputOptions(cmd) .action(async (opts: Opts) => { - // === step 0 拉原任务 (loadSchedule.getInfo) === + setupOutputFilter(opts) const c = await JnpfClient.fromToken() - await initWebapi(c) - const orig = (await loadSchedule.getInfo(opts.id)) as Record - if (!orig) { - const enhanced = enhanceFromBackend('拉原任务失败, id 不存在', 'id', { entity: 'schedule' }) - log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`) - process.exit(1) - } - // === step 1 dirty check (Phase A2 防 AI session 误覆盖) === - // v0.11e+ Phase A2: dirty check - const dirtyResult = dirtyCheck({ - expectedEnCode: opts.expectedEnCode, - force: opts.force, - current: { - enCode: orig.enCode as string | undefined, - state: orig.enabledMark as string | number | undefined, - fullName: orig.fullName as string | undefined, - type: 'di', - }, - id: opts.id, - }) - if (!dirtyResult.ok) { - dirtyCheckFailAndExit(dirtyResult, { type: 'di', id: opts.id, current: { enCode: orig.enCode as string | undefined, fullName: orig.fullName as string | undefined } }, log.error) - } else if (dirtyResult.skipped) { - log.info(`⚠ dirty check 已 --force 跳过`) - } - - // v0.11e+ Phase C1: step machine 校验 (cron 格式 + SYS131) - const validation = validateScheduleUpdate({ - fullName: opts.fullName || orig.fullName as string, - enCode: opts.enCode || orig.enCode as string, - cron: opts.cron || orig.cron as string, - startTime: opts.startTime, - endTime: opts.endTime, - enabledMark: opts.enabledMark, - }) - if (!validation.ok) { - for (const s of validation.steps) { - for (const e of s.errors) { - log.error(` ${formatErrorLine(e, { step: s.step, stepName: s.stepName })}`) + await wrapCommand({ + command: 'schedule update', + appCode: c.appCode, + startTime: Date.now(), + verbose: opts.verbose, + json: opts.json, + fixes: [], + }, async (ctx) => { + try { + // === step 0 拉原任务 (loadSchedule.getInfo) === + await initWebapi(c) + const orig = (await loadSchedule.getInfo(opts.id)) as Record + if (!orig) { + const enhanced = enhanceFromBackend('拉原任务失败, id 不存在', 'id', { entity: 'schedule' }) + log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '配置拉取' })}`) + return ctx.fail(`schedule update 失败: 拉原任务 id=${opts.id} 失败`, { id: opts.id }) } - } - process.exit(1) - } - log.info(`✓ step machine 校验通过 (${validation.steps.length}/${validation.steps.length})`) - // === step 2 PUT 后端API (loadSchedule.update) === - const body: Record = { ...orig, id: opts.id } - if (opts.fullName) body.fullName = opts.fullName - if (opts.enCode) body.enCode = opts.enCode - if (opts.cron) body.cron = opts.cron - if (opts.executeContent) body.executeContent = opts.executeContent - if (opts.enabledMark !== undefined) body.enabledMark = parseInt(opts.enabledMark, 10) - log.info(`loadSchedule.update (id=${opts.id})`) - const r = (await loadSchedule.update(body)) as { code?: number; msg?: string; data?: unknown } - if (r.code !== 200 && r.code !== undefined) { - const enhanced = enhanceFromBackend(r.msg || '', 'schedule', { entity: 'schedule' }) - log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) - if (opts.json) printJson(r) - process.exit(1) - } - log.ok(`✓ 定时任务更新成功 (id=${opts.id})`) - if (opts.json) printJson(r.data) + // === step 1 dirty check (Phase A2 防 AI session 误覆盖) === + // v0.11e+ Phase A2: dirty check + const dirtyResult = dirtyCheck({ + expectedEnCode: opts.expectedEnCode, + force: opts.force, + current: { + enCode: orig.enCode as string | undefined, + state: orig.enabledMark as string | number | undefined, + fullName: orig.fullName as string | undefined, + type: 'di', + }, + id: opts.id, + }) + if (!dirtyResult.ok) { + // v2.2+ (2026-07-21): dirtyCheckFailAndExit 改 throw (DirtyCheckError), 下方 catch → ctx.fail + try { + dirtyCheckFailAndExit(dirtyResult, { type: 'di', id: opts.id, current: { enCode: orig.enCode as string | undefined, fullName: orig.fullName as string | undefined } }, log.error) + } catch (e) { + if (e instanceof DirtyCheckError) { + return ctx.fail(e.message, { id: opts.id, type: 'schedule', errorCount: e.errorCount }) + } + throw e + } + } else if (dirtyResult.skipped) { + log.info(`⚠ dirty check 已 --force 跳过`) + } + + // v0.11e+ Phase C1: step machine 校验 (cron 格式 + SYS131) + const validation = validateScheduleUpdate({ + fullName: opts.fullName || orig.fullName as string, + enCode: opts.enCode || orig.enCode as string, + cron: opts.cron || orig.cron as string, + startTime: opts.startTime, + endTime: opts.endTime, + enabledMark: opts.enabledMark, + }) + if (!validation.ok) { + for (const s of validation.steps) { + for (const e of s.errors) { + log.error(` ${formatErrorLine(e, { step: s.step, stepName: s.stepName })}`) + } + } + return ctx.fail( + validation.steps.flatMap(s => s.errors).map(e => e.message).join('; '), + { id: opts.id }, + ) + } + log.info(`✓ step machine 校验通过 (${validation.steps.length}/${validation.steps.length})`) + + // === step 2 PUT 后端API (loadSchedule.update) === + const body: Record = { ...orig, id: opts.id } + if (opts.fullName) body.fullName = opts.fullName + if (opts.enCode) body.enCode = opts.enCode + if (opts.cron) body.cron = opts.cron + if (opts.executeContent) body.executeContent = opts.executeContent + if (opts.enabledMark !== undefined) body.enabledMark = parseInt(opts.enabledMark, 10) + log.info(`loadSchedule.update (id=${opts.id})`) + const r = (await loadSchedule.update(body)) as { code?: number; msg?: string; data?: unknown } + if (r.code !== 200 && r.code !== undefined) { + const enhanced = enhanceFromBackend(r.msg || '', 'schedule', { entity: 'schedule' }) + log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '后端API' })}`) + if (opts.json) printJson(r) + return ctx.fail(`schedule update 失败 (code=${r.code}): ${r.msg}`, { id: opts.id, code: r.code }) + } + log.ok(`✓ 定时任务更新成功 (id=${opts.id})`) + if (opts.json) printJson(r.data) + ctx.success({ id: opts.id }) + } catch (e) { + ctx.fail(`schedule update 失败: ${(e as Error).message?.slice(0, 200)}`) + } + }) }) installHelpHook(cmd, { purpose: '定时任务修改 (改 cron/executeContent/enabledMark, v0.11+ webapi + v0.11e+ dirty check + step machine)',