wrangler 2.12.2 → 2.13.0

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 (53) hide show
  1. package/package.json +4 -3
  2. package/src/__tests__/configuration.test.ts +14 -12
  3. package/src/__tests__/d1/execute.test.ts +2 -0
  4. package/src/__tests__/d1/migrate.test.ts +2 -0
  5. package/src/__tests__/delete.test.ts +6 -0
  6. package/src/__tests__/deployments.test.ts +335 -95
  7. package/src/__tests__/dev.test.tsx +71 -56
  8. package/src/__tests__/helpers/mock-console.ts +6 -0
  9. package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
  10. package/src/__tests__/helpers/msw/index.ts +4 -2
  11. package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
  12. package/src/__tests__/index.test.ts +10 -4
  13. package/src/__tests__/init.test.ts +127 -96
  14. package/src/__tests__/jest.setup.ts +4 -0
  15. package/src/__tests__/kv.test.ts +9 -9
  16. package/src/__tests__/middleware.scheduled.test.ts +2 -2
  17. package/src/__tests__/middleware.test.ts +2 -2
  18. package/src/__tests__/mtls-certificates.test.ts +5 -2
  19. package/src/__tests__/pages/deployment-list.test.ts +2 -0
  20. package/src/__tests__/pages/project-list.test.ts +2 -0
  21. package/src/__tests__/pages/project-upload.test.ts +43 -24
  22. package/src/__tests__/pages/publish.test.ts +69 -69
  23. package/src/__tests__/publish.test.ts +275 -155
  24. package/src/__tests__/pubsub.test.ts +3 -0
  25. package/src/__tests__/queues.test.ts +5 -2
  26. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  27. package/src/__tests__/worker-namespace.test.ts +1 -0
  28. package/src/bundle.ts +10 -0
  29. package/src/config/environment.ts +3 -0
  30. package/src/config/validation.ts +3 -1
  31. package/src/create-worker-upload-form.ts +1 -1
  32. package/src/d1/backups.tsx +15 -11
  33. package/src/d1/create.tsx +20 -16
  34. package/src/d1/execute.tsx +21 -18
  35. package/src/d1/list.tsx +2 -2
  36. package/src/d1/migrations/apply.tsx +35 -29
  37. package/src/d1/migrations/create.tsx +15 -12
  38. package/src/d1/migrations/list.tsx +10 -7
  39. package/src/deployments.ts +260 -8
  40. package/src/index.ts +75 -22
  41. package/src/init.ts +144 -135
  42. package/src/metrics/send-event.ts +2 -1
  43. package/src/pages/deployments.tsx +3 -5
  44. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  45. package/src/pages/projects.tsx +2 -5
  46. package/src/pages/upload.tsx +29 -9
  47. package/src/publish/publish.ts +7 -18
  48. package/src/queues/cli/commands/consumer/add.ts +6 -0
  49. package/src/queues/client.ts +1 -0
  50. package/src/utils/render.ts +93 -0
  51. package/templates/d1-beta-facade.js +3 -0
  52. package/wrangler-dist/cli.d.ts +2 -0
  53. package/wrangler-dist/cli.js +8174 -7873
@@ -32,7 +32,7 @@ import {
32
32
  createFetchResult,
33
33
  msw,
34
34
  mswSuccessDeployments,
35
- mswSuccessLastDeployment,
35
+ mswSuccessDeploymentScriptMetadata,
36
36
  } from "./helpers/msw";
37
37
  import { FileReaderSync } from "./helpers/msw/read-file-sync";
38
38
  import { runInTempDir } from "./helpers/run-in-tmp";
