保留工作流节点开通测试环境选项
- 增加可选 --is-test 配置并路由到测试 Piper - 默认仍使用标准 Piper,dry-run 与结果显示所选环境 - 更新命令帮助、Skill 与接口目录
This commit is contained in:
1 parent
e562ae9227
commit
e58841e164
13 files changed
+56
-13
No files matched your search
@@ -12,7 +12,12 @@ test("node grant previews without a gateway call and requires explicit confirmat
|
||||
expect(JSON.parse(result.stdout).dryRun).toBe(true);
|
||||
expect(JSON.parse(result.stdout).changes.nodes).toEqual(["code-js2"]);
|
||||
expect(grant).not.toHaveBeenCalled();
|
||||
const testPreview = await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code", "--is-test", "--dry-run", "--yes"]), runtime);
|
||||
expect(JSON.parse(testPreview.stdout).changes.isTest).toBe(true);
|
||||
expect(grant).not.toHaveBeenCalled();
|
||||
await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code-js2", "--confirm"]), runtime);
|
||||
expect(grant).toHaveBeenCalledTimes(1);
|
||||
await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code", "--is-test", "--yes"]), runtime);
|
||||
expect(grant).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({ nodes: ["code"], isTest: true }));
|
||||
} finally { grant.mockRestore(); }
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getWorkflowAvailableNodes, grantWorkflowNodes } from "../../../domains/platform/workflow/services.js";
|
||||
import { GRAY_NODES_CATALOG, findGrayNode } from "../../../domains/platform/workflow/nodes/gray-nodes-catalog.js";
|
||||
import { stringOption } from "../../parser.js";
|
||||
import { booleanOption, stringOption } from "../../parser.js";
|
||||
import { printJson, printTable, printKeyValue } from "../../printer.js";
|
||||
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
@@ -134,9 +134,11 @@ export async function handleGrantNodes(
|
||||
}
|
||||
|
||||
requireMutationConfirmation(parsed, runtime, "开通企业工作流灰度节点", "hose-use workflow nodes grant <type...> --yes");
|
||||
const isTest = booleanOption(parsed.options, ["is-test"]);
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "开通企业工作流灰度节点", corp.corpId || corp.credentials.corpId || corp.id, {
|
||||
nodes: targetNodes.map(node => findGrayNode(node)?.type || node.trim()),
|
||||
isTest,
|
||||
adminPasswordRequired: Boolean(process.env.HOSE_ADMIN_PASSWORD),
|
||||
});
|
||||
}
|
||||
@@ -146,6 +148,7 @@ export async function handleGrantNodes(
|
||||
const result = await grantWorkflowNodes(corp, {
|
||||
nodes: targetNodes,
|
||||
password,
|
||||
isTest,
|
||||
});
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
@@ -156,16 +159,17 @@ export async function handleGrantNodes(
|
||||
};
|
||||
}
|
||||
if (!result.success) {
|
||||
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "网关拒绝了开通请求"}\n`, exitCode: 1 };
|
||||
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "Piper 拒绝了开通请求"}\n`, exitCode: 1 };
|
||||
}
|
||||
|
||||
const lines = [
|
||||
`====== 灰度节点开通结果 [${corp.name}] ======`,
|
||||
printKeyValue({
|
||||
"申请开通节点": targetNodes.join(", "),
|
||||
"Piper 环境": result.isTest ? "测试 Piper" : "标准 Piper",
|
||||
"新开通成功": result.saved.length ? result.saved.join(", ") : "无 (已处于开通状态)",
|
||||
"跳过(已开通)": result.skipped.length ? result.skipped.join(", ") : "无",
|
||||
"网关反馈": result.rawMessage || "处理成功",
|
||||
"Piper 反馈": result.rawMessage || "处理成功",
|
||||
}),
|
||||
"",
|
||||
"✅ 节点权限已生效!工作流设计器与 hose-use workflow analyze 将立即支持该节点。",
|
||||
|
||||
@@ -89,12 +89,13 @@ export async function handleNodeCommand(
|
||||
"",
|
||||
"子命令 (企业灰度节点级别):",
|
||||
" nodes [list] [--all] 列出当前企业已开通的节点字典 (别名: probe, catalog)",
|
||||
" nodes grant <type...> 为当前企业开通灰度节点",
|
||||
" nodes grant <type...> [--is-test] 为当前企业开通灰度节点",
|
||||
"",
|
||||
"示例:",
|
||||
" hose-use workflow nodes",
|
||||
" hose-use workflow nodes --all",
|
||||
" hose-use workflow nodes grant code-js2",
|
||||
" hose-use workflow nodes grant code-js2 --is-test",
|
||||
" hose-use workflow node list 896398895352487950",
|
||||
].join("\n") + "\n",
|
||||
exitCode: 1,
|
||||
|
||||
Reference in new issue
Block a user