Skip to content

Commit 4683d5c

Browse files
committed
Show latest instance by default
1 parent a3496bf commit 4683d5c

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

.changeset/yummy-dolls-rescue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Show latest instance by dafault on `workflows instances describe` command

packages/wrangler/src/__tests__/workflows.test.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe("wrangler workflows", () => {
150150
151151
COMMANDS
152152
wrangler workflows instances list <name> Instance related commands (list, describe, terminate, pause, resume)
153-
wrangler workflows instances describe <name> <id> Describe a workflow instance - see its logs, retries and errors
153+
wrangler workflows instances describe <name> [id] Describe a workflow instance - see its logs, retries and errors
154154
wrangler workflows instances terminate <name> <id> Terminate a workflow instance
155155
wrangler workflows instances pause <name> <id> Pause a workflow instance
156156
wrangler workflows instances resume <name> <id> Resume a workflow instance
@@ -380,6 +380,18 @@ describe("wrangler workflows", () => {
380380
});
381381
},
382382
{ once: true }
383+
),
384+
http.get(
385+
`*/accounts/:accountId/workflows/some-workflow/instances`,
386+
async () => {
387+
return HttpResponse.json({
388+
success: true,
389+
errors: [],
390+
messages: [],
391+
result: [mockResponse],
392+
});
393+
},
394+
{ once: true }
383395
)
384396
);
385397
};
@@ -410,6 +422,33 @@ describe("wrangler workflows", () => {
410422
└─┴─┴─┴─┴─┘"
411423
`);
412424
});
425+
426+
it("should describe the latest instance if none is given", async () => {
427+
writeWranglerConfig();
428+
await mockDescribeInstances();
429+
430+
await runWrangler(`workflows instances describe some-workflow`);
431+
expect(std.out).toMatchInlineSnapshot(`
432+
" Name: event
433+
Type: 👀 Waiting for event
434+
Start: [mock-start-date]
435+
End: [mock-end-date]
436+
Duration: 4 years
437+
Output: {}
438+
Name: string
439+
Type: 🎯 Step
440+
Start: [mock-start-date]
441+
End: [mock-end-date]
442+
Duration: 4 years
443+
Success: ✅ Yes
444+
Output: {}
445+
┌─┬─┬─┬─┬─┐
446+
│ Start │ End │ Duration │ State │ Error │
447+
├─┼─┼─┼─┼─┤
448+
│ [mock-start-date] │ [mock-end-date] │ 4 years │ ✅ Success │ string: string │
449+
└─┴─┴─┴─┴─┘"
450+
`);
451+
});
413452
});
414453

415454
describe("instances pause", () => {

packages/wrangler/src/workflows/commands/instances/describe.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export const workflowsInstancesDescribeCommand = createCommand({
4444
describe:
4545
"ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it",
4646
type: "string",
47-
demandOption: true,
47+
demandOption: false,
48+
default: "latest",
4849
},
4950
"step-output": {
5051
describe:
@@ -78,6 +79,7 @@ export const workflowsInstancesDescribeCommand = createCommand({
7879
return;
7980
}
8081

82+
logRaw("Describing latest instance:");
8183
id = instances[0].id;
8284
}
8385

0 commit comments

Comments
 (0)