wrangler 2.1.15 → 2.2.1
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/miniflare-dist/index.mjs +3 -1
- package/package.json +2 -1
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +1 -1
- package/src/__tests__/api-devregistry.test.js +2 -2
- package/src/__tests__/configuration.test.ts +119 -2
- package/src/__tests__/d1.test.ts +2 -0
- package/src/__tests__/deployments.test.ts +22 -22
- package/src/__tests__/dev.test.tsx +167 -15
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +22 -43
- package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
- package/src/__tests__/helpers/msw/index.ts +4 -0
- package/src/__tests__/index.test.ts +42 -33
- package/src/__tests__/init.test.ts +88 -4
- package/src/__tests__/jest.setup.ts +11 -0
- package/src/__tests__/kv.test.ts +400 -400
- package/src/__tests__/pages.test.ts +206 -40
- package/src/__tests__/publish.test.ts +1161 -647
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/queues.test.ts +371 -0
- package/src/__tests__/r2.test.ts +57 -52
- package/src/__tests__/worker-namespace.test.ts +15 -10
- package/src/bundle-reporter.tsx +41 -2
- package/src/bundle.ts +105 -46
- package/src/cli.ts +0 -1
- package/src/config/environment.ts +50 -0
- package/src/config/index.ts +41 -0
- package/src/config/validation.ts +173 -0
- package/src/create-worker-preview.ts +10 -3
- package/src/create-worker-upload-form.ts +12 -0
- package/src/d1/backups.tsx +11 -5
- package/src/d1/execute.tsx +52 -47
- package/src/d1/index.ts +2 -1
- package/src/delete.ts +7 -10
- package/src/deployments.ts +73 -0
- package/src/deprecated/index.ts +9 -24
- package/src/dev/dev-vars.ts +11 -8
- package/src/dev/dev.tsx +12 -0
- package/src/dev/local.tsx +26 -0
- package/src/dev/remote.tsx +2 -0
- package/src/dev/start-server.ts +7 -0
- package/src/dev/use-esbuild.ts +12 -5
- package/src/dev.tsx +12 -9
- package/src/dispatch-namespace.ts +4 -3
- package/src/index.tsx +61 -45
- package/src/init.ts +4 -4
- package/src/inspect.ts +21 -1
- package/src/kv/index.ts +5 -54
- package/src/logger.ts +12 -0
- package/src/pages/build.tsx +33 -1
- package/src/pages/dev.tsx +22 -7
- package/src/pages/functions/buildPlugin.ts +83 -87
- package/src/pages/functions/buildWorker.ts +119 -110
- package/src/pages/publish.tsx +16 -6
- package/src/pages/upload.tsx +19 -2
- package/src/pages/utils.ts +2 -2
- package/src/proxy.ts +38 -6
- package/src/publish/index.ts +11 -8
- package/src/publish/publish.ts +152 -30
- package/src/pubsub/pubsub-commands.tsx +3 -2
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +22 -0
- package/src/queues/cli/commands/consumer/remove.ts +38 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +33 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +135 -0
- package/src/secret/index.ts +14 -39
- package/src/tail/index.ts +5 -8
- package/src/user/access.ts +69 -0
- package/src/worker.ts +7 -0
- package/src/yargs-types.ts +15 -2
- package/src/zones.ts +31 -5
- package/wrangler-dist/cli.d.ts +42 -0
- package/wrangler-dist/cli.js +4346 -3651
|
@@ -60,23 +60,24 @@ describe("pages", () => {
|
|
|
60
60
|
await endEventLoop();
|
|
61
61
|
|
|
62
62
|
expect(std.out).toMatchInlineSnapshot(`
|
|
63
|
-
|
|
63
|
+
"wrangler pages
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
⚡️ Configure Cloudflare Pages
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
Commands:
|
|
68
|
+
wrangler pages dev [directory] [-- command..] 🧑💻 Develop your full-stack Pages application locally
|
|
69
|
+
wrangler pages project ⚡️ Interact with your Pages projects
|
|
70
|
+
wrangler pages deployment 🚀 Interact with the deployments of a project
|
|
71
|
+
wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
Flags:
|
|
74
|
+
-c, --config Path to .toml configuration file [string]
|
|
75
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
76
|
+
-h, --help Show help [boolean]
|
|
77
|
+
-v, --version Show version number [boolean]
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
|
|
80
|
+
`);
|
|
80
81
|
});
|
|
81
82
|
|
|
82
83
|
describe("beta message for subcommands", () => {
|
|
@@ -315,26 +316,27 @@ describe("pages", () => {
|
|
|
315
316
|
await endEventLoop();
|
|
316
317
|
|
|
317
318
|
expect(std.out).toMatchInlineSnapshot(`
|
|
318
|
-
|
|
319
|
+
"wrangler pages publish [directory]
|
|
319
320
|
|
|
320
|
-
|
|
321
|
+
🆙 Publish a directory of static assets as a Pages deployment
|
|
321
322
|
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
Positionals:
|
|
324
|
+
directory The directory of static files to upload [string]
|
|
324
325
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
Flags:
|
|
327
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
328
|
+
-h, --help Show help [boolean]
|
|
329
|
+
-v, --version Show version number [boolean]
|
|
328
330
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
Options:
|
|
332
|
+
--project-name The name of the project you want to deploy to [string]
|
|
333
|
+
--branch The name of the branch you want to deploy to [string]
|
|
334
|
+
--commit-hash The SHA to attach to this deployment [string]
|
|
335
|
+
--commit-message The commit message to attach to this deployment [string]
|
|
336
|
+
--commit-dirty Whether or not the workspace should be considered dirty for this deployment [boolean]
|
|
335
337
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
+
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
|
|
339
|
+
`);
|
|
338
340
|
});
|
|
339
341
|
|
|
340
342
|
it("should upload a directory of files", async () => {
|
|
@@ -399,6 +401,17 @@ describe("pages", () => {
|
|
|
399
401
|
}
|
|
400
402
|
);
|
|
401
403
|
|
|
404
|
+
setMockResponse(
|
|
405
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
406
|
+
"GET",
|
|
407
|
+
async ([_url, accountId]) => {
|
|
408
|
+
assertLater(() => {
|
|
409
|
+
expect(accountId).toEqual("some-account-id");
|
|
410
|
+
});
|
|
411
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
|
|
402
415
|
await runWrangler("pages publish . --project-name=foo");
|
|
403
416
|
|
|
404
417
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -468,6 +481,17 @@ describe("pages", () => {
|
|
|
468
481
|
}
|
|
469
482
|
);
|
|
470
483
|
|
|
484
|
+
setMockResponse(
|
|
485
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
486
|
+
"GET",
|
|
487
|
+
async ([_url, accountId]) => {
|
|
488
|
+
assertLater(() => {
|
|
489
|
+
expect(accountId).toEqual("some-account-id");
|
|
490
|
+
});
|
|
491
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
|
|
471
495
|
await runWrangler("pages publish . --project-name=foo");
|
|
472
496
|
|
|
473
497
|
// Assert two identical requests
|
|
@@ -562,6 +586,17 @@ describe("pages", () => {
|
|
|
562
586
|
}
|
|
563
587
|
);
|
|
564
588
|
|
|
589
|
+
setMockResponse(
|
|
590
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
591
|
+
"GET",
|
|
592
|
+
async ([_url, accountId]) => {
|
|
593
|
+
assertLater(() => {
|
|
594
|
+
expect(accountId).toEqual("some-account-id");
|
|
595
|
+
});
|
|
596
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
|
|
565
600
|
await runWrangler("pages publish . --project-name=foo");
|
|
566
601
|
|
|
567
602
|
// Assert two requests
|
|
@@ -656,6 +691,17 @@ describe("pages", () => {
|
|
|
656
691
|
}
|
|
657
692
|
);
|
|
658
693
|
|
|
694
|
+
setMockResponse(
|
|
695
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
696
|
+
"GET",
|
|
697
|
+
async ([_url, accountId]) => {
|
|
698
|
+
assertLater(() => {
|
|
699
|
+
expect(accountId).toEqual("some-account-id");
|
|
700
|
+
});
|
|
701
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
|
|
659
705
|
await runWrangler("pages publish . --project-name=foo");
|
|
660
706
|
|
|
661
707
|
// We have 3 buckets, so expect 3 uploads
|
|
@@ -770,6 +816,17 @@ describe("pages", () => {
|
|
|
770
816
|
}
|
|
771
817
|
);
|
|
772
818
|
|
|
819
|
+
setMockResponse(
|
|
820
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
821
|
+
"GET",
|
|
822
|
+
async ([_url, accountId]) => {
|
|
823
|
+
assertLater(() => {
|
|
824
|
+
expect(accountId).toEqual("some-account-id");
|
|
825
|
+
});
|
|
826
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
827
|
+
}
|
|
828
|
+
);
|
|
829
|
+
|
|
773
830
|
await runWrangler(`pages publish public --project-name=foo`);
|
|
774
831
|
|
|
775
832
|
// We have 3 buckets, so expect 3 uploads
|
|
@@ -884,6 +941,17 @@ describe("pages", () => {
|
|
|
884
941
|
}
|
|
885
942
|
);
|
|
886
943
|
|
|
944
|
+
setMockResponse(
|
|
945
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
946
|
+
"GET",
|
|
947
|
+
async ([_url, accountId]) => {
|
|
948
|
+
assertLater(() => {
|
|
949
|
+
expect(accountId).toEqual("some-account-id");
|
|
950
|
+
});
|
|
951
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
952
|
+
}
|
|
953
|
+
);
|
|
954
|
+
|
|
887
955
|
chdir("public");
|
|
888
956
|
await runWrangler(`pages publish . --project-name=foo`);
|
|
889
957
|
|
|
@@ -986,6 +1054,17 @@ describe("pages", () => {
|
|
|
986
1054
|
})
|
|
987
1055
|
);
|
|
988
1056
|
|
|
1057
|
+
setMockResponse(
|
|
1058
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1059
|
+
"GET",
|
|
1060
|
+
async ([_url, accountId]) => {
|
|
1061
|
+
assertLater(() => {
|
|
1062
|
+
expect(accountId).toEqual("some-account-id");
|
|
1063
|
+
});
|
|
1064
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
|
|
989
1068
|
await runWrangler("pages publish . --project-name=foo");
|
|
990
1069
|
|
|
991
1070
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -1130,6 +1209,17 @@ describe("pages", () => {
|
|
|
1130
1209
|
}
|
|
1131
1210
|
);
|
|
1132
1211
|
|
|
1212
|
+
setMockResponse(
|
|
1213
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1214
|
+
"GET",
|
|
1215
|
+
async ([_url, accountId]) => {
|
|
1216
|
+
assertLater(() => {
|
|
1217
|
+
expect(accountId).toEqual("some-account-id");
|
|
1218
|
+
});
|
|
1219
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1220
|
+
}
|
|
1221
|
+
);
|
|
1222
|
+
|
|
1133
1223
|
await runWrangler("pages publish public --project-name=foo");
|
|
1134
1224
|
|
|
1135
1225
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1236,6 +1326,17 @@ describe("pages", () => {
|
|
|
1236
1326
|
}
|
|
1237
1327
|
);
|
|
1238
1328
|
|
|
1329
|
+
setMockResponse(
|
|
1330
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1331
|
+
"GET",
|
|
1332
|
+
async ([_url, accountId]) => {
|
|
1333
|
+
assertLater(() => {
|
|
1334
|
+
expect(accountId).toEqual("some-account-id");
|
|
1335
|
+
});
|
|
1336
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
|
|
1239
1340
|
await runWrangler("pages publish public --project-name=foo");
|
|
1240
1341
|
|
|
1241
1342
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1387,6 +1488,17 @@ describe("pages", () => {
|
|
|
1387
1488
|
}
|
|
1388
1489
|
);
|
|
1389
1490
|
|
|
1491
|
+
setMockResponse(
|
|
1492
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1493
|
+
"GET",
|
|
1494
|
+
async ([_url, accountId]) => {
|
|
1495
|
+
assertLater(() => {
|
|
1496
|
+
expect(accountId).toEqual("some-account-id");
|
|
1497
|
+
});
|
|
1498
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1499
|
+
}
|
|
1500
|
+
);
|
|
1501
|
+
|
|
1390
1502
|
await runWrangler("pages publish public --project-name=foo");
|
|
1391
1503
|
|
|
1392
1504
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1473,6 +1585,17 @@ describe("pages", () => {
|
|
|
1473
1585
|
});
|
|
1474
1586
|
});
|
|
1475
1587
|
|
|
1588
|
+
setMockResponse(
|
|
1589
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1590
|
+
"GET",
|
|
1591
|
+
async ([_url, accountId]) => {
|
|
1592
|
+
assertLater(() => {
|
|
1593
|
+
expect(accountId).toEqual("some-account-id");
|
|
1594
|
+
});
|
|
1595
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1596
|
+
}
|
|
1597
|
+
);
|
|
1598
|
+
|
|
1476
1599
|
await expect(runWrangler("pages publish public --project-name=foo"))
|
|
1477
1600
|
.rejects
|
|
1478
1601
|
.toThrow(`Invalid _routes.json file found at: public/_routes.json
|
|
@@ -1625,6 +1748,17 @@ and that at least one include rule is provided.
|
|
|
1625
1748
|
}
|
|
1626
1749
|
);
|
|
1627
1750
|
|
|
1751
|
+
setMockResponse(
|
|
1752
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1753
|
+
"GET",
|
|
1754
|
+
async ([_url, accountId]) => {
|
|
1755
|
+
assertLater(() => {
|
|
1756
|
+
expect(accountId).toEqual("some-account-id");
|
|
1757
|
+
});
|
|
1758
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1759
|
+
}
|
|
1760
|
+
);
|
|
1761
|
+
|
|
1628
1762
|
await runWrangler("pages publish public --project-name=foo");
|
|
1629
1763
|
|
|
1630
1764
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1710,6 +1844,17 @@ and that at least one include rule is provided.
|
|
|
1710
1844
|
});
|
|
1711
1845
|
});
|
|
1712
1846
|
|
|
1847
|
+
setMockResponse(
|
|
1848
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1849
|
+
"GET",
|
|
1850
|
+
async ([_url, accountId]) => {
|
|
1851
|
+
assertLater(() => {
|
|
1852
|
+
expect(accountId).toEqual("some-account-id");
|
|
1853
|
+
});
|
|
1854
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1855
|
+
}
|
|
1856
|
+
);
|
|
1857
|
+
|
|
1713
1858
|
await expect(runWrangler("pages publish public --project-name=foo"))
|
|
1714
1859
|
.rejects
|
|
1715
1860
|
.toThrow(`Invalid _routes.json file found at: public/_routes.json
|
|
@@ -1827,6 +1972,17 @@ and that at least one include rule is provided.
|
|
|
1827
1972
|
}
|
|
1828
1973
|
);
|
|
1829
1974
|
|
|
1975
|
+
setMockResponse(
|
|
1976
|
+
"/accounts/:accountId/pages/projects/foo",
|
|
1977
|
+
"GET",
|
|
1978
|
+
async ([_url, accountId]) => {
|
|
1979
|
+
assertLater(() => {
|
|
1980
|
+
expect(accountId).toEqual("some-account-id");
|
|
1981
|
+
});
|
|
1982
|
+
return { deployment_configs: { production: {}, preview: {} } };
|
|
1983
|
+
}
|
|
1984
|
+
);
|
|
1985
|
+
|
|
1830
1986
|
await runWrangler("pages publish public --project-name=foo");
|
|
1831
1987
|
|
|
1832
1988
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1955,29 +2111,37 @@ and that at least one include rule is provided.
|
|
|
1955
2111
|
assertLater(() => {
|
|
1956
2112
|
expect(requests.length).toBe(3);
|
|
1957
2113
|
|
|
1958
|
-
|
|
2114
|
+
const sortedRequests = requests.sort((a, b) => {
|
|
2115
|
+
return (JSON.parse(a.body as string)[0].key as string).localeCompare(
|
|
2116
|
+
JSON.parse(b.body as string)[0].key as string
|
|
2117
|
+
);
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
expect(sortedRequests[0].headers).toMatchObject({
|
|
1959
2121
|
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1960
2122
|
});
|
|
1961
2123
|
|
|
1962
2124
|
let body = JSON.parse(
|
|
1963
|
-
|
|
2125
|
+
sortedRequests[0].body as string
|
|
1964
2126
|
) as UploadPayloadFile[];
|
|
1965
2127
|
expect(body).toMatchObject([
|
|
1966
2128
|
{
|
|
1967
|
-
key: "
|
|
1968
|
-
value: Buffer.from("
|
|
2129
|
+
key: "09a79777abda8ccc8bdd51dd3ff8e9e9",
|
|
2130
|
+
value: Buffer.from("func").toString("base64"),
|
|
1969
2131
|
metadata: {
|
|
1970
|
-
contentType: "application/
|
|
2132
|
+
contentType: "application/javascript",
|
|
1971
2133
|
},
|
|
1972
2134
|
base64: true,
|
|
1973
2135
|
},
|
|
1974
2136
|
]);
|
|
1975
2137
|
|
|
1976
|
-
expect(
|
|
2138
|
+
expect(sortedRequests[1].headers).toMatchObject({
|
|
1977
2139
|
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1978
2140
|
});
|
|
1979
2141
|
|
|
1980
|
-
body = JSON.parse(
|
|
2142
|
+
body = JSON.parse(
|
|
2143
|
+
sortedRequests[1].body as string
|
|
2144
|
+
) as UploadPayloadFile[];
|
|
1981
2145
|
expect(body).toMatchObject([
|
|
1982
2146
|
{
|
|
1983
2147
|
key: "2082190357cfd3617ccfe04f340c6247",
|
|
@@ -1989,17 +2153,19 @@ and that at least one include rule is provided.
|
|
|
1989
2153
|
},
|
|
1990
2154
|
]);
|
|
1991
2155
|
|
|
1992
|
-
expect(
|
|
2156
|
+
expect(sortedRequests[2].headers).toMatchObject({
|
|
1993
2157
|
Authorization: "Bearer <<funfetti-auth-jwt>>",
|
|
1994
2158
|
});
|
|
1995
2159
|
|
|
1996
|
-
body = JSON.parse(
|
|
2160
|
+
body = JSON.parse(
|
|
2161
|
+
sortedRequests[2].body as string
|
|
2162
|
+
) as UploadPayloadFile[];
|
|
1997
2163
|
expect(body).toMatchObject([
|
|
1998
2164
|
{
|
|
1999
|
-
key: "
|
|
2000
|
-
value: Buffer.from("
|
|
2165
|
+
key: "95dedb64e6d4940fc2e0f11f711cc2f4",
|
|
2166
|
+
value: Buffer.from("headersfile").toString("base64"),
|
|
2001
2167
|
metadata: {
|
|
2002
|
-
contentType: "application/
|
|
2168
|
+
contentType: "application/octet-stream",
|
|
2003
2169
|
},
|
|
2004
2170
|
base64: true,
|
|
2005
2171
|
},
|