wrangler 0.0.0-e88a54e → 0.0.0-e95e5a0
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.
- package/README.md +25 -14
- package/bin/wrangler.js +13 -1
- package/miniflare-dist/index.mjs +4828 -21
- package/package.json +29 -24
- package/pages/functions/buildPlugin.ts +92 -0
- package/pages/functions/buildWorker.ts +80 -4
- package/pages/functions/filepath-routing.test.ts +11 -0
- package/pages/functions/filepath-routing.ts +8 -0
- package/pages/functions/routes.ts +6 -1
- package/pages/functions/template-plugin.ts +146 -0
- package/pages/functions/template-worker.ts +21 -8
- package/src/__tests__/config-cache.test.ts +36 -0
- package/src/__tests__/configuration.test.ts +530 -201
- package/src/__tests__/dev.test.tsx +284 -18
- package/src/__tests__/guess-worker-format.test.ts +28 -1
- package/src/__tests__/helpers/mock-cfetch.ts +5 -1
- package/src/__tests__/helpers/mock-console.ts +20 -3
- package/src/__tests__/helpers/mock-dialogs.ts +26 -1
- package/src/__tests__/helpers/mock-http-server.ts +46 -0
- package/src/__tests__/helpers/mock-istty.ts +27 -0
- package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
- package/src/__tests__/helpers/run-in-tmp.ts +7 -0
- package/src/__tests__/helpers/write-worker-source.ts +31 -0
- package/src/__tests__/https-options.test.ts +5 -2
- package/src/__tests__/index.test.ts +27 -769
- package/src/__tests__/init.test.ts +1516 -0
- package/src/__tests__/jest.setup.ts +4 -4
- package/src/__tests__/kv.test.ts +133 -61
- package/src/__tests__/logger.test.ts +115 -0
- package/src/__tests__/pages.test.ts +311 -26
- package/src/__tests__/publish.test.ts +2789 -618
- package/src/__tests__/r2.test.ts +26 -10
- package/src/__tests__/route.test.ts +4 -4
- package/src/__tests__/secret.test.ts +55 -34
- package/src/__tests__/tail.test.ts +146 -20
- package/src/__tests__/user.test.ts +131 -0
- package/src/__tests__/whoami.test.tsx +14 -9
- package/src/bundle.ts +30 -3
- package/src/cfetch/internal.ts +0 -2
- package/src/cli.ts +5 -11
- package/src/config/README.md +1 -1
- package/src/config/config.ts +20 -4
- package/src/config/environment.ts +32 -4
- package/src/config/index.ts +4 -3
- package/src/config/validation-helpers.ts +96 -7
- package/src/config/validation.ts +388 -54
- package/src/config-cache.ts +45 -0
- package/src/create-worker-preview.ts +22 -13
- package/src/create-worker-upload-form.ts +32 -9
- package/src/dev/dev-vars.ts +36 -0
- package/src/dev/dev.tsx +132 -78
- package/src/dev/local.tsx +101 -21
- package/src/dev/remote.tsx +23 -13
- package/src/dev/use-esbuild.ts +23 -5
- package/src/dialogs.tsx +16 -6
- package/src/entry.ts +83 -24
- package/src/environment-variables.ts +3 -1
- package/src/errors.ts +11 -0
- package/src/https-options.ts +3 -2
- package/src/index.tsx +689 -394
- package/src/inspect.ts +17 -11
- package/src/intl-polyfill.d.ts +139 -0
- package/src/logger.ts +66 -0
- package/src/miniflare-cli/index.ts +4 -0
- package/src/miniflare-cli/request-context.ts +40 -0
- package/src/module-collection.ts +7 -7
- package/src/open-in-browser.ts +5 -4
- package/src/package-manager.ts +9 -8
- package/src/pages.tsx +875 -56
- package/src/parse.ts +1 -1
- package/src/proxy.ts +28 -19
- package/src/publish.ts +263 -141
- package/src/sites.tsx +27 -14
- package/src/tail/index.ts +2 -2
- package/src/tail/printing.ts +13 -8
- package/src/update-check.ts +19 -0
- package/src/user.tsx +116 -41
- package/src/whoami.tsx +2 -1
- package/src/worker.ts +15 -6
- package/templates/gitignore +171 -0
- package/templates/static-asset-facade.js +1 -1
- package/wrangler-dist/cli.js +21162 -50227
- package/miniflare-dist/index.mjs.map +0 -7
- package/src/__tests__/dev2.test.tsx +0 -154
- package/src/__tests__/logout.test.ts +0 -52
- package/src/__tests__/sentry.test.ts +0 -146
- package/src/reporting.ts +0 -131
- package/wrangler-dist/cli.js.map +0 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { normalizeAndValidateConfig } from "../config/validation";
|
|
3
|
+
import { normalizeSlashes } from "./helpers/mock-console";
|
|
3
4
|
import type {
|
|
4
5
|
ConfigFields,
|
|
5
6
|
RawDevConfig,
|
|
@@ -9,11 +10,9 @@ import type {
|
|
|
9
10
|
|
|
10
11
|
describe("normalizeAndValidateConfig()", () => {
|
|
11
12
|
it("should use defaults for empty configuration", () => {
|
|
12
|
-
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
undefined
|
|
16
|
-
);
|
|
13
|
+
const { config, diagnostics } = normalizeAndValidateConfig({}, undefined, {
|
|
14
|
+
env: undefined,
|
|
15
|
+
});
|
|
17
16
|
|
|
18
17
|
expect(config).toEqual({
|
|
19
18
|
account_id: undefined,
|
|
@@ -37,6 +36,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
37
36
|
},
|
|
38
37
|
jsx_factory: "React.createElement",
|
|
39
38
|
jsx_fragment: "React.Fragment",
|
|
39
|
+
tsconfig: undefined,
|
|
40
40
|
kv_namespaces: [],
|
|
41
41
|
legacy_env: true,
|
|
42
42
|
main: undefined,
|
|
@@ -57,7 +57,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
57
57
|
usage_model: undefined,
|
|
58
58
|
vars: {},
|
|
59
59
|
wasm_modules: undefined,
|
|
60
|
-
|
|
60
|
+
data_blobs: undefined,
|
|
61
|
+
workers_dev: undefined,
|
|
61
62
|
zone_id: undefined,
|
|
62
63
|
});
|
|
63
64
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
@@ -79,7 +80,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
79
80
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
80
81
|
expectedConfig,
|
|
81
82
|
undefined,
|
|
82
|
-
undefined
|
|
83
|
+
{ env: undefined }
|
|
83
84
|
);
|
|
84
85
|
|
|
85
86
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
@@ -101,7 +102,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
101
102
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
102
103
|
expectedConfig as unknown as RawConfig,
|
|
103
104
|
undefined,
|
|
104
|
-
undefined
|
|
105
|
+
{ env: undefined }
|
|
105
106
|
);
|
|
106
107
|
|
|
107
108
|
expect(config).toEqual(
|
|
@@ -128,7 +129,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
128
129
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
129
130
|
expectedConfig as unknown as RawConfig,
|
|
130
131
|
undefined,
|
|
131
|
-
undefined
|
|
132
|
+
{ env: undefined }
|
|
132
133
|
);
|
|
133
134
|
|
|
134
135
|
expect("unexpected" in config).toBe(false);
|
|
@@ -139,7 +140,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
139
140
|
`);
|
|
140
141
|
});
|
|
141
142
|
|
|
142
|
-
it("should
|
|
143
|
+
it("should report a deprecation warning if `miniflare` appears at the top level", () => {
|
|
143
144
|
const expectedConfig = {
|
|
144
145
|
miniflare: {
|
|
145
146
|
host: "localhost",
|
|
@@ -149,14 +150,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
149
150
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
150
151
|
expectedConfig as unknown as RawConfig,
|
|
151
152
|
undefined,
|
|
152
|
-
undefined
|
|
153
|
+
{ env: undefined }
|
|
153
154
|
);
|
|
154
155
|
|
|
155
156
|
expect("miniflare" in config).toBe(false);
|
|
156
157
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
157
158
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
158
159
|
"Processing wrangler configuration:
|
|
159
|
-
|
|
160
|
+
- [1m😶 Ignored[0m: \\"miniflare\\":
|
|
161
|
+
Wrangler does not use configuration in the \`miniflare\` section. Unless you are using Miniflare directly you can remove this section."
|
|
160
162
|
`);
|
|
161
163
|
});
|
|
162
164
|
|
|
@@ -180,7 +182,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
180
182
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
181
183
|
expectedConfig,
|
|
182
184
|
undefined,
|
|
183
|
-
undefined
|
|
185
|
+
{ env: undefined }
|
|
184
186
|
);
|
|
185
187
|
|
|
186
188
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
@@ -208,7 +210,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
208
210
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
209
211
|
expectedConfig as unknown as RawConfig,
|
|
210
212
|
undefined,
|
|
211
|
-
undefined
|
|
213
|
+
{ env: undefined }
|
|
212
214
|
);
|
|
213
215
|
|
|
214
216
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
@@ -229,26 +231,38 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
229
231
|
const expectedConfig: RawConfig = {
|
|
230
232
|
site: {
|
|
231
233
|
bucket: "BUCKET",
|
|
232
|
-
|
|
234
|
+
"entry-point": "my-site",
|
|
233
235
|
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
236
|
+
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
234
237
|
},
|
|
235
238
|
};
|
|
236
239
|
|
|
237
240
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
238
241
|
expectedConfig,
|
|
239
242
|
undefined,
|
|
240
|
-
undefined
|
|
243
|
+
{ env: undefined }
|
|
241
244
|
);
|
|
242
245
|
|
|
243
246
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
244
247
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
245
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
248
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
249
|
+
|
|
250
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
251
|
+
.toMatchInlineSnapshot(`
|
|
252
|
+
"Processing wrangler configuration:
|
|
253
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
254
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
255
|
+
\`\`\`
|
|
256
|
+
main = \\"my-site/index.js\\"
|
|
257
|
+
\`\`\`"
|
|
258
|
+
`);
|
|
246
259
|
});
|
|
247
260
|
|
|
248
261
|
it("should error if `site` config is missing `bucket`", () => {
|
|
249
262
|
const expectedConfig: RawConfig = {
|
|
250
263
|
// @ts-expect-error we're intentionally passing an invalid configuration here
|
|
251
264
|
site: {
|
|
265
|
+
"entry-point": "workers-site",
|
|
252
266
|
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
253
267
|
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
254
268
|
},
|
|
@@ -257,22 +271,34 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
257
271
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
258
272
|
expectedConfig,
|
|
259
273
|
undefined,
|
|
260
|
-
undefined
|
|
274
|
+
{ env: undefined }
|
|
261
275
|
);
|
|
262
276
|
|
|
263
277
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
278
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
264
279
|
expect(diagnostics.hasErrors()).toBe(true);
|
|
280
|
+
|
|
281
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
282
|
+
.toMatchInlineSnapshot(`
|
|
283
|
+
"Processing wrangler configuration:
|
|
284
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
285
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
286
|
+
\`\`\`
|
|
287
|
+
main = \\"workers-site/index.js\\"
|
|
288
|
+
\`\`\`"
|
|
289
|
+
`);
|
|
290
|
+
|
|
265
291
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
266
292
|
"Processing wrangler configuration:
|
|
267
293
|
- \\"site.bucket\\" is a required field."
|
|
268
294
|
`);
|
|
269
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
270
295
|
});
|
|
271
296
|
|
|
272
297
|
it("should error on invalid `site` values", () => {
|
|
273
298
|
const expectedConfig = {
|
|
274
299
|
site: {
|
|
275
300
|
bucket: "BUCKET",
|
|
301
|
+
"entry-point": 111,
|
|
276
302
|
include: [222, 333],
|
|
277
303
|
exclude: [444, 555],
|
|
278
304
|
},
|
|
@@ -281,21 +307,32 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
281
307
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
282
308
|
expectedConfig as unknown as RawConfig,
|
|
283
309
|
undefined,
|
|
284
|
-
undefined
|
|
310
|
+
{ env: undefined }
|
|
285
311
|
);
|
|
286
312
|
|
|
287
313
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
288
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
314
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
289
315
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
290
316
|
"Processing wrangler configuration:
|
|
291
317
|
- Expected \\"sites.include.[0]\\" to be of type string but got 222.
|
|
292
318
|
- Expected \\"sites.include.[1]\\" to be of type string but got 333.
|
|
293
319
|
- Expected \\"sites.exclude.[0]\\" to be of type string but got 444.
|
|
294
|
-
- Expected \\"sites.exclude.[1]\\" to be of type string but got 555.
|
|
320
|
+
- Expected \\"sites.exclude.[1]\\" to be of type string but got 555.
|
|
321
|
+
- Expected \\"site.entry-point\\" to be of type string but got 111."
|
|
322
|
+
`);
|
|
323
|
+
|
|
324
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
325
|
+
.toMatchInlineSnapshot(`
|
|
326
|
+
"Processing wrangler configuration:
|
|
327
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
328
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
329
|
+
\`\`\`
|
|
330
|
+
main = \\"111/index.js\\"
|
|
331
|
+
\`\`\`"
|
|
295
332
|
`);
|
|
296
333
|
});
|
|
297
334
|
|
|
298
|
-
it("should
|
|
335
|
+
it("should log a deprecation warning if entry-point is defined", async () => {
|
|
299
336
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
300
337
|
{
|
|
301
338
|
site: {
|
|
@@ -304,27 +341,28 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
304
341
|
},
|
|
305
342
|
} as unknown as RawConfig,
|
|
306
343
|
undefined,
|
|
307
|
-
undefined
|
|
344
|
+
{ env: undefined }
|
|
308
345
|
);
|
|
309
346
|
|
|
310
347
|
expect(config.site).toMatchInlineSnapshot(`
|
|
311
348
|
Object {
|
|
312
349
|
"bucket": "some/path",
|
|
350
|
+
"entry-point": "some/other/script.js",
|
|
313
351
|
"exclude": Array [],
|
|
314
352
|
"include": Array [],
|
|
315
353
|
}
|
|
316
354
|
`);
|
|
317
355
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
318
|
-
expect(diagnostics.hasErrors()).toBe(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
`);
|
|
323
|
-
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
356
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
357
|
+
|
|
358
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
359
|
+
.toMatchInlineSnapshot(`
|
|
324
360
|
"Processing wrangler configuration:
|
|
325
|
-
-
|
|
326
|
-
|
|
327
|
-
|
|
361
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
362
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
363
|
+
\`\`\`
|
|
364
|
+
main = \\"some/other/script.js\\"
|
|
365
|
+
\`\`\`"
|
|
328
366
|
`);
|
|
329
367
|
});
|
|
330
368
|
});
|
|
@@ -340,7 +378,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
340
378
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
341
379
|
expectedConfig,
|
|
342
380
|
"project/wrangler.toml",
|
|
343
|
-
undefined
|
|
381
|
+
{ env: undefined }
|
|
344
382
|
);
|
|
345
383
|
|
|
346
384
|
expect(config).toEqual(
|
|
@@ -355,7 +393,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
355
393
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
356
394
|
});
|
|
357
395
|
|
|
358
|
-
it("should error on invalid `
|
|
396
|
+
it("should error on invalid `wasm_modules` paths", () => {
|
|
359
397
|
const expectedConfig = {
|
|
360
398
|
wasm_modules: {
|
|
361
399
|
MODULE_1: 111,
|
|
@@ -366,7 +404,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
366
404
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
367
405
|
expectedConfig as unknown as RawConfig,
|
|
368
406
|
"project/wrangler.toml",
|
|
369
|
-
undefined
|
|
407
|
+
{ env: undefined }
|
|
370
408
|
);
|
|
371
409
|
|
|
372
410
|
expect(config).toEqual(
|
|
@@ -393,7 +431,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
393
431
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
394
432
|
expectedConfig,
|
|
395
433
|
"project/wrangler.toml",
|
|
396
|
-
undefined
|
|
434
|
+
{ env: undefined }
|
|
397
435
|
);
|
|
398
436
|
|
|
399
437
|
expect(config).toEqual(
|
|
@@ -419,7 +457,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
419
457
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
420
458
|
expectedConfig as unknown as RawConfig,
|
|
421
459
|
"project/wrangler.toml",
|
|
422
|
-
undefined
|
|
460
|
+
{ env: undefined }
|
|
423
461
|
);
|
|
424
462
|
|
|
425
463
|
expect(config).toEqual(
|
|
@@ -435,6 +473,80 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
435
473
|
`);
|
|
436
474
|
});
|
|
437
475
|
|
|
476
|
+
it("should map `data_blobs` paths from relative to the config path to relative to the cwd", () => {
|
|
477
|
+
const expectedConfig: RawConfig = {
|
|
478
|
+
data_blobs: {
|
|
479
|
+
BLOB_1: "path/to/data1.bin",
|
|
480
|
+
BLOB_2: "data2.bin",
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
485
|
+
expectedConfig,
|
|
486
|
+
"project/wrangler.toml",
|
|
487
|
+
{ env: undefined }
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
expect(config).toEqual(
|
|
491
|
+
expect.objectContaining({
|
|
492
|
+
data_blobs: {
|
|
493
|
+
BLOB_1: path.normalize("project/path/to/data1.bin"),
|
|
494
|
+
BLOB_2: path.normalize("project/data2.bin"),
|
|
495
|
+
},
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
499
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it("should error on invalid `data_blob` paths", () => {
|
|
503
|
+
const expectedConfig = {
|
|
504
|
+
data_blobs: {
|
|
505
|
+
MODULE_1: 111,
|
|
506
|
+
MODULE_2: 222,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
511
|
+
expectedConfig as unknown as RawConfig,
|
|
512
|
+
"project/wrangler.toml",
|
|
513
|
+
{ env: undefined }
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
expect(config).toEqual(
|
|
517
|
+
expect.objectContaining({
|
|
518
|
+
data_blobs: {},
|
|
519
|
+
})
|
|
520
|
+
);
|
|
521
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
522
|
+
expect(normalizePath(diagnostics.renderErrors())).toMatchInlineSnapshot(`
|
|
523
|
+
"Processing project/wrangler.toml configuration:
|
|
524
|
+
- Expected \\"data_blobs['MODULE_1']\\" to be of type string but got 111.
|
|
525
|
+
- Expected \\"data_blobs['MODULE_2']\\" to be of type string but got 222."
|
|
526
|
+
`);
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it("should resolve tsconfig relative to wrangler.toml", async () => {
|
|
530
|
+
const expectedConfig: RawEnvironment = {
|
|
531
|
+
tsconfig: "path/to/some-tsconfig.json",
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
535
|
+
expectedConfig,
|
|
536
|
+
"project/wrangler.toml",
|
|
537
|
+
{ env: undefined }
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
expect(config).toEqual(
|
|
541
|
+
expect.objectContaining({
|
|
542
|
+
tsconfig: path.normalize("project/path/to/some-tsconfig.json"),
|
|
543
|
+
})
|
|
544
|
+
);
|
|
545
|
+
|
|
546
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
547
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
548
|
+
});
|
|
549
|
+
|
|
438
550
|
describe("(deprecated)", () => {
|
|
439
551
|
it("should remove and warn about deprecated properties", () => {
|
|
440
552
|
const rawConfig: RawConfig = {
|
|
@@ -445,7 +557,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
445
557
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
446
558
|
rawConfig,
|
|
447
559
|
undefined,
|
|
448
|
-
undefined
|
|
560
|
+
{ env: undefined }
|
|
449
561
|
);
|
|
450
562
|
|
|
451
563
|
// Note the `.not.` here...
|
|
@@ -458,12 +570,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
458
570
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
459
571
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
460
572
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
573
|
+
"Processing wrangler configuration:
|
|
574
|
+
- [1m😶 Ignored[0m: \\"type\\":
|
|
575
|
+
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.
|
|
576
|
+
- [1m😶 Ignored[0m: \\"webpack_config\\":
|
|
577
|
+
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."
|
|
578
|
+
`);
|
|
467
579
|
});
|
|
468
580
|
});
|
|
469
581
|
});
|
|
@@ -474,14 +586,20 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
474
586
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
475
587
|
|
|
476
588
|
const expectedConfig: RawEnvironment = {
|
|
477
|
-
name: "
|
|
589
|
+
name: "mock-name",
|
|
478
590
|
account_id: "ACCOUNT_ID",
|
|
479
591
|
compatibility_date: "2022-01-01",
|
|
480
592
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
481
593
|
workers_dev: false,
|
|
482
|
-
routes: [
|
|
594
|
+
routes: [
|
|
595
|
+
"ROUTE_1",
|
|
596
|
+
"ROUTE_2",
|
|
597
|
+
{ pattern: "ROUTE3", zone_id: "ZONE_ID_3" },
|
|
598
|
+
"ROUTE_4",
|
|
599
|
+
],
|
|
483
600
|
jsx_factory: "JSX_FACTORY",
|
|
484
601
|
jsx_fragment: "JSX_FRAGMENT",
|
|
602
|
+
tsconfig: "path/to/tsconfig",
|
|
485
603
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
486
604
|
usage_model: "bundled",
|
|
487
605
|
main,
|
|
@@ -535,7 +653,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
535
653
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
536
654
|
expectedConfig,
|
|
537
655
|
undefined,
|
|
538
|
-
undefined
|
|
656
|
+
{ env: undefined }
|
|
539
657
|
);
|
|
540
658
|
|
|
541
659
|
expect(config).toEqual(
|
|
@@ -555,10 +673,30 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
555
673
|
compatibility_date: 333,
|
|
556
674
|
compatibility_flags: [444, 555],
|
|
557
675
|
workers_dev: "BAD",
|
|
558
|
-
routes: [
|
|
676
|
+
routes: [
|
|
677
|
+
666,
|
|
678
|
+
777,
|
|
679
|
+
// this one's valid, but we add it here to make sure
|
|
680
|
+
// it doesn't get included in the error message
|
|
681
|
+
"example.com/*",
|
|
682
|
+
{ pattern: 123, zone_id: "zone_id_1" },
|
|
683
|
+
{ pattern: "route_2", zone_id: 123 },
|
|
684
|
+
{ pattern: "route_2", zone_name: 123 },
|
|
685
|
+
{ pattern: "route_3" },
|
|
686
|
+
{ zone_id: "zone_id_4" },
|
|
687
|
+
{ zone_name: "zone_name_4" },
|
|
688
|
+
{ pattern: undefined },
|
|
689
|
+
{ pattern: "route_5", zone_id: "zone_id_5", some_other_key: 123 },
|
|
690
|
+
{ pattern: "route_5", zone_name: "zone_name_5", some_other_key: 123 },
|
|
691
|
+
// this one's valid too
|
|
692
|
+
{ pattern: "route_6", zone_id: "zone_id_6" },
|
|
693
|
+
// as well as this one
|
|
694
|
+
{ pattern: "route_6", zone_name: "zone_name_6" },
|
|
695
|
+
],
|
|
559
696
|
route: 888,
|
|
560
697
|
jsx_factory: 999,
|
|
561
698
|
jsx_fragment: 1000,
|
|
699
|
+
tsconfig: true,
|
|
562
700
|
triggers: { crons: [1111, 1222] },
|
|
563
701
|
usage_model: "INVALID",
|
|
564
702
|
main: 1333,
|
|
@@ -572,15 +710,50 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
572
710
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
573
711
|
expectedConfig,
|
|
574
712
|
undefined,
|
|
575
|
-
undefined
|
|
713
|
+
{ env: undefined }
|
|
576
714
|
);
|
|
577
715
|
|
|
578
716
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
579
717
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
580
718
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
581
719
|
"Processing wrangler configuration:
|
|
582
|
-
- Expected \\"route\\" to be
|
|
583
|
-
- Expected \\"routes\\" to be of
|
|
720
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
|
|
721
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
|
|
722
|
+
666,
|
|
723
|
+
777,
|
|
724
|
+
{
|
|
725
|
+
\\"pattern\\": 123,
|
|
726
|
+
\\"zone_id\\": \\"zone_id_1\\"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
\\"pattern\\": \\"route_2\\",
|
|
730
|
+
\\"zone_id\\": 123
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
\\"pattern\\": \\"route_2\\",
|
|
734
|
+
\\"zone_name\\": 123
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
\\"pattern\\": \\"route_3\\"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
\\"zone_id\\": \\"zone_id_4\\"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
\\"zone_name\\": \\"zone_name_4\\"
|
|
744
|
+
},
|
|
745
|
+
{},
|
|
746
|
+
{
|
|
747
|
+
\\"pattern\\": \\"route_5\\",
|
|
748
|
+
\\"zone_id\\": \\"zone_id_5\\",
|
|
749
|
+
\\"some_other_key\\": 123
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
\\"pattern\\": \\"route_5\\",
|
|
753
|
+
\\"zone_name\\": \\"zone_name_5\\",
|
|
754
|
+
\\"some_other_key\\": 123
|
|
755
|
+
}
|
|
756
|
+
].
|
|
584
757
|
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
585
758
|
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
586
759
|
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
@@ -591,12 +764,86 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
591
764
|
- Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
|
|
592
765
|
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
593
766
|
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
594
|
-
- Expected \\"
|
|
767
|
+
- Expected \\"tsconfig\\" to be of type string but got true.
|
|
768
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
595
769
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
596
770
|
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
597
771
|
`);
|
|
598
772
|
});
|
|
599
773
|
|
|
774
|
+
it("should error on invalid `name` value with spaces", () => {
|
|
775
|
+
const expectedConfig: RawEnvironment = {
|
|
776
|
+
name: "NCC 1701 D",
|
|
777
|
+
} as unknown as RawEnvironment;
|
|
778
|
+
|
|
779
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
780
|
+
expectedConfig,
|
|
781
|
+
undefined,
|
|
782
|
+
{ env: undefined }
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
786
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
787
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
788
|
+
"Processing wrangler configuration:
|
|
789
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"NCC 1701 D\\"."
|
|
790
|
+
`);
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
it("should be valid `name` with underscores", () => {
|
|
794
|
+
const expectedConfig: RawEnvironment = {
|
|
795
|
+
name: "enterprise_nx_01",
|
|
796
|
+
} as unknown as RawEnvironment;
|
|
797
|
+
|
|
798
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
799
|
+
expectedConfig,
|
|
800
|
+
undefined,
|
|
801
|
+
{ env: undefined }
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
805
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
806
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
it("should error on invalid `name` value with special characters", () => {
|
|
810
|
+
const expectedConfig: RawEnvironment = {
|
|
811
|
+
name: "Thy'lek-Shran",
|
|
812
|
+
} as unknown as RawEnvironment;
|
|
813
|
+
|
|
814
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
815
|
+
expectedConfig,
|
|
816
|
+
undefined,
|
|
817
|
+
{ env: undefined }
|
|
818
|
+
);
|
|
819
|
+
|
|
820
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
821
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
822
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
823
|
+
"Processing wrangler configuration:
|
|
824
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"Thy'lek-Shran\\"."
|
|
825
|
+
`);
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it("should error on invalid `name` value with only special characters", () => {
|
|
829
|
+
const expectedConfig: RawEnvironment = {
|
|
830
|
+
name: "!@#$%^&*(()",
|
|
831
|
+
} as unknown as RawEnvironment;
|
|
832
|
+
|
|
833
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
834
|
+
expectedConfig,
|
|
835
|
+
undefined,
|
|
836
|
+
{ env: undefined }
|
|
837
|
+
);
|
|
838
|
+
|
|
839
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
840
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
841
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
842
|
+
"Processing wrangler configuration:
|
|
843
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"!@#$%^&*(()\\"."
|
|
844
|
+
`);
|
|
845
|
+
});
|
|
846
|
+
|
|
600
847
|
it("should override build.upload config defaults with provided values and warn about deprecations", () => {
|
|
601
848
|
const expectedConfig: RawEnvironment = {
|
|
602
849
|
build: {
|
|
@@ -612,7 +859,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
612
859
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
613
860
|
expectedConfig,
|
|
614
861
|
path.resolve("project/wrangler.toml"),
|
|
615
|
-
undefined
|
|
862
|
+
{ env: undefined }
|
|
616
863
|
);
|
|
617
864
|
|
|
618
865
|
expect(config.main).toEqual(path.resolve("project/src/index.ts"));
|
|
@@ -622,17 +869,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
622
869
|
expect(normalizePath(diagnostics.renderWarnings()))
|
|
623
870
|
.toMatchInlineSnapshot(`
|
|
624
871
|
"Processing project/wrangler.toml configuration:
|
|
625
|
-
-
|
|
872
|
+
- [1mDeprecation[0m: \\"build.upload.format\\":
|
|
626
873
|
The format is inferred automatically from the code.
|
|
627
|
-
-
|
|
874
|
+
- [1mDeprecation[0m: \\"build.upload.main\\":
|
|
628
875
|
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
629
876
|
Then add the top level \`main\` field to your configuration file:
|
|
630
877
|
\`\`\`
|
|
631
878
|
main = \\"src/index.ts\\"
|
|
632
879
|
\`\`\`
|
|
633
|
-
-
|
|
880
|
+
- [1mDeprecation[0m: \\"build.upload.dir\\":
|
|
634
881
|
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
|
|
635
|
-
-
|
|
882
|
+
- Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
|
|
636
883
|
\`\`\`
|
|
637
884
|
[[rules]]
|
|
638
885
|
type = \\"Text\\"
|
|
@@ -652,7 +899,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
652
899
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
653
900
|
expectedConfig,
|
|
654
901
|
undefined,
|
|
655
|
-
undefined
|
|
902
|
+
{ env: undefined }
|
|
656
903
|
);
|
|
657
904
|
|
|
658
905
|
expect(config.build).toEqual(
|
|
@@ -677,7 +924,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
677
924
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
678
925
|
expectedConfig,
|
|
679
926
|
"project/wrangler.toml",
|
|
680
|
-
undefined
|
|
927
|
+
{ env: undefined }
|
|
681
928
|
);
|
|
682
929
|
|
|
683
930
|
expect(config.build).toEqual(
|
|
@@ -696,7 +943,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
696
943
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
697
944
|
{ durable_objects: [] } as unknown as RawConfig,
|
|
698
945
|
undefined,
|
|
699
|
-
undefined
|
|
946
|
+
{ env: undefined }
|
|
700
947
|
);
|
|
701
948
|
|
|
702
949
|
expect(config).toEqual(
|
|
@@ -713,7 +960,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
713
960
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
714
961
|
{ durable_objects: "BAD" } as unknown as RawConfig,
|
|
715
962
|
undefined,
|
|
716
|
-
undefined
|
|
963
|
+
{ env: undefined }
|
|
717
964
|
);
|
|
718
965
|
|
|
719
966
|
expect(config).toEqual(
|
|
@@ -730,7 +977,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
730
977
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
731
978
|
{ durable_objects: 999 } as unknown as RawConfig,
|
|
732
979
|
undefined,
|
|
733
|
-
undefined
|
|
980
|
+
{ env: undefined }
|
|
734
981
|
);
|
|
735
982
|
|
|
736
983
|
expect(config).toEqual(
|
|
@@ -747,7 +994,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
747
994
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
748
995
|
{ durable_objects: null } as unknown as RawConfig,
|
|
749
996
|
undefined,
|
|
750
|
-
undefined
|
|
997
|
+
{ env: undefined }
|
|
751
998
|
);
|
|
752
999
|
|
|
753
1000
|
expect(config).toEqual(
|
|
@@ -764,7 +1011,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
764
1011
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
765
1012
|
{ durable_objects: {} } as unknown as RawConfig,
|
|
766
1013
|
undefined,
|
|
767
|
-
undefined
|
|
1014
|
+
{ env: undefined }
|
|
768
1015
|
);
|
|
769
1016
|
|
|
770
1017
|
expect(config).toEqual(
|
|
@@ -781,7 +1028,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
781
1028
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
782
1029
|
{ durable_objects: { bindings: {} } } as unknown as RawConfig,
|
|
783
1030
|
undefined,
|
|
784
|
-
undefined
|
|
1031
|
+
{ env: undefined }
|
|
785
1032
|
);
|
|
786
1033
|
|
|
787
1034
|
expect(config).toEqual(
|
|
@@ -800,7 +1047,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
800
1047
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
801
1048
|
{ durable_objects: { bindings: "BAD" } } as unknown as RawConfig,
|
|
802
1049
|
undefined,
|
|
803
|
-
undefined
|
|
1050
|
+
{ env: undefined }
|
|
804
1051
|
);
|
|
805
1052
|
|
|
806
1053
|
expect(config).toEqual(
|
|
@@ -819,7 +1066,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
819
1066
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
820
1067
|
{ durable_objects: { bindings: 999 } } as unknown as RawConfig,
|
|
821
1068
|
undefined,
|
|
822
|
-
undefined
|
|
1069
|
+
{ env: undefined }
|
|
823
1070
|
);
|
|
824
1071
|
|
|
825
1072
|
expect(config).toEqual(
|
|
@@ -838,7 +1085,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
838
1085
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
839
1086
|
{ durable_objects: { bindings: null } } as unknown as RawConfig,
|
|
840
1087
|
undefined,
|
|
841
|
-
undefined
|
|
1088
|
+
{ env: undefined }
|
|
842
1089
|
);
|
|
843
1090
|
|
|
844
1091
|
expect(config).toEqual(
|
|
@@ -870,7 +1117,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
870
1117
|
},
|
|
871
1118
|
} as unknown as RawConfig,
|
|
872
1119
|
undefined,
|
|
873
|
-
undefined
|
|
1120
|
+
{ env: undefined }
|
|
874
1121
|
);
|
|
875
1122
|
|
|
876
1123
|
expect(config).toEqual(
|
|
@@ -906,7 +1153,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
906
1153
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
907
1154
|
{ kv_namespaces: {} } as unknown as RawConfig,
|
|
908
1155
|
undefined,
|
|
909
|
-
undefined
|
|
1156
|
+
{ env: undefined }
|
|
910
1157
|
);
|
|
911
1158
|
|
|
912
1159
|
expect(config).toEqual(
|
|
@@ -923,7 +1170,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
923
1170
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
924
1171
|
{ kv_namespaces: "BAD" } as unknown as RawConfig,
|
|
925
1172
|
undefined,
|
|
926
|
-
undefined
|
|
1173
|
+
{ env: undefined }
|
|
927
1174
|
);
|
|
928
1175
|
|
|
929
1176
|
expect(config).toEqual(
|
|
@@ -940,7 +1187,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
940
1187
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
941
1188
|
{ kv_namespaces: 999 } as unknown as RawConfig,
|
|
942
1189
|
undefined,
|
|
943
|
-
undefined
|
|
1190
|
+
{ env: undefined }
|
|
944
1191
|
);
|
|
945
1192
|
|
|
946
1193
|
expect(config).toEqual(
|
|
@@ -957,7 +1204,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
957
1204
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
958
1205
|
{ kv_namespaces: null } as unknown as RawConfig,
|
|
959
1206
|
undefined,
|
|
960
|
-
undefined
|
|
1207
|
+
{ env: undefined }
|
|
961
1208
|
);
|
|
962
1209
|
|
|
963
1210
|
expect(config).toEqual(
|
|
@@ -985,7 +1232,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
985
1232
|
],
|
|
986
1233
|
} as unknown as RawConfig,
|
|
987
1234
|
undefined,
|
|
988
|
-
undefined
|
|
1235
|
+
{ env: undefined }
|
|
989
1236
|
);
|
|
990
1237
|
|
|
991
1238
|
expect(config).toEqual(
|
|
@@ -1011,7 +1258,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1011
1258
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1012
1259
|
{ r2_buckets: {} } as unknown as RawConfig,
|
|
1013
1260
|
undefined,
|
|
1014
|
-
undefined
|
|
1261
|
+
{ env: undefined }
|
|
1015
1262
|
);
|
|
1016
1263
|
|
|
1017
1264
|
expect(config).toEqual(
|
|
@@ -1028,7 +1275,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1028
1275
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1029
1276
|
{ r2_buckets: "BAD" } as unknown as RawConfig,
|
|
1030
1277
|
undefined,
|
|
1031
|
-
undefined
|
|
1278
|
+
{ env: undefined }
|
|
1032
1279
|
);
|
|
1033
1280
|
|
|
1034
1281
|
expect(config).toEqual(
|
|
@@ -1045,7 +1292,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1045
1292
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1046
1293
|
{ r2_buckets: 999 } as unknown as RawConfig,
|
|
1047
1294
|
undefined,
|
|
1048
|
-
undefined
|
|
1295
|
+
{ env: undefined }
|
|
1049
1296
|
);
|
|
1050
1297
|
|
|
1051
1298
|
expect(config).toEqual(
|
|
@@ -1062,7 +1309,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1062
1309
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1063
1310
|
{ r2_buckets: null } as unknown as RawConfig,
|
|
1064
1311
|
undefined,
|
|
1065
|
-
undefined
|
|
1312
|
+
{ env: undefined }
|
|
1066
1313
|
);
|
|
1067
1314
|
|
|
1068
1315
|
expect(config).toEqual(
|
|
@@ -1090,7 +1337,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1090
1337
|
],
|
|
1091
1338
|
} as unknown as RawConfig,
|
|
1092
1339
|
undefined,
|
|
1093
|
-
undefined
|
|
1340
|
+
{ env: undefined }
|
|
1094
1341
|
);
|
|
1095
1342
|
|
|
1096
1343
|
expect(config).toEqual(
|
|
@@ -1116,7 +1363,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1116
1363
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1117
1364
|
{ unsafe: [] } as unknown as RawConfig,
|
|
1118
1365
|
undefined,
|
|
1119
|
-
undefined
|
|
1366
|
+
{ env: undefined }
|
|
1120
1367
|
);
|
|
1121
1368
|
|
|
1122
1369
|
expect(config).toEqual(
|
|
@@ -1136,7 +1383,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1136
1383
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1137
1384
|
{ unsafe: "BAD" } as unknown as RawConfig,
|
|
1138
1385
|
undefined,
|
|
1139
|
-
undefined
|
|
1386
|
+
{ env: undefined }
|
|
1140
1387
|
);
|
|
1141
1388
|
|
|
1142
1389
|
expect(config).toEqual(
|
|
@@ -1156,7 +1403,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1156
1403
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1157
1404
|
{ unsafe: 999 } as unknown as RawConfig,
|
|
1158
1405
|
undefined,
|
|
1159
|
-
undefined
|
|
1406
|
+
{ env: undefined }
|
|
1160
1407
|
);
|
|
1161
1408
|
|
|
1162
1409
|
expect(config).toEqual(
|
|
@@ -1176,7 +1423,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1176
1423
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1177
1424
|
{ unsafe: null } as unknown as RawConfig,
|
|
1178
1425
|
undefined,
|
|
1179
|
-
undefined
|
|
1426
|
+
{ env: undefined }
|
|
1180
1427
|
);
|
|
1181
1428
|
|
|
1182
1429
|
expect(config).toEqual(
|
|
@@ -1196,7 +1443,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1196
1443
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1197
1444
|
{ unsafe: {} } as unknown as RawConfig,
|
|
1198
1445
|
undefined,
|
|
1199
|
-
undefined
|
|
1446
|
+
{ env: undefined }
|
|
1200
1447
|
);
|
|
1201
1448
|
|
|
1202
1449
|
expect(config).toEqual(
|
|
@@ -1216,7 +1463,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1216
1463
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1217
1464
|
{ unsafe: { bindings: {} } } as unknown as RawConfig,
|
|
1218
1465
|
undefined,
|
|
1219
|
-
undefined
|
|
1466
|
+
{ env: undefined }
|
|
1220
1467
|
);
|
|
1221
1468
|
|
|
1222
1469
|
expect(config).toEqual(
|
|
@@ -1238,7 +1485,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1238
1485
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1239
1486
|
{ unsafe: { bindings: "BAD" } } as unknown as RawConfig,
|
|
1240
1487
|
undefined,
|
|
1241
|
-
undefined
|
|
1488
|
+
{ env: undefined }
|
|
1242
1489
|
);
|
|
1243
1490
|
|
|
1244
1491
|
expect(config).toEqual(
|
|
@@ -1260,7 +1507,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1260
1507
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1261
1508
|
{ unsafe: { bindings: 999 } } as unknown as RawConfig,
|
|
1262
1509
|
undefined,
|
|
1263
|
-
undefined
|
|
1510
|
+
{ env: undefined }
|
|
1264
1511
|
);
|
|
1265
1512
|
|
|
1266
1513
|
expect(config).toEqual(
|
|
@@ -1282,7 +1529,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1282
1529
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1283
1530
|
{ unsafe: { bindings: null } } as unknown as RawConfig,
|
|
1284
1531
|
undefined,
|
|
1285
|
-
undefined
|
|
1532
|
+
{ env: undefined }
|
|
1286
1533
|
);
|
|
1287
1534
|
|
|
1288
1535
|
expect(config).toEqual(
|
|
@@ -1317,7 +1564,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1317
1564
|
},
|
|
1318
1565
|
} as unknown as RawConfig,
|
|
1319
1566
|
undefined,
|
|
1320
|
-
undefined
|
|
1567
|
+
{ env: undefined }
|
|
1321
1568
|
);
|
|
1322
1569
|
|
|
1323
1570
|
expect(config).toEqual(
|
|
@@ -1352,7 +1599,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1352
1599
|
zone_id: "ZONE_ID",
|
|
1353
1600
|
experimental_services: [
|
|
1354
1601
|
{
|
|
1355
|
-
name: "
|
|
1602
|
+
name: "mock-name",
|
|
1356
1603
|
service: "SERVICE",
|
|
1357
1604
|
environment: "ENV",
|
|
1358
1605
|
},
|
|
@@ -1362,7 +1609,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1362
1609
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1363
1610
|
rawConfig,
|
|
1364
1611
|
undefined,
|
|
1365
|
-
undefined
|
|
1612
|
+
{ env: undefined }
|
|
1366
1613
|
);
|
|
1367
1614
|
|
|
1368
1615
|
expect("experimental_services" in config).toBe(false);
|
|
@@ -1371,19 +1618,19 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1371
1618
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1372
1619
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1373
1620
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1621
|
+
"Processing wrangler configuration:
|
|
1622
|
+
- [1mDeprecation[0m: \\"zone_id\\":
|
|
1623
|
+
This is unnecessary since we can deduce this from routes directly.
|
|
1624
|
+
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
1625
|
+
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
|
|
1626
|
+
\`\`\`
|
|
1627
|
+
[[unsafe.bindings]]
|
|
1628
|
+
name = \\"mock-name\\"
|
|
1629
|
+
type = \\"service\\"
|
|
1630
|
+
service = \\"SERVICE\\"
|
|
1631
|
+
environment = \\"ENV\\"
|
|
1632
|
+
\`\`\`"
|
|
1633
|
+
`);
|
|
1387
1634
|
});
|
|
1388
1635
|
});
|
|
1389
1636
|
|
|
@@ -1397,7 +1644,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1397
1644
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
1398
1645
|
rawConfig,
|
|
1399
1646
|
undefined,
|
|
1400
|
-
undefined
|
|
1647
|
+
{ env: undefined }
|
|
1401
1648
|
);
|
|
1402
1649
|
|
|
1403
1650
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
@@ -1411,11 +1658,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1411
1658
|
describe("named environments", () => {
|
|
1412
1659
|
it("should warn if we specify an environment but there are no named environments", () => {
|
|
1413
1660
|
const rawConfig: RawConfig = {};
|
|
1414
|
-
const { diagnostics } = normalizeAndValidateConfig(
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
"DEV"
|
|
1418
|
-
);
|
|
1661
|
+
const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
|
|
1662
|
+
env: "DEV",
|
|
1663
|
+
});
|
|
1419
1664
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1420
1665
|
"Processing wrangler configuration:
|
|
1421
1666
|
"
|
|
@@ -1435,11 +1680,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1435
1680
|
|
|
1436
1681
|
it("should error if we specify an environment that does not match the named environments", () => {
|
|
1437
1682
|
const rawConfig: RawConfig = { env: { ENV1: {} } };
|
|
1438
|
-
const { diagnostics } = normalizeAndValidateConfig(
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
"DEV"
|
|
1442
|
-
);
|
|
1683
|
+
const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
|
|
1684
|
+
env: "DEV",
|
|
1685
|
+
});
|
|
1443
1686
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1444
1687
|
"Processing wrangler configuration:
|
|
1445
1688
|
- No environment found in configuration with name \\"DEV\\".
|
|
@@ -1461,8 +1704,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1461
1704
|
it("should use top-level values for inheritable config fields", () => {
|
|
1462
1705
|
const main = "src/index.ts";
|
|
1463
1706
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1464
|
-
const
|
|
1465
|
-
name: "
|
|
1707
|
+
const rawConfig: RawConfig = {
|
|
1708
|
+
name: "mock-name",
|
|
1466
1709
|
account_id: "ACCOUNT_ID",
|
|
1467
1710
|
compatibility_date: "2022-01-01",
|
|
1468
1711
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -1470,6 +1713,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1470
1713
|
routes: ["ROUTE_1", "ROUTE_2"],
|
|
1471
1714
|
jsx_factory: "JSX_FACTORY",
|
|
1472
1715
|
jsx_fragment: "JSX_FRAGMENT",
|
|
1716
|
+
tsconfig: "path/to/tsconfig.json",
|
|
1473
1717
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
1474
1718
|
usage_model: "bundled",
|
|
1475
1719
|
main,
|
|
@@ -1481,13 +1725,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1481
1725
|
};
|
|
1482
1726
|
|
|
1483
1727
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1484
|
-
{ ...
|
|
1728
|
+
{ ...rawConfig, env: { dev: {} } },
|
|
1485
1729
|
undefined,
|
|
1486
|
-
"
|
|
1730
|
+
{ env: "dev" }
|
|
1487
1731
|
);
|
|
1488
1732
|
|
|
1489
1733
|
expect(config).toEqual(
|
|
1490
|
-
expect.objectContaining({
|
|
1734
|
+
expect.objectContaining({
|
|
1735
|
+
...rawConfig,
|
|
1736
|
+
main: resolvedMain,
|
|
1737
|
+
name: "mock-name-dev",
|
|
1738
|
+
})
|
|
1491
1739
|
);
|
|
1492
1740
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1493
1741
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1497,7 +1745,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1497
1745
|
const main = "src/index.ts";
|
|
1498
1746
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1499
1747
|
const rawEnv: RawEnvironment = {
|
|
1500
|
-
name: "
|
|
1748
|
+
name: "mock-env-name",
|
|
1501
1749
|
account_id: "ENV_ACCOUNT_ID",
|
|
1502
1750
|
compatibility_date: "2022-02-02",
|
|
1503
1751
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -1505,6 +1753,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1505
1753
|
routes: ["ENV_ROUTE_1", "ENV_ROUTE_2"],
|
|
1506
1754
|
jsx_factory: "ENV_JSX_FACTORY",
|
|
1507
1755
|
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
1756
|
+
tsconfig: "ENV_path/to/tsconfig.json",
|
|
1508
1757
|
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
1509
1758
|
usage_model: "unbound",
|
|
1510
1759
|
main,
|
|
@@ -1515,7 +1764,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1515
1764
|
},
|
|
1516
1765
|
};
|
|
1517
1766
|
const rawConfig: RawConfig = {
|
|
1518
|
-
name: "
|
|
1767
|
+
name: "mock-name",
|
|
1519
1768
|
account_id: "ACCOUNT_ID",
|
|
1520
1769
|
compatibility_date: "2022-01-01",
|
|
1521
1770
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -1523,6 +1772,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1523
1772
|
routes: ["ROUTE_1", "ROUTE_2"],
|
|
1524
1773
|
jsx_factory: "JSX_FACTORY",
|
|
1525
1774
|
jsx_fragment: "JSX_FRAGMENT",
|
|
1775
|
+
tsconfig: "path/to/tsconfig.json",
|
|
1526
1776
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
1527
1777
|
usage_model: "bundled",
|
|
1528
1778
|
main: "top-level.js",
|
|
@@ -1539,7 +1789,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1539
1789
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1540
1790
|
rawConfig,
|
|
1541
1791
|
undefined,
|
|
1542
|
-
"ENV1"
|
|
1792
|
+
{ env: "ENV1" }
|
|
1543
1793
|
);
|
|
1544
1794
|
|
|
1545
1795
|
expect(config).toEqual(
|
|
@@ -1552,7 +1802,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1552
1802
|
describe("non-legacy", () => {
|
|
1553
1803
|
it("should use top-level `name` field", () => {
|
|
1554
1804
|
const rawConfig: RawConfig = {
|
|
1555
|
-
name: "
|
|
1805
|
+
name: "mock-name",
|
|
1556
1806
|
legacy_env: false,
|
|
1557
1807
|
env: { DEV: {} },
|
|
1558
1808
|
};
|
|
@@ -1560,12 +1810,16 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1560
1810
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1561
1811
|
rawConfig,
|
|
1562
1812
|
undefined,
|
|
1563
|
-
"DEV"
|
|
1813
|
+
{ env: "DEV" }
|
|
1564
1814
|
);
|
|
1565
1815
|
|
|
1566
|
-
expect(config.name).toEqual("
|
|
1816
|
+
expect(config.name).toEqual("mock-name");
|
|
1567
1817
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1568
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
1818
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1819
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1820
|
+
"Processing wrangler configuration:
|
|
1821
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1822
|
+
`);
|
|
1569
1823
|
});
|
|
1570
1824
|
|
|
1571
1825
|
it("should error if named environment contains a `name` field, even if there is no top-level name", () => {
|
|
@@ -1573,7 +1827,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1573
1827
|
legacy_env: false,
|
|
1574
1828
|
env: {
|
|
1575
1829
|
DEV: {
|
|
1576
|
-
name: "
|
|
1830
|
+
name: "mock-env-name",
|
|
1577
1831
|
},
|
|
1578
1832
|
},
|
|
1579
1833
|
};
|
|
@@ -1581,10 +1835,16 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1581
1835
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1582
1836
|
rawConfig,
|
|
1583
1837
|
undefined,
|
|
1584
|
-
"DEV"
|
|
1838
|
+
{ env: "DEV" }
|
|
1585
1839
|
);
|
|
1586
1840
|
|
|
1587
1841
|
expect(config.name).toBeUndefined();
|
|
1842
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1843
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1844
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1845
|
+
"Processing wrangler configuration:
|
|
1846
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1847
|
+
`);
|
|
1588
1848
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1589
1849
|
"Processing wrangler configuration:
|
|
1590
1850
|
|
|
@@ -1592,16 +1852,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1592
1852
|
- The \\"name\\" field is not allowed in named service environments.
|
|
1593
1853
|
Please remove the field from this environment."
|
|
1594
1854
|
`);
|
|
1595
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1596
1855
|
});
|
|
1597
1856
|
|
|
1598
1857
|
it("should error if top-level config and a named environment both contain a `name` field", () => {
|
|
1599
1858
|
const rawConfig: RawConfig = {
|
|
1600
|
-
name: "
|
|
1859
|
+
name: "mock-name",
|
|
1601
1860
|
legacy_env: false,
|
|
1602
1861
|
env: {
|
|
1603
1862
|
DEV: {
|
|
1604
|
-
name: "
|
|
1863
|
+
name: "mock-env-name",
|
|
1605
1864
|
},
|
|
1606
1865
|
},
|
|
1607
1866
|
};
|
|
@@ -1609,10 +1868,16 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1609
1868
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1610
1869
|
rawConfig,
|
|
1611
1870
|
undefined,
|
|
1612
|
-
"DEV"
|
|
1871
|
+
{ env: "DEV" }
|
|
1613
1872
|
);
|
|
1614
1873
|
|
|
1615
|
-
expect(config.name).toEqual("
|
|
1874
|
+
expect(config.name).toEqual("mock-name");
|
|
1875
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1876
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1877
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1878
|
+
"Processing wrangler configuration:
|
|
1879
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1880
|
+
`);
|
|
1616
1881
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1617
1882
|
"Processing wrangler configuration:
|
|
1618
1883
|
|
|
@@ -1620,10 +1885,73 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1620
1885
|
- The \\"name\\" field is not allowed in named service environments.
|
|
1621
1886
|
Please remove the field from this environment."
|
|
1622
1887
|
`);
|
|
1623
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1624
1888
|
});
|
|
1625
1889
|
});
|
|
1626
1890
|
|
|
1891
|
+
it("should error if named environment contains a `account_id` field, even if there is no top-level name", () => {
|
|
1892
|
+
const rawConfig: RawConfig = {
|
|
1893
|
+
legacy_env: false,
|
|
1894
|
+
env: {
|
|
1895
|
+
DEV: {
|
|
1896
|
+
account_id: "some_account_id",
|
|
1897
|
+
},
|
|
1898
|
+
},
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1902
|
+
rawConfig,
|
|
1903
|
+
undefined,
|
|
1904
|
+
{ env: "DEV" }
|
|
1905
|
+
);
|
|
1906
|
+
|
|
1907
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1908
|
+
expect(config.account_id).toBeUndefined();
|
|
1909
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1910
|
+
"Processing wrangler configuration:
|
|
1911
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1912
|
+
`);
|
|
1913
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1914
|
+
"Processing wrangler configuration:
|
|
1915
|
+
|
|
1916
|
+
- \\"env.DEV\\" environment configuration
|
|
1917
|
+
- The \\"account_id\\" field is not allowed in named service environments.
|
|
1918
|
+
Please remove the field from this environment."
|
|
1919
|
+
`);
|
|
1920
|
+
});
|
|
1921
|
+
|
|
1922
|
+
it("should error if top-level config and a named environment both contain a `account_id` field", () => {
|
|
1923
|
+
const rawConfig: RawConfig = {
|
|
1924
|
+
account_id: "ACCOUNT_ID",
|
|
1925
|
+
legacy_env: false,
|
|
1926
|
+
env: {
|
|
1927
|
+
DEV: {
|
|
1928
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
1929
|
+
},
|
|
1930
|
+
},
|
|
1931
|
+
};
|
|
1932
|
+
|
|
1933
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1934
|
+
rawConfig,
|
|
1935
|
+
undefined,
|
|
1936
|
+
{ env: "DEV" }
|
|
1937
|
+
);
|
|
1938
|
+
|
|
1939
|
+
expect(config.account_id).toEqual("ACCOUNT_ID");
|
|
1940
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1941
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1942
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1943
|
+
"Processing wrangler configuration:
|
|
1944
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1945
|
+
`);
|
|
1946
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1947
|
+
"Processing wrangler configuration:
|
|
1948
|
+
|
|
1949
|
+
- \\"env.DEV\\" environment configuration
|
|
1950
|
+
- The \\"account_id\\" field is not allowed in named service environments.
|
|
1951
|
+
Please remove the field from this environment."
|
|
1952
|
+
`);
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1627
1955
|
it("should warn for non-inherited fields that are missing in environments", () => {
|
|
1628
1956
|
const vars: RawConfig["vars"] = {
|
|
1629
1957
|
FOO: "foo",
|
|
@@ -1648,7 +1976,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1648
1976
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1649
1977
|
rawConfig,
|
|
1650
1978
|
undefined,
|
|
1651
|
-
"ENV1"
|
|
1979
|
+
{ env: "ENV1" }
|
|
1652
1980
|
);
|
|
1653
1981
|
|
|
1654
1982
|
expect(config).toEqual(
|
|
@@ -1694,6 +2022,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1694
2022
|
route: 888,
|
|
1695
2023
|
jsx_factory: 999,
|
|
1696
2024
|
jsx_fragment: 1000,
|
|
2025
|
+
tsconfig: 123,
|
|
1697
2026
|
triggers: { crons: [1111, 1222] },
|
|
1698
2027
|
usage_model: "INVALID",
|
|
1699
2028
|
main: 1333,
|
|
@@ -1707,7 +2036,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1707
2036
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1708
2037
|
{ env: { ENV1: expectedConfig } },
|
|
1709
2038
|
undefined,
|
|
1710
|
-
"ENV1"
|
|
2039
|
+
{ env: "ENV1" }
|
|
1711
2040
|
);
|
|
1712
2041
|
|
|
1713
2042
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
@@ -1716,8 +2045,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1716
2045
|
"Processing wrangler configuration:
|
|
1717
2046
|
|
|
1718
2047
|
- \\"env.ENV1\\" environment configuration
|
|
1719
|
-
- Expected \\"route\\" to be
|
|
1720
|
-
- Expected \\"routes\\" to be of
|
|
2048
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
|
|
2049
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
|
|
2050
|
+
666,
|
|
2051
|
+
777
|
|
2052
|
+
].
|
|
1721
2053
|
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
1722
2054
|
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
1723
2055
|
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
@@ -1728,7 +2060,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1728
2060
|
- Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
|
|
1729
2061
|
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
1730
2062
|
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
1731
|
-
- Expected \\"
|
|
2063
|
+
- Expected \\"tsconfig\\" to be of type string but got 123.
|
|
2064
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
1732
2065
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
1733
2066
|
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
1734
2067
|
`);
|
|
@@ -1739,7 +2072,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1739
2072
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1740
2073
|
{ env: { ENV1: { durable_objects: [] } } } as unknown as RawConfig,
|
|
1741
2074
|
undefined,
|
|
1742
|
-
"ENV1"
|
|
2075
|
+
{ env: "ENV1" }
|
|
1743
2076
|
);
|
|
1744
2077
|
|
|
1745
2078
|
expect(config).toEqual(
|
|
@@ -1758,7 +2091,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1758
2091
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1759
2092
|
{ env: { ENV1: { durable_objects: "BAD" } } } as unknown as RawConfig,
|
|
1760
2093
|
undefined,
|
|
1761
|
-
"ENV1"
|
|
2094
|
+
{ env: "ENV1" }
|
|
1762
2095
|
);
|
|
1763
2096
|
|
|
1764
2097
|
expect(config).toEqual(
|
|
@@ -1777,7 +2110,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1777
2110
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1778
2111
|
{ env: { ENV1: { durable_objects: 999 } } } as unknown as RawConfig,
|
|
1779
2112
|
undefined,
|
|
1780
|
-
"ENV1"
|
|
2113
|
+
{ env: "ENV1" }
|
|
1781
2114
|
);
|
|
1782
2115
|
|
|
1783
2116
|
expect(config).toEqual(
|
|
@@ -1796,7 +2129,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1796
2129
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1797
2130
|
{ env: { ENV1: { durable_objects: null } } } as unknown as RawConfig,
|
|
1798
2131
|
undefined,
|
|
1799
|
-
"ENV1"
|
|
2132
|
+
{ env: "ENV1" }
|
|
1800
2133
|
);
|
|
1801
2134
|
|
|
1802
2135
|
expect(config).toEqual(
|
|
@@ -1815,7 +2148,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1815
2148
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1816
2149
|
{ env: { ENV1: { durable_objects: {} } } } as unknown as RawConfig,
|
|
1817
2150
|
undefined,
|
|
1818
|
-
"ENV1"
|
|
2151
|
+
{ env: "ENV1" }
|
|
1819
2152
|
);
|
|
1820
2153
|
|
|
1821
2154
|
expect(config).toEqual(
|
|
@@ -1836,7 +2169,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1836
2169
|
env: { ENV1: { durable_objects: { bindings: {} } } },
|
|
1837
2170
|
} as unknown as RawConfig,
|
|
1838
2171
|
undefined,
|
|
1839
|
-
"ENV1"
|
|
2172
|
+
{ env: "ENV1" }
|
|
1840
2173
|
);
|
|
1841
2174
|
|
|
1842
2175
|
expect(config).toEqual(
|
|
@@ -1859,7 +2192,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1859
2192
|
env: { ENV1: { durable_objects: { bindings: "BAD" } } },
|
|
1860
2193
|
} as unknown as RawConfig,
|
|
1861
2194
|
undefined,
|
|
1862
|
-
"ENV1"
|
|
2195
|
+
{ env: "ENV1" }
|
|
1863
2196
|
);
|
|
1864
2197
|
|
|
1865
2198
|
expect(config).toEqual(
|
|
@@ -1882,7 +2215,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1882
2215
|
env: { ENV1: { durable_objects: { bindings: 999 } } },
|
|
1883
2216
|
} as unknown as RawConfig,
|
|
1884
2217
|
undefined,
|
|
1885
|
-
"ENV1"
|
|
2218
|
+
{ env: "ENV1" }
|
|
1886
2219
|
);
|
|
1887
2220
|
|
|
1888
2221
|
expect(config).toEqual(
|
|
@@ -1905,7 +2238,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1905
2238
|
env: { ENV1: { durable_objects: { bindings: null } } },
|
|
1906
2239
|
} as unknown as RawConfig,
|
|
1907
2240
|
undefined,
|
|
1908
|
-
"ENV1"
|
|
2241
|
+
{ env: "ENV1" }
|
|
1909
2242
|
);
|
|
1910
2243
|
|
|
1911
2244
|
expect(config).toEqual(
|
|
@@ -1943,7 +2276,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1943
2276
|
},
|
|
1944
2277
|
} as unknown as RawConfig,
|
|
1945
2278
|
undefined,
|
|
1946
|
-
"ENV1"
|
|
2279
|
+
{ env: "ENV1" }
|
|
1947
2280
|
);
|
|
1948
2281
|
|
|
1949
2282
|
expect(config).toEqual(
|
|
@@ -1981,7 +2314,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1981
2314
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1982
2315
|
{ env: { ENV1: { kv_namespaces: {} } } } as unknown as RawConfig,
|
|
1983
2316
|
undefined,
|
|
1984
|
-
"ENV1"
|
|
2317
|
+
{ env: "ENV1" }
|
|
1985
2318
|
);
|
|
1986
2319
|
|
|
1987
2320
|
expect(config).toEqual(
|
|
@@ -2000,7 +2333,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2000
2333
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2001
2334
|
{ env: { ENV1: { kv_namespaces: "BAD" } } } as unknown as RawConfig,
|
|
2002
2335
|
undefined,
|
|
2003
|
-
"ENV1"
|
|
2336
|
+
{ env: "ENV1" }
|
|
2004
2337
|
);
|
|
2005
2338
|
|
|
2006
2339
|
expect(config).toEqual(
|
|
@@ -2019,7 +2352,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2019
2352
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2020
2353
|
{ env: { ENV1: { kv_namespaces: 999 } } } as unknown as RawConfig,
|
|
2021
2354
|
undefined,
|
|
2022
|
-
"ENV1"
|
|
2355
|
+
{ env: "ENV1" }
|
|
2023
2356
|
);
|
|
2024
2357
|
|
|
2025
2358
|
expect(config).toEqual(
|
|
@@ -2038,7 +2371,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2038
2371
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2039
2372
|
{ env: { ENV1: { kv_namespaces: null } } } as unknown as RawConfig,
|
|
2040
2373
|
undefined,
|
|
2041
|
-
"ENV1"
|
|
2374
|
+
{ env: "ENV1" }
|
|
2042
2375
|
);
|
|
2043
2376
|
|
|
2044
2377
|
expect(config).toEqual(
|
|
@@ -2072,7 +2405,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2072
2405
|
},
|
|
2073
2406
|
} as unknown as RawConfig,
|
|
2074
2407
|
undefined,
|
|
2075
|
-
"ENV1"
|
|
2408
|
+
{ env: "ENV1" }
|
|
2076
2409
|
);
|
|
2077
2410
|
|
|
2078
2411
|
expect(config).toEqual(
|
|
@@ -2100,7 +2433,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2100
2433
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2101
2434
|
{ env: { ENV1: { r2_buckets: {} } } } as unknown as RawConfig,
|
|
2102
2435
|
undefined,
|
|
2103
|
-
"ENV1"
|
|
2436
|
+
{ env: "ENV1" }
|
|
2104
2437
|
);
|
|
2105
2438
|
|
|
2106
2439
|
expect(config).toEqual(
|
|
@@ -2119,7 +2452,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2119
2452
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2120
2453
|
{ env: { ENV1: { r2_buckets: "BAD" } } } as unknown as RawConfig,
|
|
2121
2454
|
undefined,
|
|
2122
|
-
"ENV1"
|
|
2455
|
+
{ env: "ENV1" }
|
|
2123
2456
|
);
|
|
2124
2457
|
|
|
2125
2458
|
expect(config).toEqual(
|
|
@@ -2138,7 +2471,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2138
2471
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2139
2472
|
{ env: { ENV1: { r2_buckets: 999 } } } as unknown as RawConfig,
|
|
2140
2473
|
undefined,
|
|
2141
|
-
"ENV1"
|
|
2474
|
+
{ env: "ENV1" }
|
|
2142
2475
|
);
|
|
2143
2476
|
|
|
2144
2477
|
expect(config).toEqual(
|
|
@@ -2157,7 +2490,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2157
2490
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2158
2491
|
{ env: { ENV1: { r2_buckets: null } } } as unknown as RawConfig,
|
|
2159
2492
|
undefined,
|
|
2160
|
-
"ENV1"
|
|
2493
|
+
{ env: "ENV1" }
|
|
2161
2494
|
);
|
|
2162
2495
|
|
|
2163
2496
|
expect(config).toEqual(
|
|
@@ -2191,7 +2524,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2191
2524
|
},
|
|
2192
2525
|
} as unknown as RawConfig,
|
|
2193
2526
|
undefined,
|
|
2194
|
-
"ENV1"
|
|
2527
|
+
{ env: "ENV1" }
|
|
2195
2528
|
);
|
|
2196
2529
|
|
|
2197
2530
|
expect(config).toEqual(
|
|
@@ -2219,7 +2552,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2219
2552
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2220
2553
|
{ env: { ENV1: { unsafe: [] } } } as unknown as RawConfig,
|
|
2221
2554
|
undefined,
|
|
2222
|
-
"ENV1"
|
|
2555
|
+
{ env: "ENV1" }
|
|
2223
2556
|
);
|
|
2224
2557
|
|
|
2225
2558
|
expect(config).toEqual(
|
|
@@ -2243,7 +2576,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2243
2576
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2244
2577
|
{ env: { ENV1: { unsafe: "BAD" } } } as unknown as RawConfig,
|
|
2245
2578
|
undefined,
|
|
2246
|
-
"ENV1"
|
|
2579
|
+
{ env: "ENV1" }
|
|
2247
2580
|
);
|
|
2248
2581
|
|
|
2249
2582
|
expect(config).toEqual(
|
|
@@ -2267,7 +2600,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2267
2600
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2268
2601
|
{ env: { ENV1: { unsafe: 999 } } } as unknown as RawConfig,
|
|
2269
2602
|
undefined,
|
|
2270
|
-
"ENV1"
|
|
2603
|
+
{ env: "ENV1" }
|
|
2271
2604
|
);
|
|
2272
2605
|
|
|
2273
2606
|
expect(config).toEqual(
|
|
@@ -2291,7 +2624,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2291
2624
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2292
2625
|
{ env: { ENV1: { unsafe: null } } } as unknown as RawConfig,
|
|
2293
2626
|
undefined,
|
|
2294
|
-
"ENV1"
|
|
2627
|
+
{ env: "ENV1" }
|
|
2295
2628
|
);
|
|
2296
2629
|
|
|
2297
2630
|
expect(config).toEqual(
|
|
@@ -2315,7 +2648,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2315
2648
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2316
2649
|
{ env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
|
|
2317
2650
|
undefined,
|
|
2318
|
-
"ENV1"
|
|
2651
|
+
{ env: "ENV1" }
|
|
2319
2652
|
);
|
|
2320
2653
|
|
|
2321
2654
|
expect(config).toEqual(
|
|
@@ -2341,7 +2674,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2341
2674
|
env: { ENV1: { unsafe: { bindings: {} } } },
|
|
2342
2675
|
} as unknown as RawConfig,
|
|
2343
2676
|
undefined,
|
|
2344
|
-
"ENV1"
|
|
2677
|
+
{ env: "ENV1" }
|
|
2345
2678
|
);
|
|
2346
2679
|
|
|
2347
2680
|
expect(config).toEqual(
|
|
@@ -2369,7 +2702,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2369
2702
|
env: { ENV1: { unsafe: { bindings: "BAD" } } },
|
|
2370
2703
|
} as unknown as RawConfig,
|
|
2371
2704
|
undefined,
|
|
2372
|
-
"ENV1"
|
|
2705
|
+
{ env: "ENV1" }
|
|
2373
2706
|
);
|
|
2374
2707
|
|
|
2375
2708
|
expect(config).toEqual(
|
|
@@ -2397,7 +2730,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2397
2730
|
env: { ENV1: { unsafe: { bindings: 999 } } },
|
|
2398
2731
|
} as unknown as RawConfig,
|
|
2399
2732
|
undefined,
|
|
2400
|
-
"ENV1"
|
|
2733
|
+
{ env: "ENV1" }
|
|
2401
2734
|
);
|
|
2402
2735
|
|
|
2403
2736
|
expect(config).toEqual(
|
|
@@ -2425,7 +2758,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2425
2758
|
env: { ENV1: { unsafe: { bindings: null } } },
|
|
2426
2759
|
} as unknown as RawConfig,
|
|
2427
2760
|
undefined,
|
|
2428
|
-
"ENV1"
|
|
2761
|
+
{ env: "ENV1" }
|
|
2429
2762
|
);
|
|
2430
2763
|
|
|
2431
2764
|
expect(config).toEqual(
|
|
@@ -2468,7 +2801,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2468
2801
|
},
|
|
2469
2802
|
} as unknown as RawConfig,
|
|
2470
2803
|
undefined,
|
|
2471
|
-
"ENV1"
|
|
2804
|
+
{ env: "ENV1" }
|
|
2472
2805
|
);
|
|
2473
2806
|
|
|
2474
2807
|
expect(config).toEqual(
|
|
@@ -2507,7 +2840,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2507
2840
|
zone_id: "ZONE_ID",
|
|
2508
2841
|
experimental_services: [
|
|
2509
2842
|
{
|
|
2510
|
-
name: "
|
|
2843
|
+
name: "mock-name",
|
|
2511
2844
|
service: "SERVICE",
|
|
2512
2845
|
environment: "ENV",
|
|
2513
2846
|
},
|
|
@@ -2521,7 +2854,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2521
2854
|
},
|
|
2522
2855
|
},
|
|
2523
2856
|
undefined,
|
|
2524
|
-
"ENV1"
|
|
2857
|
+
{ env: "ENV1" }
|
|
2525
2858
|
);
|
|
2526
2859
|
|
|
2527
2860
|
expect("experimental_services" in config).toBe(false);
|
|
@@ -2533,13 +2866,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2533
2866
|
"Processing wrangler configuration:
|
|
2534
2867
|
|
|
2535
2868
|
- \\"env.ENV1\\" environment configuration
|
|
2536
|
-
-
|
|
2869
|
+
- [1mDeprecation[0m: \\"zone_id\\":
|
|
2537
2870
|
This is unnecessary since we can deduce this from routes directly.
|
|
2538
|
-
-
|
|
2871
|
+
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
2539
2872
|
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
|
|
2540
2873
|
\`\`\`
|
|
2541
2874
|
[[unsafe.bindings]]
|
|
2542
|
-
name = \\"
|
|
2875
|
+
name = \\"mock-name\\"
|
|
2543
2876
|
type = \\"service\\"
|
|
2544
2877
|
service = \\"SERVICE\\"
|
|
2545
2878
|
environment = \\"ENV\\"
|
|
@@ -2551,7 +2884,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2551
2884
|
describe("route & routes fields", () => {
|
|
2552
2885
|
it("should error if both route and routes are specified in the same environment", () => {
|
|
2553
2886
|
const environment: RawEnvironment = {
|
|
2554
|
-
name: "
|
|
2887
|
+
name: "mock-env-name",
|
|
2555
2888
|
account_id: "ENV_ACCOUNT_ID",
|
|
2556
2889
|
compatibility_date: "2022-02-02",
|
|
2557
2890
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2564,7 +2897,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2564
2897
|
usage_model: "unbound",
|
|
2565
2898
|
};
|
|
2566
2899
|
const expectedConfig: RawConfig = {
|
|
2567
|
-
name: "
|
|
2900
|
+
name: "mock-name",
|
|
2568
2901
|
account_id: "ACCOUNT_ID",
|
|
2569
2902
|
compatibility_date: "2022-01-01",
|
|
2570
2903
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2582,7 +2915,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2582
2915
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2583
2916
|
expectedConfig,
|
|
2584
2917
|
undefined,
|
|
2585
|
-
"ENV1"
|
|
2918
|
+
{ env: "ENV1" }
|
|
2586
2919
|
);
|
|
2587
2920
|
|
|
2588
2921
|
expect(config).toEqual(expect.objectContaining(environment));
|
|
@@ -2599,7 +2932,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2599
2932
|
|
|
2600
2933
|
it("should error if both route and routes are specified in the top-level environment", () => {
|
|
2601
2934
|
const environment: RawEnvironment = {
|
|
2602
|
-
name: "
|
|
2935
|
+
name: "mock-env-name",
|
|
2603
2936
|
account_id: "ENV_ACCOUNT_ID",
|
|
2604
2937
|
compatibility_date: "2022-02-02",
|
|
2605
2938
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2611,7 +2944,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2611
2944
|
usage_model: "unbound",
|
|
2612
2945
|
};
|
|
2613
2946
|
const expectedConfig: RawConfig = {
|
|
2614
|
-
name: "
|
|
2947
|
+
name: "mock-name",
|
|
2615
2948
|
account_id: "ACCOUNT_ID",
|
|
2616
2949
|
compatibility_date: "2022-01-01",
|
|
2617
2950
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2630,7 +2963,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2630
2963
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2631
2964
|
expectedConfig,
|
|
2632
2965
|
undefined,
|
|
2633
|
-
"ENV1"
|
|
2966
|
+
{ env: "ENV1" }
|
|
2634
2967
|
);
|
|
2635
2968
|
|
|
2636
2969
|
expect(config).toEqual(expect.objectContaining(environment));
|
|
@@ -2645,7 +2978,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2645
2978
|
|
|
2646
2979
|
it("should not error if <env>.route and <top-level>.routes are specified", () => {
|
|
2647
2980
|
const environment: RawEnvironment = {
|
|
2648
|
-
name: "
|
|
2981
|
+
name: "mock-env-name",
|
|
2649
2982
|
account_id: "ENV_ACCOUNT_ID",
|
|
2650
2983
|
compatibility_date: "2022-02-02",
|
|
2651
2984
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2657,7 +2990,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2657
2990
|
usage_model: "unbound",
|
|
2658
2991
|
};
|
|
2659
2992
|
const expectedConfig: RawConfig = {
|
|
2660
|
-
name: "
|
|
2993
|
+
name: "mock-name",
|
|
2661
2994
|
account_id: "ACCOUNT_ID",
|
|
2662
2995
|
compatibility_date: "2022-01-01",
|
|
2663
2996
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2675,7 +3008,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2675
3008
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2676
3009
|
expectedConfig,
|
|
2677
3010
|
undefined,
|
|
2678
|
-
"ENV1"
|
|
3011
|
+
{ env: "ENV1" }
|
|
2679
3012
|
);
|
|
2680
3013
|
|
|
2681
3014
|
expect(config).toEqual(expect.objectContaining(environment));
|
|
@@ -2685,7 +3018,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2685
3018
|
|
|
2686
3019
|
it("should not error if <env>.routes and <top-level>.route are specified", () => {
|
|
2687
3020
|
const environment: RawEnvironment = {
|
|
2688
|
-
name: "
|
|
3021
|
+
name: "mock-env-name",
|
|
2689
3022
|
account_id: "ENV_ACCOUNT_ID",
|
|
2690
3023
|
compatibility_date: "2022-02-02",
|
|
2691
3024
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2697,7 +3030,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2697
3030
|
usage_model: "unbound",
|
|
2698
3031
|
};
|
|
2699
3032
|
const expectedConfig: RawConfig = {
|
|
2700
|
-
name: "
|
|
3033
|
+
name: "mock-name",
|
|
2701
3034
|
account_id: "ACCOUNT_ID",
|
|
2702
3035
|
compatibility_date: "2022-01-01",
|
|
2703
3036
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2715,7 +3048,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2715
3048
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2716
3049
|
expectedConfig,
|
|
2717
3050
|
undefined,
|
|
2718
|
-
"ENV1"
|
|
3051
|
+
{ env: "ENV1" }
|
|
2719
3052
|
);
|
|
2720
3053
|
|
|
2721
3054
|
expect(config).toEqual(expect.objectContaining(environment));
|
|
@@ -2725,7 +3058,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2725
3058
|
|
|
2726
3059
|
it("should not error if <env1>.route and <env2>.routes are specified", () => {
|
|
2727
3060
|
const environment1: RawEnvironment = {
|
|
2728
|
-
name: "
|
|
3061
|
+
name: "mock-env-name",
|
|
2729
3062
|
account_id: "ENV_ACCOUNT_ID",
|
|
2730
3063
|
compatibility_date: "2022-02-02",
|
|
2731
3064
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2737,7 +3070,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2737
3070
|
usage_model: "unbound",
|
|
2738
3071
|
};
|
|
2739
3072
|
const environment2: RawEnvironment = {
|
|
2740
|
-
name: "
|
|
3073
|
+
name: "mock-env-name",
|
|
2741
3074
|
account_id: "ENV_ACCOUNT_ID",
|
|
2742
3075
|
compatibility_date: "2022-02-02",
|
|
2743
3076
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2749,7 +3082,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2749
3082
|
usage_model: "unbound",
|
|
2750
3083
|
};
|
|
2751
3084
|
const expectedConfig: RawConfig = {
|
|
2752
|
-
name: "
|
|
3085
|
+
name: "mock-name",
|
|
2753
3086
|
account_id: "ACCOUNT_ID",
|
|
2754
3087
|
compatibility_date: "2022-01-01",
|
|
2755
3088
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2765,21 +3098,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2765
3098
|
},
|
|
2766
3099
|
};
|
|
2767
3100
|
|
|
2768
|
-
const result1 = normalizeAndValidateConfig(
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
"ENV1"
|
|
2772
|
-
);
|
|
3101
|
+
const result1 = normalizeAndValidateConfig(expectedConfig, undefined, {
|
|
3102
|
+
env: "ENV1",
|
|
3103
|
+
});
|
|
2773
3104
|
|
|
2774
3105
|
expect(result1.config).toEqual(expect.objectContaining(environment1));
|
|
2775
3106
|
expect(result1.diagnostics.hasErrors()).toBe(false);
|
|
2776
3107
|
expect(result1.diagnostics.hasWarnings()).toBe(false);
|
|
2777
3108
|
|
|
2778
|
-
const result2 = normalizeAndValidateConfig(
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
"ENV2"
|
|
2782
|
-
);
|
|
3109
|
+
const result2 = normalizeAndValidateConfig(expectedConfig, undefined, {
|
|
3110
|
+
env: "ENV2",
|
|
3111
|
+
});
|
|
2783
3112
|
|
|
2784
3113
|
expect(result2.config).toEqual(expect.objectContaining(environment2));
|
|
2785
3114
|
expect(result2.diagnostics.hasErrors()).toBe(false);
|