wrangler 0.0.0-e2f9bb2 → 0.0.0-e3278fa

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 (90) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +3 -1
  3. package/bin/wrangler.js +36 -4
  4. package/package.json +12 -7
  5. package/pages/functions/buildPlugin.ts +13 -0
  6. package/pages/functions/buildWorker.ts +14 -1
  7. package/pages/functions/template-plugin.ts +3 -2
  8. package/src/__tests__/configuration.test.ts +370 -87
  9. package/src/__tests__/dev.test.tsx +298 -77
  10. package/src/__tests__/helpers/mock-dialogs.ts +43 -2
  11. package/src/__tests__/index.test.ts +79 -72
  12. package/src/__tests__/init.test.ts +718 -123
  13. package/src/__tests__/jest.setup.ts +8 -0
  14. package/src/__tests__/kv.test.ts +173 -146
  15. package/src/__tests__/package-manager.test.ts +154 -7
  16. package/src/__tests__/pages.test.ts +478 -53
  17. package/src/__tests__/parse.test.ts +8 -0
  18. package/src/__tests__/publish.test.ts +1094 -215
  19. package/src/__tests__/r2.test.ts +55 -36
  20. package/src/__tests__/secret.test.ts +39 -4
  21. package/src/__tests__/whoami.test.tsx +34 -0
  22. package/src/abort.d.ts +3 -0
  23. package/src/bundle.ts +34 -6
  24. package/src/cfetch/index.ts +21 -4
  25. package/src/cfetch/internal.ts +23 -18
  26. package/src/config/config.ts +2 -2
  27. package/src/config/environment.ts +40 -14
  28. package/src/config/index.ts +162 -0
  29. package/src/config/validation-helpers.ts +10 -1
  30. package/src/config/validation.ts +180 -65
  31. package/src/create-worker-preview.ts +32 -22
  32. package/src/create-worker-upload-form.ts +22 -8
  33. package/src/dev/dev.tsx +12 -18
  34. package/src/dev/local.tsx +10 -0
  35. package/src/dev/remote.tsx +40 -16
  36. package/src/dialogs.tsx +48 -0
  37. package/src/durable.ts +102 -0
  38. package/src/entry.ts +64 -9
  39. package/src/index.tsx +548 -317
  40. package/src/inspect.ts +39 -0
  41. package/src/kv.ts +114 -25
  42. package/src/open-in-browser.ts +5 -12
  43. package/src/package-manager.ts +50 -3
  44. package/src/pages.tsx +434 -207
  45. package/src/parse.ts +23 -4
  46. package/src/proxy.ts +59 -35
  47. package/src/publish.ts +374 -127
  48. package/src/sites.tsx +61 -28
  49. package/src/user.tsx +23 -2
  50. package/src/whoami.tsx +3 -2
  51. package/src/worker.ts +10 -1
  52. package/src/zones.ts +73 -0
  53. package/templates/new-worker-scheduled.js +17 -0
  54. package/templates/new-worker-scheduled.ts +32 -0
  55. package/templates/new-worker.ts +16 -1
  56. package/templates/static-asset-facade.js +0 -4
  57. package/wrangler-dist/cli.js +96965 -83414
  58. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  59. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  60. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  61. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  62. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  63. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  64. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  65. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  66. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  67. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  68. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  69. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  70. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  71. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  72. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  73. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  74. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  75. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  76. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  77. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  78. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  79. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  80. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  81. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  82. package/vendor/wrangler-mime/LICENSE +0 -21
  83. package/vendor/wrangler-mime/Mime.js +0 -97
  84. package/vendor/wrangler-mime/README.md +0 -187
  85. package/vendor/wrangler-mime/cli.js +0 -46
  86. package/vendor/wrangler-mime/index.js +0 -4
  87. package/vendor/wrangler-mime/lite.js +0 -4
  88. package/vendor/wrangler-mime/package.json +0 -52
  89. package/vendor/wrangler-mime/types/other.js +0 -1
  90. package/vendor/wrangler-mime/types/standard.js +0 -1
@@ -2,6 +2,8 @@ import { getPackageManager } from "../package-manager";
2
2
  import { mockConsoleMethods } from "./helpers/mock-console";
3
3
  import { runInTempDir } from "./helpers/run-in-tmp";
4
4
  import { runWrangler } from "./helpers/run-wrangler";
5
+ import { writeWorkerSource } from "./helpers/write-worker-source";
6
+ import writeWranglerToml from "./helpers/write-wrangler-toml";
5
7
  import type { PackageManager } from "../package-manager";
6
8
 
