Skip to content

Commit 37293d3

Browse files
committed
Show latest instance by default
1 parent f007751 commit 37293d3

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 isntances 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
@@ -316,6 +316,18 @@ describe("wrangler workflows", () => {
316316
{ once: true }
317317
)
318318
);
319+
http.get(
320+
`*/accounts/:accountId/workflows/some-workflow/instances`,
321+
async () => {
322+
return HttpResponse.json({
323+
success: true,
324+
errors: [],
325+
messages: [],
326+
result: [mockResponse],
327+
});
328+
},
329+
{ once: true }
330+
);
319331
};
320332

321333
it("should describe the bar instance given a name", async () => {
@@ -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 bar`);
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)