wrangler 0.0.0-e2b7352 → 0.0.0-e2f9bb2
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 +24 -13
- package/bin/wrangler.js +3 -0
- package/miniflare-dist/index.mjs +4828 -21
- package/package.json +29 -22
- 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 +386 -81
- package/src/__tests__/dev.test.tsx +242 -21
- package/src/__tests__/guess-worker-format.test.ts +18 -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 +24 -0
- 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 +25 -759
- package/src/__tests__/init.test.ts +1042 -0
- package/src/__tests__/jest.setup.ts +4 -4
- package/src/__tests__/kv.test.ts +130 -56
- package/src/__tests__/logger.test.ts +115 -0
- package/src/__tests__/pages.test.ts +290 -43
- package/src/__tests__/publish.test.ts +1699 -333
- package/src/__tests__/r2.test.ts +24 -8
- package/src/__tests__/route.test.ts +4 -4
- package/src/__tests__/secret.test.ts +55 -34
- package/src/__tests__/tail.test.ts +97 -45
- package/src/__tests__/user.test.ts +131 -0
- package/src/__tests__/whoami.test.tsx +14 -9
- package/src/bundle.ts +15 -1
- 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 +26 -3
- package/src/config/index.ts +2 -1
- package/src/config/validation-helpers.ts +26 -5
- package/src/config/validation.ts +233 -41
- 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 +60 -34
- package/src/dev/local.tsx +101 -21
- package/src/dev/remote.tsx +23 -13
- package/src/dev/use-esbuild.ts +19 -5
- package/src/dialogs.tsx +16 -6
- package/src/entry.ts +38 -11
- package/src/environment-variables.ts +3 -1
- package/src/errors.ts +11 -0
- package/src/https-options.ts +3 -2
- package/src/index.tsx +529 -303
- package/src/inspect.ts +17 -11
- 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 +860 -55
- package/src/parse.ts +1 -1
- package/src/proxy.ts +25 -11
- package/src/publish.ts +260 -141
- package/src/sites.tsx +27 -14
- package/src/tail/index.ts +1 -1
- package/src/tail/printing.ts +13 -8
- package/src/update-check.ts +19 -0
- package/src/user.tsx +104 -38
- 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 +20948 -50169
- package/miniflare-dist/index.mjs.map +0 -7
- 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,
|
|
@@ -56,6 +57,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
56
57
|
usage_model: undefined,
|
|
57
58
|
vars: {},
|
|
58
59
|
wasm_modules: undefined,
|
|
60
|
+
data_blobs: undefined,
|
|
59
61
|
workers_dev: undefined,
|
|
60
62
|
zone_id: undefined,
|
|
61
63
|
});
|
|
@@ -138,7 +140,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
138
140
|
`);
|
|
139
141
|
});
|
|
140
142
|
|
|
141
|
-
it("should
|
|
143
|
+
it("should report a deprecation warning if `miniflare` appears at the top level", () => {
|
|
142
144
|
const expectedConfig = {
|
|
143
145
|
miniflare: {
|
|
144
146
|
host: "localhost",
|
|
@@ -155,7 +157,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
155
157
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
156
158
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
157
159
|
"Processing wrangler configuration:
|
|
158
|
-
|
|
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."
|
|
159
162
|
`);
|
|
160
163
|
});
|
|
161
164
|
|
|
@@ -228,8 +231,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
228
231
|
const expectedConfig: RawConfig = {
|
|
229
232
|
site: {
|
|
230
233
|
bucket: "BUCKET",
|
|
231
|
-
|
|
234
|
+
"entry-point": "my-site",
|
|
232
235
|
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
236
|
+
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
233
237
|
},
|
|
234
238
|
};
|
|
235
239
|
|
|
@@ -241,13 +245,24 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
241
245
|
|
|
242
246
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
243
247
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
244
|
-
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
|
+
`);
|
|
245
259
|
});
|
|
246
260
|
|
|
247
261
|
it("should error if `site` config is missing `bucket`", () => {
|
|
248
262
|
const expectedConfig: RawConfig = {
|
|
249
263
|
// @ts-expect-error we're intentionally passing an invalid configuration here
|
|
250
264
|
site: {
|
|
265
|
+
"entry-point": "workers-site",
|
|
251
266
|
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
252
267
|
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
253
268
|
},
|
|
@@ -260,18 +275,30 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
260
275
|
);
|
|
261
276
|
|
|
262
277
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
278
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
263
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
|
+
|
|
264
291
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
265
292
|
"Processing wrangler configuration:
|
|
266
293
|
- \\"site.bucket\\" is a required field."
|
|
267
294
|
`);
|
|
268
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
269
295
|
});
|
|
270
296
|
|
|
271
297
|
it("should error on invalid `site` values", () => {
|
|
272
298
|
const expectedConfig = {
|
|
273
299
|
site: {
|
|
274
300
|
bucket: "BUCKET",
|
|
301
|
+
"entry-point": 111,
|
|
275
302
|
include: [222, 333],
|
|
276
303
|
exclude: [444, 555],
|
|
277
304
|
},
|
|
@@ -284,17 +311,28 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
284
311
|
);
|
|
285
312
|
|
|
286
313
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
287
|
-
expect(diagnostics.hasWarnings()).toBe(
|
|
314
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
288
315
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
289
316
|
"Processing wrangler configuration:
|
|
290
317
|
- Expected \\"sites.include.[0]\\" to be of type string but got 222.
|
|
291
318
|
- Expected \\"sites.include.[1]\\" to be of type string but got 333.
|
|
292
319
|
- Expected \\"sites.exclude.[0]\\" to be of type string but got 444.
|
|
293
|
-
- 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
|
+
\`\`\`"
|
|
294
332
|
`);
|
|
295
333
|
});
|
|
296
334
|
|
|
297
|
-
it("should
|
|
335
|
+
it("should log a deprecation warning if entry-point is defined", async () => {
|
|
298
336
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
299
337
|
{
|
|
300
338
|
site: {
|
|
@@ -309,21 +347,22 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
309
347
|
expect(config.site).toMatchInlineSnapshot(`
|
|
310
348
|
Object {
|
|
311
349
|
"bucket": "some/path",
|
|
350
|
+
"entry-point": "some/other/script.js",
|
|
312
351
|
"exclude": Array [],
|
|
313
352
|
"include": Array [],
|
|
314
353
|
}
|
|
315
354
|
`);
|
|
316
355
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
317
|
-
expect(diagnostics.hasErrors()).toBe(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
`);
|
|
322
|
-
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
356
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
357
|
+
|
|
358
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
359
|
+
.toMatchInlineSnapshot(`
|
|
323
360
|
"Processing wrangler configuration:
|
|
324
|
-
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
+
\`\`\`"
|
|
327
366
|
`);
|
|
328
367
|
});
|
|
329
368
|
});
|
|
@@ -354,7 +393,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
354
393
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
355
394
|
});
|
|
356
395
|
|
|
357
|
-
it("should error on invalid `
|
|
396
|
+
it("should error on invalid `wasm_modules` paths", () => {
|
|
358
397
|
const expectedConfig = {
|
|
359
398
|
wasm_modules: {
|
|
360
399
|
MODULE_1: 111,
|
|
@@ -434,6 +473,59 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
434
473
|
`);
|
|
435
474
|
});
|
|
436
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
|
+
|
|
437
529
|
it("should resolve tsconfig relative to wrangler.toml", async () => {
|
|
438
530
|
const expectedConfig: RawEnvironment = {
|
|
439
531
|
tsconfig: "path/to/some-tsconfig.json",
|
|
@@ -478,12 +570,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
478
570
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
479
571
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
480
572
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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
|
+
`);
|
|
487
579
|
});
|
|
488
580
|
});
|
|
489
581
|
});
|
|
@@ -494,12 +586,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
494
586
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
495
587
|
|
|
496
588
|
const expectedConfig: RawEnvironment = {
|
|
497
|
-
name: "
|
|
589
|
+
name: "mock-name",
|
|
498
590
|
account_id: "ACCOUNT_ID",
|
|
499
591
|
compatibility_date: "2022-01-01",
|
|
500
592
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
501
593
|
workers_dev: false,
|
|
502
|
-
routes: [
|
|
594
|
+
routes: [
|
|
595
|
+
"ROUTE_1",
|
|
596
|
+
"ROUTE_2",
|
|
597
|
+
{ pattern: "ROUTE3", zone_id: "ZONE_ID_3" },
|
|
598
|
+
"ROUTE_4",
|
|
599
|
+
],
|
|
503
600
|
jsx_factory: "JSX_FACTORY",
|
|
504
601
|
jsx_fragment: "JSX_FRAGMENT",
|
|
505
602
|
tsconfig: "path/to/tsconfig",
|
|
@@ -576,7 +673,26 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
576
673
|
compatibility_date: 333,
|
|
577
674
|
compatibility_flags: [444, 555],
|
|
578
675
|
workers_dev: "BAD",
|
|
579
|
-
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
|
+
],
|
|
580
696
|
route: 888,
|
|
581
697
|
jsx_factory: 999,
|
|
582
698
|
jsx_fragment: 1000,
|
|
@@ -601,8 +717,43 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
601
717
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
602
718
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
603
719
|
"Processing wrangler configuration:
|
|
604
|
-
- Expected \\"route\\" to be
|
|
605
|
-
- 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
|
+
].
|
|
606
757
|
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
607
758
|
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
608
759
|
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
@@ -614,12 +765,85 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
614
765
|
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
615
766
|
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
616
767
|
- Expected \\"tsconfig\\" to be of type string but got true.
|
|
617
|
-
- Expected \\"name\\" to be of type string but got 111.
|
|
768
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
618
769
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
619
770
|
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
620
771
|
`);
|
|
621
772
|
});
|
|
622
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
|
+
|
|
623
847
|
it("should override build.upload config defaults with provided values and warn about deprecations", () => {
|
|
624
848
|
const expectedConfig: RawEnvironment = {
|
|
625
849
|
build: {
|
|
@@ -645,17 +869,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
645
869
|
expect(normalizePath(diagnostics.renderWarnings()))
|
|
646
870
|
.toMatchInlineSnapshot(`
|
|
647
871
|
"Processing project/wrangler.toml configuration:
|
|
648
|
-
-
|
|
872
|
+
- [1mDeprecation[0m: \\"build.upload.format\\":
|
|
649
873
|
The format is inferred automatically from the code.
|
|
650
|
-
-
|
|
874
|
+
- [1mDeprecation[0m: \\"build.upload.main\\":
|
|
651
875
|
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
652
876
|
Then add the top level \`main\` field to your configuration file:
|
|
653
877
|
\`\`\`
|
|
654
878
|
main = \\"src/index.ts\\"
|
|
655
879
|
\`\`\`
|
|
656
|
-
-
|
|
880
|
+
- [1mDeprecation[0m: \\"build.upload.dir\\":
|
|
657
881
|
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
|
|
658
|
-
-
|
|
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:
|
|
659
883
|
\`\`\`
|
|
660
884
|
[[rules]]
|
|
661
885
|
type = \\"Text\\"
|
|
@@ -1375,7 +1599,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1375
1599
|
zone_id: "ZONE_ID",
|
|
1376
1600
|
experimental_services: [
|
|
1377
1601
|
{
|
|
1378
|
-
name: "
|
|
1602
|
+
name: "mock-name",
|
|
1379
1603
|
service: "SERVICE",
|
|
1380
1604
|
environment: "ENV",
|
|
1381
1605
|
},
|
|
@@ -1394,19 +1618,19 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1394
1618
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1395
1619
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1396
1620
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
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
|
+
`);
|
|
1410
1634
|
});
|
|
1411
1635
|
});
|
|
1412
1636
|
|
|
@@ -1481,7 +1705,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1481
1705
|
const main = "src/index.ts";
|
|
1482
1706
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1483
1707
|
const rawConfig: RawConfig = {
|
|
1484
|
-
name: "
|
|
1708
|
+
name: "mock-name",
|
|
1485
1709
|
account_id: "ACCOUNT_ID",
|
|
1486
1710
|
compatibility_date: "2022-01-01",
|
|
1487
1711
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -1501,16 +1725,16 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1501
1725
|
};
|
|
1502
1726
|
|
|
1503
1727
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1504
|
-
{ ...rawConfig, env: {
|
|
1728
|
+
{ ...rawConfig, env: { dev: {} } },
|
|
1505
1729
|
undefined,
|
|
1506
|
-
{ env: "
|
|
1730
|
+
{ env: "dev" }
|
|
1507
1731
|
);
|
|
1508
1732
|
|
|
1509
1733
|
expect(config).toEqual(
|
|
1510
1734
|
expect.objectContaining({
|
|
1511
1735
|
...rawConfig,
|
|
1512
1736
|
main: resolvedMain,
|
|
1513
|
-
name: "
|
|
1737
|
+
name: "mock-name-dev",
|
|
1514
1738
|
})
|
|
1515
1739
|
);
|
|
1516
1740
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
@@ -1521,7 +1745,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1521
1745
|
const main = "src/index.ts";
|
|
1522
1746
|
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1523
1747
|
const rawEnv: RawEnvironment = {
|
|
1524
|
-
name: "
|
|
1748
|
+
name: "mock-env-name",
|
|
1525
1749
|
account_id: "ENV_ACCOUNT_ID",
|
|
1526
1750
|
compatibility_date: "2022-02-02",
|
|
1527
1751
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -1540,7 +1764,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1540
1764
|
},
|
|
1541
1765
|
};
|
|
1542
1766
|
const rawConfig: RawConfig = {
|
|
1543
|
-
name: "
|
|
1767
|
+
name: "mock-name",
|
|
1544
1768
|
account_id: "ACCOUNT_ID",
|
|
1545
1769
|
compatibility_date: "2022-01-01",
|
|
1546
1770
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -1578,7 +1802,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1578
1802
|
describe("non-legacy", () => {
|
|
1579
1803
|
it("should use top-level `name` field", () => {
|
|
1580
1804
|
const rawConfig: RawConfig = {
|
|
1581
|
-
name: "
|
|
1805
|
+
name: "mock-name",
|
|
1582
1806
|
legacy_env: false,
|
|
1583
1807
|
env: { DEV: {} },
|
|
1584
1808
|
};
|
|
@@ -1589,9 +1813,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1589
1813
|
{ env: "DEV" }
|
|
1590
1814
|
);
|
|
1591
1815
|
|
|
1592
|
-
expect(config.name).toEqual("
|
|
1816
|
+
expect(config.name).toEqual("mock-name");
|
|
1593
1817
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1594
|
-
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
|
+
`);
|
|
1595
1823
|
});
|
|
1596
1824
|
|
|
1597
1825
|
it("should error if named environment contains a `name` field, even if there is no top-level name", () => {
|
|
@@ -1599,7 +1827,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1599
1827
|
legacy_env: false,
|
|
1600
1828
|
env: {
|
|
1601
1829
|
DEV: {
|
|
1602
|
-
name: "
|
|
1830
|
+
name: "mock-env-name",
|
|
1603
1831
|
},
|
|
1604
1832
|
},
|
|
1605
1833
|
};
|
|
@@ -1611,6 +1839,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1611
1839
|
);
|
|
1612
1840
|
|
|
1613
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
|
+
`);
|
|
1614
1848
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1615
1849
|
"Processing wrangler configuration:
|
|
1616
1850
|
|
|
@@ -1618,16 +1852,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1618
1852
|
- The \\"name\\" field is not allowed in named service environments.
|
|
1619
1853
|
Please remove the field from this environment."
|
|
1620
1854
|
`);
|
|
1621
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1622
1855
|
});
|
|
1623
1856
|
|
|
1624
1857
|
it("should error if top-level config and a named environment both contain a `name` field", () => {
|
|
1625
1858
|
const rawConfig: RawConfig = {
|
|
1626
|
-
name: "
|
|
1859
|
+
name: "mock-name",
|
|
1627
1860
|
legacy_env: false,
|
|
1628
1861
|
env: {
|
|
1629
1862
|
DEV: {
|
|
1630
|
-
name: "
|
|
1863
|
+
name: "mock-env-name",
|
|
1631
1864
|
},
|
|
1632
1865
|
},
|
|
1633
1866
|
};
|
|
@@ -1638,7 +1871,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1638
1871
|
{ env: "DEV" }
|
|
1639
1872
|
);
|
|
1640
1873
|
|
|
1641
|
-
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
|
+
`);
|
|
1642
1881
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1643
1882
|
"Processing wrangler configuration:
|
|
1644
1883
|
|
|
@@ -1646,10 +1885,73 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1646
1885
|
- The \\"name\\" field is not allowed in named service environments.
|
|
1647
1886
|
Please remove the field from this environment."
|
|
1648
1887
|
`);
|
|
1649
|
-
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1650
1888
|
});
|
|
1651
1889
|
});
|
|
1652
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
|
+
|
|
1653
1955
|
it("should warn for non-inherited fields that are missing in environments", () => {
|
|
1654
1956
|
const vars: RawConfig["vars"] = {
|
|
1655
1957
|
FOO: "foo",
|
|
@@ -1743,8 +2045,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1743
2045
|
"Processing wrangler configuration:
|
|
1744
2046
|
|
|
1745
2047
|
- \\"env.ENV1\\" environment configuration
|
|
1746
|
-
- Expected \\"route\\" to be
|
|
1747
|
-
- 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
|
+
].
|
|
1748
2053
|
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
1749
2054
|
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
1750
2055
|
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
@@ -1756,7 +2061,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1756
2061
|
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
1757
2062
|
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
1758
2063
|
- Expected \\"tsconfig\\" to be of type string but got 123.
|
|
1759
|
-
- Expected \\"name\\" to be of type string but got 111.
|
|
2064
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
1760
2065
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
1761
2066
|
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
1762
2067
|
`);
|
|
@@ -2535,7 +2840,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2535
2840
|
zone_id: "ZONE_ID",
|
|
2536
2841
|
experimental_services: [
|
|
2537
2842
|
{
|
|
2538
|
-
name: "
|
|
2843
|
+
name: "mock-name",
|
|
2539
2844
|
service: "SERVICE",
|
|
2540
2845
|
environment: "ENV",
|
|
2541
2846
|
},
|
|
@@ -2561,13 +2866,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2561
2866
|
"Processing wrangler configuration:
|
|
2562
2867
|
|
|
2563
2868
|
- \\"env.ENV1\\" environment configuration
|
|
2564
|
-
-
|
|
2869
|
+
- [1mDeprecation[0m: \\"zone_id\\":
|
|
2565
2870
|
This is unnecessary since we can deduce this from routes directly.
|
|
2566
|
-
-
|
|
2871
|
+
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
2567
2872
|
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
|
|
2568
2873
|
\`\`\`
|
|
2569
2874
|
[[unsafe.bindings]]
|
|
2570
|
-
name = \\"
|
|
2875
|
+
name = \\"mock-name\\"
|
|
2571
2876
|
type = \\"service\\"
|
|
2572
2877
|
service = \\"SERVICE\\"
|
|
2573
2878
|
environment = \\"ENV\\"
|
|
@@ -2579,7 +2884,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2579
2884
|
describe("route & routes fields", () => {
|
|
2580
2885
|
it("should error if both route and routes are specified in the same environment", () => {
|
|
2581
2886
|
const environment: RawEnvironment = {
|
|
2582
|
-
name: "
|
|
2887
|
+
name: "mock-env-name",
|
|
2583
2888
|
account_id: "ENV_ACCOUNT_ID",
|
|
2584
2889
|
compatibility_date: "2022-02-02",
|
|
2585
2890
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2592,7 +2897,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2592
2897
|
usage_model: "unbound",
|
|
2593
2898
|
};
|
|
2594
2899
|
const expectedConfig: RawConfig = {
|
|
2595
|
-
name: "
|
|
2900
|
+
name: "mock-name",
|
|
2596
2901
|
account_id: "ACCOUNT_ID",
|
|
2597
2902
|
compatibility_date: "2022-01-01",
|
|
2598
2903
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2627,7 +2932,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2627
2932
|
|
|
2628
2933
|
it("should error if both route and routes are specified in the top-level environment", () => {
|
|
2629
2934
|
const environment: RawEnvironment = {
|
|
2630
|
-
name: "
|
|
2935
|
+
name: "mock-env-name",
|
|
2631
2936
|
account_id: "ENV_ACCOUNT_ID",
|
|
2632
2937
|
compatibility_date: "2022-02-02",
|
|
2633
2938
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2639,7 +2944,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2639
2944
|
usage_model: "unbound",
|
|
2640
2945
|
};
|
|
2641
2946
|
const expectedConfig: RawConfig = {
|
|
2642
|
-
name: "
|
|
2947
|
+
name: "mock-name",
|
|
2643
2948
|
account_id: "ACCOUNT_ID",
|
|
2644
2949
|
compatibility_date: "2022-01-01",
|
|
2645
2950
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2673,7 +2978,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2673
2978
|
|
|
2674
2979
|
it("should not error if <env>.route and <top-level>.routes are specified", () => {
|
|
2675
2980
|
const environment: RawEnvironment = {
|
|
2676
|
-
name: "
|
|
2981
|
+
name: "mock-env-name",
|
|
2677
2982
|
account_id: "ENV_ACCOUNT_ID",
|
|
2678
2983
|
compatibility_date: "2022-02-02",
|
|
2679
2984
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2685,7 +2990,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2685
2990
|
usage_model: "unbound",
|
|
2686
2991
|
};
|
|
2687
2992
|
const expectedConfig: RawConfig = {
|
|
2688
|
-
name: "
|
|
2993
|
+
name: "mock-name",
|
|
2689
2994
|
account_id: "ACCOUNT_ID",
|
|
2690
2995
|
compatibility_date: "2022-01-01",
|
|
2691
2996
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2713,7 +3018,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2713
3018
|
|
|
2714
3019
|
it("should not error if <env>.routes and <top-level>.route are specified", () => {
|
|
2715
3020
|
const environment: RawEnvironment = {
|
|
2716
|
-
name: "
|
|
3021
|
+
name: "mock-env-name",
|
|
2717
3022
|
account_id: "ENV_ACCOUNT_ID",
|
|
2718
3023
|
compatibility_date: "2022-02-02",
|
|
2719
3024
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2725,7 +3030,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2725
3030
|
usage_model: "unbound",
|
|
2726
3031
|
};
|
|
2727
3032
|
const expectedConfig: RawConfig = {
|
|
2728
|
-
name: "
|
|
3033
|
+
name: "mock-name",
|
|
2729
3034
|
account_id: "ACCOUNT_ID",
|
|
2730
3035
|
compatibility_date: "2022-01-01",
|
|
2731
3036
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
@@ -2753,7 +3058,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2753
3058
|
|
|
2754
3059
|
it("should not error if <env1>.route and <env2>.routes are specified", () => {
|
|
2755
3060
|
const environment1: RawEnvironment = {
|
|
2756
|
-
name: "
|
|
3061
|
+
name: "mock-env-name",
|
|
2757
3062
|
account_id: "ENV_ACCOUNT_ID",
|
|
2758
3063
|
compatibility_date: "2022-02-02",
|
|
2759
3064
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2765,7 +3070,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2765
3070
|
usage_model: "unbound",
|
|
2766
3071
|
};
|
|
2767
3072
|
const environment2: RawEnvironment = {
|
|
2768
|
-
name: "
|
|
3073
|
+
name: "mock-env-name",
|
|
2769
3074
|
account_id: "ENV_ACCOUNT_ID",
|
|
2770
3075
|
compatibility_date: "2022-02-02",
|
|
2771
3076
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
@@ -2777,7 +3082,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2777
3082
|
usage_model: "unbound",
|
|
2778
3083
|
};
|
|
2779
3084
|
const expectedConfig: RawConfig = {
|
|
2780
|
-
name: "
|
|
3085
|
+
name: "mock-name",
|
|
2781
3086
|
account_id: "ACCOUNT_ID",
|
|
2782
3087
|
compatibility_date: "2022-01-01",
|
|
2783
3088
|
compatibility_flags: ["FLAG1", "FLAG2"],
|