7
9
  describe("wrangler", () => {
@@ -44,10 +46,9 @@ describe("wrangler", () => {
44
46
  wrangler whoami 🕵️ Retrieve your user info and test your auth config
45
47
 
46
48
  Flags:
47
- -c, --config Path to .toml configuration file [string]
48
- -h, --help Show help [boolean]
49
- -v, --version Show version number [boolean]
50
- --legacy-env Use legacy environments [boolean]"
49
+ -c, --config Path to .toml configuration file [string]
50
+ -h, --help Show help [boolean]
51
+ -v, --version Show version number [boolean]"
51
52
  `);
52
53
 
53
54
  expect(std.err).toMatchInlineSnapshot(`""`);
@@ -64,10 +65,7 @@ describe("wrangler", () => {
64
65
 
65
66
  expect(std.out).toMatchInlineSnapshot(`
66
67
  "
67
- "
68
- `);
69
- expect(std.err).toMatchInlineSnapshot(`
70
- "wrangler
68
+ wrangler
71
69
 
72
70
  Commands:
73
71
  wrangler init [name] 📥 Create a wrangler.toml configuration file
@@ -85,11 +83,12 @@ describe("wrangler", () => {
85
83
  wrangler whoami 🕵️ Retrieve your user info and test your auth config
86
84
 
87
85
  Flags:
88
- -c, --config Path to .toml configuration file [string]
89
- -h, --help Show help [boolean]
90
- -v, --version Show version number [boolean]
91
- --legacy-env Use legacy environments [boolean]
92
- X [ERROR] Unknown argument: invalid-command
86
+ -c, --config Path to .toml configuration file [string]
87
+ -h, --help Show help [boolean]
88
+ -v, --version Show version number [boolean]"
89
+ `);
90
+ expect(std.err).toMatchInlineSnapshot(`
91
+ "X [ERROR] Unknown argument: invalid-command
93
92
 
94
93
  "
95
94
  `);
@@ -116,9 +115,6 @@ describe("wrangler", () => {
116
115
  });
117
116
 
118
117
  describe("subcommand implicit help ran on incomplete command execution", () => {
119
- function endEventLoop() {
120
- return new Promise((resolve) => setImmediate(resolve));
121
- }
122
118
  it("no subcommand for 'secret' should display a list of available subcommands", async () => {
123
119
  await runWrangler("secret");
124
120
  await endEventLoop();
@@ -133,10 +129,9 @@ describe("wrangler", () => {
133
129
  wrangler secret list List all secrets for a script
134
130
 
135
131
  Flags:
136
- -c, --config Path to .toml configuration file [string]
137
- -h, --help Show help [boolean]
138
- -v, --version Show version number [boolean]
139
- --legacy-env Use legacy environments [boolean]"
132
+ -c, --config Path to .toml configuration file [string]
133
+ -h, --help Show help [boolean]
134
+ -v, --version Show version number [boolean]"
140
135
  `);
141
136
  });
142
137
 
@@ -144,20 +139,19 @@ describe("wrangler", () => {
144
139
  await runWrangler("kv:namespace");
145
140
  await endEventLoop();
146
141
  expect(std.out).toMatchInlineSnapshot(`
147
- "wrangler kv:namespace
142
+ "wrangler kv:namespace
148
143
 
149
- 🗂️ Interact with your Workers KV Namespaces
144
+ 🗂️ Interact with your Workers KV Namespaces
150
145
 
151
- Commands:
152
- wrangler kv:namespace create <namespace> Create a new namespace
153
- wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
154
- wrangler kv:namespace delete Deletes a given namespace.
146
+ Commands:
147
+ wrangler kv:namespace create <namespace> Create a new namespace
148
+ wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
149
+ wrangler kv:namespace delete Deletes a given namespace.
155
150
 
156
- Flags:
157
- -c, --config Path to .toml configuration file [string]
158
- -h, --help Show help [boolean]
159
- -v, --version Show version number [boolean]
160
- --legacy-env Use legacy environments [boolean]"
151
+ Flags:
152
+ -c, --config Path to .toml configuration file [string]
153
+ -h, --help Show help [boolean]
154
+ -v, --version Show version number [boolean]"
161
155
  `);
162
156
  });
163
157
 
@@ -165,62 +159,61 @@ describe("wrangler", () => {
165
159
  await runWrangler("kv:key");
166
160
  await endEventLoop();
167
161
  expect(std.out).toMatchInlineSnapshot(`
168
- "wrangler kv:key
162
+ "wrangler kv:key
169
163
 
170
- 🔑 Individually manage Workers KV key-value pairs
164
+ 🔑 Individually manage Workers KV key-value pairs
171
165
 
172
- Commands:
173
- wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
174
- wrangler kv:key list Outputs a list of all keys in a given namespace.
175
- wrangler kv:key get <key> Reads a single value by key from the given namespace.
176
- wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
166
+ Commands:
167
+ wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
168
+ wrangler kv:key list Outputs a list of all keys in a given namespace.
169
+ wrangler kv:key get <key> Reads a single value by key from the given namespace.
170
+ wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
177
171
 
178
- Flags:
179
- -c, --config Path to .toml configuration file [string]
180
- -h, --help Show help [boolean]
181
- -v, --version Show version number [boolean]
182
- --legacy-env Use legacy environments [boolean]"
183
- `);
172
+ Flags:
173
+ -c, --config Path to .toml configuration file [string]
174
+ -h, --help Show help [boolean]
175
+ -v, --version Show version number [boolean]"
176
+ `);
184
177
  });
185
178
 
186
179
  it("no subcommand 'kv:bulk' should display a list of available subcommands", async () => {
187
180
  await runWrangler("kv:bulk");
188
181
  await endEventLoop();
189
182
  expect(std.out).toMatchInlineSnapshot(`
190
- "wrangler kv:bulk
183
+ "wrangler kv:bulk
191
184
 
192
- 💪 Interact with multiple Workers KV key-value pairs at once
185
+ 💪 Interact with multiple Workers KV key-value pairs at once
193
186
 
194
- Commands:
195
- wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
196
- wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
187
+ Commands:
188
+ wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
189
+ wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
197
190
 
198
- Flags:
199
- -c, --config Path to .toml configuration file [string]
200
- -h, --help Show help [boolean]
201
- -v, --version Show version number [boolean]
202
- --legacy-env Use legacy environments [boolean]"
203
- `);
191
+ Flags:
192
+ -c, --config Path to .toml configuration file [string]
193
+ -h, --help Show help [boolean]
194
+ -v, --version Show version number [boolean]"
195
+ `);
204
196
  });
197
+
205
198
  it("no subcommand 'r2' should display a list of available subcommands", async () => {
206
199
  await runWrangler("r2");
207
200
  await endEventLoop();
208
201
  expect(std.out).toMatchInlineSnapshot(`
209
- "wrangler r2
202
+ "wrangler r2
210
203
 
211
- 📦 Interact with an R2 store
204
+ 📦 Interact with an R2 store
212
205
 
213
- Commands:
214
- wrangler r2 bucket Manage R2 buckets
206
+ Commands:
207
+ wrangler r2 bucket Manage R2 buckets
215
208
 
216
- Flags:
217
- -c, --config Path to .toml configuration file [string]
218
- -h, --help Show help [boolean]
219
- -v, --version Show version number [boolean]
220
- --legacy-env Use legacy environments [boolean]"
221
- `);
209
+ Flags:
210
+ -c, --config Path to .toml configuration file [string]
211
+ -h, --help Show help [boolean]
212
+ -v, --version Show version number [boolean]"
213
+ `);
222
214
  });
223
215
  });
216
+
224
217
  describe("Deprecated commands", () => {
225
218
  it("should print a deprecation message for 'generate'", async () => {
226
219
  await runWrangler("generate").catch((err) => {
@@ -237,13 +230,27 @@ describe("wrangler", () => {
237
230
  `);
238
231
  });
239
232
  });
