wrangler 0.0.0-e151223 → 0.0.0-e29a241

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 (92) hide show
  1. package/miniflare-dist/index.mjs +79 -0
  2. package/miniflare-dist/index.mjs.map +7 -0
  3. package/package.json +29 -13
  4. package/pages/functions/filepath-routing.test.ts +212 -36
  5. package/pages/functions/filepath-routing.ts +69 -119
  6. package/pages/functions/routes.ts +8 -17
  7. package/pages/functions/template-worker.ts +3 -9
  8. package/src/__tests__/configuration.test.ts +2754 -0
  9. package/src/__tests__/dev.test.tsx +488 -63
  10. package/src/__tests__/dev2.test.tsx +154 -0
  11. package/src/__tests__/guess-worker-format.test.ts +58 -0
  12. package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
  13. package/src/__tests__/helpers/faye-websocket.d.ts +6 -0
  14. package/src/__tests__/helpers/mock-account-id.ts +26 -8
  15. package/src/__tests__/helpers/mock-bin.ts +36 -0
  16. package/src/__tests__/helpers/mock-cfetch.ts +44 -10
  17. package/src/__tests__/helpers/mock-console.ts +21 -7
  18. package/src/__tests__/helpers/mock-kv.ts +9 -16
  19. package/src/__tests__/helpers/mock-stdin.ts +103 -0
  20. package/src/__tests__/helpers/mock-web-socket.ts +29 -0
  21. package/src/__tests__/helpers/run-in-tmp.ts +3 -0
  22. package/src/__tests__/helpers/run-wrangler.ts +5 -3
  23. package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
  24. package/src/__tests__/https-options.test.ts +127 -0
  25. package/src/__tests__/index.test.ts +617 -32
  26. package/src/__tests__/jest.setup.ts +41 -6
  27. package/src/__tests__/kv.test.ts +455 -222
  28. package/src/__tests__/logout.test.ts +15 -13
  29. package/src/__tests__/package-manager.test.ts +206 -0
  30. package/src/__tests__/pages.test.ts +44 -0
  31. package/src/__tests__/parse.test.ts +322 -0
  32. package/src/__tests__/publish.test.ts +1919 -437
  33. package/src/__tests__/r2.test.ts +198 -0
  34. package/src/__tests__/route.test.ts +45 -0
  35. package/src/__tests__/secret.test.ts +301 -86
  36. package/src/__tests__/sentry.test.ts +146 -0
  37. package/src/__tests__/tail.test.ts +564 -0
  38. package/src/__tests__/whoami.test.tsx +21 -7
  39. package/src/bundle.ts +142 -0
  40. package/src/cfetch/index.ts +9 -16
  41. package/src/cfetch/internal.ts +89 -22
  42. package/src/cli.ts +10 -0
  43. package/src/config/README.md +107 -0
  44. package/src/config/config.ts +274 -0
  45. package/src/config/diagnostics.ts +80 -0
  46. package/src/config/environment.ts +310 -0
  47. package/src/config/index.ts +56 -0
  48. package/src/config/validation-helpers.ts +486 -0
  49. package/src/config/validation.ts +1096 -0
  50. package/src/{api/preview.ts → create-worker-preview.ts} +59 -21
  51. package/src/create-worker-upload-form.ts +217 -0
  52. package/src/dev/dev.tsx +364 -0
  53. package/src/dev/local.tsx +226 -0
  54. package/src/dev/remote.tsx +203 -0
  55. package/src/dev/use-esbuild.ts +100 -0
  56. package/src/entry.ts +208 -0
  57. package/src/environment-variables.ts +33 -0
  58. package/src/https-options.ts +122 -0
  59. package/src/index.tsx +1079 -766
  60. package/src/inspect.ts +25 -4
  61. package/src/{kv.tsx → kv.ts} +104 -61
  62. package/src/miniflare-cli/README.md +30 -0
  63. package/src/miniflare-cli/enum-keys.ts +17 -0
  64. package/src/miniflare-cli/index.ts +37 -0
  65. package/src/module-collection.ts +226 -31
  66. package/src/open-in-browser.ts +25 -0
  67. package/src/package-manager.ts +126 -0
  68. package/src/pages.tsx +11 -11
  69. package/src/parse.ts +183 -0
  70. package/src/proxy.ts +115 -45
  71. package/src/publish.ts +265 -328
  72. package/src/r2.ts +50 -0
  73. package/src/reporting.ts +131 -0
  74. package/src/selfsigned.d.ts +29 -0
  75. package/src/sites.tsx +83 -43
  76. package/src/tail/filters.ts +279 -0
  77. package/src/tail/index.ts +299 -0
  78. package/src/tail/printing.ts +62 -0
  79. package/src/user.tsx +223 -124
  80. package/src/{api/worker.ts → worker.ts} +44 -36
  81. package/templates/new-worker.js +15 -0
  82. package/templates/new-worker.ts +15 -0
  83. package/{static-asset-facade.js → templates/static-asset-facade.js} +0 -0
  84. package/templates/tsconfig.json +105 -0
  85. package/wrangler-dist/cli.js +60837 -43876
  86. package/wrangler-dist/cli.js.map +3 -3
  87. package/src/__tests__/helpers/mock-user.ts +0 -27
  88. package/src/api/form_data.ts +0 -134
  89. package/src/config.ts +0 -641
  90. package/src/dev.tsx +0 -834
  91. package/src/npm-installer.ts +0 -20
  92. package/src/tail.tsx +0 -73
