wrangler 2.8.1 → 2.9.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 (66) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/d1/d1.test.ts +10 -52
  3. package/src/__tests__/d1/migrate.test.ts +48 -0
  4. package/src/__tests__/dev.test.tsx +5 -4
  5. package/src/__tests__/index.test.ts +35 -28
  6. package/src/__tests__/kv.test.ts +55 -44
  7. package/src/__tests__/pages.test.ts +27 -20
  8. package/src/__tests__/parse.test.ts +106 -0
  9. package/src/__tests__/pubsub.test.ts +15 -12
  10. package/src/__tests__/queues.test.ts +35 -28
  11. package/src/__tests__/r2.test.ts +25 -20
  12. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  13. package/src/__tests__/worker-namespace.test.ts +25 -20
  14. package/src/api/dev.ts +80 -11
  15. package/src/api/pages/publish.tsx +7 -4
  16. package/src/bundle.ts +1 -1
  17. package/src/config/config.ts +7 -0
  18. package/src/config/index.ts +24 -20
  19. package/src/d1/backups.tsx +20 -24
  20. package/src/d1/create.tsx +6 -5
  21. package/src/d1/delete.ts +7 -10
  22. package/src/d1/execute.tsx +82 -84
  23. package/src/d1/index.ts +5 -6
  24. package/src/d1/list.tsx +21 -9
  25. package/src/d1/migrations/apply.tsx +7 -5
  26. package/src/d1/migrations/create.tsx +7 -10
  27. package/src/d1/migrations/list.tsx +7 -5
  28. package/src/d1/migrations/options.ts +2 -2
  29. package/src/d1/options.ts +3 -3
  30. package/src/delete.ts +5 -8
  31. package/src/deprecated/index.ts +7 -8
  32. package/src/dev.tsx +42 -80
  33. package/src/dispatch-namespace.ts +20 -16
  34. package/src/docs/index.ts +7 -8
  35. package/src/generate/index.ts +5 -7
  36. package/src/index.ts +22 -21
  37. package/src/init.ts +5 -7
  38. package/src/kv/index.ts +15 -17
  39. package/src/pages/build.ts +6 -4
  40. package/src/pages/deployment-tails.ts +7 -10
  41. package/src/pages/deployments.tsx +6 -4
  42. package/src/pages/dev.ts +15 -17
  43. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  44. package/src/pages/functions.ts +8 -4
  45. package/src/pages/index.ts +3 -3
  46. package/src/pages/projects.tsx +7 -12
  47. package/src/pages/publish.tsx +6 -4
  48. package/src/pages/types.ts +5 -0
  49. package/src/pages/upload.tsx +6 -4
  50. package/src/parse.ts +23 -1
  51. package/src/publish/index.ts +19 -15
  52. package/src/publish/publish.ts +2 -2
  53. package/src/pubsub/pubsub-commands.ts +18 -19
  54. package/src/queues/cli/commands/consumer/add.ts +18 -24
  55. package/src/queues/cli/commands/consumer/index.ts +3 -6
  56. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  57. package/src/queues/cli/commands/create.ts +8 -8
  58. package/src/queues/cli/commands/delete.ts +8 -8
  59. package/src/queues/cli/commands/index.ts +3 -4
  60. package/src/queues/cli/commands/list.ts +8 -8
  61. package/src/r2/index.ts +28 -28
  62. package/src/secret/index.ts +9 -14
  63. package/src/tail/index.ts +6 -8
  64. package/src/yargs-types.ts +18 -5
  65. package/templates/checked-fetch.js +9 -1
  66. package/wrangler-dist/cli.js +1969 -1228
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -1,9 +1,6 @@
1
- import { cwd } from "process";
2
1
  import { mockConsoleMethods } from "../helpers/mock-console";
3
- import { useMockIsTTY } from "../helpers/mock-istty";
4
2
  import { runInTempDir } from "../helpers/run-in-tmp";
5
3
  import { runWrangler } from "../helpers/run-wrangler";
6
- import writeWranglerToml from "../helpers/write-wrangler-toml";
7
4
 
