Skip to content

Commit 1d5bc6d

Browse files
authored
fix(wrangler): [Queues] Output suggested wrangler.toml changes after creating a queue (#7191)
1 parent f6879d3 commit 1d5bc6d

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

.changeset/spicy-pigs-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Output suggested wrangler.toml changes after creating a Queue

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,19 @@ describe("wrangler", () => {
258258
const requests = mockCreateRequest("testQueue");
259259
await runWrangler("queues create testQueue");
260260
expect(std.out).toMatchInlineSnapshot(`
261-
"Creating queue testQueue.
262-
Created queue testQueue."
261+
"🌀 Creating queue 'testQueue'
262+
✅ Created queue 'testQueue'
263+
264+
Configure your Worker to send messages to this queue:
265+
266+
[[queues.producers]]
267+
queue = \\"testQueue\\"
268+
binding = \\"testQueue\\"
269+
270+
Configure your Worker to consume messages from this queue:
271+
272+
[[queues.consumers]]
273+
queue = \\"testQueue\\""
263274
`);
264275
expect(requests.count).toEqual(1);
265276
});
@@ -290,7 +301,7 @@ describe("wrangler", () => {
290301
runWrangler(`queues create ${queueName}`)
291302
).rejects.toThrowError();
292303
expect(std.out).toMatchInlineSnapshot(`
293-
"Creating queue testQueue.
304+
"🌀 Creating queue 'testQueue'
294305
Queues is not currently enabled on this account. Go to https://dash.cloudflare.com/some-account-id/workers/queues to enable it.
295306
296307
X [ERROR] A request to the Cloudflare API (/accounts/some-account-id/queues) failed.
@@ -308,8 +319,19 @@ describe("wrangler", () => {
308319
const requests = mockCreateRequest("testQueue", { delivery_delay: 10 });
309320
await runWrangler("queues create testQueue --delivery-delay-secs=10");
310321
expect(std.out).toMatchInlineSnapshot(`
311-
"Creating queue testQueue.
312-
Created queue testQueue."
322+
"🌀 Creating queue 'testQueue'
323+
✅ Created queue 'testQueue'
324+
325+
Configure your Worker to send messages to this queue:
326+
327+
[[queues.producers]]
328+
queue = \\"testQueue\\"
329+
binding = \\"testQueue\\"
330+
331+
Configure your Worker to consume messages from this queue:
332+
333+
[[queues.consumers]]
334+
queue = \\"testQueue\\""
313335
`);
314336
expect(requests.count).toEqual(1);
315337
});

packages/wrangler/src/queues/cli/commands/create.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { readConfig } from "../../../config";
22
import { CommandLineArgsError } from "../../../errors";
33
import { logger } from "../../../logger";
4+
import { getValidBindingName } from "../../../utils/getValidBindingName";
45
import { createQueue } from "../../client";
56
import { handleFetchError } from "../../utils";
67
import type {
@@ -53,9 +54,18 @@ export async function handler(
5354
const config = readConfig(args.config, args);
5455
const body = createBody(args);
5556
try {
56-
logger.log(`Creating queue ${args.name}.`);
57+
logger.log(`🌀 Creating queue '${args.name}'`);
5758
await createQueue(config, body);
58-
logger.log(`Created queue ${args.name}.`);
59+
logger.log(
60+
`✅ Created queue '${args.name}'\n\n` +
61+
"Configure your Worker to send messages to this queue:\n\n" +
62+
"[[queues.producers]]\n" +
63+
`queue = "${args.name}"\n` +
64+
`binding = "${getValidBindingName(args.name, "queue")}"\n\n` +
65+
"Configure your Worker to consume messages from this queue:\n\n" +
66+
"[[queues.consumers]]\n" +
67+
`queue = "${args.name}"`
68+
);
5969
} catch (e) {
6070
handleFetchError(e as { code?: number });
6171
}

0 commit comments

Comments
 (0)