wrangler 0.0.0-e6c9c5c0 → 0.0.0-e6e1daba

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 (126) hide show
  1. package/README.md +3 -3
  2. package/miniflare-dist/index.mjs +22 -18
  3. package/package.json +12 -12
  4. package/src/__tests__/configuration.test.ts +70 -0
  5. package/src/__tests__/d1/d1.test.ts +13 -58
  6. package/src/__tests__/d1/execute.test.ts +64 -0
  7. package/src/__tests__/d1/migrate.test.ts +155 -0
  8. package/src/__tests__/deployments.test.ts +40 -16
  9. package/src/__tests__/dev.test.tsx +8 -7
  10. package/src/__tests__/generate.test.ts +1 -1
  11. package/src/__tests__/guess-worker-format.test.ts +35 -0
  12. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  13. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  14. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  15. package/src/__tests__/helpers/msw/handlers/deployments.ts +40 -16
  16. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  17. package/src/__tests__/index.test.ts +38 -32
  18. package/src/__tests__/init.test.ts +1 -1
  19. package/src/__tests__/kv.test.ts +63 -52
  20. package/src/__tests__/middleware.test.ts +65 -0
  21. package/src/__tests__/mtls-certificates.test.ts +585 -0
  22. package/src/__tests__/pages/deployment-list.test.ts +78 -0
  23. package/src/__tests__/pages/functions-build.test.ts +402 -0
  24. package/src/__tests__/pages/pages.test.ts +81 -0
  25. package/src/__tests__/pages/project-create.test.ts +63 -0
  26. package/src/__tests__/pages/project-list.test.ts +108 -0
  27. package/src/__tests__/pages/project-upload.test.ts +481 -0
  28. package/src/__tests__/pages/publish.test.ts +2745 -0
  29. package/src/__tests__/parse.test.ts +106 -0
  30. package/src/__tests__/publish.test.ts +80 -30
  31. package/src/__tests__/pubsub.test.ts +15 -12
  32. package/src/__tests__/queues.test.ts +37 -30
  33. package/src/__tests__/r2.test.ts +25 -20
  34. package/src/__tests__/secret.test.ts +4 -4
  35. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  36. package/src/__tests__/user.test.ts +1 -1
  37. package/src/__tests__/whoami.test.tsx +1 -1
  38. package/src/__tests__/worker-namespace.test.ts +26 -21
  39. package/src/api/dev.ts +80 -11
  40. package/src/api/index.ts +8 -0
  41. package/src/api/mtls-certificate.ts +148 -0
  42. package/src/api/pages/create-worker-bundle-contents.ts +75 -0
  43. package/src/api/pages/publish.tsx +59 -12
  44. package/src/bundle.ts +9 -7
  45. package/src/config/config.ts +14 -7
  46. package/src/config/environment.ts +9 -2
  47. package/src/config/index.ts +37 -20
  48. package/src/config/validation.ts +50 -3
  49. package/src/create-worker-preview.ts +19 -8
  50. package/src/create-worker-upload-form.ts +9 -0
  51. package/src/d1/backups.tsx +20 -24
  52. package/src/d1/create.tsx +6 -5
  53. package/src/d1/delete.ts +7 -10
  54. package/src/d1/execute.tsx +174 -143
  55. package/src/d1/index.ts +5 -6
  56. package/src/d1/list.tsx +21 -9
  57. package/src/d1/migrations/apply.tsx +42 -33
  58. package/src/d1/migrations/create.tsx +16 -17
  59. package/src/d1/migrations/helpers.ts +63 -38
  60. package/src/d1/migrations/list.tsx +37 -24
  61. package/src/d1/migrations/options.ts +7 -2
  62. package/src/d1/options.ts +3 -3
  63. package/src/d1/types.ts +1 -0
  64. package/src/d1/utils.ts +2 -1
  65. package/src/delete.ts +5 -8
  66. package/src/deployments.ts +62 -39
  67. package/src/deprecated/index.ts +7 -8
  68. package/src/dev/dev.tsx +1 -15
  69. package/src/dev/local.tsx +5 -6
  70. package/src/dev/remote.tsx +2 -2
  71. package/src/dev.tsx +51 -86
  72. package/src/dispatch-namespace.ts +20 -16
  73. package/src/docs/index.ts +7 -8
  74. package/src/entry.ts +1 -2
  75. package/src/generate/index.ts +6 -8
  76. package/src/index.ts +37 -26
  77. package/src/init.ts +5 -7
  78. package/src/inspect.ts +16 -1
  79. package/src/kv/index.ts +15 -17
  80. package/src/miniflare-cli/assets.ts +9 -8
  81. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  82. package/src/mtls-certificate/cli.ts +155 -0
  83. package/src/pages/build.ts +109 -27
  84. package/src/pages/buildFunctions.ts +32 -31
  85. package/src/pages/deployment-tails.ts +7 -10
  86. package/src/pages/deployments.tsx +6 -4
  87. package/src/pages/dev.ts +19 -19
  88. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  89. package/src/pages/functions.ts +8 -4
  90. package/src/pages/index.ts +3 -3
  91. package/src/pages/projects.tsx +7 -12
  92. package/src/pages/publish.tsx +18 -5
  93. package/src/pages/types.ts +5 -0
  94. package/src/pages/upload.tsx +6 -4
  95. package/src/pages/utils.ts +1 -1
  96. package/src/parse.ts +23 -1
  97. package/src/publish/index.ts +19 -15
  98. package/src/publish/publish.ts +5 -4
  99. package/src/pubsub/pubsub-commands.ts +18 -19
  100. package/src/queues/cli/commands/consumer/add.ts +18 -24
  101. package/src/queues/cli/commands/consumer/index.ts +3 -6
  102. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  103. package/src/queues/cli/commands/create.ts +8 -8
  104. package/src/queues/cli/commands/delete.ts +8 -8
  105. package/src/queues/cli/commands/index.ts +3 -4
  106. package/src/queues/cli/commands/list.ts +8 -8
  107. package/src/r2/helpers.ts +1 -0
  108. package/src/r2/index.ts +28 -28
  109. package/src/secret/index.ts +10 -14
  110. package/src/sites.ts +1 -1
  111. package/src/tail/filters.ts +1 -1
  112. package/src/tail/index.ts +6 -8
  113. package/src/user/user.ts +4 -3
  114. package/src/worker.ts +6 -0
  115. package/src/yargs-types.ts +18 -5
  116. package/templates/checked-fetch.js +9 -1
  117. package/templates/format-dev-errors.ts +1 -0
  118. package/templates/new-worker.ts +3 -0
  119. package/templates/pages-template-plugin.ts +7 -3
  120. package/templates/serve-static-assets.ts +1 -0
  121. package/templates/service-bindings-module-facade.js +1 -0
  122. package/templates/tsconfig.init.json +1 -1
  123. package/templates/tsconfig.tsbuildinfo +1 -1
  124. package/wrangler-dist/cli.d.ts +596 -3
  125. package/wrangler-dist/cli.js +14276 -6748
  126. 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 = "";
