diff --git a/.changeset/yummy-dolls-rescue.md b/.changeset/yummy-dolls-rescue.md new file mode 100644 index 000000000000..6e8ddef265bc --- /dev/null +++ b/.changeset/yummy-dolls-rescue.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Show latest instance by default 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; }