From 4683d5cb8b767f3021b2af888f9bb727ec23be36 Mon Sep 17 00:00:00 2001 From: Caio Nogueira Date: Wed, 16 Apr 2025 11:59:27 +0100 Subject: [PATCH 1/2] Show latest instance by default --- .changeset/yummy-dolls-rescue.md | 5 +++ .../wrangler/src/__tests__/workflows.test.ts | 41 ++++++++++++++++++- .../workflows/commands/instances/describe.ts | 4 +- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .changeset/yummy-dolls-rescue.md diff --git a/.changeset/yummy-dolls-rescue.md b/.changeset/yummy-dolls-rescue.md new file mode 100644 index 000000000000..c9fd601a33a8 --- /dev/null +++ b/.changeset/yummy-dolls-rescue.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Show latest instance by dafault on `workflows instances describe` command diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 0fef51adf51d..1af1a75b0af0 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -150,7 +150,7 @@ describe("wrangler workflows", () => { COMMANDS wrangler workflows instances list Instance related commands (list, describe, terminate, pause, resume) - wrangler workflows instances describe Describe a workflow instance - see its logs, retries and errors + wrangler workflows instances describe [id] Describe a workflow instance - see its logs, retries and errors wrangler workflows instances terminate Terminate a workflow instance wrangler workflows instances pause Pause a workflow instance wrangler workflows instances resume Resume a workflow instance @@ -380,6 +380,18 @@ describe("wrangler workflows", () => { }); }, { once: true } + ), + http.get( + `*/accounts/:accountId/workflows/some-workflow/instances`, + async () => { + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: [mockResponse], + }); + }, + { once: true } ) ); }; @@ -410,6 +422,33 @@ describe("wrangler workflows", () => { └─┴─┴─┴─┴─┘" `); }); + + it("should describe the latest instance if none is given", async () => { + writeWranglerConfig(); + await mockDescribeInstances(); + + await runWrangler(`workflows instances describe some-workflow`); + expect(std.out).toMatchInlineSnapshot(` + " Name: event + Type: 👀 Waiting for event + Start: [mock-start-date] + End: [mock-end-date] + Duration: 4 years + Output: {} + Name: string + Type: 🎯 Step + Start: [mock-start-date] + End: [mock-end-date] + Duration: 4 years + Success: ✅ Yes + Output: {} + ┌─┬─┬─┬─┬─┐ + │ Start │ End │ Duration │ State │ Error │ + ├─┼─┼─┼─┼─┤ + │ [mock-start-date] │ [mock-end-date] │ 4 years │ ✅ Success │ string: string │ + └─┴─┴─┴─┴─┘" + `); + }); }); describe("instances pause", () => { diff --git a/packages/wrangler/src/workflows/commands/instances/describe.ts b/packages/wrangler/src/workflows/commands/instances/describe.ts index 5117d54083b5..f000a6c6975e 100644 --- a/packages/wrangler/src/workflows/commands/instances/describe.ts +++ b/packages/wrangler/src/workflows/commands/instances/describe.ts @@ -44,7 +44,8 @@ export const workflowsInstancesDescribeCommand = createCommand({ describe: "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it", type: "string", - demandOption: true, + demandOption: false, + default: "latest", }, "step-output": { describe: @@ -78,6 +79,7 @@ export const workflowsInstancesDescribeCommand = createCommand({ return; } + logRaw("Describing latest instance:"); id = instances[0].id; } From b8c34c106353fc2d2cc4140393f5967dd3961b29 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 22 May 2025 13:36:12 +0200 Subject: [PATCH 2/2] Update .changeset/yummy-dolls-rescue.md --- .changeset/yummy-dolls-rescue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/yummy-dolls-rescue.md b/.changeset/yummy-dolls-rescue.md index c9fd601a33a8..6e8ddef265bc 100644 --- a/.changeset/yummy-dolls-rescue.md +++ b/.changeset/yummy-dolls-rescue.md @@ -2,4 +2,4 @@ "wrangler": minor --- -Show latest instance by dafault on `workflows instances describe` command +Show latest instance by default on `workflows instances describe` command