8
5
  function endEventLoop() {
9
6
  return new Promise((resolve) => setImmediate(resolve));
@@ -12,7 +9,6 @@ function endEventLoop() {
12
9
  describe("d1", () => {
13
10
  const std = mockConsoleMethods();
14
11
  runInTempDir();
15
- const { setIsTTY } = useMockIsTTY();
16
12
 
17
13
  it("should show help when no argument is passed", async () => {
18
14
  await runWrangler("d1");
@@ -32,10 +28,11 @@ describe("d1", () => {
32
28
  wrangler d1 migrations Interact with D1 Migrations
33
29
 
34
30
  Flags:
35
- -c, --config Path to .toml configuration file [string]
36
- -e, --env Environment to use for operations and .env files [string]
37
- -h, --help Show help [boolean]
38
- -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]
39
36
 
40
37
  --------------------
41
38
  🚧 D1 is currently in open alpha and is not recommended for production data and traffic
@@ -71,10 +68,11 @@ describe("d1", () => {
71
68
  wrangler d1 migrations Interact with D1 Migrations
72
69
 
73
70
  Flags:
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]
71
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
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]
78
76
 
79
77
  --------------------
80
78
  🚧 D1 is currently in open alpha and is not recommended for production data and traffic
@@ -84,44 +82,4 @@ describe("d1", () => {
84
82
  --------------------"
85
83
  `);
86
84
  });
87
-
88
- describe("migrate", () => {
89
- describe("apply", () => {
90
- it("should not attempt to login in local mode", async () => {
91
- setIsTTY(false);
92
- writeWranglerToml({
93
- d1_databases: [
94
- { binding: "DATABASE", database_name: "db", database_id: "xxxx" },
95
- ],
96
- });
97
- // If we get to the point where we are checking for migrations then we have not been asked to log in.
98
- await expect(
99
- runWrangler("d1 migrations apply --local DATABASE")
100
- ).rejects.toThrowError(
101
- `No migrations present at ${cwd().replaceAll("\\", "/")}/migrations.`
102
- );
103
- });
104
-
105
- it("should try to read D1 config from wrangler.toml", async () => {
106
- setIsTTY(false);
107
- writeWranglerToml();
108
- await expect(
109
- runWrangler("d1 migrations apply DATABASE")
110
- ).rejects.toThrowError(
111
- "Can't find a DB with name/binding 'DATABASE' in local config. Check info in wrangler.toml..."
112
- );
113
- });
114
-
115
- it("should not try to read wrangler.toml in local mode", async () => {
116
- setIsTTY(false);
117
- writeWranglerToml();
118
- // If we get to the point where we are checking for migrations then we have not checked wrangler.toml.
119
- await expect(
120
- runWrangler("d1 migrations apply --local DATABASE")
121
- ).rejects.toThrowError(
122
- `No migrations present at ${cwd().replaceAll("\\", "/")}/migrations.`
123
- );
124
- });
125
- });
126
- });
127
85
  });
@@ -0,0 +1,48 @@
1
+ import { cwd } from "process";
2
+ import { useMockIsTTY } from "../helpers/mock-istty";
3
+ import { runInTempDir } from "../helpers/run-in-tmp";
4
+ import { runWrangler } from "../helpers/run-wrangler";
5
+ import writeWranglerToml from "../helpers/write-wrangler-toml";
6
+
7
+ describe("migrate", () => {
8
+ runInTempDir();
9
+ const { setIsTTY } = useMockIsTTY();
10
+
11
+ describe("apply", () => {
12
+ it("should not attempt to login in local mode", async () => {
13
+ setIsTTY(false);
14
+ writeWranglerToml({
15
+ d1_databases: [
16
+ { binding: "DATABASE", database_name: "db", database_id: "xxxx" },
17
+ ],
18
+ });
19
+ // If we get to the point where we are checking for migrations then we have not been asked to log in.
20
+ await expect(
21
+ runWrangler("d1 migrations apply --local DATABASE")
22
+ ).rejects.toThrowError(
23
+ `No migrations present at ${cwd().replaceAll("\\", "/")}/migrations.`
24
+ );
25
+ });
26
+
27
+ it("should try to read D1 config from wrangler.toml", async () => {
28
+ setIsTTY(false);
29
+ writeWranglerToml();
30
+ await expect(
31
+ runWrangler("d1 migrations apply DATABASE")
32
+ ).rejects.toThrowError(
33
+ "Can't find a DB with name/binding 'DATABASE' in local config. Check info in wrangler.toml..."
34
+ );
35
+ });
36
+
37
+ it("should not try to read wrangler.toml in local mode", async () => {
38
+ setIsTTY(false);
39
+ writeWranglerToml();
40
+ // If we get to the point where we are checking for migrations then we have not checked wrangler.toml.
41
+ await expect(
42
+ runWrangler("d1 migrations apply --local DATABASE")
43
+ ).rejects.toThrowError(
44
+ `No migrations present at ${cwd().replaceAll("\\", "/")}/migrations.`
45
+ );
46
+ });
47
+ });
48
+ });
@@ -1218,10 +1218,11 @@ describe("wrangler dev", () => {
1218
1218
  script The path to an entry point for your worker [string]
1219
1219
 
1220
1220
  Flags:
1221
- -c, --config Path to .toml configuration file [string]
1222
- -e, --env Environment to use for operations and .env files [string]
1223
- -h, --help Show help [boolean]
1224
- -v, --version Show version number [boolean]
1221
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
1222
+ -c, --config Path to .toml configuration file [string]
1223
+ -e, --env Environment to use for operations and .env files [string]
1224
+ -h, --help Show help [boolean]
1225
+ -v, --version Show version number [boolean]
1225
1226
 
1226
1227
  Options:
1227
1228
  --name Name of the worker [string]
@@ -56,10 +56,11 @@ describe("wrangler", () => {
56
56
  wrangler deployments 🚢 Displays the 10 most recent deployments for a worker
57
57
 
58
58
  Flags:
59
- -c, --config Path to .toml configuration file [string]
60
- -e, --env Environment to use for operations and .env files [string]
61
- -h, --help Show help [boolean]
62
- -v, --version Show version number [boolean]"
59
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
60
+ -c, --config Path to .toml configuration file [string]
61
+ -e, --env Environment to use for operations and .env files [string]
62
+ -h, --help Show help [boolean]
63
+ -v, --version Show version number [boolean]"
63
64
  `);
64
65
 
65
66
  expect(std.err).toMatchInlineSnapshot(`""`);
@@ -104,10 +105,11 @@ describe("wrangler", () => {
104
105
  wrangler deployments 🚢 Displays the 10 most recent deployments for a worker
105
106
 
106
107
  Flags:
107
- -c, --config Path to .toml configuration file [string]
108
- -e, --env Environment to use for operations and .env files [string]
109
- -h, --help Show help [boolean]
110
- -v, --version Show version number [boolean]"
108
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
109
+ -c, --config Path to .toml configuration file [string]
110
+ -e, --env Environment to use for operations and .env files [string]
111
+ -h, --help Show help [boolean]
112
+ -v, --version Show version number [boolean]"
111
113
  `);
112
114
  expect(std.err).toMatchInlineSnapshot(`
113
115
  "X [ERROR] Unknown argument: invalid-command
@@ -151,10 +153,11 @@ describe("wrangler", () => {
151
153
  wrangler secret list List all secrets for a Worker
152
154
 
153
155
  Flags:
154
- -c, --config Path to .toml configuration file [string]
155
- -e, --env Environment to use for operations and .env files [string]
156
- -h, --help Show help [boolean]
157
- -v, --version Show version number [boolean]"
156
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
157
+ -c, --config Path to .toml configuration file [string]
158
+ -e, --env Environment to use for operations and .env files [string]
159
+ -h, --help Show help [boolean]
160
+ -v, --version Show version number [boolean]"
158
161
  `);
159
162
  });
160
163
 
@@ -172,10 +175,11 @@ describe("wrangler", () => {
172
175
  wrangler kv:namespace delete Deletes a given namespace.
173
176
 
174
177
  Flags:
175
- -c, --config Path to .toml configuration file [string]
176
- -e, --env Environment to use for operations and .env files [string]
177
- -h, --help Show help [boolean]
178
- -v, --version Show version number [boolean]"
178
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
179
+ -c, --config Path to .toml configuration file [string]
180
+ -e, --env Environment to use for operations and .env files [string]
181
+ -h, --help Show help [boolean]
182
+ -v, --version Show version number [boolean]"
179
183
  `);
180
184
  });
181
185
 
@@ -194,10 +198,11 @@ describe("wrangler", () => {
194
198
  wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
195
199
 
196
200
  Flags:
197
- -c, --config Path to .toml configuration file [string]
198
- -e, --env Environment to use for operations and .env files [string]
199
- -h, --help Show help [boolean]
200
- -v, --version Show version number [boolean]"
201
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
202
+ -c, --config Path to .toml configuration file [string]
203
+ -e, --env Environment to use for operations and .env files [string]
204
+ -h, --help Show help [boolean]
205
+ -v, --version Show version number [boolean]"
201
206
  `);
202
207
  });
203
208
 
@@ -214,10 +219,11 @@ describe("wrangler", () => {
214
219
  wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
215
220
 
216
221
  Flags:
217
- -c, --config Path to .toml configuration file [string]
218
- -e, --env Environment to use for operations and .env files [string]
219
- -h, --help Show help [boolean]
220
- -v, --version Show version number [boolean]"
222
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
223
+ -c, --config Path to .toml configuration file [string]
224
+ -e, --env Environment to use for operations and .env files [string]
225
+ -h, --help Show help [boolean]
226
+ -v, --version Show version number [boolean]"
221
227
  `);
222
228
  });
223
229
 
@@ -234,10 +240,11 @@ describe("wrangler", () => {
234
240
  wrangler r2 bucket Manage R2 buckets
235
241
 
236
242
  Flags:
237
- -c, --config Path to .toml configuration file [string]
238
- -e, --env Environment to use for operations and .env files [string]
239
- -h, --help Show help [boolean]
240
- -v, --version Show version number [boolean]"
243
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
244
+ -c, --config Path to .toml configuration file [string]
245
+ -e, --env Environment to use for operations and .env files [string]
246
+ -h, --help Show help [boolean]
247
+ -v, --version Show version number [boolean]"
241
248
  `);
242
249
  });
243
250
  });
@@ -63,10 +63,11 @@ describe("wrangler", () => {
63
63
  namespace The name of the new namespace [string] [required]
64
64
 
65
65
  Flags:
66
- -c, --config Path to .toml configuration file [string]
67
- -e, --env Environment to use for operations and .env files [string]
68
- -h, --help Show help [boolean]
69
- -v, --version Show version number [boolean]
66
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
67
+ -c, --config Path to .toml configuration file [string]
68
+ -e, --env Environment to use for operations and .env files [string]
69
+ -h, --help Show help [boolean]
70
+ -v, --version Show version number [boolean]
70
71
 
71
72
  Options:
72
73
  --preview Interact with a preview namespace [boolean]"
@@ -94,10 +95,11 @@ describe("wrangler", () => {
94
95
  namespace The name of the new namespace [string] [required]
95
96
 
96
97
  Flags:
97
- -c, --config Path to .toml configuration file [string]
98
- -e, --env Environment to use for operations and .env files [string]
99
- -h, --help Show help [boolean]
100
- -v, --version Show version number [boolean]
98
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
99
+ -c, --config Path to .toml configuration file [string]
100
+ -e, --env Environment to use for operations and .env files [string]
101
+ -h, --help Show help [boolean]
102
+ -v, --version Show version number [boolean]
101
103
 
102
104
  Options:
103
105
  --preview Interact with a preview namespace [boolean]"
@@ -126,10 +128,11 @@ describe("wrangler", () => {
126
128
  namespace The name of the new namespace [string] [required]
127
129
 
128
130
  Flags:
129
- -c, --config Path to .toml configuration file [string]
130
- -e, --env Environment to use for operations and .env files [string]
131
- -h, --help Show help [boolean]
132
- -v, --version Show version number [boolean]
131
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
132
+ -c, --config Path to .toml configuration file [string]
133
+ -e, --env Environment to use for operations and .env files [string]
134
+ -h, --help Show help [boolean]
135
+ -v, --version Show version number [boolean]
133
136
 
134
137
  Options:
135
138
  --preview Interact with a preview namespace [boolean]"
@@ -552,10 +555,11 @@ describe("wrangler", () => {
552
555
  value The value to write [string]
553
556
 
554
557
  Flags:
555
- -c, --config Path to .toml configuration file [string]
556
- -e, --env Environment to use for operations and .env files [string]
557
- -h, --help Show help [boolean]
558
- -v, --version Show version number [boolean]
558
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
559
+ -c, --config Path to .toml configuration file [string]
560
+ -e, --env Environment to use for operations and .env files [string]
561
+ -h, --help Show help [boolean]
562
+ -v, --version Show version number [boolean]
559
563
 
560
564
  Options:
561
565
  --binding The binding of the namespace to write to [string]
@@ -591,10 +595,11 @@ describe("wrangler", () => {
591
595
  value The value to write [string]
592
596
 
593
597
  Flags:
594
- -c, --config Path to .toml configuration file [string]
595
- -e, --env Environment to use for operations and .env files [string]
596
- -h, --help Show help [boolean]
597
- -v, --version Show version number [boolean]
598
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
599
+ -c, --config Path to .toml configuration file [string]
600
+ -e, --env Environment to use for operations and .env files [string]
601
+ -h, --help Show help [boolean]
602
+ -v, --version Show version number [boolean]
598
603
 
599
604
  Options:
600
605
  --binding The binding of the namespace to write to [string]
@@ -630,10 +635,11 @@ describe("wrangler", () => {
630
635
  value The value to write [string]
631
636
 
632
637
  Flags:
633
- -c, --config Path to .toml configuration file [string]
634
- -e, --env Environment to use for operations and .env files [string]
635
- -h, --help Show help [boolean]
636
- -v, --version Show version number [boolean]
638
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
639
+ -c, --config Path to .toml configuration file [string]
640
+ -e, --env Environment to use for operations and .env files [string]
641
+ -h, --help Show help [boolean]
642
+ -v, --version Show version number [boolean]
637
643
 
638
644
  Options:
639
645
  --binding The binding of the namespace to write to [string]
@@ -669,10 +675,11 @@ describe("wrangler", () => {
669
675
  value The value to write [string]
670
676
 
671
677
  Flags:
672
- -c, --config Path to .toml configuration file [string]
673
- -e, --env Environment to use for operations and .env files [string]
674
- -h, --help Show help [boolean]
675
- -v, --version Show version number [boolean]
678
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
679
+ -c, --config Path to .toml configuration file [string]
680
+ -e, --env Environment to use for operations and .env files [string]
681
+ -h, --help Show help [boolean]
682
+ -v, --version Show version number [boolean]
676
683
 
677
684
  Options:
678
685
  --binding The binding of the namespace to write to [string]
@@ -708,10 +715,11 @@ describe("wrangler", () => {
708
715
  value The value to write [string]
709
716
 
710
717
  Flags:
711
- -c, --config Path to .toml configuration file [string]
712
- -e, --env Environment to use for operations and .env files [string]
713
- -h, --help Show help [boolean]
714
- -v, --version Show version number [boolean]
718
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
719
+ -c, --config Path to .toml configuration file [string]
720
+ -e, --env Environment to use for operations and .env files [string]
721
+ -h, --help Show help [boolean]
722
+ -v, --version Show version number [boolean]
715
723
 
716
724
  Options:
717
725
  --binding The binding of the namespace to write to [string]
@@ -1083,10 +1091,11 @@ describe("wrangler", () => {
1083
1091
  key The key value to get. [string] [required]
1084
1092
 
1085
1093
  Flags:
1086
- -c, --config Path to .toml configuration file [string]
1087
- -e, --env Environment to use for operations and .env files [string]
1088
- -h, --help Show help [boolean]
1089
- -v, --version Show version number [boolean]
1094
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
1095
+ -c, --config Path to .toml configuration file [string]
1096
+ -e, --env Environment to use for operations and .env files [string]
1097
+ -h, --help Show help [boolean]
1098
+ -v, --version Show version number [boolean]
1090
1099
 
1091
1100
  Options:
1092
1101
  --binding The name of the namespace to get from [string]
@@ -1117,10 +1126,11 @@ describe("wrangler", () => {
1117
1126
  key The key value to get. [string] [required]
1118
1127
 
1119
1128
  Flags:
1120
- -c, --config Path to .toml configuration file [string]
1121
- -e, --env Environment to use for operations and .env files [string]
1122
- -h, --help Show help [boolean]
1123
- -v, --version Show version number [boolean]
1129
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
1130
+ -c, --config Path to .toml configuration file [string]
1131
+ -e, --env Environment to use for operations and .env files [string]
1132
+ -h, --help Show help [boolean]
1133
+ -v, --version Show version number [boolean]
1124
1134
 
1125
1135
  Options:
1126
1136
  --binding The name of the namespace to get from [string]
@@ -1152,10 +1162,11 @@ describe("wrangler", () => {
1152
1162
  key The key value to get. [string] [required]
1153
1163
 
1154
1164
  Flags:
1155
- -c, --config Path to .toml configuration file [string]
1156
- -e, --env Environment to use for operations and .env files [string]
1157
- -h, --help Show help [boolean]
1158
- -v, --version Show version number [boolean]
1165
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
1166
+ -c, --config Path to .toml configuration file [string]
1167
+ -e, --env Environment to use for operations and .env files [string]
1168
+ -h, --help Show help [boolean]
1169
+ -v, --version Show version number [boolean]
1159
1170
 
1160
1171
  Options:
1161
1172
  --binding The name of the namespace to get from [string]
@@ -69,10 +69,11 @@ describe("pages", () => {
69
69
  wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment
70
70
 
71
71
  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]
72
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
73
+ -c, --config Path to .toml configuration file [string]
74
+ -e, --env Environment to use for operations and .env files [string]
75
+ -h, --help Show help [boolean]
76
+ -v, --version Show version number [boolean]
76
77
 
77
78
  🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
78
79
  `);
@@ -340,9 +341,10 @@ describe("pages", () => {
340
341
  directory The directory of static files to upload [string]
341
342
 
342
343
  Flags:
343
- -e, --env Environment to use for operations and .env files [string]
344
- -h, --help Show help [boolean]
345
- -v, --version Show version number [boolean]
344
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
345
+ -e, --env Environment to use for operations and .env files [string]
346
+ -h, --help Show help [boolean]
347
+ -v, --version Show version number [boolean]
346
348
 
347
349
  Options:
348
350
  --project-name The name of the project you want to deploy to [string]
@@ -1468,6 +1470,8 @@ describe("pages", () => {
1468
1470
  expect(std.err).toMatchInlineSnapshot('""');
1469
1471
  });
1470
1472
 
1473
+ const workerHasD1Shim = (contents: string) => contents.includes("D1_ERROR");
1474
+
1471
1475
  it("should upload an Advanced Mode project", async () => {
1472
1476
  // set up the directory of static files to upload.
1473
1477
  mkdirSync("public");
@@ -1480,6 +1484,7 @@ describe("pages", () => {
1480
1484
  export default {
1481
1485
  async fetch(request, env) {
1482
1486
  const url = new URL(request.url);
1487
+ console.log("SOMETHING FROM WITHIN THE WORKER");
1483
1488
  return url.pathname.startsWith('/api/') ? new Response('Ok') : env.ASSETS.fetch(request);
1484
1489
  }
1485
1490
  };
@@ -1555,16 +1560,11 @@ describe("pages", () => {
1555
1560
  }
1556
1561
  `);
1557
1562
 
1558
- expect(customWorkerJS).toMatchInlineSnapshot(`
1559
- "
1560
- export default {
1561
- async fetch(request, env) {
1562
- const url = new URL(request.url);
1563
- return url.pathname.startsWith('/api/') ? new Response('Ok') : env.ASSETS.fetch(request);
1564
- }
1565
- };
1566
- "
1567
- `);
1563
+ expect(workerHasD1Shim(customWorkerJS as string)).toBeTruthy();
1564
+ expect(customWorkerJS).toContain(
1565
+ `console.log("SOMETHING FROM WITHIN THE WORKER");`
1566
+ );
1567
+
1568
1568
  return res.once(
1569
1569
  ctx.status(200),
1570
1570
  ctx.json({
@@ -1590,15 +1590,22 @@ describe("pages", () => {
1590
1590
  errors: [],
1591
1591
  messages: [],
1592
1592
  result: {
1593
- deployment_configs: { production: {}, preview: {} },
1594
- },
1593
+ deployment_configs: {
1594
+ production: {
1595
+ d1_databases: { MY_D1_DB: { id: "fake-db" } },
1596
+ },
1597
+ preview: {
1598
+ d1_databases: { MY_D1_DB: { id: "fake-db" } },
1599
+ },
1600
+ },
1601
+ } as Partial<Project>,
1595
1602
  })
1596
1603
  );
1597
1604
  }
1598
1605
  )
1599
1606
  );
1600
1607
 
1601
- await runWrangler("pages publish public --project-name=foo");
1608
+ await runWrangler("pages publish public --project-name=foo --bundle");
1602
1609
 
1603
1610
  expect(std.out).toMatchInlineSnapshot(`
1604
1611
  "✨ Success! Uploaded 1 files (TIMINGS)