diff --git a/.changeset/yummy-dolls-rescue.md b/.changeset/yummy-dolls-rescue.md new file mode 100644 index 000000000000..99821eb9bcf4 --- /dev/null +++ b/.changeset/yummy-dolls-rescue.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Show latest instance by dafault on workflows describe command diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 90434e47e7d5..78016be3ea40 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -97,11 +97,11 @@ describe("wrangler workflows", () => { Manage Workflow instances [open-beta] COMMANDS - wrangler workflows instances list Instance related commands (list, describe, terminate, pause, resume) [open-beta] - wrangler workflows instances describe Describe a workflow instance - see its logs, retries and errors [open-beta] - wrangler workflows instances terminate Terminate a workflow instance [open-beta] - wrangler workflows instances pause Pause a workflow instance [open-beta] - wrangler workflows instances resume Resume a workflow instance [open-beta] + wrangler workflows instances list Instance related commands (list, describe, terminate, pause, resume) + 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 GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] @@ -272,6 +272,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 } + ); }; it("should describe the bar instance given a name", async () => { @@ -284,6 +296,20 @@ describe("wrangler workflows", () => { │ Start │ End │ Duration │ State │ Error │ ├───────────────────────┼───────────────────────┼───────────┼────────────┼────────────────┤ │ 1/1/2021, 12:00:00 AM │ 1/1/2021, 12:00:00 AM │ 0 seconds │ ✅ Success │ string: string │ +└───────────────────────┴───────────────────────┴───────────┴────────────┴────────────────┘" + `); + }); + + it("should describe the latest instance if none is given", async () => { + writeWranglerConfig(); + await mockDescribeInstances(); + + await runWrangler(`workflows instances describe some-workflow bar`); + expect(std.out).toMatchInlineSnapshot(` +"┌───────────────────────┬───────────────────────┬───────────┬────────────┬────────────────┐ +│ Start │ End │ Duration │ State │ Error │ +├───────────────────────┼───────────────────────┼───────────┼────────────┼────────────────┤ +│ 1/1/2021, 12:00:00 AM │ 1/1/2021, 12:00:00 AM │ 0 seconds │ ✅ Success │ string: string │ └───────────────────────┴───────────────────────┴───────────┴────────────┴────────────────┘" `); }); diff --git a/packages/wrangler/src/workflows/commands/instances/describe.ts b/packages/wrangler/src/workflows/commands/instances/describe.ts index da1eafff946a..7f22b86d07a4 100644 --- a/packages/wrangler/src/workflows/commands/instances/describe.ts +++ b/packages/wrangler/src/workflows/commands/instances/describe.ts @@ -43,7 +43,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: