wrangler 2.8.1 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/miniflare-dist/index.mjs +1 -14
  2. package/package.json +2 -2
  3. package/src/__tests__/d1/d1.test.ts +11 -56
  4. package/src/__tests__/d1/migrate.test.ts +141 -0
  5. package/src/__tests__/dev.test.tsx +5 -4
  6. package/src/__tests__/generate.test.ts +1 -1
  7. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  8. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  9. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  10. package/src/__tests__/index.test.ts +36 -32
  11. package/src/__tests__/init.test.ts +1 -1
  12. package/src/__tests__/kv.test.ts +55 -44
  13. package/src/__tests__/pages/deployment-list.test.ts +78 -0
  14. package/src/__tests__/pages/pages.test.ts +81 -0
  15. package/src/__tests__/pages/project-create.test.ts +63 -0
  16. package/src/__tests__/pages/project-list.test.ts +108 -0
  17. package/src/__tests__/pages/project-upload.test.ts +481 -0
  18. package/src/__tests__/pages/publish.test.ts +2221 -0
  19. package/src/__tests__/parse.test.ts +106 -0
  20. package/src/__tests__/pubsub.test.ts +15 -12
  21. package/src/__tests__/queues.test.ts +35 -28
  22. package/src/__tests__/r2.test.ts +25 -20
  23. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  24. package/src/__tests__/worker-namespace.test.ts +26 -21
  25. package/src/api/dev.ts +80 -11
  26. package/src/api/pages/publish.tsx +7 -4
  27. package/src/bundle.ts +1 -1
  28. package/src/config/config.ts +7 -0
  29. package/src/config/index.ts +24 -20
  30. package/src/d1/backups.tsx +20 -24
  31. package/src/d1/create.tsx +6 -5
  32. package/src/d1/delete.ts +7 -10
  33. package/src/d1/execute.tsx +83 -85
  34. package/src/d1/index.ts +5 -6
  35. package/src/d1/list.tsx +21 -9
  36. package/src/d1/migrations/apply.tsx +13 -9
  37. package/src/d1/migrations/create.tsx +9 -10
  38. package/src/d1/migrations/list.tsx +19 -9
  39. package/src/d1/migrations/options.ts +2 -2
  40. package/src/d1/options.ts +3 -3
  41. package/src/delete.ts +5 -8
  42. package/src/deprecated/index.ts +7 -8
  43. package/src/dev.tsx +42 -80
  44. package/src/dispatch-namespace.ts +20 -16
  45. package/src/docs/index.ts +7 -8
  46. package/src/generate/index.ts +5 -7
  47. package/src/index.ts +22 -21
  48. package/src/init.ts +5 -7
  49. package/src/kv/index.ts +15 -17
  50. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  51. package/src/pages/build.ts +6 -4
  52. package/src/pages/deployment-tails.ts +7 -10
  53. package/src/pages/deployments.tsx +6 -4
  54. package/src/pages/dev.ts +15 -17
  55. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  56. package/src/pages/functions.ts +8 -4
  57. package/src/pages/index.ts +3 -3
  58. package/src/pages/projects.tsx +7 -12
  59. package/src/pages/publish.tsx +6 -4
  60. package/src/pages/types.ts +5 -0
  61. package/src/pages/upload.tsx +6 -4
  62. package/src/parse.ts +23 -1
  63. package/src/publish/index.ts +19 -15
  64. package/src/publish/publish.ts +2 -2
  65. package/src/pubsub/pubsub-commands.ts +18 -19
  66. package/src/queues/cli/commands/consumer/add.ts +18 -24
  67. package/src/queues/cli/commands/consumer/index.ts +3 -6
  68. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  69. package/src/queues/cli/commands/create.ts +8 -8
  70. package/src/queues/cli/commands/delete.ts +8 -8
  71. package/src/queues/cli/commands/index.ts +3 -4
  72. package/src/queues/cli/commands/list.ts +8 -8
  73. package/src/r2/index.ts +28 -28
  74. package/src/secret/index.ts +9 -14
  75. package/src/tail/index.ts +6 -8
  76. package/src/yargs-types.ts +18 -5
  77. package/templates/checked-fetch.js +9 -1
  78. package/templates/tsconfig.init.json +1 -1
  79. package/templates/tsconfig.tsbuildinfo +1 -1
  80. package/wrangler-dist/cli.js +2180 -1799
  81. package/src/__tests__/pages.test.ts +0 -2898
@@ -4,6 +4,7 @@ import {
4
4
  indexLocation,
5
5
  parseJSON,
6
6
  parseTOML,
7
+ parseJSONC,
7
8
  } from "../parse";
8
9
  import type { Message } from "../parse";