package/src/config.ts DELETED
@@ -1,641 +0,0 @@
1
- import assert from "node:assert";
2
-
3
- /**
4
- * This is the static type definition for the configuration object.
5
- * It reflects the configuration that you can write in wrangler.toml,
6
- * and optionally augment with arguments passed directly to wrangler.
7
- * The type definition doesn't fully reflect the constraints applied
8
- * to the configuration, but it is a good starting point. Later, we
9
- * also defined a validator function that will validate the configuration
10
- * with the same rules as the type definition, as well as the extra
11
- * constraints. The type definition is good for asserting correctness
12
- * in the wrangler codebase, whereas the validator function is useful
13
- * for signalling errors in the configuration to a user of wrangler.
14
- *
15
- * For more information about the configuration object, see the
16
- * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
17
- *
18
- * Legend for the annotations:
19
- *
20
- * *:optional means providing a value isn't mandatory
21
- * *:deprecated means the field itself isn't necessary anymore in wrangler.toml
22
- * *:breaking means the deprecation/optionality is a breaking change from wrangler 1
23
- * *:todo means there's more work to be done (with details attached)
24
- * *:inherited means the field is copied to all environments
25
- */
26
- export type Config = {
27
- /**
28
- * The name of your worker. Alphanumeric + dashes only.
29
- *
30
- * @optional
31
- * @inherited
32
- */
33
- name?: string;
34
-
35
- /**
36
- * The entrypoint/path to the JavaScript file that will be executed.
37
- *
38
- * @optional
39
- * @inherited
40
- * @todo this needs to be implemented!
41
- */
42
- entry?: string;
43
-
44
- /**
45
- * This is the ID of the account associated with your zone.
46
- * You might have more than one account, so make sure to use
47
- * the ID of the account associated with the zone/route you
48
- * provide, if you provide one. It can also be specified through
49
- * the CF_ACCOUNT_ID environment variable.
50
- *
51
- * @optional
52
- * @inherited
53
- */
54
- account_id?: string;
55
-
56
- /**
57
- * The project "type". A holdover from wrangler 1.x.
58
- * Valid values were "webpack", "javascript", and "rust".
59
- *
60
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
61
- * @optional
62
- * @inherited
63
- * @breaking
64
- */
65
- type?: "webpack" | "javascript" | "rust";
66
-
67
- /**
68
- * A date in the form yyyy-mm-dd, which will be used to determine
69
- * which version of the Workers runtime is used. More details at
70
- * https://developers.cloudflare.com/workers/platform/compatibility-dates
71
- * @optional true for `dev`, false for `publish`
72
- * @inherited
73
- */
74
- compatibility_date?: string;
75
-
76
- /**
77
- * A list of flags that enable features from upcoming features of
78
- * the Workers runtime, usually used together with compatibility_flags.
79
- * More details at
80
- * https://developers.cloudflare.com/workers/platform/compatibility-dates
81
- *
82
- * @optional
83
- * @inherited
84
- */
85
- compatibility_flags?: string[];
86
-
87
- /**
88
- * Whether we use <name>.<subdomain>.workers.dev to
89
- * test and deploy your worker.
90
- *
91
- * @default `true` (This is a breaking change from wrangler 1)
92
- * @optional
93
- * @inherited
94
- * @breaking
95
- */
96
- workers_dev?: boolean;
97
-
98
- /**
99
- * The zone ID of the zone you want to deploy to. You can find this
100
- * in your domain page on the dashboard.
101
- *
102
- * @deprecated This is unnecessary since we can deduce this from routes directly.
103
- * @optional
104
- * @inherited
105
- */
106
- zone_id?: string;
107
-
108
- /**
109
- * A list of routes that your worker should be deployed to.
110
- * Only one of `routes` or `route` is required.
111
- *
112
- * @optional false only when workers_dev is false, and there's no scheduled worker
113
- * @inherited
114
- */
115
- routes?: string[];
116
-
117
- /**
118
- * A route that your worker should be deployed to. Literally
119
- * the same as routes, but only one.
120
- * Only one of `routes` or `route` is required.
121
- *
122
- * @optional false only when workers_dev is false, and there's no scheduled worker
123
- * @inherited
124
- */
125
- route?: string;
126
-
127
- /**
128
- * Path to the webpack config to use when building your worker.
129
- * A holdover from wrangler 1.x, used with `type: "webpack"`.
130
- *
131
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
132
- * @inherited
133
- * @breaking
134
- */
135
- webpack_config?: string;
136
-
137
- /**
138
- * The function to use to replace jsx syntax.
139
- *
140
- * @default `"React.createElement"`
141
- * @optional
142
- * @inherited
143
- */
144
- jsx_factory?: string;
145
-
146
- /**
147
- * The function to use to replace jsx fragment syntax.
148
- *
149
- * @default `"React.Fragment"`
150
- * @optional
151
- * @inherited
152
- */
153
- jsx_fragment?: string;
154
-
155
- /**
156
- * A map of environment variables to set when deploying your worker.
157
- * Of note, they can only be strings. Which is unfortunate, really.
158
- * (TODO: verify that they can only be strings?)
159
- * NB: these are not inherited, and HAVE to be duplicated across all environments.
160
- *
161
- * @default `{}`
162
- * @optional
163
- * @inherited false
164
- */
165
- vars?: { [key: string]: string };
166
-
167
- /**
168
- * A list of durable objects that your worker should be bound to.
169
- * For more information about Durable Objects, see the documentation at
170
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
171
- * NB: these are not inherited, and HAVE to be duplicated across all environments.
172
- *
173
- * @default `{ bindings: [] }`
174
- * @optional
175
- * @inherited false
176
- */
177
- durable_objects?: {
178
- bindings: {
179
- /** The name of the binding used to refer to the Durable Object */
180
- name: string;
181
- /** The exported class name of the Durable Object */
182
- class_name: string;
183
- /** The script where the Durable Object is defined (if it's external to this worker) */
184
- script_name?: string;
185
- }[];
186
- };
187
-
188
- /**
189
- * These specify any Workers KV Namespaces you want to
190
- * access from inside your Worker. To learn more about KV Namespaces,
191
- * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
192
- * NB: these are not inherited, and HAVE to be duplicated across all environments.
193
- *
194
- * @default `[]`
195
- * @optional
196
- * @inherited false
197
- */
198
- kv_namespaces?: {
199
- /** The binding name used to refer to the KV Namespace */
200
- binding: string;
201
- /** The ID of the KV namespace */
202
- id: string;
203
- /** The ID of the KV namespace used during `wrangler dev` */
204
- preview_id?: string;
205
- }[];
206
-
207
- /**
208
- * A list of services that your worker should be bound to.
209
- * NB: these are not inherited, and HAVE to be duplicated across all environments.
210
- *
211
- * @default `[]`
212
- * @optional
213
- * @inherited false
214
- */
215
- experimental_services?: {
216
- /** The binding name used to refer to the Service */
217
- name: string;
218
- /** The name of the Service being bound */
219
- service: string;
220
- /** The Service's environment */
221
- environment: string;
222
- }[];
223
-
224
- /**
225
- * A list of migrations that should be uploaded with your Worker.
226
- * These define changes in your Durable Object declarations.
227
- * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
228
- * NB: these ARE inherited, and SHOULD NOT be duplicated across all environments.
229
- *
230
- * @default `[]`
231
- * @optional
232
- * @inherited true
233
- */
234
- migrations?: {
235
- /** A unique identifier for this migration. */
236
- tag: string;
237
- /** The new Durable Objects being defined. */
238
- new_classes?: string[];
239
- /** The Durable Objects being renamed. */
240
- renamed_classes?: {
241
- from: string;
242
- to: string;
243
- }[];
244
- /** The Durable Objects being removed. */
245
- deleted_classes?: string[];
246
- }[];
247
-
248
- /**
249
- * The definition of a Worker Site, a feature that lets you upload
250
- * static assets with your Worker.
251
- * More details at https://developers.cloudflare.com/workers/platform/sites
252
- * NB: This IS inherited, and SHOULD NOT be duplicated across all environments.
253
- *
254
- * @default `undefined`
255
- * @optional
256
- * @inherited true
257
- */
258
- site?: {
259
- /**
260
- * The directory containing your static assets. It must be
261
- * a path relative to your wrangler.toml file.
262
- * Example: bucket = "./public"
263
- *
264
- * optional false
265
- */
266
- bucket: string;
267
-
268
- /**
269
- * The location of your Worker script.
270
- *
271
- * @deprecated DO NOT use this (it's a holdover from wrangler 1.x). Either use the top level `entry` field, or pass the path to your entry file as a command line argument.
272
- * @breaking
273
- */
274
- "entry-point"?: string;
275
-
276
- /**
277
- * An exclusive list of .gitignore-style patterns that match file
278
- * or directory names from your bucket location. Only matched
279
- * items will be uploaded. Example: include = ["upload_dir"]
280
- *
281
- * @optional
282
- * @default `[]`
283
- */
284
- include?: string[];
285
-
286
- /**
287
- * A list of .gitignore-style patterns that match files or
288
- * directories in your bucket that should be excluded from
289
- * uploads. Example: exclude = ["ignore_dir"]
290
- *
291
- * @optional
292
- * @default `[]`
293
- */
294
- exclude?: string[];
295
- };
296
-
297
- /**
298
- * "Cron" definitions to trigger a worker's "scheduled" function.
299
- * Lets you call workers periodically, much like a cron job.
300
- * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
301
- *
302
- * @inherited
303
- * @default `{ crons: [] }`
304
- * @optional
305
- */
306
- triggers?: { crons: string[] };
307
-
308
- /**
309
- * Options to configure the development server that your worker will use.
310
- * NB: This is NOT inherited, and SHOULD NOT be duplicated across all environments.
311
- *
312
- * @default `{}`
313
- * @optional
314
- * @inherited false
315
- */
316
- dev?: {
317
- /**
318
- * IP address for the local dev server to listen on,
319
- *
320
- * @default `127.0.0.1`
321
- * @todo this needs to be implemented
322
- */
323
- ip?: string;
324
-
325
- /**
326
- * Port for the local dev server to listen on
327
- *
328
- * @default `8787`
329
- */
330
- port?: number;
331
-
332
- /**
333
- * Protocol that local wrangler dev server listens to requests on.
334
- *
335
- * @default `http`
336
- * @todo this needs to be implemented
337
- */
338
- local_protocol?: string;
339
-
340
- /**
341
- * Protocol that wrangler dev forwards requests on
342
- *
343
- * @default `https`
344
- * @todo this needs to be implemented
345
- */
346
- upstream_protocol?: string;
347
- };
348
-
349
- /**
350
- * Specifies the Usage Model for your Worker. There are two options -
351
- * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
352
- * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
353
- * For newly created Workers, if the Usage Model is omitted
354
- * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
355
- * For existing Workers, if the Usage Model is omitted, it will be
356
- * set to the Usage Model configured in the dashboard for that Worker.
357
- */
358
- usage_model?: undefined | "bundled" | "unbound";
359
-
360
- /**
361
- * Configures a custom build step to be run by Wrangler when
362
- * building your Worker. Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
363
- * for more details.
364
- *
365
- * @default `undefined`
366
- * @optional
367
- * @inherited false
368
- */
369
- build?: {
370
- /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
371
- command?: string;
372
- /** The directory in which the command is executed. */
373
- cwd?: string;
374
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
375
- watch_dir?: string;
376
- } & /**
377
- * Much of the rest of this configuration isn't necessary anymore
378
- * in wrangler2. We infer the format automatically, and we can pass
379
- * the path to the script either in the CLI (or, @todo, as the top level
380
- * `entry` property).
381
- */ (
382
- | {
383
- upload?: {
384
- /**
385
- * The format of the Worker script, must be "service-worker".
386
- *
387
- * @deprecated We infer the format automatically now.
388
- */
389
- format?: "service-worker";
390
-
391
- /**
392
- * The path to the Worker script. This should be replaced
393
- * by the top level `entry' property.
394
- *
395
- * @deprecated This will be replaced by the top level `entry' property.
396
- */
397
- main: string;
398
- };
399
- }
400
- | {
401
- /**
402
- * When we use the module format, we only really
403
- * need to specify the entry point. The format is deduced
404
- * automatically in wrangler2.
405
- */
406
- upload?: {
407
- /**
408
- * The format of the Worker script, must be "modules".
409
- *
410
- * @deprecated We infer the format automatically now.
411
- */
412
- format?: "modules";
413
-
414
- /**
415
- * The directory you wish to upload your modules from,
416
- * defaults to the dist relative to the project root directory.
417
- *
418
- * @deprecated
419
- * @breaking
420
- */
421
- dir?: string;
422
-
423
- /**
424
- * The path to the Worker script. This should be replaced
425
- * by the top level `entry' property.
426
- *
427
- * @deprecated This will be replaced by the top level `entry' property.
428
- */
429
- main?: string;
430
-
431
- /**
432
- * An ordered list of rules that define which modules to import,
433
- * and what type to import them as. You will need to specify rules
434
- * to use Text, Data, and CompiledWasm modules, or when you wish to
435
- * have a .js file be treated as an ESModule instead of CommonJS.
436
- *
437
- * @deprecated These are now inferred automatically for major file types, but you can still specify them manually.
438
- * @todo this needs to be implemented!
439
- * @breaking
440
- */
441
- rules?: {
442
- type: "ESModule" | "CommonJS" | "Text" | "Data" | "CompiledWasm";
443
- globs: string[];
444
- fallthrough?: boolean;
445
- };
446
- };
447
- }
448
- );
449
-
450
- /**
451
- * The `env` section defines overrides for the configuration for
452
- * different environments. Most fields can be overridden, while
453
- * some have to be specifically duplicated in every environment.
454
- * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
455
- */
456
- env?: {
457
- [envName: string]:
458
- | undefined
459
- | Omit<Config, "env" | "migrations" | "site" | "dev">;
460
- };
461
- };
462
-
463
- type ValidationResults = (
464
- | { key: string; info: string }
465
- | { key: string; error: string }
466
- | { key: string; warning: string }
467
- )[];
468
-
469
- /**
470
- * We also define a validation function that manually validates
471
- * every field in the configuration as per the type definitions,
472
- * as well as extra constraints we apply to some fields, as well
473
- * as some constraints on combinations of fields. This is useful for
474
- * presenting errors and messages to the user. Eventually, we will
475
- * combine this with some automatic config rewriting tools.
476
- *
477
- */
478
- export async function validateConfig(
479
- _config: Partial<Config>
480
- ): Promise<ValidationResults> {
481
- const results: ValidationResults = [];
482
-
483
- return results;
484
- }
485
-
486
- /**
487
- * Process the environments (`env`) specified in the `config`.
488
- *
489
- * The environments configuration is complicated since each environment is a customized version of the main config.
490
- * Some of the configuration can be inherited from the main config, while other configuration must replace what is in the main config.
491
- *
492
- * This function ensures that each environment is set up correctly with inherited configuration, as necessary.
493
- * It will log a warning if an environment is missing required configuration.
494
- */
495
- export function normaliseAndValidateEnvironmentsConfig(config: Config) {
496
- if (config.env == undefined) {
497
- // There are no environments specified so there is nothing to do here.
498
- return;
499
- }
500
-
501
- const environments = config.env;
502
-
503
- for (const envKey of Object.keys(environments)) {
504
- const environment = environments[envKey];
505
-
506
- // Given how TOML works, there should never be an environment containing nothing.
507
- // I.e. if there is a section in a TOML file, then the parser will create an object for it.
508
- // But it may be possible in the future if we change how the configuration is stored.
509
- assert(
510
- environment,
511
- `Environment ${envKey} is specified in the config but not defined.`
512
- );
513
-
514
- // Fall back on "inherited fields" from the config, if not specified in the environment.
515
- const inheritedFields = [
516
- "name",
517
- "account_id",
518
- "workers_dev",
519
- "compatibility_date",
520
- "compatibility_flags",
521
- "zone_id",
522
- "routes",
523
- "route",
524
- "jsx_factory",
525
- "jsx_fragment",
526
- "site",
527
- "triggers",
528
- "usage_model",
529
- ];
530
- for (const inheritedField of inheritedFields) {
531
- if (config[inheritedField] !== undefined) {
532
- if (environment[inheritedField] === undefined) {
533
- environment[inheritedField] = config[inheritedField]; // TODO: - shallow or deep copy?
534
- }
535
- }
536
- }
537
-
538
- // Warn if there is a "required" field in the top level config that has not been specified specified in the environment.
539
- // These required fields are `vars`, `durable_objects`, `kv_namespaces` and `experimental_services`.
540
- // Each of them has different characteristics that need to be checked.
541
-
542
- // `vars` is just an object
543
- if (config.vars !== undefined) {
544
- if (environment.vars === undefined) {
545
- console.warn(
546
- `In your configuration, "vars" exists at the top level, but not on "env.${envKey}".\n` +
547
- `This is not what you probably want, since "vars" is not inherited by environments.\n` +
548
- `Please add "vars" to "env.${envKey}".`
549
- );
550
- } else {
551
- for (const varField of Object.keys(config.vars)) {
552
- if (!(varField in environment.vars)) {
553
- console.warn(
554
- `In your configuration, "vars.${varField}" exists at the top level, but not on "env.${envKey}".\n` +
555
- `This is not what you probably want, since "vars" is not inherited by environments.\n` +
556
- `Please add "vars.${varField}" to "env.${envKey}".`
557
- );
558
- }
559
- }
560
- }
561
- }
562
-
563
- // `durable_objects` is an object containing a `bindings` array
564
- if (config.durable_objects !== undefined) {
565
- if (environment.durable_objects === undefined) {
566
- console.warn(
567
- `In your configuration, "durable_objects.bindings" exists at the top level, but not on "env.${envKey}".\n` +
568
- `This is not what you probably want, since "durable_objects" is not inherited by environments.\n` +
569
- `Please add "durable_objects.bindings" to "env.${envKey}".`
570
- );
571
- } else {
572
- const envBindingNames = new Set(
573
- environment.durable_objects.bindings.map((b) => b.name)
574
- );
575
- for (const bindingName of config.durable_objects.bindings.map(
576
- (b) => b.name
577
- )) {
578
- if (!envBindingNames.has(bindingName)) {
579
- console.warn(
580
- `In your configuration, there is a durable_objects binding with name "${bindingName}" at the top level, but not on "env.${envKey}".\n` +
581
- `This is not what you probably want, since "durable_objects" is not inherited by environments.\n` +
582
- `Please add a binding for "${bindingName}" to "env.${envKey}.durable_objects.bindings".`
583
- );
584
- }
585
- }
586
- }
587
- }
588
-
589
- // `kv_namespaces` contains an array of namespace bindings
590
- if (config.kv_namespaces !== undefined) {
591
- if (environment.kv_namespaces === undefined) {
592
- console.warn(
593
- `In your configuration, "kv_namespaces" exists at the top level, but not on "env.${envKey}".\n` +
594
- `This is not what you probably want, since "kv_namespaces" is not inherited by environments.\n` +
595
- `Please add "kv_namespaces" to "env.${envKey}".`
596
- );
597
- } else {
598
- const envBindings = new Set(
599
- environment.kv_namespaces.map((kvNamespace) => kvNamespace.binding)
600
- );
601
- for (const bindingName of config.kv_namespaces.map(
602
- (kvNamespace) => kvNamespace.binding
603
- )) {
604
- if (!envBindings.has(bindingName)) {
605
- console.warn(
606
- `In your configuration, there is a kv_namespaces with binding "${bindingName}" at the top level, but not on "env.${envKey}".\n` +
607
- `This is not what you probably want, since "kv_namespaces" is not inherited by environments.\n` +
608
- `Please add a binding for "${bindingName}" to "env.${envKey}.kv_namespaces".`
609
- );
610
- }
611
- }
612
- }
613
- }
614
-
615
- // `experimental_services` contains an array of namespace bindings
616
- if (config.experimental_services !== undefined) {
617
- if (environment.experimental_services === undefined) {
618
- console.warn(
619
- `In your configuration, "experimental_services" exists at the top level, but not on "env.${envKey}".\n` +
620
- `This is not what you probably want, since "experimental_services" is not inherited by environments.\n` +
621
- `Please add "experimental_services" to "env.${envKey}".`
622
- );
623
- } else {
624
- const envBindingNames = new Set(
625
- environment.experimental_services.map((service) => service.name)
626
- );
627
- for (const bindingName of config.experimental_services.map(
628
- (service) => service.name
629
- )) {
630
- if (!envBindingNames.has(bindingName)) {
631
- console.warn(
632
- `In your configuration, there is a experimental_services with binding name "${bindingName}" at the top level, but not on "env.${envKey}".\n` +
633
- `This is not what you probably want, since "experimental_services" is not inherited by environments.\n` +
634
- `Please add a service for "${bindingName}" to "env.${envKey}.experimental_services".`
635
- );
636
- }
637
- }
638
- }
639
- }
640
- }
641
- }