@@ -137,7 +137,7 @@ describe("publish", () => {
137
137
 
138
138
  expect(std.out).toMatchInlineSnapshot(`
139
139
  "Attempting to login via OAuth...
140
- Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
140
+ Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20ssl_certs%3Awrite%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
141
141
  Successfully logged in.
142
142
  Total Upload: xx KiB / gzip: xx KiB
143
143
  Uploaded test-name (TIMINGS)
@@ -177,7 +177,7 @@ describe("publish", () => {
177
177
 
178
178
  expect(std.out).toMatchInlineSnapshot(`
179
179
  "Attempting to login via OAuth...
180
- Opening a link in your default browser: https://dash.staging.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
180
+ Opening a link in your default browser: https://dash.staging.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20ssl_certs%3Awrite%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
181
181
  Successfully logged in.
182
182
  Total Upload: xx KiB / gzip: xx KiB
183
183
  Uploaded test-name (TIMINGS)
@@ -209,7 +209,7 @@ describe("publish", () => {
209
209
  Current Deployment ID: Galaxy-Class"
210
210
  `);
211
211
  expect(std.warn).toMatchInlineSnapshot(`
212
- "▲ [WARNING] It looks like you have used Wrangler 1's \`config\` command to login with an API token.
212
+ "▲ [WARNING] It looks like you have used Wrangler v1's \`config\` command to login with an API token.
213
213
 
214
214
  This is no longer supported in the current version of Wrangler.
215
215
  If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
@@ -791,7 +791,7 @@ describe("publish", () => {
791
791
  await runWrangler("publish ./index --env dev --legacy-env false");
792
792
  });
793
793
 
794
- it("should fallback to the Wrangler 1 zone-based API if the bulk-routes API fails", async () => {
794
+ it("should fallback to the Wrangler v1 zone-based API if the bulk-routes API fails", async () => {
795
795
  writeWranglerToml({
796
796
  routes: ["example.com/some-route/*"],
797
797
  });
@@ -1467,7 +1467,7 @@ addEventListener('fetch', event => {});`
1467
1467
 
1468
1468
  expect(std.out).toMatchInlineSnapshot(`
1469
1469
  "
1470
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1470
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
1471
1471
  `);
1472
1472
  expect(std.err).toMatchInlineSnapshot(`
1473
1473
  "X [ERROR] Processing wrangler.toml configuration:
@@ -1629,7 +1629,7 @@ addEventListener('fetch', event => {});`
1629
1629
 
1630
1630
  expect(std.out).toMatchInlineSnapshot(`
1631
1631
  "
1632
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1632
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
1633
1633
  `);
1634
1634
  expect(std.err).toMatchInlineSnapshot(`
1635
1635
  "X [ERROR] Missing entry-point: The entry-point should be specified via the command line (e.g. \`wrangler publish path/to/script\`) or the \`main\` config field.
@@ -1787,7 +1787,7 @@ addEventListener('fetch', event => {});`
1787
1787
 
1788
1788
  ",
1789
1789
  "out": "
1790
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose",
1790
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1791
1791
  "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1792
1792
 
1793
1793
  ",
@@ -1813,7 +1813,7 @@ addEventListener('fetch', event => {});`
1813
1813
 
1814
1814
  ",
1815
1815
  "out": "
1816
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose",
1816
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1817
1817
  "warn": "",
1818
1818
  }
1819
1819
  `);
@@ -1840,7 +1840,7 @@ addEventListener('fetch', event => {});`
1840
1840
 
1841
1841
  ",
1842
1842
  "out": "
1843
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose",
1843
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1844
1844
  "warn": "",
1845
1845
  }
1846
1846
  `);
@@ -1866,7 +1866,7 @@ addEventListener('fetch', event => {});`
1866
1866
 
1867
1867
  ",
1868
1868
  "out": "
1869
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose",
1869
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1870
1870
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1871
1871
 
1872
1872
  - \\"assets\\" fields are experimental and may change or break at any time.
@@ -1899,7 +1899,7 @@ addEventListener('fetch', event => {});`
1899
1899
 
1900
1900
  ",
1901
1901
  "out": "
1902
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose",
1902
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1903
1903
  "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1904
1904
 
1905
1905
  - \\"assets\\" fields are experimental and may change or break at any time.
@@ -2693,7 +2693,7 @@ addEventListener('fetch', event => {});`
2693
2693
  Uploading as large-file.0ea0637a45.txt...
2694
2694
  Reading too-large-file.txt...
2695
2695
 
2696
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
2696
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
2697
2697
  `);
2698
2698
  expect(std.err).toMatchInlineSnapshot(`
2699
2699
  "X [ERROR] File too-large-file.txt is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits
@@ -2834,7 +2834,7 @@ addEventListener('fetch', event => {});`
2834
2834
  expect(std.out).toMatchInlineSnapshot(`
2835
2835
  "Reading folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/file.txt...
2836
2836
 
2837
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
2837
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
2838
2838
  `);
2839
2839
  expect(std.err).toMatchInlineSnapshot(`
2840
2840
  "X [ERROR] The asset path key \\"folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/file.3da0d0cd12.txt\\" exceeds the maximum key size limit of 512. See https://developers.cloudflare.com/workers/platform/limits#kv-limits\\",
@@ -3905,7 +3905,7 @@ addEventListener('fetch', event => {});`
3905
3905
  expect(std.out).toMatchInlineSnapshot(`
3906
3906
  "Running custom build: node -e \\"console.log('custom build');\\"
3907
3907
 
3908
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
3908
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
3909
3909
  `);
3910
3910
  expect(std.err).toMatchInlineSnapshot(`
3911
3911
  "X [ERROR] The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
@@ -3944,7 +3944,7 @@ addEventListener('fetch', event => {});`
3944
3944
  expect(std.out).toMatchInlineSnapshot(`
3945
3945
  "Running custom build: node -e \\"console.log('custom build');\\"
3946
3946
 
3947
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
3947
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
3948
3948
  `);
3949
3949
  expect(std.err).toMatchInlineSnapshot(`
3950
3950
  "X [ERROR] The expected output file at \\".\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
@@ -4830,7 +4830,7 @@ addEventListener('fetch', event => {});`
4830
4830
  `);
4831
4831
  expect(std.out).toMatchInlineSnapshot(`
4832
4832
  "
4833
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
4833
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
4834
4834
  `);
4835
4835
  expect(std.err).toMatchInlineSnapshot(`
4836
4836
  "X [ERROR] Processing wrangler.toml configuration:
@@ -4940,7 +4940,7 @@ addEventListener('fetch', event => {});`
4940
4940
  `);
4941
4941
  expect(std.out).toMatchInlineSnapshot(`
4942
4942
  "
4943
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
4943
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
4944
4944
  `);
4945
4945
  expect(std.err).toMatchInlineSnapshot(`
4946
4946
  "X [ERROR] Processing wrangler.toml configuration:
@@ -5094,7 +5094,7 @@ addEventListener('fetch', event => {});`
5094
5094
  `);
5095
5095
  expect(std.out).toMatchInlineSnapshot(`
5096
5096
  "
5097
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
5097
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
5098
5098
  `);
5099
5099
  expect(std.err).toMatchInlineSnapshot(`
5100
5100
  "X [ERROR] Processing wrangler.toml configuration:
@@ -5173,7 +5173,7 @@ addEventListener('fetch', event => {});`
5173
5173
  );
5174
5174
  expect(std.out).toMatchInlineSnapshot(`
5175
5175
  "
5176
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
5176
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
5177
5177
  `);
5178
5178
  expect(std.err).toMatchInlineSnapshot(`
5179
5179
  "X [ERROR] You cannot configure [wasm_modules] with an ES module worker. Instead, import the .wasm module directly in your code
@@ -5316,7 +5316,7 @@ addEventListener('fetch', event => {});`
5316
5316
  );
5317
5317
  expect(std.out).toMatchInlineSnapshot(`
5318
5318
  "
5319
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
5319
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
5320
5320
  `);
5321
5321
  expect(std.err).toMatchInlineSnapshot(`
5322
5322
  "X [ERROR] You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your wrangler.toml
@@ -5429,7 +5429,7 @@ addEventListener('fetch', event => {});`
5429
5429
  );
5430
5430
  expect(std.out).toMatchInlineSnapshot(`
5431
5431
  "
5432
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
5432
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
5433
5433
  `);
5434
5434
  expect(std.err).toMatchInlineSnapshot(`
5435
5435
  "X [ERROR] You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your wrangler.toml
@@ -5825,7 +5825,7 @@ addEventListener('fetch', event => {});`
5825
5825
  "▲ [WARNING] Processing wrangler.toml configuration:
5826
5826
 
5827
5827
  - D1 Bindings are currently in alpha to allow the API to evolve before general availability.
5828
- Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
5828
+ Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
5829
5829
  Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message
5830
5830
 
5831
5831
  For example: \`export NO_D1_WARNING=true && wrangler <YOUR COMMAND HERE>\`
@@ -6422,7 +6422,7 @@ addEventListener('fetch', event => {});`
6422
6422
  });
6423
6423
 
6424
6424
  it("should not match regular module specifiers when there aren't any possible legacy module matches", async () => {
6425
- // see https://github.com/cloudflare/wrangler2/issues/655 for bug details
6425
+ // see https://github.com/cloudflare/workers-sdk/issues/655 for bug details
6426
6426
 
6427
6427
  fs.writeFileSync(
6428
6428
  "./index.js",
@@ -6489,9 +6489,22 @@ addEventListener('fetch', event => {});`
6489
6489
  `);
6490
6490
  });
6491
6491
 
6492
- it("should output to target es2020 even if tsconfig says otherwise", async () => {
6492
+ it("should output to target es2022 even if tsconfig says otherwise", async () => {
6493
6493
  writeWranglerToml();
6494
6494
  writeWorkerSource();
6495
+ fs.writeFileSync(
6496
+ "./index.js",
6497
+ `
6498
+ import { foo } from "./another";
6499
+ const topLevelAwait = await new Promise((resolve) => setTimeout(resolve, 0));
6500
+
6501
+ export default {
6502
+ async fetch(request) {
6503
+
6504
+ return new Response("Hello world!");
6505
+ },
6506
+ };`
6507
+ );
6495
6508
  fs.writeFileSync(
6496
6509
  "tsconfig.json",
6497
6510
  JSON.stringify({
@@ -6502,8 +6515,14 @@ addEventListener('fetch', event => {});`
6502
6515
  })
6503
6516
  );
6504
6517
  mockSubDomainRequest();
6518
+ /**
6519
+ * When we compile with es2022, we should preserve the export statement and top level await
6520
+ * If you attempt to target es2020 top level await will cause a build error
6521
+ * @error Build failed with 1 error:
6522
+ * index.js:3:25: ERROR: Top-level await is not available in the configured target environment ("es2020")
6523
+ */
6505
6524
  mockUploadWorkerRequest({
6506
- expectedEntry: "export {", // just check that the export is preserved
6525
+ expectedEntry: "export {", // check that the export is preserved
6507
6526
  });
6508
6527
  await runWrangler("publish index.js"); // this would throw if we tried to compile with es5
6509
6528
  expect(std).toMatchInlineSnapshot(`
@@ -6544,7 +6563,7 @@ addEventListener('fetch', event => {});`
6544
6563
  `);
6545
6564
  });
6546
6565
 
6547
- it("should copy any module imports related assets at --outdir if specified", async () => {
6566
+ it("should copy any module imports related assets to --outdir if specified", async () => {
6548
6567
  writeWranglerToml();
6549
6568
  fs.writeFileSync(
6550
6569
  "./index.js",
@@ -6808,7 +6827,7 @@ export default{
6808
6827
  the global scope. [code: 11337]
6809
6828
 
6810
6829
  If you think this is a bug, please open an issue at:
6811
- https://github.com/cloudflare/wrangler2/issues/new/choose
6830
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
6812
6831
 
6813
6832
  ",
6814
6833
  "warn": "",
@@ -6870,7 +6889,7 @@ export default{
6870
6889
  workers.api.error.script_too_large [code: 10027]
6871
6890
 
6872
6891
  If you think this is a bug, please open an issue at:
6873
- https://github.com/cloudflare/wrangler2/issues/new/choose
6892
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
6874
6893
 
6875
6894
  ",
6876
6895
  "warn": "▲ [WARNING] Here are the 2 largest dependencies included in your script:
@@ -6936,7 +6955,7 @@ export default{
6936
6955
  Error: Script startup exceeded CPU time limit. [code: 10021]
6937
6956
 
6938
6957
  If you think this is a bug, please open an issue at:
6939
- https://github.com/cloudflare/wrangler2/issues/new/choose
6958
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
6940
6959
 
6941
6960
  ",
6942
6961
  "warn": "▲ [WARNING] Your Worker failed validation because it exceeded startup limits.
@@ -7339,6 +7358,37 @@ export default{
7339
7358
  });
7340
7359
  });
7341
7360
 
7361
+ describe("mtls_certificates", () => {
7362
+ it("should upload mtls_certificate bindings", async () => {
7363
+ writeWranglerToml({
7364
+ mtls_certificates: [{ binding: "CERT_ONE", certificate_id: "1234" }],
7365
+ });
7366
+ await fs.promises.writeFile("index.js", `export default {};`);
7367
+ mockSubDomainRequest();
7368
+ mockUploadWorkerRequest({
7369
+ expectedBindings: [
7370
+ {
7371
+ type: "mtls_certificate",
7372
+ name: "CERT_ONE",
7373
+ certificate_id: "1234",
7374
+ },
7375
+ ],
7376
+ });
7377
+
7378
+ await runWrangler("publish index.js");
7379
+ expect(std.out).toMatchInlineSnapshot(`
7380
+ "Total Upload: xx KiB / gzip: xx KiB
7381
+ Your worker has access to the following bindings:
7382
+ - mTLS Certificates:
7383
+ - CERT_ONE: 1234
7384
+ Uploaded test-name (TIMINGS)
7385
+ Published test-name (TIMINGS)
7386
+ https://test-name.test-sub-domain.workers.dev
7387
+ Current Deployment ID: Galaxy-Class"
7388
+ `);
7389
+ });
7390
+ });
7391
+
7342
7392
  describe("--keep-vars", () => {
7343
7393
  it("should send keepVars when keep-vars is passed in", async () => {
7344
7394
  process.env = {
@@ -7417,7 +7467,7 @@ function mockLastDeploymentRequest() {
7417
7467
  function mockUploadWorkerRequest(
7418
7468
  options: {
7419
7469
  available_on_subdomain?: boolean;
7420
- expectedEntry?: string;
7470
+ expectedEntry?: string | RegExp;
7421
7471
  expectedMainModule?: string;
7422
7472
  expectedType?: "esm" | "sw";
7423
7473
  expectedBindings?: unknown;
@@ -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
 
@@ -212,7 +215,7 @@ describe("wrangler", () => {
212
215
  workers.api.error.unauthorized [code: 10023]
213
216
 
214
217
  If you think this is a bug, please open an issue at:
215
- https://github.com/cloudflare/wrangler2/issues/new/choose
218
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
216
219
 
217
220
  "
218
221
  `);
@@ -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]
@@ -428,7 +434,7 @@ describe("wrangler", () => {
428
434
  workers.api.error.unauthorized [code: 10023]
429
435
 
430
436
  If you think this is a bug, please open an issue at:
431
- https://github.com/cloudflare/wrangler2/issues/new/choose
437
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
432
438
 
433
439
  "
434
440
  `);
@@ -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