@@ -89,7 +89,7 @@ describe("publish", () => {
89
89
  );
90
90
  writeWorkerSource();
91
91
  mockSubDomainRequest();
92
- mockUploadWorkerRequest({ expectedType: "esm", sendScriptIds: true });
92
+ mockUploadWorkerRequest({ expectedType: "esm" });
93
93
  mockOAuthServerCallback();
94
94
 
95
95
  await runWrangler("publish ./index");
@@ -98,6 +98,7 @@ describe("publish", () => {
98
98
  Object {
99
99
  "debug": "",
100
100
  "err": "",
101
+ "info": "",
101
102
  "out": "Total Upload: xx KiB / gzip: xx KiB
102
103
  Worker ID: abc12345
103
104
  Worker ETag: etag98765
@@ -617,6 +618,7 @@ describe("publish", () => {
617
618
  Object {
618
619
  "debug": "",
619
620
  "err": "",
621
+ "info": "",
620
622
  "out": "Total Upload: xx KiB / gzip: xx KiB
621
623
  Uploaded test-name (TIMINGS)
622
624
  Published test-name (TIMINGS)
@@ -664,6 +666,7 @@ describe("publish", () => {
664
666
  Object {
665
667
  "debug": "",
666
668
  "err": "",
669
+ "info": "",
667
670
  "out": "Total Upload: xx KiB / gzip: xx KiB
668
671
  Uploaded test-name (TIMINGS)
669
672
  Published test-name (TIMINGS)
@@ -726,6 +729,7 @@ describe("publish", () => {
726
729
  Object {
727
730
  "debug": "",
728
731
  "err": "",
732
+ "info": "",
729
733
  "out": "Total Upload: xx KiB / gzip: xx KiB
730
734
  Uploaded test-name (staging) (TIMINGS)
731
735
  Published test-name (staging) (TIMINGS)
@@ -1337,6 +1341,32 @@ export default{
1337
1341
  expect(std.err).toMatchInlineSnapshot(`""`);
1338
1342
  });
1339
1343
 
1344
+ it("should allow cloudflare module import", async () => {
1345
+ writeWranglerToml();
1346
+ fs.writeFileSync(
1347
+ "./index.js",
1348
+ `
1349
+ import { EmailMessage } from "cloudflare:email";
1350
+ export default{
1351
+ fetch(){
1352
+ return new Response("all done");
1353
+ }
1354
+ }
1355
+ `
1356
+ );
1357
+ mockUploadWorkerRequest();
1358
+ mockSubDomainRequest();
1359
+ await runWrangler("publish index.js");
1360
+ expect(std.out).toMatchInlineSnapshot(`
1361
+ "Total Upload: xx KiB / gzip: xx KiB
1362
+ Uploaded test-name (TIMINGS)
1363
+ Published test-name (TIMINGS)
1364
+ https://test-name.test-sub-domain.workers.dev
1365
+ Current Deployment ID: Galaxy-Class"
1366
+ `);
1367
+ expect(std.err).toMatchInlineSnapshot(`""`);
1368
+ });
1369
+
1340
1370
  it("should be able to transpile entry-points in sub-directories (esm)", async () => {
1341
1371
  writeWranglerToml();
1342
1372
  writeWorkerSource({ basePath: "./src" });
@@ -1387,6 +1417,7 @@ export default {};`
1387
1417
  Object {
1388
1418
  "debug": "",
1389
1419
  "err": "",
1420
+ "info": "",
1390
1421
  "out": "Total Upload: xx KiB / gzip: xx KiB
1391
1422
  --dry-run: exiting now.",
1392
1423
  "warn": "",
@@ -1420,6 +1451,7 @@ addEventListener('fetch', event => {});`
1420
1451
  Object {
1421
1452
  "debug": "",
1422
1453
  "err": "",
1454
+ "info": "",
1423
1455
  "out": "Total Upload: xx KiB / gzip: xx KiB
1424
1456
  --dry-run: exiting now.",
1425
1457
  "warn": "▲ [WARNING] The entrypoint index.js has exports like an ES Module, but hasn't defined a default export like a module worker normally would. Building the worker using \\"service-worker\\" format...
@@ -1519,6 +1551,7 @@ addEventListener('fetch', event => {});`
1519
1551
  Object {
1520
1552
  "debug": "",
1521
1553
  "err": "",
1554
+ "info": "",
1522
1555
  "out": "Reading file-1.txt...
1523
1556
  Uploading as file-1.2ca234f380.txt...
1524
1557
  Reading file-2.txt...
@@ -1662,6 +1695,7 @@ addEventListener('fetch', event => {});`
1662
1695
  Object {
1663
1696
  "debug": "",
1664
1697
  "err": "",
1698
+ "info": "",
1665
1699
  "out": "Reading file-1.txt...
1666
1700
  Uploading as file-1.2ca234f380.txt...
1667
1701
  Reading file-2.txt...
@@ -1752,6 +1786,7 @@ addEventListener('fetch', event => {});`
1752
1786
  Object {
1753
1787
  "debug": "",
1754
1788
  "err": "",
1789
+ "info": "",
1755
1790
  "out": "Reading file-1.txt...
1756
1791
  Uploading as file-1.2ca234f380.txt...
1757
1792
  Reading file-2.txt...
@@ -1781,18 +1816,19 @@ addEventListener('fetch', event => {});`
1781
1816
  );
1782
1817
 
1783
1818
  expect(std).toMatchInlineSnapshot(`
1784
- Object {
1785
- "debug": "",
1786
- "err": "X [ERROR] You cannot use the service-worker format with an \`assets\` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/
1819
+ Object {
1820
+ "debug": "",
1821
+ "err": "X [ERROR] You cannot use the service-worker format with an \`assets\` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/
1787
1822
 
1788
- ",
1789
- "out": "
1790
- If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1791
- "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1823
+ ",
1824
+ "info": "",
1825
+ "out": "
1826
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1827
+ "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
1792
1828
 
1793
- ",
1794
- }
1795
- `);
1829
+ ",
1830
+ }
1831
+ `);
1796
1832
  });
1797
1833
 
1798
1834
  it("should error if --assets and --site are used together", async () => {
@@ -1807,16 +1843,17 @@ addEventListener('fetch', event => {});`
1807
1843
  );
1808
1844
 
1809
1845
  expect(std).toMatchInlineSnapshot(`
1810
- Object {
1811
- "debug": "",
1812
- "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1813
-
1814
- ",
1815
- "out": "
1816
- If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1817
- "warn": "",
1818
- }
1819
- `);
1846
+ Object {
1847
+ "debug": "",
1848
+ "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1849
+
1850
+ ",
1851
+ "info": "",
1852
+ "out": "
1853
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1854
+ "warn": "",
1855
+ }
1856
+ `);
1820
1857
  });
1821
1858
 
1822
1859
  it("should error if --assets and config.site are used together", async () => {
@@ -1834,16 +1871,17 @@ addEventListener('fetch', event => {});`
1834
1871
  );
1835
1872
 
1836
1873
  expect(std).toMatchInlineSnapshot(`
1837
- Object {
1838
- "debug": "",
1839
- "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1840
-
1841
- ",
1842
- "out": "
1843
- If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1844
- "warn": "",
1845
- }
1846
- `);
1874
+ Object {
1875
+ "debug": "",
1876
+ "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1877
+
1878
+ ",
1879
+ "info": "",
1880
+ "out": "
1881
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1882
+ "warn": "",
1883
+ }
1884
+ `);
1847
1885
  });
1848
1886
 
1849
1887
  it("should error if config.assets and --site are used together", async () => {
@@ -1860,20 +1898,21 @@ addEventListener('fetch', event => {});`
1860
1898
  );
1861
1899
 
1862
1900
  expect(std).toMatchInlineSnapshot(`
1863
- Object {
1864
- "debug": "",
1865
- "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1901
+ Object {
1902
+ "debug": "",
1903
+ "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1866
1904
 
1867
- ",
1868
- "out": "
1869
- If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1870
- "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1905
+ ",
1906
+ "info": "",
1907
+ "out": "
1908
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1909
+ "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1871
1910
 
1872
- - \\"assets\\" fields are experimental and may change or break at any time.
1911
+ - \\"assets\\" fields are experimental and may change or break at any time.
1873
1912
 
1874
- ",
1875
- }
1876
- `);
1913
+ ",
1914
+ }
1915
+ `);
1877
1916
  });
1878
1917
 
1879
1918
  it("should error if config.assets and config.site are used together", async () => {
@@ -1893,20 +1932,21 @@ addEventListener('fetch', event => {});`
1893
1932
  );
1894
1933
 
1895
1934
  expect(std).toMatchInlineSnapshot(`
1896
- Object {
1897
- "debug": "",
1898
- "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1935
+ Object {
1936
+ "debug": "",
1937
+ "err": "X [ERROR] Cannot use Assets and Workers Sites in the same Worker.
1899
1938
 
1900
- ",
1901
- "out": "
1902
- If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1903
- "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1939
+ ",
1940
+ "info": "",
1941
+ "out": "
1942
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose",
1943
+ "warn": "▲ [WARNING] Processing wrangler.toml configuration:
1904
1944
 
1905
- - \\"assets\\" fields are experimental and may change or break at any time.
1945
+ - \\"assets\\" fields are experimental and may change or break at any time.
1906
1946
 
1907
- ",
1908
- }
1909
- `);
1947
+ ",
1948
+ }
1949
+ `);
1910
1950
  });
1911
1951
 
1912
1952
  it("should warn if --assets is used", async () => {
@@ -1937,6 +1977,7 @@ addEventListener('fetch', event => {});`
1937
1977
  Object {
1938
1978
  "debug": "",
1939
1979
  "err": "",
1980
+ "info": "",
1940
1981
  "out": "Reading subdir/file-1.txt...
1941
1982
  Uploading as subdir/file-1.2ca234f380.txt...
1942
1983
  Reading subdir/file-2.txt...
@@ -1984,6 +2025,7 @@ addEventListener('fetch', event => {});`
1984
2025
  Object {
1985
2026
  "debug": "",
1986
2027
  "err": "",
2028
+ "info": "",
1987
2029
  "out": "Reading subdir/file-1.txt...
1988
2030
  Uploading as subdir/file-1.2ca234f380.txt...
1989
2031
  Reading subdir/file-2.txt...
@@ -2752,6 +2794,7 @@ addEventListener('fetch', event => {});`
2752
2794
  Object {
2753
2795
  "debug": "",
2754
2796
  "err": "",
2797
+ "info": "",
2755
2798
  "out": "Reading file-00.txt...
2756
2799
  Uploading as file-00.be5be5dd26.txt...
2757
2800
  Reading file-01.txt...
@@ -2985,6 +3028,7 @@ addEventListener('fetch', event => {});`
2985
3028
  Object {
2986
3029
  "debug": "",
2987
3030
  "err": "",
3031
+ "info": "",
2988
3032
  "out": "Reading file-1.txt...
2989
3033
  Uploading as file-1.2ca234f380.txt...
2990
3034
  Reading file-2.txt...
@@ -3028,6 +3072,7 @@ addEventListener('fetch', event => {});`
3028
3072
  Object {
3029
3073
  "debug": "",
3030
3074
  "err": "",
3075
+ "info": "",
3031
3076
  "out": "Reading file-1.txt...
3032
3077
  Uploading as file-1.2ca234f380.txt...
3033
3078
  Reading file-2.txt...
@@ -3840,7 +3885,7 @@ addEventListener('fetch', event => {});`
3840
3885
  it("should run a custom build before publishing", async () => {
3841
3886
  writeWranglerToml({
3842
3887
  build: {
3843
- command: `node -e "console.log('custom build'); require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')"`,
3888
+ command: `node -e "4+4; require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')"`,
3844
3889
  },
3845
3890
  });
3846
3891
 
@@ -3851,7 +3896,7 @@ addEventListener('fetch', event => {});`
3851
3896
 
3852
3897
  await runWrangler("publish index.js");
3853
3898
  expect(std.out).toMatchInlineSnapshot(`
3854
- "Running custom build: node -e \\"console.log('custom build'); require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\\"
3899
+ "Running custom build: node -e \\"4+4; require('fs').writeFileSync('index.js', 'export default { fetch(){ return new Response(123) } }')\\"
3855
3900
  Total Upload: xx KiB / gzip: xx KiB
3856
3901
  Uploaded test-name (TIMINGS)
3857
3902
  Published test-name (TIMINGS)
@@ -3866,7 +3911,7 @@ addEventListener('fetch', event => {});`
3866
3911
  it("should run a custom build of multiple steps combined by && before publishing", async () => {
3867
3912
  writeWranglerToml({
3868
3913
  build: {
3869
- command: `echo "custom build" && echo "export default { fetch(){ return new Response(123) } }" > index.js`,
3914
+ command: `echo "export default { fetch(){ return new Response(123) } }" > index.js`,
3870
3915
  },
3871
3916
  });
3872
3917
 
@@ -3877,7 +3922,7 @@ addEventListener('fetch', event => {});`
3877
3922
 
3878
3923
  await runWrangler("publish index.js");
3879
3924
  expect(std.out).toMatchInlineSnapshot(`
3880
- "Running custom build: echo \\"custom build\\" && echo \\"export default { fetch(){ return new Response(123) } }\\" > index.js
3925
+ "Running custom build: echo \\"export default { fetch(){ return new Response(123) } }\\" > index.js
3881
3926
  Total Upload: xx KiB / gzip: xx KiB
3882
3927
  Uploaded test-name (TIMINGS)
3883
3928
  Published test-name (TIMINGS)
@@ -3893,22 +3938,22 @@ addEventListener('fetch', event => {});`
3893
3938
  writeWranglerToml({
3894
3939
  main: "index.js",
3895
3940
  build: {
3896
- command: `node -e "console.log('custom build');"`,
3941
+ command: `node -e "4+4;"`,
3897
3942
  },
3898
3943
  });
3899
3944
 
3900
3945
  await expect(runWrangler("publish index.js")).rejects
3901
3946
  .toThrowErrorMatchingInlineSnapshot(`
3902
- "The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
3947
+ "The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"4+4;\\".
3903
3948
  The \`main\` property in wrangler.toml should point to the file generated by the custom build."
3904
3949
  `);
3905
3950
  expect(std.out).toMatchInlineSnapshot(`
3906
- "Running custom build: node -e \\"console.log('custom build');\\"
3951
+ "Running custom build: node -e \\"4+4;\\"
3907
3952
 
3908
3953
  If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
3909
3954
  `);
3910
3955
  expect(std.err).toMatchInlineSnapshot(`
3911
- "X [ERROR] The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
3956
+ "X [ERROR] The expected output file at \\"index.js\\" was not found after running custom build: node -e \\"4+4;\\".
3912
3957
 
3913
3958
  The \`main\` property in wrangler.toml should point to the file generated by the custom build.
3914
3959
 
@@ -3921,7 +3966,7 @@ addEventListener('fetch', event => {});`
3921
3966
  writeWranglerToml({
3922
3967
  main: "./",
3923
3968
  build: {
3924
- command: `node -e "console.log('custom build');"`,
3969
+ command: `node -e "4+4;"`,
3925
3970
  },
3926
3971
  });
3927
3972
 
@@ -3931,7 +3976,7 @@ addEventListener('fetch', event => {});`
3931
3976
 
3932
3977
  await expect(runWrangler("publish")).rejects
3933
3978
  .toThrowErrorMatchingInlineSnapshot(`
3934
- "The expected output file at \\".\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
3979
+ "The expected output file at \\".\\" was not found after running custom build: node -e \\"4+4;\\".
3935
3980
  The \`main\` property in wrangler.toml should point to the file generated by the custom build.
3936
3981
  The provided entry-point path, \\".\\", points to a directory, rather than a file.
3937
3982
 
@@ -3942,12 +3987,12 @@ addEventListener('fetch', event => {});`
3942
3987
  \`\`\`"
3943
3988
  `);
3944
3989
  expect(std.out).toMatchInlineSnapshot(`
3945
- "Running custom build: node -e \\"console.log('custom build');\\"
3990
+ "Running custom build: node -e \\"4+4;\\"
3946
3991
 
3947
3992
  If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
3948
3993
  `);
3949
3994
  expect(std.err).toMatchInlineSnapshot(`
3950
- "X [ERROR] The expected output file at \\".\\" was not found after running custom build: node -e \\"console.log('custom build');\\".
3995
+ "X [ERROR] The expected output file at \\".\\" was not found after running custom build: node -e \\"4+4;\\".
3951
3996
 
3952
3997
  The \`main\` property in wrangler.toml should point to the file generated by the custom build.
3953
3998
  The provided entry-point path, \\".\\", points to a directory, rather than a file.
@@ -4197,6 +4242,7 @@ addEventListener('fetch', event => {});`
4197
4242
  Object {
4198
4243
  "debug": "",
4199
4244
  "err": "",
4245
+ "info": "",
4200
4246
  "out": "Total Upload: xx KiB / gzip: xx KiB
4201
4247
  Your worker has access to the following bindings:
4202
4248
  - Durable Objects:
@@ -4242,6 +4288,7 @@ addEventListener('fetch', event => {});`
4242
4288
  Object {
4243
4289
  "debug": "",
4244
4290
  "err": "",
4291
+ "info": "",
4245
4292
  "out": "Total Upload: xx KiB / gzip: xx KiB
4246
4293
  Your worker has access to the following bindings:
4247
4294
  - Durable Objects:
@@ -4415,6 +4462,7 @@ addEventListener('fetch', event => {});`
4415
4462
  Object {
4416
4463
  "debug": "",
4417
4464
  "err": "",
4465
+ "info": "",
4418
4466
  "out": "Total Upload: xx KiB / gzip: xx KiB
4419
4467
  Your worker has access to the following bindings:
4420
4468
  - Durable Objects:
@@ -4485,6 +4533,7 @@ addEventListener('fetch', event => {});`
4485
4533
  Object {
4486
4534
  "debug": "",
4487
4535
  "err": "",
4536
+ "info": "",
4488
4537
  "out": "Total Upload: xx KiB / gzip: xx KiB
4489
4538
  Your worker has access to the following bindings:
4490
4539
  - Durable Objects:
@@ -5555,6 +5604,7 @@ addEventListener('fetch', event => {});`
5555
5604
  Object {
5556
5605
  "debug": "",
5557
5606
  "err": "",
5607
+ "info": "",
5558
5608
  "out": "Total Upload: xx KiB / gzip: xx KiB
5559
5609
  Your worker has access to the following bindings:
5560
5610
  - Vars:
@@ -6495,6 +6545,7 @@ addEventListener('fetch', event => {});`
6495
6545
  Object {
6496
6546
  "debug": "",
6497
6547
  "err": "",
6548
+ "info": "",
6498
6549
  "out": "Total Upload: xx KiB / gzip: xx KiB
6499
6550
  Uploaded test-name (TIMINGS)
6500
6551
  Published test-name (TIMINGS)
@@ -6545,6 +6596,7 @@ addEventListener('fetch', event => {});`
6545
6596
  Object {
6546
6597
  "debug": "",
6547
6598
  "err": "",
6599
+ "info": "",
6548
6600
  "out": "Total Upload: xx KiB / gzip: xx KiB
6549
6601
  Uploaded test-name (TIMINGS)
6550
6602
  Published test-name (TIMINGS)
@@ -6569,6 +6621,7 @@ addEventListener('fetch', event => {});`
6569
6621
  Object {
6570
6622
  "debug": "",
6571
6623
  "err": "",
6624
+ "info": "",
6572
6625
  "out": "Total Upload: xx KiB / gzip: xx KiB
6573
6626
  Uploaded test-name (TIMINGS)
6574
6627
  Published test-name (TIMINGS)
@@ -6603,6 +6656,7 @@ addEventListener('fetch', event => {});`
6603
6656
  Object {
6604
6657
  "debug": "",
6605
6658
  "err": "",
6659
+ "info": "",
6606
6660
  "out": "Reading file-1.txt...
6607
6661
  Uploading as file-1.2ca234f380.txt...
6608
6662
  Reading file-2.txt...
@@ -6665,6 +6719,7 @@ export default{
6665
6719
  Object {
6666
6720
  "debug": "",
6667
6721
  "err": "",
6722
+ "info": "",
6668
6723
  "out": "Total Upload: xx KiB / gzip: xx KiB
6669
6724
  Uploaded test-name (TIMINGS)
6670
6725
  Published test-name (TIMINGS)
@@ -6693,6 +6748,7 @@ export default{
6693
6748
  Object {
6694
6749
  "debug": "",
6695
6750
  "err": "",
6751
+ "info": "",
6696
6752
  "out": "Total Upload: xx KiB / gzip: xx KiB
6697
6753
  Your worker has access to the following bindings:
6698
6754
  - Durable Objects:
@@ -6710,16 +6766,17 @@ export default{
6710
6766
  writeWorkerSource();
6711
6767
  await runWrangler("publish index.js --node-compat --dry-run");
6712
6768
  expect(std).toMatchInlineSnapshot(`
6713
- Object {
6714
- "debug": "",
6715
- "err": "",
6716
- "out": "Total Upload: xx KiB / gzip: xx KiB
6717
- --dry-run: exiting now.",
6718
- "warn": "▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
6719
-
6720
- ",
6721
- }
6722
- `);
6769
+ Object {
6770
+ "debug": "",
6771
+ "err": "",
6772
+ "info": "",
6773
+ "out": "Total Upload: xx KiB / gzip: xx KiB
6774
+ --dry-run: exiting now.",
6775
+ "warn": "▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
6776
+
6777
+ ",
6778
+ }
6779
+ `);
6723
6780
  });
6724
6781
 
6725
6782
  it("should recommend node compatibility mode when using node builtins and node-compat isn't enabled", async () => {
@@ -6757,16 +6814,17 @@ export default{
6757
6814
  );
6758
6815
  await runWrangler("publish index.js --node-compat --dry-run"); // this would throw if node compatibility didn't exist
6759
6816
  expect(std).toMatchInlineSnapshot(`
6760
- Object {
6761
- "debug": "",
6762
- "err": "",
6763
- "out": "Total Upload: xx KiB / gzip: xx KiB
6764
- --dry-run: exiting now.",
6765
- "warn": "▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
6766
-
6767
- ",
6768
- }
6769
- `);
6817
+ Object {
6818
+ "debug": "",
6819
+ "err": "",
6820
+ "info": "",
6821
+ "out": "Total Upload: xx KiB / gzip: xx KiB
6822
+ --dry-run: exiting now.",
6823
+ "warn": "▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
6824
+
6825
+ ",
6826
+ }
6827
+ `);
6770
6828
  });
6771
6829
  });
6772
6830
 
@@ -6811,6 +6869,7 @@ export default{
6811
6869
  Object {
6812
6870
  "debug": "",
6813
6871
  "err": "",
6872
+ "info": "",
6814
6873
  "out": "Total Upload: xx KiB / gzip: xx KiB
6815
6874
  --dry-run: exiting now.",
6816
6875
  "warn": "",
@@ -6883,6 +6942,7 @@ export default{
6883
6942
  Object {
6884
6943
  "debug": "",
6885
6944
  "err": "",
6945
+ "info": "",
6886
6946
  "out": "Total Upload: xx KiB / gzip: xx KiB
6887
6947
  Uploaded test-name (TIMINGS)
6888
6948
  Published test-name (TIMINGS)
@@ -6945,23 +7005,24 @@ export default{
6945
7005
  `[ParseError: A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.]`
6946
7006
  );
6947
7007
  expect(std).toMatchInlineSnapshot(`
6948
- Object {
6949
- "debug": "",
6950
- "err": "",
6951
- "out": "Total Upload: xx KiB / gzip: xx KiB
7008
+ Object {
7009
+ "debug": "",
7010
+ "err": "",
7011
+ "info": "",
7012
+ "out": "Total Upload: xx KiB / gzip: xx KiB
6952
7013
 
6953
- X [ERROR] A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.
7014
+ X [ERROR] A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.
6954
7015
 
6955
- Script startup timed out. This could be due to script exceeding size limits or expensive code in
6956
- the global scope. [code: 11337]
7016
+ Script startup timed out. This could be due to script exceeding size limits or expensive code in
7017
+ the global scope. [code: 11337]
6957
7018
 
6958
- If you think this is a bug, please open an issue at:
6959
- https://github.com/cloudflare/workers-sdk/issues/new/choose
7019
+ If you think this is a bug, please open an issue at:
7020
+ https://github.com/cloudflare/workers-sdk/issues/new/choose
6960
7021
 
6961
- ",
6962
- "warn": "",
6963
- }
6964
- `);
7022
+ ",
7023
+ "warn": "",
7024
+ }
7025
+ `);
6965
7026
  });
6966
7027
 
6967
7028
  test("should check biggest dependencies when upload fails with script size error", async () => {
@@ -7011,6 +7072,7 @@ export default{
7011
7072
  Object {
7012
7073
  "debug": "",
7013
7074
  "err": "",
7075
+ "info": "",
7014
7076
  "out": "Total Upload: xx KiB / gzip: xx KiB
7015
7077
 
7016
7078
  X [ERROR] A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.
@@ -7077,6 +7139,7 @@ export default{
7077
7139
  Object {
7078
7140
  "debug": "",
7079
7141
  "err": "",
7142
+ "info": "",
7080
7143
  "out": "Total Upload: xx KiB / gzip: xx KiB
7081
7144
 
7082
7145
  X [ERROR] A request to the Cloudflare API (/accounts/some-account-id/workers/scripts/test-name) failed.
@@ -7115,6 +7178,7 @@ export default{
7115
7178
  Object {
7116
7179
  "debug": "",
7117
7180
  "err": "",
7181
+ "info": "",
7118
7182
  "out": "Total Upload: xx KiB / gzip: xx KiB",
7119
7183
  "warn": "▲ [WARNING] We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding past this can affect cold start time
7120
7184
 
@@ -7137,6 +7201,7 @@ export default{
7137
7201
  Object {
7138
7202
  "debug": "",
7139
7203
  "err": "",
7204
+ "info": "",
7140
7205
  "out": "Total Upload: xx KiB / gzip: xx KiB",
7141
7206
  "warn": "",
7142
7207
  }
@@ -7165,6 +7230,7 @@ export default{
7165
7230
  Object {
7166
7231
  "debug": "",
7167
7232
  "err": "",
7233
+ "info": "",
7168
7234
  "out": "",
7169
7235
  "warn": "▲ [WARNING] Here are the 5 largest dependencies included in your script:
7170
7236
 
@@ -7284,53 +7350,6 @@ export default{
7284
7350
  });
7285
7351
  });
7286
7352
 
7287
- it("should publish if the last deployed source check fails", async () => {
7288
- writeWorkerSource();
7289
- writeWranglerToml();
7290
- mockSubDomainRequest();
7291
- mockUploadWorkerRequest();
7292
- msw.use(
7293
- rest.get(
7294
- "*/accounts/:accountId/workers/deployments/by-script/:scriptTag",
7295
- (_, res, ctx) => {
7296
- return res(
7297
- ctx.json(
7298
- createFetchResult({
7299
- latest: { number: "2" },
7300
- })
7301
- )
7302
- );
7303
- }
7304
- ),
7305
- rest.get(
7306
- "*/accounts/:accountId/workers/services/:scriptName",
7307
- (_, res, ctx) => {
7308
- return res(
7309
- ctx.json(
7310
- createFetchResult(null, false, [
7311
- { code: 10090, message: "workers.api.error.service_not_found" },
7312
- ])
7313
- )
7314
- );
7315
- }
7316
- )
7317
- );
7318
-
7319
- await runWrangler("publish index.js");
7320
- expect(std).toMatchInlineSnapshot(`
7321
- Object {
7322
- "debug": "",
7323
- "err": "",
7324
- "out": "Total Upload: xx KiB / gzip: xx KiB
7325
- Uploaded test-name (TIMINGS)
7326
- Published test-name (TIMINGS)
7327
- https://test-name.test-sub-domain.workers.dev
7328
- Current Deployment ID: undefined",
7329
- "warn": "",
7330
- }
7331
- `);
7332
- });
7333
-
7334
7353
  it("should not publish if there's any other kind of error when checking deployment source", async () => {
7335
7354
  writeWorkerSource();
7336
7355
  writeWranglerToml();
@@ -7440,6 +7459,83 @@ export default{
7440
7459
  `);
7441
7460
  });
7442
7461
 
7462
+ it("should support queue consumer concurrency with a max concurrency specified", async () => {
7463
+ writeWranglerToml({
7464
+ queues: {
7465
+ consumers: [
7466
+ {
7467
+ queue: "queue1",
7468
+ dead_letter_queue: "myDLQ",
7469
+ max_batch_size: 5,
7470
+ max_batch_timeout: 3,
7471
+ max_retries: 10,
7472
+ max_concurrency: 5,
7473
+ },
7474
+ ],
7475
+ },
7476
+ });
7477
+ await fs.promises.writeFile("index.js", `export default {};`);
7478
+ mockSubDomainRequest();
7479
+ mockUploadWorkerRequest();
7480
+ mockGetQueue("queue1");
7481
+ mockPutQueueConsumer("queue1", "test-name", {
7482
+ dead_letter_queue: "myDLQ",
7483
+ settings: {
7484
+ batch_size: 5,
7485
+ max_retries: 10,
7486
+ max_wait_time_ms: 3000,
7487
+ max_concurrency: 5,
7488
+ },
7489
+ });
7490
+ await runWrangler("publish index.js");
7491
+ expect(std.out).toMatchInlineSnapshot(`
7492
+ "Total Upload: xx KiB / gzip: xx KiB
7493
+ Uploaded test-name (TIMINGS)
7494
+ Published test-name (TIMINGS)
7495
+ https://test-name.test-sub-domain.workers.dev
7496
+ Consumer for queue1
7497
+ Current Deployment ID: Galaxy-Class"
7498
+ `);
7499
+ });
7500
+
7501
+ it("should support queue consumer concurrency with a null max concurrency", async () => {
7502
+ writeWranglerToml({
7503
+ queues: {
7504
+ consumers: [
7505
+ {
7506
+ queue: "queue1",
7507
+ dead_letter_queue: "myDLQ",
7508
+ max_batch_size: 5,
7509
+ max_batch_timeout: 3,
7510
+ max_retries: 10,
7511
+ max_concurrency: null,
7512
+ },
7513
+ ],
7514
+ },
7515
+ });
7516
+ await fs.promises.writeFile("index.js", `export default {};`);
7517
+ mockSubDomainRequest();
7518
+ mockUploadWorkerRequest();
7519
+ mockGetQueue("queue1");
7520
+ mockPutQueueConsumer("queue1", "test-name", {
7521
+ dead_letter_queue: "myDLQ",
7522
+ settings: {
7523
+ batch_size: 5,
7524
+ max_retries: 10,
7525
+ max_wait_time_ms: 3000,
7526
+ },
7527
+ });
7528
+ await runWrangler("publish index.js");
7529
+ expect(std.out).toMatchInlineSnapshot(`
7530
+ "Total Upload: xx KiB / gzip: xx KiB
7531
+ Uploaded test-name (TIMINGS)
7532
+ Published test-name (TIMINGS)
7533
+ https://test-name.test-sub-domain.workers.dev
7534
+ Consumer for queue1
7535
+ Current Deployment ID: Galaxy-Class"
7536
+ `);
7537
+ });
7538
+
7443
7539
  it("consumer should error when a queue doesn't exist", async () => {
7444
7540
  writeWranglerToml({
7445
7541
  queues: {
@@ -7568,6 +7664,33 @@ export default{
7568
7664
  `);
7569
7665
  expect(std.err).toMatchInlineSnapshot(`""`);
7570
7666
  });
7667
+
7668
+ it("should send keepVars when `keep_vars = true`", async () => {
7669
+ process.env = {
7670
+ CLOUDFLARE_API_TOKEN: "hunter2",
7671
+ CLOUDFLARE_ACCOUNT_ID: "some-account-id",
7672
+ };
7673
+ setIsTTY(false);
7674
+ writeWranglerToml({
7675
+ keep_vars: true,
7676
+ });
7677
+ writeWorkerSource();
7678
+ mockSubDomainRequest();
7679
+ mockUploadWorkerRequest({ keepVars: true });
7680
+ mockOAuthServerCallback();
7681
+ mockGetMemberships([]);
7682
+
7683
+ await runWrangler("publish index.js");
7684
+
7685
+ expect(std.out).toMatchInlineSnapshot(`
7686
+ "Total Upload: xx KiB / gzip: xx KiB
7687
+ Uploaded test-name (TIMINGS)
7688
+ Published test-name (TIMINGS)
7689
+ https://test-name.test-sub-domain.workers.dev
7690
+ Current Deployment ID: Galaxy-Class"
7691
+ `);
7692
+ expect(std.err).toMatchInlineSnapshot(`""`);
7693
+ });
7571
7694
  });
7572
7695
  });
7573
7696
 
@@ -7589,7 +7712,7 @@ function mockDeploymentsListRequest() {
7589
7712
  }
7590
7713
 
7591
7714
  function mockLastDeploymentRequest() {
7592
- msw.use(...mswSuccessLastDeployment);
7715
+ msw.use(...mswSuccessDeploymentScriptMetadata);
7593
7716
  }
7594
7717
 
7595
7718
  /** Create a mock handler for the request to upload a worker script. */
@@ -7607,7 +7730,6 @@ function mockUploadWorkerRequest(
7607
7730
  expectedUnsafeMetaData?: Record<string, string>;
7608
7731
  env?: string;
7609
7732
  legacyEnv?: boolean;
7610
- sendScriptIds?: boolean;
7611
7733
  keepVars?: boolean;
7612
7734
  tag?: string;
7613
7735
  } = {}
@@ -7625,7 +7747,6 @@ function mockUploadWorkerRequest(
7625
7747
  legacyEnv = false,
7626
7748
  expectedMigrations,
7627
7749
  expectedUnsafeMetaData,
7628
- sendScriptIds,
7629
7750
  keepVars,
7630
7751
  } = options;
7631
7752
  if (env && !legacyEnv) {
@@ -7707,12 +7828,11 @@ function mockUploadWorkerRequest(
7707
7828
  ctx.json(
7708
7829
  createFetchResult({
7709
7830
  available_on_subdomain,
7710
- ...(sendScriptIds && {
7711
- id: "abc12345",
7712
- etag: "etag98765",
7713
- pipeline_hash: "hash9999",
7714
- tag: "sample-tag",
7715
- }),
7831
+ id: "abc12345",
7832
+ etag: "etag98765",
7833
+ pipeline_hash: "hash9999",
7834
+ tag: "sample-tag",
7835
+ deployment_id: "Galaxy-Class",
7716
7836
  })
7717
7837
  )
7718
7838
  );