Skip to content

Commit 1a9e81d

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

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
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: 37 additions & 11 deletions
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
});
@@ -360,7 +386,7 @@ describe("wrangler workflows", () => {
360386

361387
await runWrangler(`workflows instances pause some-workflow bar`);
362388
expect(std.info).toMatchInlineSnapshot(
363-
`"⏸️ The instance \\"bar\\" from some-workflow was paused successfully"`
389+
`"⏸️ The instance "bar" from some-workflow was paused successfully"`
364390
);
365391
});
366392
});
@@ -392,7 +418,7 @@ describe("wrangler workflows", () => {
392418

393419
await runWrangler(`workflows instances resume some-workflow bar`);
394420
expect(std.info).toMatchInlineSnapshot(
395-
`"🔄 The instance \\"bar\\" from some-workflow was resumed successfully"`
421+
`"🔄 The instance "bar" from some-workflow was resumed successfully"`
396422
);
397423
});
398424
});
@@ -424,7 +450,7 @@ describe("wrangler workflows", () => {
424450

425451
await runWrangler(`workflows instances terminate some-workflow bar`);
426452
expect(std.info).toMatchInlineSnapshot(
427-
`"🥷 The instance \\"bar\\" from some-workflow was terminated successfully"`
453+
`"🥷 The instance "bar" from some-workflow was terminated successfully"`
428454
);
429455
});
430456
});
@@ -436,7 +462,7 @@ describe("wrangler workflows", () => {
436462

437463
await runWrangler(`workflows instances terminate-all some-workflow`);
438464
expect(std.info).toMatchInlineSnapshot(
439-
`"🥷 A job to terminate instances from Workflow \\"some-workflow\\" has been started. It might take a few minutes to complete."`
465+
`"🥷 A job to terminate instances from Workflow "some-workflow" has been started. It might take a few minutes to complete."`
440466
);
441467
});
442468

@@ -446,7 +472,7 @@ describe("wrangler workflows", () => {
446472

447473
await runWrangler(`workflows instances terminate-all some-workflow`);
448474
expect(std.info).toMatchInlineSnapshot(
449-
`"🥷 A job to terminate instances from Workflow \\"some-workflow\\" has been started. It might take a few minutes to complete."`
475+
`"🥷 A job to terminate instances from Workflow "some-workflow" has been started. It might take a few minutes to complete."`
450476
);
451477
});
452478

@@ -458,7 +484,7 @@ describe("wrangler workflows", () => {
458484
`workflows instances terminate-all some-workflow --status queued`
459485
);
460486
expect(std.info).toMatchInlineSnapshot(
461-
`"🥷 A job to terminate instances from Workflow \\"some-workflow\\" with status \\"queued\\" has been started. It might take a few minutes to complete."`
487+
`"🥷 A job to terminate instances from Workflow "some-workflow" with status "queued" has been started. It might take a few minutes to complete."`
462488
);
463489
});
464490

@@ -474,7 +500,7 @@ describe("wrangler workflows", () => {
474500
`workflows instances terminate-all some-workflow --status queued`
475501
);
476502
expect(std.info).toMatchInlineSnapshot(
477-
`"🥷 A job to terminate instances from Workflow \\"some-workflow\\" with status \\"queued\\" is already running. It might take a few minutes to complete."`
503+
`"🥷 A job to terminate instances from Workflow "some-workflow" with status "queued" is already running. It might take a few minutes to complete."`
478504
);
479505
});
480506

@@ -489,7 +515,7 @@ describe("wrangler workflows", () => {
489515
);
490516
expect(std.err).toMatchInlineSnapshot(
491517
`
492-
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mProvided status \\"not-a-status\\" is not valid, it must be one of the following: queued, running, paused, waitingForPause, waiting.[0m
518+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mProvided status "not-a-status" is not valid, it must be one of the following: queued, running, paused, waitingForPause, waiting.[0m
493519
494520
"
495521
`
@@ -527,7 +553,7 @@ describe("wrangler workflows", () => {
527553
await runWrangler(`workflows trigger some-workflow`);
528554
expect(std);
529555
expect(std.info).toMatchInlineSnapshot(
530-
`"🚀 Workflow instance \\"3c70754a-8435-4498-92ad-22e2e2c90853\\" has been queued successfully"`
556+
`"🚀 Workflow instance "3c70754a-8435-4498-92ad-22e2e2c90853" has been queued successfully"`
531557
);
532558
});
533559
});
@@ -541,7 +567,7 @@ describe("wrangler workflows", () => {
541567
await runWrangler(`workflows delete some-workflow`);
542568
expect(std.out).toMatchInlineSnapshot(
543569
`
544-
"✅ Workflow \\"some-workflow\\" removed successfully.
570+
"✅ Workflow "some-workflow" removed successfully.
545571
Note that running instances might take a few minutes to be properly terminated."
546572
`
547573
);

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)