wrangler 0.0.0-e6e1daba → 0.0.0-e7cf0caa
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/bin/wrangler.js +1 -1
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +14 -9
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +294 -18
- package/src/__tests__/d1/execute.test.ts +3 -1
- package/src/__tests__/d1/migrate.test.ts +2 -0
- package/src/__tests__/delete.test.ts +6 -0
- package/src/__tests__/deployments.test.ts +335 -95
- package/src/__tests__/dev.test.tsx +87 -57
- package/src/__tests__/generate.test.ts +3 -4
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
- package/src/__tests__/helpers/msw/index.ts +4 -2
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +10 -4
- package/src/__tests__/init.test.ts +136 -104
- package/src/__tests__/jest.setup.ts +4 -0
- package/src/__tests__/kv.test.ts +9 -9
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/middleware.scheduled.test.ts +2 -2
- package/src/__tests__/middleware.test.ts +4 -3
- package/src/__tests__/mtls-certificates.test.ts +5 -2
- package/src/__tests__/pages/deployment-list.test.ts +2 -0
- package/src/__tests__/pages/functions-build.test.ts +91 -41
- package/src/__tests__/pages/project-list.test.ts +2 -0
- package/src/__tests__/pages/project-upload.test.ts +43 -24
- package/src/__tests__/pages/publish.test.ts +267 -148
- package/src/__tests__/publish.test.ts +420 -164
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/queues.test.ts +5 -2
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/type-generation.test.ts +1 -0
- package/src/__tests__/user.test.ts +1 -1
- package/src/__tests__/worker-namespace.test.ts +1 -0
- package/src/api/dev.ts +10 -22
- package/src/api/pages/create-worker-bundle-contents.ts +1 -0
- package/src/api/pages/publish.tsx +38 -51
- package/src/bundle.ts +44 -13
- package/src/config/environment.ts +36 -4
- package/src/config/index.ts +30 -2
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +149 -5
- package/src/create-worker-upload-form.ts +28 -3
- package/src/d1/backups.tsx +15 -11
- package/src/d1/create.tsx +20 -16
- package/src/d1/execute.tsx +22 -19
- package/src/d1/list.tsx +2 -2
- package/src/d1/migrations/apply.tsx +35 -29
- package/src/d1/migrations/create.tsx +15 -12
- package/src/d1/migrations/list.tsx +10 -7
- package/src/deployments.ts +260 -8
- package/src/dev/dev.tsx +4 -4
- package/src/dev/local.tsx +14 -16
- package/src/dev/start-server.ts +12 -16
- package/src/dev/use-esbuild.ts +11 -13
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/dev-registry.ts +2 -1
- package/src/dev.tsx +28 -13
- package/src/entry.ts +18 -8
- package/src/generate/index.ts +2 -2
- package/src/index.ts +76 -23
- package/src/init.ts +144 -134
- package/src/logger.ts +18 -3
- package/src/metrics/send-event.ts +2 -1
- package/src/miniflare-cli/index.ts +1 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/module-collection.ts +91 -25
- package/src/pages/build.ts +277 -99
- package/src/pages/buildFunctions.ts +20 -10
- package/src/pages/deployments.tsx +3 -5
- package/src/pages/dev.ts +21 -21
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +57 -34
- package/src/pages/functions/buildWorker.ts +34 -31
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/projects.tsx +2 -5
- package/src/pages/publish.tsx +1 -10
- package/src/pages/upload.tsx +29 -9
- package/src/paths.ts +1 -1
- package/src/publish/index.ts +1 -1
- package/src/publish/publish.ts +29 -34
- package/src/queues/cli/commands/consumer/add.ts +6 -0
- package/src/queues/client.ts +1 -0
- package/src/secret/index.ts +2 -1
- package/src/traverse-module-graph.ts +53 -0
- package/src/type-generation.ts +1 -1
- package/src/user/user.ts +1 -1
- package/src/utils/render.ts +93 -0
- package/src/worker.ts +18 -1
- package/templates/d1-beta-facade.js +5 -2
- package/templates/gitignore +1 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +17 -5
- package/templates/tsconfig.init.json +1 -2
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +33 -13
- package/wrangler-dist/cli.js +20732 -19984
- package/src/__tests__/api-devregistry.test.js +0 -64
|
@@ -40,6 +40,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
40
40
|
jsx_fragment: "React.Fragment",
|
|
41
41
|
tsconfig: undefined,
|
|
42
42
|
kv_namespaces: [],
|
|
43
|
+
send_email: [],
|
|
43
44
|
legacy_env: true,
|
|
44
45
|
logfwdr: {
|
|
45
46
|
bindings: [],
|
|
@@ -65,7 +66,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
65
66
|
crons: [],
|
|
66
67
|
},
|
|
67
68
|
unsafe: {
|
|
68
|
-
bindings:
|
|
69
|
+
bindings: undefined,
|
|
70
|
+
metadata: undefined,
|
|
69
71
|
},
|
|
70
72
|
dispatch_namespaces: [],
|
|
71
73
|
mtls_certificates: [],
|
|
@@ -902,6 +904,17 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
902
904
|
preview_id: "KV_PREVIEW_1",
|
|
903
905
|
},
|
|
904
906
|
],
|
|
907
|
+
send_email: [
|
|
908
|
+
{ name: "SEB_TARGET", destination_address: "teste@example.com" },
|
|
909
|
+
{ name: "SEB_UNRESTRICTED" },
|
|
910
|
+
{
|
|
911
|
+
name: "SEB_ALLOWLIST",
|
|
912
|
+
allowed_destination_addresses: [
|
|
913
|
+
"email1@example.com",
|
|
914
|
+
"email2@example.com",
|
|
915
|
+
],
|
|
916
|
+
},
|
|
917
|
+
],
|
|
905
918
|
r2_buckets: [
|
|
906
919
|
{ binding: "R2_BINDING_1", bucket_name: "R2_BUCKET_1" },
|
|
907
920
|
{
|
|
@@ -935,6 +948,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
935
948
|
extra: "UNSAFE_EXTRA_1",
|
|
936
949
|
},
|
|
937
950
|
],
|
|
951
|
+
metadata: undefined,
|
|
938
952
|
},
|
|
939
953
|
no_bundle: true,
|
|
940
954
|
minify: true,
|
|
@@ -1627,6 +1641,39 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1627
1641
|
});
|
|
1628
1642
|
});
|
|
1629
1643
|
|
|
1644
|
+
it("should error if send_email.bindings are not valid", () => {
|
|
1645
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
1646
|
+
{
|
|
1647
|
+
send_email: [
|
|
1648
|
+
{},
|
|
1649
|
+
{ binding: "VALID" },
|
|
1650
|
+
{ name: "SEB", destination_address: 123 },
|
|
1651
|
+
{
|
|
1652
|
+
name: "SEB2",
|
|
1653
|
+
allowed_destination_addresses: 123,
|
|
1654
|
+
},
|
|
1655
|
+
{
|
|
1656
|
+
name: "SEB3",
|
|
1657
|
+
destination_address: "email@example.com",
|
|
1658
|
+
allowed_destination_addresses: ["email@example.com"],
|
|
1659
|
+
},
|
|
1660
|
+
],
|
|
1661
|
+
} as unknown as RawConfig,
|
|
1662
|
+
undefined,
|
|
1663
|
+
{ env: undefined }
|
|
1664
|
+
);
|
|
1665
|
+
|
|
1666
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1667
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1668
|
+
"Processing wrangler configuration:
|
|
1669
|
+
- \\"send_email[0]\\" bindings should have a string \\"name\\" field but got {}.
|
|
1670
|
+
- \\"send_email[1]\\" bindings should have a string \\"name\\" field but got {\\"binding\\":\\"VALID\\"}.
|
|
1671
|
+
- \\"send_email[2]\\" bindings should, optionally, have a string \\"destination_address\\" field but got {\\"name\\":\\"SEB\\",\\"destination_address\\":123}.
|
|
1672
|
+
- \\"send_email[3]\\" bindings should, optionally, have a []string \\"allowed_destination_addresses\\" field but got {\\"name\\":\\"SEB2\\",\\"allowed_destination_addresses\\":123}.
|
|
1673
|
+
- \\"send_email[4]\\" bindings should have either a \\"destination_address\\" or \\"allowed_destination_addresses\\" field, but not both."
|
|
1674
|
+
`);
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1630
1677
|
describe("[d1_databases]", () => {
|
|
1631
1678
|
it("should error if d1_databases is an object", () => {
|
|
1632
1679
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1789,6 +1836,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1789
1836
|
max_batch_timeout: null,
|
|
1790
1837
|
max_retries: "hello",
|
|
1791
1838
|
dead_letter_queue: 5,
|
|
1839
|
+
max_concurrency: "hello",
|
|
1792
1840
|
},
|
|
1793
1841
|
],
|
|
1794
1842
|
},
|
|
@@ -1804,20 +1852,21 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1804
1852
|
);
|
|
1805
1853
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1806
1854
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1855
|
+
"Processing wrangler configuration:
|
|
1856
|
+
- Unexpected fields found in queues field: \\"invalidField\\"
|
|
1857
|
+
- Unexpected fields found in queues.consumers[2] field: \\"invalidField\\""
|
|
1858
|
+
`);
|
|
1811
1859
|
|
|
1812
1860
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1861
|
+
"Processing wrangler configuration:
|
|
1862
|
+
- \\"queues.consumers[0]\\" should have a string \\"queue\\" field but got {}.
|
|
1863
|
+
- \\"queues.consumers[1]\\" should have a string \\"queue\\" field but got {\\"queue\\":22}.
|
|
1864
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_batch_size\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1865
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_batch_timeout\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1866
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_retries\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1867
|
+
- \\"queues.consumers[3]\\" should, optionally, have a string \\"dead_letter_queue\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}.
|
|
1868
|
+
- \\"queues.consumers[3]\\" should, optionally, have a number \\"max_concurrency\\" field but got {\\"queue\\":\\"myQueue\\",\\"max_batch_size\\":\\"3\\",\\"max_batch_timeout\\":null,\\"max_retries\\":\\"hello\\",\\"dead_letter_queue\\":5,\\"max_concurrency\\":\\"hello\\"}."
|
|
1869
|
+
`);
|
|
1821
1870
|
});
|
|
1822
1871
|
});
|
|
1823
1872
|
|
|
@@ -2329,7 +2378,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2329
2378
|
`);
|
|
2330
2379
|
});
|
|
2331
2380
|
|
|
2332
|
-
it("should error if unsafe.bindings
|
|
2381
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
2333
2382
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
2334
2383
|
{ unsafe: {} } as unknown as RawConfig,
|
|
2335
2384
|
undefined,
|
|
@@ -2341,9 +2390,37 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2341
2390
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2342
2391
|
`);
|
|
2343
2392
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2393
|
+
"Processing wrangler configuration:
|
|
2394
|
+
- The field \\"unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
2395
|
+
`);
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2398
|
+
it("should not error if at least unsafe.bindings is defined", () => {
|
|
2399
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2400
|
+
{ unsafe: { bindings: [] } } as unknown as RawConfig,
|
|
2401
|
+
undefined,
|
|
2402
|
+
{ env: undefined }
|
|
2403
|
+
);
|
|
2404
|
+
|
|
2405
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2406
|
+
"Processing wrangler configuration:
|
|
2407
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2408
|
+
`);
|
|
2409
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2410
|
+
});
|
|
2411
|
+
|
|
2412
|
+
it("should not error if at least unsafe.metadata is defined", () => {
|
|
2413
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2414
|
+
{ unsafe: { metadata: {} } } as unknown as RawConfig,
|
|
2415
|
+
undefined,
|
|
2416
|
+
{ env: undefined }
|
|
2417
|
+
);
|
|
2418
|
+
|
|
2419
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2344
2420
|
"Processing wrangler configuration:
|
|
2345
|
-
-
|
|
2421
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2346
2422
|
`);
|
|
2423
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2347
2424
|
});
|
|
2348
2425
|
|
|
2349
2426
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -2453,6 +2530,74 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2453
2530
|
- binding should have a string \\"type\\" field."
|
|
2454
2531
|
`);
|
|
2455
2532
|
});
|
|
2533
|
+
|
|
2534
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
2535
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2536
|
+
{ unsafe: { metadata: [] } } as unknown as RawConfig,
|
|
2537
|
+
undefined,
|
|
2538
|
+
{ env: undefined }
|
|
2539
|
+
);
|
|
2540
|
+
|
|
2541
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2542
|
+
"Processing wrangler configuration:
|
|
2543
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2544
|
+
`);
|
|
2545
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2546
|
+
"Processing wrangler configuration:
|
|
2547
|
+
- The field \\"unsafe.metadata\\" should be an object but got []."
|
|
2548
|
+
`);
|
|
2549
|
+
});
|
|
2550
|
+
|
|
2551
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
2552
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2553
|
+
{ unsafe: { metadata: "BAD" } } as unknown as RawConfig,
|
|
2554
|
+
undefined,
|
|
2555
|
+
{ env: undefined }
|
|
2556
|
+
);
|
|
2557
|
+
|
|
2558
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2559
|
+
"Processing wrangler configuration:
|
|
2560
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2561
|
+
`);
|
|
2562
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2563
|
+
"Processing wrangler configuration:
|
|
2564
|
+
- The field \\"unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
2565
|
+
`);
|
|
2566
|
+
});
|
|
2567
|
+
|
|
2568
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
2569
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2570
|
+
{ unsafe: { metadata: 999 } } as unknown as RawConfig,
|
|
2571
|
+
undefined,
|
|
2572
|
+
{ env: undefined }
|
|
2573
|
+
);
|
|
2574
|
+
|
|
2575
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2576
|
+
"Processing wrangler configuration:
|
|
2577
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2578
|
+
`);
|
|
2579
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2580
|
+
"Processing wrangler configuration:
|
|
2581
|
+
- The field \\"unsafe.metadata\\" should be an object but got 999."
|
|
2582
|
+
`);
|
|
2583
|
+
});
|
|
2584
|
+
|
|
2585
|
+
it("should error if unsafe.metadata is null", () => {
|
|
2586
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2587
|
+
{ unsafe: { metadata: null } } as unknown as RawConfig,
|
|
2588
|
+
undefined,
|
|
2589
|
+
{ env: undefined }
|
|
2590
|
+
);
|
|
2591
|
+
|
|
2592
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2593
|
+
"Processing wrangler configuration:
|
|
2594
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2595
|
+
`);
|
|
2596
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2597
|
+
"Processing wrangler configuration:
|
|
2598
|
+
- The field \\"unsafe.metadata\\" should be an object but got null."
|
|
2599
|
+
`);
|
|
2600
|
+
});
|
|
2456
2601
|
});
|
|
2457
2602
|
|
|
2458
2603
|
describe("(deprecated)", () => {
|
|
@@ -2836,7 +2981,10 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2836
2981
|
const r2_buckets: RawConfig["r2_buckets"] = [];
|
|
2837
2982
|
const analytics_engine_datasets: RawConfig["analytics_engine_datasets"] =
|
|
2838
2983
|
[];
|
|
2839
|
-
const unsafe: RawConfig["unsafe"] = {
|
|
2984
|
+
const unsafe: RawConfig["unsafe"] = {
|
|
2985
|
+
bindings: undefined,
|
|
2986
|
+
metadata: undefined,
|
|
2987
|
+
};
|
|
2840
2988
|
const rawConfig: RawConfig = {
|
|
2841
2989
|
define,
|
|
2842
2990
|
vars,
|
|
@@ -3784,7 +3932,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3784
3932
|
`);
|
|
3785
3933
|
});
|
|
3786
3934
|
|
|
3787
|
-
it("should error if unsafe.bindings
|
|
3935
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
3788
3936
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
3789
3937
|
{ env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
|
|
3790
3938
|
undefined,
|
|
@@ -3798,11 +3946,47 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3798
3946
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3799
3947
|
`);
|
|
3800
3948
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3949
|
+
"Processing wrangler configuration:
|
|
3950
|
+
|
|
3951
|
+
- \\"env.ENV1\\" environment configuration
|
|
3952
|
+
- The field \\"env.ENV1.unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
3953
|
+
`);
|
|
3954
|
+
});
|
|
3955
|
+
|
|
3956
|
+
it("should not error if at least unsafe.bindings is undefined", () => {
|
|
3957
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3958
|
+
{
|
|
3959
|
+
env: { ENV1: { unsafe: { bindings: [] } } },
|
|
3960
|
+
} as unknown as RawConfig,
|
|
3961
|
+
undefined,
|
|
3962
|
+
{ env: "ENV1" }
|
|
3963
|
+
);
|
|
3964
|
+
|
|
3965
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3801
3966
|
"Processing wrangler configuration:
|
|
3802
3967
|
|
|
3803
3968
|
- \\"env.ENV1\\" environment configuration
|
|
3804
|
-
-
|
|
3969
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3805
3970
|
`);
|
|
3971
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3972
|
+
});
|
|
3973
|
+
|
|
3974
|
+
it("should not error if at least unsafe.metadata is undefined", () => {
|
|
3975
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3976
|
+
{
|
|
3977
|
+
env: { ENV1: { unsafe: { metadata: {} } } },
|
|
3978
|
+
} as unknown as RawConfig,
|
|
3979
|
+
undefined,
|
|
3980
|
+
{ env: "ENV1" }
|
|
3981
|
+
);
|
|
3982
|
+
|
|
3983
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3984
|
+
"Processing wrangler configuration:
|
|
3985
|
+
|
|
3986
|
+
- \\"env.ENV1\\" environment configuration
|
|
3987
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3988
|
+
`);
|
|
3989
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3806
3990
|
});
|
|
3807
3991
|
|
|
3808
3992
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -3944,6 +4128,98 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3944
4128
|
- binding should have a string \\"type\\" field."
|
|
3945
4129
|
`);
|
|
3946
4130
|
});
|
|
4131
|
+
|
|
4132
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
4133
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4134
|
+
{
|
|
4135
|
+
env: { ENV1: { unsafe: { metadata: [] } } },
|
|
4136
|
+
} as unknown as RawConfig,
|
|
4137
|
+
undefined,
|
|
4138
|
+
{ env: "ENV1" }
|
|
4139
|
+
);
|
|
4140
|
+
|
|
4141
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4142
|
+
"Processing wrangler configuration:
|
|
4143
|
+
|
|
4144
|
+
- \\"env.ENV1\\" environment configuration
|
|
4145
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4146
|
+
`);
|
|
4147
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4148
|
+
"Processing wrangler configuration:
|
|
4149
|
+
|
|
4150
|
+
- \\"env.ENV1\\" environment configuration
|
|
4151
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got []."
|
|
4152
|
+
`);
|
|
4153
|
+
});
|
|
4154
|
+
|
|
4155
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
4156
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4157
|
+
{
|
|
4158
|
+
env: { ENV1: { unsafe: { metadata: "BAD" } } },
|
|
4159
|
+
} as unknown as RawConfig,
|
|
4160
|
+
undefined,
|
|
4161
|
+
{ env: "ENV1" }
|
|
4162
|
+
);
|
|
4163
|
+
|
|
4164
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4165
|
+
"Processing wrangler configuration:
|
|
4166
|
+
|
|
4167
|
+
- \\"env.ENV1\\" environment configuration
|
|
4168
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4169
|
+
`);
|
|
4170
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4171
|
+
"Processing wrangler configuration:
|
|
4172
|
+
|
|
4173
|
+
- \\"env.ENV1\\" environment configuration
|
|
4174
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
4175
|
+
`);
|
|
4176
|
+
});
|
|
4177
|
+
|
|
4178
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
4179
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4180
|
+
{
|
|
4181
|
+
env: { ENV1: { unsafe: { metadata: 999 } } },
|
|
4182
|
+
} as unknown as RawConfig,
|
|
4183
|
+
undefined,
|
|
4184
|
+
{ env: "ENV1" }
|
|
4185
|
+
);
|
|
4186
|
+
|
|
4187
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4188
|
+
"Processing wrangler configuration:
|
|
4189
|
+
|
|
4190
|
+
- \\"env.ENV1\\" environment configuration
|
|
4191
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4192
|
+
`);
|
|
4193
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4194
|
+
"Processing wrangler configuration:
|
|
4195
|
+
|
|
4196
|
+
- \\"env.ENV1\\" environment configuration
|
|
4197
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got 999."
|
|
4198
|
+
`);
|
|
4199
|
+
});
|
|
4200
|
+
|
|
4201
|
+
it("should error if unsafe.metadata is null", () => {
|
|
4202
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4203
|
+
{
|
|
4204
|
+
env: { ENV1: { unsafe: { metadata: null } } },
|
|
4205
|
+
} as unknown as RawConfig,
|
|
4206
|
+
undefined,
|
|
4207
|
+
{ env: "ENV1" }
|
|
4208
|
+
);
|
|
4209
|
+
|
|
4210
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4211
|
+
"Processing wrangler configuration:
|
|
4212
|
+
|
|
4213
|
+
- \\"env.ENV1\\" environment configuration
|
|
4214
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4215
|
+
`);
|
|
4216
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4217
|
+
"Processing wrangler configuration:
|
|
4218
|
+
|
|
4219
|
+
- \\"env.ENV1\\" environment configuration
|
|
4220
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got null."
|
|
4221
|
+
`);
|
|
4222
|
+
});
|
|
3947
4223
|
});
|
|
3948
4224
|
|
|
3949
4225
|
describe("(deprecated)", () => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
1
2
|
import { useMockIsTTY } from "../helpers/mock-istty";
|
|
2
3
|
import { runInTempDir } from "../helpers/run-in-tmp";
|
|
3
4
|
import { runWrangler } from "../helpers/run-wrangler";
|
|
4
5
|
import writeWranglerToml from "../helpers/write-wrangler-toml";
|
|
5
6
|
|
|
6
7
|
describe("execute", () => {
|
|
8
|
+
mockConsoleMethods();
|
|
7
9
|
runInTempDir();
|
|
8
10
|
const { setIsTTY } = useMockIsTTY();
|
|
9
11
|
|
|
@@ -18,7 +20,7 @@ describe("execute", () => {
|
|
|
18
20
|
await expect(
|
|
19
21
|
runWrangler("d1 execute --command 'select 1;'")
|
|
20
22
|
).rejects.toThrowError(
|
|
21
|
-
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/api/
|
|
23
|
+
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.`
|
|
22
24
|
);
|
|
23
25
|
});
|
|
24
26
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cwd } from "process";
|
|
2
2
|
import { reinitialiseAuthTokens } from "../../user";
|
|
3
3
|
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id";
|
|
4
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
4
5
|
import { useMockIsTTY } from "../helpers/mock-istty";
|
|
5
6
|
import { runInTempDir } from "../helpers/run-in-tmp";
|
|
6
7
|
import { runWrangler } from "../helpers/run-wrangler";
|
|
@@ -8,6 +9,7 @@ import writeWranglerToml from "../helpers/write-wrangler-toml";
|
|
|
8
9
|
|
|
9
10
|
describe("migrate", () => {
|
|
10
11
|
runInTempDir();
|
|
12
|
+
mockConsoleMethods();
|
|
11
13
|
const { setIsTTY } = useMockIsTTY();
|
|
12
14
|
|
|
13
15
|
describe("create", () => {
|
|
@@ -31,6 +31,7 @@ describe("delete", () => {
|
|
|
31
31
|
Object {
|
|
32
32
|
"debug": "",
|
|
33
33
|
"err": "",
|
|
34
|
+
"info": "",
|
|
34
35
|
"out": "Successfully deleted my-script",
|
|
35
36
|
"warn": "",
|
|
36
37
|
}
|
|
@@ -51,6 +52,7 @@ describe("delete", () => {
|
|
|
51
52
|
Object {
|
|
52
53
|
"debug": "",
|
|
53
54
|
"err": "",
|
|
55
|
+
"info": "",
|
|
54
56
|
"out": "Successfully deleted test-name",
|
|
55
57
|
"warn": "",
|
|
56
58
|
}
|
|
@@ -64,6 +66,7 @@ describe("delete", () => {
|
|
|
64
66
|
Object {
|
|
65
67
|
"debug": "",
|
|
66
68
|
"err": "",
|
|
69
|
+
"info": "",
|
|
67
70
|
"out": "--dry-run: exiting now.",
|
|
68
71
|
"warn": "",
|
|
69
72
|
}
|
|
@@ -82,6 +85,7 @@ describe("delete", () => {
|
|
|
82
85
|
Object {
|
|
83
86
|
"debug": "",
|
|
84
87
|
"err": "",
|
|
88
|
+
"info": "",
|
|
85
89
|
"out": "",
|
|
86
90
|
"warn": "",
|
|
87
91
|
}
|
|
@@ -126,6 +130,7 @@ describe("delete", () => {
|
|
|
126
130
|
Object {
|
|
127
131
|
"debug": "",
|
|
128
132
|
"err": "",
|
|
133
|
+
"info": "",
|
|
129
134
|
"out": "🌀 Deleted asset namespace for Workers Site \\"__my-script-workers_sites_assets\\"
|
|
130
135
|
Successfully deleted my-script",
|
|
131
136
|
"warn": "",
|
|
@@ -202,6 +207,7 @@ describe("delete", () => {
|
|
|
202
207
|
Object {
|
|
203
208
|
"debug": "",
|
|
204
209
|
"err": "",
|
|
210
|
+
"info": "",
|
|
205
211
|
"out": "🌀 Deleted asset namespace for Workers Site \\"__my-script-workers_sites_assets\\"
|
|
206
212
|
🌀 Deleted asset namespace for Workers Site \\"__my-script-workers_sites_assets_preview\\"
|
|
207
213
|
Successfully deleted my-script",
|