fix(cli): keep secrets configure JSON singular · openclaw/openclaw@97c63e6
steipete
·
2026-05-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -293,6 +293,21 @@ describe("secrets CLI", () => {
|
293 | 293 | expect(runtimeLogs.at(-1)).toContain("Secrets applied"); |
294 | 294 | }); |
295 | 295 | |
| 296 | +it("emits one JSON document when --yes applies configure output", async () => { |
| 297 | +runSecretsConfigureInteractive.mockResolvedValue(createConfigureInteractiveResult()); |
| 298 | +runSecretsApply.mockResolvedValue(createSecretsApplyResult({ mode: "write", changed: true })); |
| 299 | + |
| 300 | +await createProgram().parseAsync(["secrets", "configure", "--json", "--yes"], { |
| 301 | +from: "user", |
| 302 | +}); |
| 303 | + |
| 304 | +expect(runSecretsApply).toHaveBeenCalledTimes(1); |
| 305 | +expect(defaultRuntime.writeJson).toHaveBeenCalledTimes(1); |
| 306 | +expect(mockFirstObjectArg(defaultRuntime.writeJson)).toEqual( |
| 307 | +createSecretsApplyResult({ mode: "write", changed: true }), |
| 308 | +); |
| 309 | +}); |
| 310 | + |
296 | 311 | it("shows the irreversibility warning on the interactive apply path (#83883)", async () => { |
297 | 312 | runSecretsConfigureInteractive.mockResolvedValue( |
298 | 313 | createConfigureInteractiveResult({ changed: true }), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -181,11 +181,15 @@ export function registerSecretsCli(program: Command): void {
|
181 | 181 | const { writeFileSync } = await import("node:fs"); |
182 | 182 | writeFileSync(opts.planOut, `${JSON.stringify(configured.plan, null, 2)}\n`, "utf8"); |
183 | 183 | } |
| 184 | + |
| 185 | +let shouldApply = Boolean(opts.apply || opts.yes); |
184 | 186 | if (opts.json) { |
185 | | -defaultRuntime.writeJson({ |
186 | | -plan: configured.plan, |
187 | | -preflight: configured.preflight, |
188 | | -}); |
| 187 | +if (!shouldApply) { |
| 188 | +defaultRuntime.writeJson({ |
| 189 | +plan: configured.plan, |
| 190 | +preflight: configured.preflight, |
| 191 | +}); |
| 192 | +} |
189 | 193 | } else { |
190 | 194 | defaultRuntime.log( |
191 | 195 | `Preflight: changed=${configured.preflight.changed}, files=${configured.preflight.changedFiles.length}, warnings=${configured.preflight.warningCount}.`, |
@@ -213,7 +217,6 @@ export function registerSecretsCli(program: Command): void {
|
213 | 217 | } |
214 | 218 | } |
215 | 219 | |
216 | | -let shouldApply = Boolean(opts.apply || opts.yes); |
217 | 220 | if (!shouldApply && !opts.json) { |
218 | 221 | const { confirm } = await import("@clack/prompts"); |
219 | 222 | const approved = await confirm({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。