Skip to content

Commit 6c19dc5

Browse files
committed
Show latest instance by default
1 parent f007751 commit 6c19dc5

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-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: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe("wrangler workflows", () => {
142142
143143
COMMANDS
144144
wrangler workflows instances list <name> Instance related commands (list, describe, terminate, pause, resume)
145-
wrangler workflows instances describe <name> <id> Describe a workflow instance - see its logs, retries and errors
145+
wrangler workflows instances describe <name> [id] Describe a workflow instance - see its logs, retries and errors
146146
wrangler workflows instances terminate <name> <id> Terminate a workflow instance
147147
wrangler workflows instances pause <name> <id> Pause a workflow instance
148148
wrangler workflows instances resume <name> <id> Resume a workflow instance
@@ -314,6 +314,18 @@ describe("wrangler workflows", () => {
314314
});
315315
},
316316
{ once: true }
317+
),
318+
http.get(
319+
`*/accounts/:accountId/workflows/some-workflow/instances`,
320+
async () => {
321+
return HttpResponse.json({
322+
success: true,
323+
errors: [],
324+
messages: [],
325+
result: [mockResponse],
326+
});
327+
},
328+
{ once: true }
317329
)
318330
);
319331
};
@@ -328,6 +340,20 @@ describe("wrangler workflows", () => {
328340
│ Start │ End │ Duration │ State │ Error │
329341
├───────────────────────┼───────────────────────┼───────────┼────────────┼────────────────┤
330342
│ 1/1/2021, 12:00:00 AM │ 1/1/2021, 12:00:00 AM │ 0 seconds │ ✅ Success │ string: string │
343+
└───────────────────────┴───────────────────────┴───────────┴────────────┴────────────────┘"
344+
`);
345+
});
346+
347+
it("should describe the latest instance if none is given", async () => {
348+
writeWranglerConfig();
349+
await mockDescribeInstances();
350+
351+
await runWrangler(`workflows instances describe some-workflow`);
352+
expect(std.out).toMatchInlineSnapshot(`
353+
"┌───────────────────────┬───────────────────────┬───────────┬────────────┬────────────────┐
354+
│ Start │ End │ Duration │ State │ Error │
355+
├───────────────────────┼───────────────────────┼───────────┼────────────┼────────────────┤
356+
│ 1/1/2021, 12:00:00 AM │ 1/1/2021, 12:00:00 AM │ 0 seconds │ ✅ Success │ string: string │
331357
└───────────────────────┴───────────────────────┴───────────┴────────────┴────────────────┘"
332358
`);
333359
});

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

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

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

0 commit comments

Comments
 (0)