240
- it("should print a deprecation message for 'build'", async () => {
241
- await runWrangler("build").catch((err) => {
242
- expect(err.message).toMatchInlineSnapshot(`
243
- "Deprecation:
244
- \`wrangler build\` has been deprecated, please refer to https://github.com/cloudflare/wrangler2/blob/main/docs/deprecations.md#build for alternatives"
245
- `);
246
- });
233
+ });
234
+
235
+ it("should print a deprecation message for 'build' and then try to run `publish --dry-run --outdir`", async () => {
236
+ writeWranglerToml({
237
+ main: "index.js",
247
238
  });
239
+ writeWorkerSource();
240
+ await runWrangler("build");
241
+ await endEventLoop();
242
+ expect(std.out).toMatchInlineSnapshot(`
243
+ "▲ [WARNING] Deprecation: \`wrangler build\` has been deprecated.
244
+
245
+ Please refer to https://developers.cloudflare.com/workers/wrangler/migration/deprecations/#build for more information.
246
+ Attempting to run \`wrangler publish --dry-run --outdir=dist\` for you instead:
247
+
248
+
249
+ --dry-run: exiting now."
250
+ `);
248
251
  });
249
252
  });
253
+
254
+ function endEventLoop() {
255
+ return new Promise((resolve) => setImmediate(resolve));
256
+ }