Skip to content

Commit 234afae

Browse files
authored
Continue createCommand migration with ✨AI✨ (#8966)
* wrangler init * wrangler delete * wrangler triggers * halfway through wrangler queues * complete queues migration * wrangler d1 * wrangler ai * hyperdrive & vectorize * pages * Fix AI code * Create thirty-apples-invite.md * more ai fixups * mtls-certificate * wrangler build * wrangler pipelines * wrangler dispatch-namespace * fix check * fix tests * cleanup * address comments * fix lint
1 parent 508df7d commit 234afae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+6218
-6355
lines changed

.changeset/thirty-apples-invite.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+
Internal refactor to use the `createCommand` utility

packages/wrangler/src/__tests__/d1/create.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ describe("create", () => {
3232
mockGetMemberships([
3333
{ id: "IG-88", account: { id: "1701", name: "enterprise" } },
3434
]);
35-
await expect(
36-
runWrangler("d1 create test --location sydney")
37-
).rejects.toThrowError(
38-
`Location 'sydney' invalid. Valid values are weur,eeur,apac,oc,wnam,enam`
39-
);
35+
await expect(runWrangler("d1 create test --location sydney")).rejects
36+
.toThrowErrorMatchingInlineSnapshot(`
37+
[Error: Invalid values:
38+
Argument: location, Given: "sydney", Choices: "weur", "eeur", "apac", "oc", "wnam", "enam"]
39+
`);
4040
});
4141

4242
it("should try send a request to the API for a valid input", async () => {

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("d1", () => {
1919
COMMANDS
2020
wrangler d1 list List D1 databases
2121
wrangler d1 info <name> Get information about a D1 database, including the current database size and state
22-
wrangler d1 insights <name> Experimental command. Get information about the queries run on a D1 database.
22+
wrangler d1 insights <name> Get information about the queries run on a D1 database. [experimental]
2323
wrangler d1 create <name> Create D1 database
2424
wrangler d1 delete <name> Delete D1 database
2525
wrangler d1 execute <database> Execute a command or SQL file
@@ -55,7 +55,7 @@ describe("d1", () => {
5555
COMMANDS
5656
wrangler d1 list List D1 databases
5757
wrangler d1 info <name> Get information about a D1 database, including the current database size and state
58-
wrangler d1 insights <name> Experimental command. Get information about the queries run on a D1 database.
58+
wrangler d1 insights <name> Get information about the queries run on a D1 database. [experimental]
5959
wrangler d1 create <name> Create D1 database
6060
wrangler d1 delete <name> Delete D1 database
6161
wrangler d1 execute <database> Execute a command or SQL file
@@ -73,18 +73,11 @@ describe("d1", () => {
7373
});
7474

7575
it("should show help when the migrations command is passed", async () => {
76-
await expect(() => runWrangler("d1 migrations")).rejects.toThrow(
77-
"Not enough non-option arguments: got 0, need at least 1"
78-
);
79-
80-
expect(std.err).toMatchInlineSnapshot(`
81-
"X [ERROR] Not enough non-option arguments: got 0, need at least 1
76+
await runWrangler("d1 migrations");
77+
await endEventLoop();
8278

83-
"
84-
`);
8579
expect(std.out).toMatchInlineSnapshot(`
86-
"
87-
wrangler d1 migrations
80+
"wrangler d1 migrations
8881
8982
Interact with D1 migrations
9083
@@ -103,18 +96,10 @@ describe("d1", () => {
10396
});
10497

10598
it("should show help when the time travel command is passed", async () => {
106-
await expect(() => runWrangler("d1 time-travel")).rejects.toThrow(
107-
"Not enough non-option arguments: got 0, need at least 1"
108-
);
109-
110-
expect(std.err).toMatchInlineSnapshot(`
111-
"X [ERROR] Not enough non-option arguments: got 0, need at least 1
112-
113-
"
114-
`);
99+
await runWrangler("d1 time-travel");
100+
await endEventLoop();
115101
expect(std.out).toMatchInlineSnapshot(`
116-
"
117-
wrangler d1 time-travel
102+
"wrangler d1 time-travel
118103
119104
Use Time Travel to restore, fork or copy a database at a specific point-in-time
120105

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("wrangler", () => {
4444
wrangler deployments 🚢 List and view the current and past deployments for your Worker
4545
wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker
4646
wrangler versions 🫧 List, view, upload and deploy Versions of your Worker to Cloudflare
47-
wrangler triggers 🎯 Updates the triggers of your current deployment
47+
wrangler triggers 🎯 Updates the triggers of your current deployment [experimental]
4848
wrangler delete [script] 🗑 Delete a Worker from Cloudflare
4949
wrangler tail [worker] 🦚 Start a log tailing session for a Worker
5050
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
@@ -54,7 +54,7 @@ describe("wrangler", () => {
5454
wrangler queues 🇶 Manage Workers Queues
5555
wrangler r2 📦 Manage R2 buckets & objects
5656
wrangler d1 🗄 Manage Workers D1 databases
57-
wrangler vectorize 🧮 Manage Vectorize indexes [open beta]
57+
wrangler vectorize 🧮 Manage Vectorize indexes
5858
wrangler hyperdrive 🚀 Manage Hyperdrive databases
5959
wrangler cert 🪪 Manage client mTLS certificates and CA certificate chains used for secured connections [open-beta]
6060
wrangler pages ⚡️ Configure Cloudflare Pages
@@ -63,7 +63,7 @@ describe("wrangler", () => {
6363
wrangler dispatch-namespace 🏗️ Manage dispatch namespaces
6464
wrangler ai 🤖 Manage AI models
6565
wrangler workflows 🔁 Manage Workflows
66-
wrangler pipelines 🚰 Manage Cloudflare Pipelines [open beta]
66+
wrangler pipelines 🚰 Manage Cloudflare Pipelines [open-beta]
6767
wrangler login 🔓 Login to Cloudflare
6868
wrangler logout 🚪 Logout from Cloudflare
6969
wrangler whoami 🕵️ Retrieve your user information
@@ -104,7 +104,7 @@ describe("wrangler", () => {
104104
wrangler deployments 🚢 List and view the current and past deployments for your Worker
105105
wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker
106106
wrangler versions 🫧 List, view, upload and deploy Versions of your Worker to Cloudflare
107-
wrangler triggers 🎯 Updates the triggers of your current deployment
107+
wrangler triggers 🎯 Updates the triggers of your current deployment [experimental]
108108
wrangler delete [script] 🗑 Delete a Worker from Cloudflare
109109
wrangler tail [worker] 🦚 Start a log tailing session for a Worker
110110
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
@@ -114,7 +114,7 @@ describe("wrangler", () => {
114114
wrangler queues 🇶 Manage Workers Queues
115115
wrangler r2 📦 Manage R2 buckets & objects
116116
wrangler d1 🗄 Manage Workers D1 databases
117-
wrangler vectorize 🧮 Manage Vectorize indexes [open beta]
117+
wrangler vectorize 🧮 Manage Vectorize indexes
118118
wrangler hyperdrive 🚀 Manage Hyperdrive databases
119119
wrangler cert 🪪 Manage client mTLS certificates and CA certificate chains used for secured connections [open-beta]
120120
wrangler pages ⚡️ Configure Cloudflare Pages
@@ -123,7 +123,7 @@ describe("wrangler", () => {
123123
wrangler dispatch-namespace 🏗️ Manage dispatch namespaces
124124
wrangler ai 🤖 Manage AI models
125125
wrangler workflows 🔁 Manage Workflows
126-
wrangler pipelines 🚰 Manage Cloudflare Pipelines [open beta]
126+
wrangler pipelines 🚰 Manage Cloudflare Pipelines [open-beta]
127127
wrangler login 🔓 Login to Cloudflare
128128
wrangler logout 🚪 Logout from Cloudflare
129129
wrangler whoami 🕵️ Retrieve your user information

packages/wrangler/src/__tests__/pages/deploy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ and that at least one include rule is provided.
30553055

30563056
await expect(runWrangler("pages deploy public --project-name=foo"))
30573057
.rejects.toThrow(`Deployment failed!
3058-
Failed to publish your Function. Got error: Uncaught TypeError: a is not a function
3058+
Failed to publish your Function. Got error: Uncaught TypeError: a is not a function
30593059
at functionsWorker-0.11031665179307093.js:41:1`);
30603060
});
30613061
});
@@ -4711,7 +4711,7 @@ and that at least one include rule is provided.
47114711

47124712
await expect(runWrangler("pages deploy public --project-name=foo"))
47134713
.rejects.toThrow(`Deployment failed!
4714-
Failed to publish your Function. Got error: Uncaught TypeError: a is not a function
4714+
Failed to publish your Function. Got error: Uncaught TypeError: a is not a function
47154715
at functionsWorker-0.11031665179307093.js:41:1`);
47164716
});
47174717
});

packages/wrangler/src/__tests__/pages/pages-deployment-tail.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import type {
2121
import type { RequestInit } from "undici";
2222
import type WebSocket from "ws";
2323

24-
// we want to include the banner to make sure it doesn't show up in the output when
25-
// when --format=json
24+
// we want to include the banner to make sure it doesn't show up in the output when --format=json
2625
vi.unmock("../../wrangler-banner");
2726
vi.mock("ws", async (importOriginal) => {
2827
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
@@ -52,6 +51,7 @@ vi.mock("ws", async (importOriginal) => {
5251

5352
describe("pages deployment tail", () => {
5453
runInTempDir();
54+
const { setIsTTY } = useMockIsTTY();
5555

5656
let api: MockAPI;
5757
afterEach(async () => {
@@ -65,11 +65,6 @@ describe("pages deployment tail", () => {
6565
mockApiToken();
6666
const std = mockConsoleMethods();
6767

68-
beforeEach(() => {
69-
// Force the CLI to be "non-interactive" in test env
70-
vi.stubEnv("CF_PAGES", "1");
71-
});
72-
7368
/**
7469
* Interaction with the tailing API, including tail creation,
7570
* deletion, and connection.
@@ -417,8 +412,6 @@ describe("pages deployment tail", () => {
417412
});
418413

419414
describe("printing", () => {
420-
const { setIsTTY } = useMockIsTTY();
421-
422415
it("logs request messages in JSON format", async () => {
423416
api = mockTailAPIs();
424417
await runWrangler(

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ describe("pages", () => {
2323
⚡️ Configure Cloudflare Pages
2424
2525
COMMANDS
26-
wrangler pages dev [directory] [-- command..] Develop your full-stack Pages application locally
27-
wrangler pages functions Helpers related to Pages Functions
28-
wrangler pages project Interact with your Pages projects
29-
wrangler pages deployment Interact with the deployments of a project
30-
wrangler pages deploy [directory] Deploy a directory of static assets as a Pages deployment [aliases: publish]
31-
wrangler pages secret Generate a secret that can be referenced in a Pages project
32-
wrangler pages download Download settings from your project
26+
wrangler pages dev [directory] [command] Develop your full-stack Pages application locally
27+
wrangler pages functions Helpers related to Pages Functions
28+
wrangler pages project Interact with your Pages projects
29+
wrangler pages deployment Interact with the deployments of a project
30+
wrangler pages deploy [directory] Deploy a directory of static assets as a Pages deployment
31+
wrangler pages secret Generate a secret that can be referenced in a Pages project
32+
wrangler pages download Download settings from your project
3333
3434
GLOBAL FLAGS
3535
--cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
@@ -43,7 +43,7 @@ describe("pages", () => {
4343
await endEventLoop();
4444

4545
expect(std.out).toMatchInlineSnapshot(`
46-
"wrangler pages dev [directory] [-- command..]
46+
"wrangler pages dev [directory] [command]
4747
4848
Develop your full-stack Pages application locally
4949
@@ -96,8 +96,8 @@ describe("pages", () => {
9696
9797
COMMANDS
9898
wrangler pages project list List your Cloudflare Pages projects
99-
wrangler pages project create [project-name] Create a new Cloudflare Pages project
100-
wrangler pages project delete [project-name] Delete a Cloudflare Pages project
99+
wrangler pages project create <project-name> Create a new Cloudflare Pages project
100+
wrangler pages project delete <project-name> Delete a Cloudflare Pages project
101101
102102
GLOBAL FLAGS
103103
--cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
@@ -117,7 +117,9 @@ describe("pages", () => {
117117
118118
COMMANDS
119119
wrangler pages deployment list List deployments in your Cloudflare Pages project
120-
wrangler pages deployment create [directory] Publish a directory of static assets as a Pages deployment
120+
wrangler pages deployment create [directory] Deploy a directory of static assets as a Pages deployment
121+
122+
Alias for \\"wrangler pages deploy\\".
121123
wrangler pages deployment tail [deployment] Start a tailing session for a project's deployment and livestream logs from your Functions
122124
123125
GLOBAL FLAGS
@@ -188,7 +190,7 @@ describe("pages", () => {
188190
Download settings from your project
189191
190192
COMMANDS
191-
wrangler pages download config [projectName] Experimental: Download your Pages project config as a Wrangler configuration file
193+
wrangler pages download config [projectName] Download your Pages project config as a Wrangler configuration file [experimental]
192194
193195
GLOBAL FLAGS
194196
--cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]

packages/wrangler/src/__tests__/pages/project-delete.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe("pages project delete", () => {
6767
await expect(
6868
runWrangler("pages project delete")
6969
).rejects.toThrowErrorMatchingInlineSnapshot(
70-
`[Error: Missing required argument: project-name]`
70+
`[Error: Not enough non-option arguments: got 0, need at least 1]`
7171
);
7272
});
7373

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,14 @@ describe("pipelines", () => {
274274
expect(std.out).toMatchInlineSnapshot(`
275275
"wrangler pipelines
276276
277-
🚰 Manage Cloudflare Pipelines [open beta]
277+
🚰 Manage Cloudflare Pipelines [open-beta]
278278
279279
COMMANDS
280-
wrangler pipelines create <pipeline> Create a new pipeline
281-
wrangler pipelines list List all pipelines
282-
wrangler pipelines get <pipeline> Get a pipeline's configuration
283-
wrangler pipelines update <pipeline> Update a pipeline
284-
wrangler pipelines delete <pipeline> Delete a pipeline
280+
wrangler pipelines create <pipeline> Create a new pipeline [open-beta]
281+
wrangler pipelines list List all pipelines [open-beta]
282+
wrangler pipelines get <pipeline> Get a pipeline's configuration [open-beta]
283+
wrangler pipelines update <pipeline> Update a pipeline [open-beta]
284+
wrangler pipelines delete <pipeline> Delete a pipeline [open-beta]
285285
286286
GLOBAL FLAGS
287287
-c, --config Path to Wrangler configuration file [string]
@@ -301,10 +301,7 @@ describe("pipelines", () => {
301301
expect(std.out).toMatchInlineSnapshot(`
302302
"wrangler pipelines create <pipeline>
303303
304-
Create a new pipeline
305-
306-
POSITIONALS
307-
pipeline The name of the new pipeline [string] [required]
304+
Create a new pipeline [open-beta]
308305
309306
Source settings
310307
--source Space separated list of allowed sources. Options are 'http' or 'worker' [array] [default: [\\"http\\",\\"worker\\"]]
@@ -326,6 +323,9 @@ describe("pipelines", () => {
326323
Pipeline settings
327324
--shard-count Number of shards for the pipeline. More shards handle higher request volume; fewer shards produce larger output files. Defaults to 2 if unset. Minimum: 1, Maximum: 15 [number]
328325
326+
POSITIONALS
327+
pipeline The name of the new pipeline [string] [required]
328+
329329
GLOBAL FLAGS
330330
-c, --config Path to Wrangler configuration file [string]
331331
--cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]

0 commit comments

Comments
 (0)