9
10
 
@@ -257,7 +258,112 @@ describe("parseJSON", () => {
257
258
  }
258
259
  });
259
260
  });
261
+ describe("parseJSONC", () => {
262
+ it("should parse jsonc that is empty", () => {
263
+ expect(parseJSONC("{}")).toStrictEqual({});
264
+ });
265
+
266
+ it("should parse jsonc with basic values", () => {
267
+ expect(
268
+ parseJSONC(`
269
+ {
270
+ "name" : "basic",
271
+ "version": 1
272
+ }`)
273
+ ).toStrictEqual({
274
+ name: "basic",
275
+ version: 1,
276
+ });
277
+ });
278
+
279
+ it("should parse jsonc with complex values", () => {
280
+ expect(
281
+ parseJSONC(
282
+ `{
283
+ "name":"complex",
284
+ "spec":{
285
+ "uptime":[1,2.5,3],
286
+ "ok":true
287
+ }
288
+ }`
289
+ )
290
+ ).toStrictEqual({
291
+ name: "complex",
292
+ spec: {
293
+ uptime: [1, 2.5, 3],
294
+ ok: true,
295
+ },
296
+ });
297
+ });
260
298
 
299
+ it("should parse jsonc with comments", () => {
300
+ expect(
301
+ parseJSONC(
302
+ `{
303
+ // Comment A
304
+ "name":"complex",
305
+ "spec":{
306
+ // Nested comment
307
+ "uptime":[1,2.5,3],
308
+ "ok":true
309
+ }
310
+ }`
311
+ )
312
+ ).toStrictEqual({
313
+ name: "complex",
314
+ spec: {
315
+ uptime: [1, 2.5, 3],
316
+ ok: true,
317
+ },
318
+ });
319
+ });
320
+
321
+ it("should fail to parse jsonc with invalid string", () => {
322
+ try {
323
+ parseJSONC(`\n{\n"version" "1\n}\n`);
324
+ fail("parseJSONC did not throw");
325
+ } catch (err) {
326
+ expect({ ...(err as Error) }).toStrictEqual({
327
+ name: "ParseError",
328
+ text: "UnexpectedEndOfString",
329
+ kind: "error",
330
+ location: {
331
+ length: 2,
332
+ line: 3,
333
+ column: 10,
334
+ lineText: '"version" "1',
335
+ file: undefined,
336
+ fileText: `\n{\n"version" "1\n}\n`,
337
+ },
338
+ notes: [],
339
+ });
340
+ }
341
+ });
342
+
343
+ it("should fail to parse jsonc with invalid number", () => {
344
+ const file = "config.json",
345
+ fileText = `{\n\t"a":{\n\t\t"b":{\n\t\t\t"c":[012345]\n}\n}\n}`;
346
+ try {
347
+ parseJSONC(fileText, file);
348
+ fail("parseJSONC did not throw");
349
+ } catch (err) {
350
+ expect({ ...(err as Error) }).toStrictEqual({
351
+ name: "ParseError",
352
+ text: "CommaExpected",
353
+ kind: "error",
354
+ location: {
355
+ file,
356
+ fileText,
357
+ length: 5,
358
+ line: 4,
359
+ column: 9,
360
+ lineText: `\t\t\t"c":[012345]`,
361
+ },
362
+ notes: [],
363
+ });
364
+ }
365
+ });
366
+ });
261
367
  describe("indexLocation", () => {
262
368
  it("should calculate location from one-line input", () => {
263
369
  const fileText = "";
@@ -34,10 +34,11 @@ describe("wrangler", () => {
34
34
  wrangler pubsub broker Interact with your Pub/Sub Brokers
35
35
 
36
36
  Flags:
37
- -c, --config Path to .toml configuration file [string]
38
- -e, --env Environment to use for operations and .env files [string]
39
- -h, --help Show help [boolean]
40
- -v, --version Show version number [boolean]
37
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
38
+ -c, --config Path to .toml configuration file [string]
39
+ -e, --env Environment to use for operations and .env files [string]
40
+ -h, --help Show help [boolean]
41
+ -v, --version Show version number [boolean]
41
42
 
42
43
  👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
43
44
  "warn": "",
@@ -65,10 +66,11 @@ describe("wrangler", () => {
65
66
  wrangler pubsub namespace describe <name> Describe a Pub/Sub Namespace
66
67
 
67
68
  Flags:
68
- -c, --config Path to .toml configuration file [string]
69
- -e, --env Environment to use for operations and .env files [string]
70
- -h, --help Show help [boolean]
71
- -v, --version Show version number [boolean]
69
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
70
+ -c, --config Path to .toml configuration file [string]
71
+ -e, --env Environment to use for operations and .env files [string]
72
+ -h, --help Show help [boolean]
73
+ -v, --version Show version number [boolean]
72
74
 
73
75
  👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
74
76
  "warn": "",
@@ -186,10 +188,11 @@ describe("wrangler", () => {
186
188
  wrangler pubsub broker public-keys <name> Show the public keys used for verifying on-publish hooks and credentials for a Broker.
187
189
 
188
190
  Flags:
189
- -c, --config Path to .toml configuration file [string]
190
- -e, --env Environment to use for operations and .env files [string]
191
- -h, --help Show help [boolean]
192
- -v, --version Show version number [boolean]
191
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
192
+ -c, --config Path to .toml configuration file [string]
193
+ -e, --env Environment to use for operations and .env files [string]
194
+ -h, --help Show help [boolean]
195
+ -v, --version Show version number [boolean]
193
196
 
194
197
  👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
195
198
  "warn": "",
@@ -28,10 +28,11 @@ describe("wrangler", () => {
28
28
  wrangler queues consumer Configure Queue Consumers
29
29
 
30
30
  Flags:
31
- -c, --config Path to .toml configuration file [string]
32
- -e, --env Environment to use for operations and .env files [string]
33
- -h, --help Show help [boolean]
34
- -v, --version Show version number [boolean]"
31
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
32
+ -c, --config Path to .toml configuration file [string]
33
+ -e, --env Environment to use for operations and .env files [string]
34
+ -h, --help Show help [boolean]
35
+ -v, --version Show version number [boolean]"
35
36
  `);
36
37
  });
37
38
 
@@ -69,10 +70,11 @@ describe("wrangler", () => {
69
70
  List Queues
70
71
 
71
72
  Flags:
72
- -c, --config Path to .toml configuration file [string]
73
- -e, --env Environment to use for operations and .env files [string]
74
- -h, --help Show help [boolean]
75
- -v, --version Show version number [boolean]
73
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
74
+ -c, --config Path to .toml configuration file [string]
75
+ -e, --env Environment to use for operations and .env files [string]
76
+ -h, --help Show help [boolean]
77
+ -v, --version Show version number [boolean]
76
78
 
77
79
  Options:
78
80
  --page Page number for pagination [number]"
@@ -162,10 +164,11 @@ describe("wrangler", () => {
162
164
  name The name of the queue [string] [required]
163
165
 
164
166
  Flags:
165
- -c, --config Path to .toml configuration file [string]
166
- -e, --env Environment to use for operations and .env files [string]
167
- -h, --help Show help [boolean]
168
- -v, --version Show version number [boolean]"
167
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
168
+ -c, --config Path to .toml configuration file [string]
169
+ -e, --env Environment to use for operations and .env files [string]
170
+ -h, --help Show help [boolean]
171
+ -v, --version Show version number [boolean]"
169
172
  `);
170
173
  });
171
174
 
@@ -255,10 +258,11 @@ describe("wrangler", () => {
255
258
  name The name of the queue [string] [required]
256
259
 
257
260
  Flags:
258
- -c, --config Path to .toml configuration file [string]
259
- -e, --env Environment to use for operations and .env files [string]
260
- -h, --help Show help [boolean]
261
- -v, --version Show version number [boolean]"
261
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
262
+ -c, --config Path to .toml configuration file [string]
263
+ -e, --env Environment to use for operations and .env files [string]
264
+ -h, --help Show help [boolean]
265
+ -v, --version Show version number [boolean]"
262
266
  `);
263
267
  });
264
268
 
@@ -288,10 +292,11 @@ describe("wrangler", () => {
288
292
  wrangler queues consumer remove <queue-name> <script-name> Remove a Queue Consumer
289
293
 
290
294
  Flags:
291
- -c, --config Path to .toml configuration file [string]
292
- -e, --env Environment to use for operations and .env files [string]
293
- -h, --help Show help [boolean]
294
- -v, --version Show version number [boolean]"
295
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
296
+ -c, --config Path to .toml configuration file [string]
297
+ -e, --env Environment to use for operations and .env files [string]
298
+ -h, --help Show help [boolean]
299
+ -v, --version Show version number [boolean]"
295
300
  `);
296
301
  });
297
302
 
@@ -336,10 +341,11 @@ describe("wrangler", () => {
336
341
  script-name Name of the consumer script [string] [required]
337
342
 
338
343
  Flags:
339
- -c, --config Path to .toml configuration file [string]
340
- -e, --env Environment to use for operations and .env files [string]
341
- -h, --help Show help [boolean]
342
- -v, --version Show version number [boolean]
344
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
345
+ -c, --config Path to .toml configuration file [string]
346
+ -e, --env Environment to use for operations and .env files [string]
347
+ -h, --help Show help [boolean]
348
+ -v, --version Show version number [boolean]
343
349
 
344
350
  Options:
345
351
  --batch-size Maximum number of messages per batch [number]
@@ -482,10 +488,11 @@ describe("wrangler", () => {
482
488
  script-name Name of the consumer script [string] [required]
483
489
 
484
490
  Flags:
485
- -c, --config Path to .toml configuration file [string]
486
- -e, --env Environment to use for operations and .env files [string]
487
- -h, --help Show help [boolean]
488
- -v, --version Show version number [boolean]"
491
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
492
+ -c, --config Path to .toml configuration file [string]
493
+ -e, --env Environment to use for operations and .env files [string]
494
+ -h, --help Show help [boolean]
495
+ -v, --version Show version number [boolean]"
489
496
  `);
490
497
  });
491
498
 
@@ -39,10 +39,11 @@ describe("r2", () => {
39
39
  wrangler r2 bucket delete <name> Delete an R2 bucket
40
40
 
41
41
  Flags:
42
- -c, --config Path to .toml configuration file [string]
43
- -e, --env Environment to use for operations and .env files [string]
44
- -h, --help Show help [boolean]
45
- -v, --version Show version number [boolean]"
42
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
43
+ -c, --config Path to .toml configuration file [string]
44
+ -e, --env Environment to use for operations and .env files [string]
45
+ -h, --help Show help [boolean]
46
+ -v, --version Show version number [boolean]"
46
47
  `);
47
48
  });
48
49
 
@@ -103,10 +104,11 @@ describe("r2", () => {
103
104
  name The name of the new bucket [string] [required]
104
105
 
105
106
  Flags:
106
- -c, --config Path to .toml configuration file [string]
107
- -e, --env Environment to use for operations and .env files [string]
108
- -h, --help Show help [boolean]
109
- -v, --version Show version number [boolean]"
107
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
108
+ -c, --config Path to .toml configuration file [string]
109
+ -e, --env Environment to use for operations and .env files [string]
110
+ -h, --help Show help [boolean]
111
+ -v, --version Show version number [boolean]"
110
112
  `);
111
113
  expect(std.err).toMatchInlineSnapshot(`
112
114
  "X [ERROR] Not enough non-option arguments: got 0, need at least 1
@@ -131,10 +133,11 @@ describe("r2", () => {
131
133
  name The name of the new bucket [string] [required]
132
134
 
133
135
  Flags:
134
- -c, --config Path to .toml configuration file [string]
135
- -e, --env Environment to use for operations and .env files [string]
136
- -h, --help Show help [boolean]
137
- -v, --version Show version number [boolean]"
136
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
137
+ -c, --config Path to .toml configuration file [string]
138
+ -e, --env Environment to use for operations and .env files [string]
139
+ -h, --help Show help [boolean]
140
+ -v, --version Show version number [boolean]"
138
141
  `);
139
142
  expect(std.err).toMatchInlineSnapshot(`
140
143
  "X [ERROR] Unknown arguments: def, ghi
@@ -180,10 +183,11 @@ describe("r2", () => {
180
183
  name The name of the bucket to delete [string] [required]
181
184
 
182
185
  Flags:
183
- -c, --config Path to .toml configuration file [string]
184
- -e, --env Environment to use for operations and .env files [string]
185
- -h, --help Show help [boolean]
186
- -v, --version Show version number [boolean]"
186
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
187
+ -c, --config Path to .toml configuration file [string]
188
+ -e, --env Environment to use for operations and .env files [string]
189
+ -h, --help Show help [boolean]
190
+ -v, --version Show version number [boolean]"
187
191
  `);
188
192
  expect(std.err).toMatchInlineSnapshot(`
189
193
  "X [ERROR] Not enough non-option arguments: got 0, need at least 1
@@ -208,10 +212,11 @@ describe("r2", () => {
208
212
  name The name of the bucket to delete [string] [required]
209
213
 
210
214
  Flags:
211
- -c, --config Path to .toml configuration file [string]
212
- -e, --env Environment to use for operations and .env files [string]
213
- -h, --help Show help [boolean]
214
- -v, --version Show version number [boolean]"
215
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
216
+ -c, --config Path to .toml configuration file [string]
217
+ -e, --env Environment to use for operations and .env files [string]
218
+ -h, --help Show help [boolean]
219
+ -v, --version Show version number [boolean]"
215
220
  `);
216
221
  expect(std.err).toMatchInlineSnapshot(`
217
222
  "X [ERROR] Unknown arguments: def, ghi