wrangler 2.0.5 → 2.0.6
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/package.json +1 -1
- package/src/__tests__/configuration.test.ts +204 -27
- package/src/__tests__/dev.test.tsx +60 -7
- package/src/__tests__/index.test.ts +5 -6
- package/src/__tests__/kv.test.ts +85 -85
- package/src/__tests__/pages.test.ts +28 -5
- package/src/__tests__/publish.test.ts +306 -7
- package/src/__tests__/r2.test.ts +47 -24
- package/src/__tests__/secret.test.ts +35 -0
- package/src/bundle.ts +32 -1
- package/src/config/environment.ts +40 -14
- package/src/config/validation.ts +102 -35
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/local.tsx +6 -0
- package/src/index.tsx +45 -20
- package/src/kv.ts +18 -3
- package/src/pages.tsx +3 -4
- package/src/publish.ts +210 -21
- package/src/sites.tsx +3 -1
- package/src/worker.ts +8 -0
- package/wrangler-dist/cli.js +432 -234
package/package.json
CHANGED
|
@@ -43,6 +43,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
43
43
|
migrations: [],
|
|
44
44
|
name: undefined,
|
|
45
45
|
r2_buckets: [],
|
|
46
|
+
services: [],
|
|
46
47
|
route: undefined,
|
|
47
48
|
routes: undefined,
|
|
48
49
|
rules: [],
|
|
@@ -620,6 +621,12 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
620
621
|
class_name: "CLASS2",
|
|
621
622
|
script_name: "SCRIPT2",
|
|
622
623
|
},
|
|
624
|
+
{
|
|
625
|
+
name: "DO_BINDING_3",
|
|
626
|
+
class_name: "CLASS3",
|
|
627
|
+
script_name: "SCRIPT3",
|
|
628
|
+
environment: "ENV3",
|
|
629
|
+
},
|
|
623
630
|
],
|
|
624
631
|
},
|
|
625
632
|
kv_namespaces: [
|
|
@@ -638,6 +645,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
638
645
|
preview_bucket_name: "R2_PREVIEW_2",
|
|
639
646
|
},
|
|
640
647
|
],
|
|
648
|
+
services: [
|
|
649
|
+
{
|
|
650
|
+
binding: "SERVICE_BINDING_1",
|
|
651
|
+
service: "SERVICE_TYPE_1",
|
|
652
|
+
environment: "SERVICE_BINDING_ENVIRONMENT_1",
|
|
653
|
+
},
|
|
654
|
+
],
|
|
641
655
|
unsafe: {
|
|
642
656
|
bindings: [
|
|
643
657
|
{ name: "UNSAFE_BINDING_1", type: "UNSAFE_TYPE_1" },
|
|
@@ -661,9 +675,10 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
661
675
|
);
|
|
662
676
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
663
677
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
678
|
+
"Processing wrangler configuration:
|
|
679
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
680
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
681
|
+
`);
|
|
667
682
|
});
|
|
668
683
|
|
|
669
684
|
it("should error on invalid environment values", () => {
|
|
@@ -717,8 +732,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
717
732
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
718
733
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
719
734
|
"Processing wrangler configuration:
|
|
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: [
|
|
735
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, custom_domain, zone_id | zone_name }, but got 888.
|
|
736
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, custom_domain, zone_id | zone_name }, but these weren't valid: [
|
|
722
737
|
666,
|
|
723
738
|
777,
|
|
724
739
|
{
|
|
@@ -1106,13 +1121,29 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1106
1121
|
durable_objects: {
|
|
1107
1122
|
bindings: [
|
|
1108
1123
|
{},
|
|
1109
|
-
{ name: "
|
|
1124
|
+
{ name: "MISSING_CLASS" },
|
|
1110
1125
|
{ name: 1555, class_name: 1666 },
|
|
1111
1126
|
{
|
|
1112
1127
|
name: 1777,
|
|
1113
1128
|
class_name: 1888,
|
|
1114
1129
|
script_name: 1999,
|
|
1115
1130
|
},
|
|
1131
|
+
{
|
|
1132
|
+
name: "SOMENAME",
|
|
1133
|
+
class_name: "SomeClass",
|
|
1134
|
+
environment: "staging",
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: 1778,
|
|
1138
|
+
class_name: 1889,
|
|
1139
|
+
script_name: 1992,
|
|
1140
|
+
environment: 2111,
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
name: 1772,
|
|
1144
|
+
class_name: 1883,
|
|
1145
|
+
environment: 2112,
|
|
1146
|
+
},
|
|
1116
1147
|
],
|
|
1117
1148
|
},
|
|
1118
1149
|
} as unknown as RawConfig,
|
|
@@ -1133,7 +1164,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1133
1164
|
- binding should have a string \\"name\\" field.
|
|
1134
1165
|
- binding should have a string \\"class_name\\" field.
|
|
1135
1166
|
|
|
1136
|
-
- \\"durable_objects.bindings[1]\\": {\\"name\\":\\"
|
|
1167
|
+
- \\"durable_objects.bindings[1]\\": {\\"name\\":\\"MISSING_CLASS\\"}
|
|
1137
1168
|
- binding should have a string \\"class_name\\" field.
|
|
1138
1169
|
|
|
1139
1170
|
- \\"durable_objects.bindings[2]\\": {\\"name\\":1555,\\"class_name\\":1666}
|
|
@@ -1143,7 +1174,22 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1143
1174
|
- \\"durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
|
|
1144
1175
|
- binding should have a string \\"name\\" field.
|
|
1145
1176
|
- binding should have a string \\"class_name\\" field.
|
|
1146
|
-
-
|
|
1177
|
+
- the field \\"script_name\\", when present, should be a string.
|
|
1178
|
+
|
|
1179
|
+
- \\"durable_objects.bindings[4]\\": {\\"name\\":\\"SOMENAME\\",\\"class_name\\":\\"SomeClass\\",\\"environment\\":\\"staging\\"}
|
|
1180
|
+
- binding should have a \\"script_name\\" field if \\"environment\\" is present.
|
|
1181
|
+
|
|
1182
|
+
- \\"durable_objects.bindings[5]\\": {\\"name\\":1778,\\"class_name\\":1889,\\"script_name\\":1992,\\"environment\\":2111}
|
|
1183
|
+
- binding should have a string \\"name\\" field.
|
|
1184
|
+
- binding should have a string \\"class_name\\" field.
|
|
1185
|
+
- the field \\"script_name\\", when present, should be a string.
|
|
1186
|
+
- the field \\"environment\\", when present, should be a string.
|
|
1187
|
+
|
|
1188
|
+
- \\"durable_objects.bindings[6]\\": {\\"name\\":1772,\\"class_name\\":1883,\\"environment\\":2112}
|
|
1189
|
+
- binding should have a string \\"name\\" field.
|
|
1190
|
+
- binding should have a string \\"class_name\\" field.
|
|
1191
|
+
- the field \\"environment\\", when present, should be a string.
|
|
1192
|
+
- binding should have a \\"script_name\\" field if \\"environment\\" is present."
|
|
1147
1193
|
`);
|
|
1148
1194
|
});
|
|
1149
1195
|
});
|
|
@@ -1358,6 +1404,151 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1358
1404
|
});
|
|
1359
1405
|
});
|
|
1360
1406
|
|
|
1407
|
+
describe("services field", () => {
|
|
1408
|
+
it("should error if services is an object", () => {
|
|
1409
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1410
|
+
{ services: {} } as unknown as RawConfig,
|
|
1411
|
+
undefined,
|
|
1412
|
+
{ env: undefined }
|
|
1413
|
+
);
|
|
1414
|
+
|
|
1415
|
+
expect(config).toEqual(
|
|
1416
|
+
expect.not.objectContaining({ services: expect.anything })
|
|
1417
|
+
);
|
|
1418
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1419
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1420
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1421
|
+
"Processing wrangler configuration:
|
|
1422
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
1423
|
+
`);
|
|
1424
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1425
|
+
"Processing wrangler configuration:
|
|
1426
|
+
- The field \\"services\\" should be an array but got {}."
|
|
1427
|
+
`);
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
it("should error if services is a string", () => {
|
|
1431
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1432
|
+
{ services: "BAD" } as unknown as RawConfig,
|
|
1433
|
+
undefined,
|
|
1434
|
+
{ env: undefined }
|
|
1435
|
+
);
|
|
1436
|
+
|
|
1437
|
+
expect(config).toEqual(
|
|
1438
|
+
expect.not.objectContaining({ services: expect.anything })
|
|
1439
|
+
);
|
|
1440
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1441
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1442
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1443
|
+
"Processing wrangler configuration:
|
|
1444
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
1445
|
+
`);
|
|
1446
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1447
|
+
"Processing wrangler configuration:
|
|
1448
|
+
- The field \\"services\\" should be an array but got \\"BAD\\"."
|
|
1449
|
+
`);
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
it("should error if services is a number", () => {
|
|
1453
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1454
|
+
{ services: 999 } as unknown as RawConfig,
|
|
1455
|
+
undefined,
|
|
1456
|
+
{ env: undefined }
|
|
1457
|
+
);
|
|
1458
|
+
|
|
1459
|
+
expect(config).toEqual(
|
|
1460
|
+
expect.not.objectContaining({ services: expect.anything })
|
|
1461
|
+
);
|
|
1462
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1463
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1464
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1465
|
+
"Processing wrangler configuration:
|
|
1466
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
1467
|
+
`);
|
|
1468
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1469
|
+
"Processing wrangler configuration:
|
|
1470
|
+
- The field \\"services\\" should be an array but got 999."
|
|
1471
|
+
`);
|
|
1472
|
+
});
|
|
1473
|
+
|
|
1474
|
+
it("should error if services is null", () => {
|
|
1475
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1476
|
+
{ services: null } as unknown as RawConfig,
|
|
1477
|
+
undefined,
|
|
1478
|
+
{ env: undefined }
|
|
1479
|
+
);
|
|
1480
|
+
|
|
1481
|
+
expect(config).toEqual(
|
|
1482
|
+
expect.not.objectContaining({ services: expect.anything })
|
|
1483
|
+
);
|
|
1484
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1485
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1486
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1487
|
+
"Processing wrangler configuration:
|
|
1488
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
1489
|
+
`);
|
|
1490
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1491
|
+
"Processing wrangler configuration:
|
|
1492
|
+
- The field \\"services\\" should be an array but got null."
|
|
1493
|
+
`);
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
it("should error if services bindings are not valid", () => {
|
|
1497
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1498
|
+
{
|
|
1499
|
+
services: [
|
|
1500
|
+
{},
|
|
1501
|
+
{ binding: "SERVICE_BINDING_1" },
|
|
1502
|
+
{ binding: 123, service: 456 },
|
|
1503
|
+
{ binding: 123, service: 456, environment: 789 },
|
|
1504
|
+
{ binding: "SERVICE_BINDING_1", service: 456, environment: 789 },
|
|
1505
|
+
{
|
|
1506
|
+
binding: 123,
|
|
1507
|
+
service: "SERVICE_BINDING_SERVICE_1",
|
|
1508
|
+
environment: 789,
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
binding: 123,
|
|
1512
|
+
service: 456,
|
|
1513
|
+
environment: "SERVICE_BINDING_ENVIRONMENT_1",
|
|
1514
|
+
},
|
|
1515
|
+
],
|
|
1516
|
+
} as unknown as RawConfig,
|
|
1517
|
+
undefined,
|
|
1518
|
+
{ env: undefined }
|
|
1519
|
+
);
|
|
1520
|
+
|
|
1521
|
+
expect(config).toEqual(
|
|
1522
|
+
expect.not.objectContaining({
|
|
1523
|
+
services: { bindings: expect.anything },
|
|
1524
|
+
})
|
|
1525
|
+
);
|
|
1526
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1527
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1528
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1529
|
+
"Processing wrangler configuration:
|
|
1530
|
+
- \\"services\\" fields are experimental and may change or break at any time."
|
|
1531
|
+
`);
|
|
1532
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1533
|
+
"Processing wrangler configuration:
|
|
1534
|
+
- \\"services[0]\\" bindings should have a string \\"binding\\" field but got {}.
|
|
1535
|
+
- \\"services[0]\\" bindings should have a string \\"service\\" field but got {}.
|
|
1536
|
+
- \\"services[1]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\"}.
|
|
1537
|
+
- \\"services[2]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456}.
|
|
1538
|
+
- \\"services[2]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456}.
|
|
1539
|
+
- \\"services[3]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
|
|
1540
|
+
- \\"services[3]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
|
|
1541
|
+
- \\"services[3]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
|
|
1542
|
+
- \\"services[4]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\",\\"service\\":456,\\"environment\\":789}.
|
|
1543
|
+
- \\"services[4]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\",\\"service\\":456,\\"environment\\":789}.
|
|
1544
|
+
- \\"services[5]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":\\"SERVICE_BINDING_SERVICE_1\\",\\"environment\\":789}.
|
|
1545
|
+
- \\"services[5]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":123,\\"service\\":\\"SERVICE_BINDING_SERVICE_1\\",\\"environment\\":789}.
|
|
1546
|
+
- \\"services[6]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":\\"SERVICE_BINDING_ENVIRONMENT_1\\"}.
|
|
1547
|
+
- \\"services[6]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":\\"SERVICE_BINDING_ENVIRONMENT_1\\"}."
|
|
1548
|
+
`);
|
|
1549
|
+
});
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1361
1552
|
describe("unsafe field", () => {
|
|
1362
1553
|
it("should error if unsafe is an array", () => {
|
|
1363
1554
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1622,14 +1813,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1622
1813
|
- [1mDeprecation[0m: \\"zone_id\\":
|
|
1623
1814
|
This is unnecessary since we can deduce this from routes directly.
|
|
1624
1815
|
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
1625
|
-
The \\"experimental_services\\" field is no longer supported.
|
|
1626
|
-
\`\`\`
|
|
1627
|
-
[[unsafe.bindings]]
|
|
1628
|
-
name = \\"mock-name\\"
|
|
1629
|
-
type = \\"service\\"
|
|
1630
|
-
service = \\"SERVICE\\"
|
|
1631
|
-
environment = \\"ENV\\"
|
|
1632
|
-
\`\`\`"
|
|
1816
|
+
The \\"experimental_services\\" field is no longer supported. Simply rename the [experimental_services] field to [services]."
|
|
1633
1817
|
`);
|
|
1634
1818
|
});
|
|
1635
1819
|
});
|
|
@@ -2045,8 +2229,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2045
2229
|
"Processing wrangler configuration:
|
|
2046
2230
|
|
|
2047
2231
|
- \\"env.ENV1\\" environment configuration
|
|
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: [
|
|
2232
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, custom_domain, zone_id | zone_name }, but got 888.
|
|
2233
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, custom_domain, zone_id | zone_name }, but these weren't valid: [
|
|
2050
2234
|
666,
|
|
2051
2235
|
777
|
|
2052
2236
|
].
|
|
@@ -2304,7 +2488,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2304
2488
|
- \\"env.ENV1.durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
|
|
2305
2489
|
- binding should have a string \\"name\\" field.
|
|
2306
2490
|
- binding should have a string \\"class_name\\" field.
|
|
2307
|
-
-
|
|
2491
|
+
- the field \\"script_name\\", when present, should be a string."
|
|
2308
2492
|
`);
|
|
2309
2493
|
});
|
|
2310
2494
|
});
|
|
@@ -2869,14 +3053,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2869
3053
|
- [1mDeprecation[0m: \\"zone_id\\":
|
|
2870
3054
|
This is unnecessary since we can deduce this from routes directly.
|
|
2871
3055
|
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
2872
|
-
The \\"experimental_services\\" field is no longer supported.
|
|
2873
|
-
\`\`\`
|
|
2874
|
-
[[unsafe.bindings]]
|
|
2875
|
-
name = \\"mock-name\\"
|
|
2876
|
-
type = \\"service\\"
|
|
2877
|
-
service = \\"SERVICE\\"
|
|
2878
|
-
environment = \\"ENV\\"
|
|
2879
|
-
\`\`\`"
|
|
3056
|
+
The \\"experimental_services\\" field is no longer supported. Simply rename the [experimental_services] field to [services]."
|
|
2880
3057
|
`);
|
|
2881
3058
|
});
|
|
2882
3059
|
});
|
|
@@ -225,6 +225,32 @@ describe("wrangler dev", () => {
|
|
|
225
225
|
);
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
it("should strip leading `*` from given host when deducing a zone id", async () => {
|
|
229
|
+
writeWranglerToml({
|
|
230
|
+
main: "index.js",
|
|
231
|
+
route: "*some-host.com/some/path/*",
|
|
232
|
+
});
|
|
233
|
+
fs.writeFileSync("index.js", `export default {};`);
|
|
234
|
+
mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
|
|
235
|
+
await runWrangler("dev");
|
|
236
|
+
expect((Dev as jest.Mock).mock.calls[0][0].zone.host).toEqual(
|
|
237
|
+
"some-host.com"
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should strip leading `*.` from given host when deducing a zone id", async () => {
|
|
242
|
+
writeWranglerToml({
|
|
243
|
+
main: "index.js",
|
|
244
|
+
route: "*.some-host.com/some/path/*",
|
|
245
|
+
});
|
|
246
|
+
fs.writeFileSync("index.js", `export default {};`);
|
|
247
|
+
mockGetZones("some-host.com", [{ id: "some-zone-id" }]);
|
|
248
|
+
await runWrangler("dev");
|
|
249
|
+
expect((Dev as jest.Mock).mock.calls[0][0].zone.host).toEqual(
|
|
250
|
+
"some-host.com"
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
|
|
228
254
|
it("should, when provided, use a configured zone_id", async () => {
|
|
229
255
|
writeWranglerToml({
|
|
230
256
|
main: "index.js",
|
|
@@ -748,7 +774,11 @@ describe("wrangler dev", () => {
|
|
|
748
774
|
expect(std).toMatchInlineSnapshot(`
|
|
749
775
|
Object {
|
|
750
776
|
"debug": "",
|
|
751
|
-
"err": "
|
|
777
|
+
"err": "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough arguments following: site[0m
|
|
778
|
+
|
|
779
|
+
",
|
|
780
|
+
"out": "
|
|
781
|
+
wrangler dev [script]
|
|
752
782
|
|
|
753
783
|
👂 Start a local server for developing your worker
|
|
754
784
|
|
|
@@ -785,12 +815,7 @@ describe("wrangler dev", () => {
|
|
|
785
815
|
--minify Minify the script [boolean]
|
|
786
816
|
--node-compat Enable node.js compatibility [boolean]
|
|
787
817
|
--experimental-enable-local-persistence Enable persistence for this session (only for local mode) [boolean]
|
|
788
|
-
--inspect Enable dev tools [deprecated] [boolean]
|
|
789
|
-
[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough arguments following: site[0m
|
|
790
|
-
|
|
791
|
-
",
|
|
792
|
-
"out": "
|
|
793
|
-
",
|
|
818
|
+
--inspect Enable dev tools [deprecated] [boolean]",
|
|
794
819
|
"warn": "",
|
|
795
820
|
}
|
|
796
821
|
`);
|
|
@@ -813,6 +838,34 @@ describe("wrangler dev", () => {
|
|
|
813
838
|
`);
|
|
814
839
|
});
|
|
815
840
|
});
|
|
841
|
+
|
|
842
|
+
describe("service bindings", () => {
|
|
843
|
+
it("should warn when using service bindings", async () => {
|
|
844
|
+
writeWranglerToml({
|
|
845
|
+
services: [
|
|
846
|
+
{ binding: "WorkerA", service: "A" },
|
|
847
|
+
{ binding: "WorkerB", service: "B", environment: "staging" },
|
|
848
|
+
],
|
|
849
|
+
});
|
|
850
|
+
fs.writeFileSync("index.js", `export default {};`);
|
|
851
|
+
await runWrangler("dev index.js");
|
|
852
|
+
expect(std).toMatchInlineSnapshot(`
|
|
853
|
+
Object {
|
|
854
|
+
"debug": "",
|
|
855
|
+
"err": "",
|
|
856
|
+
"out": "",
|
|
857
|
+
"warn": "[33mâ–² [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
858
|
+
|
|
859
|
+
- \\"services\\" fields are experimental and may change or break at any time.
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
[33mâ–² [43;33m[[43;30mWARNING[43;33m][0m [1mThis worker is bound to live services: WorkerA (A), WorkerB (B@staging)[0m
|
|
863
|
+
|
|
864
|
+
",
|
|
865
|
+
}
|
|
866
|
+
`);
|
|
867
|
+
});
|
|
868
|
+
});
|
|
816
869
|
});
|
|
817
870
|
|
|
818
871
|
function mockGetZones(domain: string, zones: { id: string }[] = []) {
|
|
@@ -63,10 +63,7 @@ describe("wrangler", () => {
|
|
|
63
63
|
|
|
64
64
|
expect(std.out).toMatchInlineSnapshot(`
|
|
65
65
|
"
|
|
66
|
-
|
|
67
|
-
`);
|
|
68
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
69
|
-
"wrangler
|
|
66
|
+
wrangler
|
|
70
67
|
|
|
71
68
|
Commands:
|
|
72
69
|
wrangler init [name] 📥 Create a wrangler.toml configuration file
|
|
@@ -86,8 +83,10 @@ describe("wrangler", () => {
|
|
|
86
83
|
Flags:
|
|
87
84
|
-c, --config Path to .toml configuration file [string]
|
|
88
85
|
-h, --help Show help [boolean]
|
|
89
|
-
-v, --version Show version number [boolean]
|
|
90
|
-
|
|
86
|
+
-v, --version Show version number [boolean]"
|
|
87
|
+
`);
|
|
88
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
89
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown argument: invalid-command[0m
|
|
91
90
|
|
|
92
91
|
"
|
|
93
92
|
`);
|