wrangler 2.0.9 → 2.0.11
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 +34 -0
- package/src/__tests__/publish.test.ts +244 -131
- package/src/config/validation-helpers.ts +10 -1
- package/src/pages.tsx +295 -240
- package/src/sites.tsx +49 -16
- package/wrangler-dist/cli.js +227 -167
|
@@ -1223,8 +1223,8 @@ addEventListener('fetch', event => {});`
|
|
|
1223
1223
|
|
|
1224
1224
|
it("should warn if there is a `site.entry-point` configuration", async () => {
|
|
1225
1225
|
const assets = [
|
|
1226
|
-
{ filePath: "
|
|
1227
|
-
{ filePath: "
|
|
1226
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1227
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1228
1228
|
];
|
|
1229
1229
|
const kvNamespace = {
|
|
1230
1230
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1250,10 +1250,10 @@ addEventListener('fetch', event => {});`
|
|
|
1250
1250
|
Object {
|
|
1251
1251
|
"debug": "",
|
|
1252
1252
|
"err": "",
|
|
1253
|
-
"out": "Reading
|
|
1254
|
-
Uploading as
|
|
1255
|
-
Reading
|
|
1256
|
-
Uploading as
|
|
1253
|
+
"out": "Reading file-1.txt...
|
|
1254
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1255
|
+
Reading file-2.txt...
|
|
1256
|
+
Uploading as file-2.5938485188.txt...
|
|
1257
1257
|
↗️ Done syncing assets
|
|
1258
1258
|
Uploaded test-name (TIMINGS)
|
|
1259
1259
|
Published test-name (TIMINGS)
|
|
@@ -1274,8 +1274,8 @@ addEventListener('fetch', event => {});`
|
|
|
1274
1274
|
|
|
1275
1275
|
it("should resolve site.entry-point relative to wrangler.toml", async () => {
|
|
1276
1276
|
const assets = [
|
|
1277
|
-
{ filePath: "
|
|
1278
|
-
{ filePath: "
|
|
1277
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1278
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1279
1279
|
];
|
|
1280
1280
|
const kvNamespace = {
|
|
1281
1281
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1301,10 +1301,10 @@ addEventListener('fetch', event => {});`
|
|
|
1301
1301
|
await runWrangler("publish --config ./my-site/wrangler.toml");
|
|
1302
1302
|
|
|
1303
1303
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1304
|
-
"Reading
|
|
1305
|
-
Uploading as
|
|
1306
|
-
Reading
|
|
1307
|
-
Uploading as
|
|
1304
|
+
"Reading file-1.txt...
|
|
1305
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1306
|
+
Reading file-2.txt...
|
|
1307
|
+
Uploading as file-2.5938485188.txt...
|
|
1308
1308
|
↗️ Done syncing assets
|
|
1309
1309
|
Uploaded test-name (TIMINGS)
|
|
1310
1310
|
Published test-name (TIMINGS)
|
|
@@ -1369,8 +1369,8 @@ addEventListener('fetch', event => {});`
|
|
|
1369
1369
|
describe("asset upload", () => {
|
|
1370
1370
|
it("should upload all the files in the directory specified by `config.site.bucket`", async () => {
|
|
1371
1371
|
const assets = [
|
|
1372
|
-
{ filePath: "
|
|
1373
|
-
{ filePath: "
|
|
1372
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1373
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1374
1374
|
];
|
|
1375
1375
|
const kvNamespace = {
|
|
1376
1376
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1392,10 +1392,10 @@ addEventListener('fetch', event => {});`
|
|
|
1392
1392
|
await runWrangler("publish");
|
|
1393
1393
|
|
|
1394
1394
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1395
|
-
"Reading
|
|
1396
|
-
Uploading as
|
|
1397
|
-
Reading
|
|
1398
|
-
Uploading as
|
|
1395
|
+
"Reading file-1.txt...
|
|
1396
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1397
|
+
Reading file-2.txt...
|
|
1398
|
+
Uploading as file-2.5938485188.txt...
|
|
1399
1399
|
↗️ Done syncing assets
|
|
1400
1400
|
Uploaded test-name (TIMINGS)
|
|
1401
1401
|
Published test-name (TIMINGS)
|
|
@@ -1406,8 +1406,8 @@ addEventListener('fetch', event => {});`
|
|
|
1406
1406
|
|
|
1407
1407
|
it("should not contain backslash for assets with nested directories", async () => {
|
|
1408
1408
|
const assets = [
|
|
1409
|
-
{ filePath: "
|
|
1410
|
-
{ filePath: "
|
|
1409
|
+
{ filePath: "subdir/file-1.txt", content: "Content of file-1" },
|
|
1410
|
+
{ filePath: "subdir/file-2.txt", content: "Content of file-2" },
|
|
1411
1411
|
];
|
|
1412
1412
|
const kvNamespace = {
|
|
1413
1413
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1431,7 +1431,7 @@ addEventListener('fetch', event => {});`
|
|
|
1431
1431
|
],
|
|
1432
1432
|
expectedModules: {
|
|
1433
1433
|
__STATIC_CONTENT_MANIFEST:
|
|
1434
|
-
'{"subdir/file-1.txt":"
|
|
1434
|
+
'{"subdir/file-1.txt":"subdir/file-1.2ca234f380.txt","subdir/file-2.txt":"subdir/file-2.5938485188.txt"}',
|
|
1435
1435
|
},
|
|
1436
1436
|
});
|
|
1437
1437
|
mockSubDomainRequest();
|
|
@@ -1442,10 +1442,10 @@ addEventListener('fetch', event => {});`
|
|
|
1442
1442
|
await runWrangler("publish");
|
|
1443
1443
|
|
|
1444
1444
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1445
|
-
"Reading
|
|
1446
|
-
Uploading as
|
|
1447
|
-
Reading
|
|
1448
|
-
Uploading as
|
|
1445
|
+
"Reading subdir/file-1.txt...
|
|
1446
|
+
Uploading as subdir/file-1.2ca234f380.txt...
|
|
1447
|
+
Reading subdir/file-2.txt...
|
|
1448
|
+
Uploading as subdir/file-2.5938485188.txt...
|
|
1449
1449
|
↗️ Done syncing assets
|
|
1450
1450
|
Uploaded test-name (TIMINGS)
|
|
1451
1451
|
Published test-name (TIMINGS)
|
|
@@ -1456,8 +1456,8 @@ addEventListener('fetch', event => {});`
|
|
|
1456
1456
|
|
|
1457
1457
|
it("when using a service-worker type, it should add an asset manifest as a text_blob, and bind to a namespace", async () => {
|
|
1458
1458
|
const assets = [
|
|
1459
|
-
{ filePath: "
|
|
1460
|
-
{ filePath: "
|
|
1459
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1460
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1461
1461
|
];
|
|
1462
1462
|
const kvNamespace = {
|
|
1463
1463
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1475,7 +1475,7 @@ addEventListener('fetch', event => {});`
|
|
|
1475
1475
|
expectedType: "sw",
|
|
1476
1476
|
expectedModules: {
|
|
1477
1477
|
__STATIC_CONTENT_MANIFEST:
|
|
1478
|
-
'{"file-1.txt":"
|
|
1478
|
+
'{"file-1.txt":"file-1.2ca234f380.txt","file-2.txt":"file-2.5938485188.txt"}',
|
|
1479
1479
|
},
|
|
1480
1480
|
expectedBindings: [
|
|
1481
1481
|
{
|
|
@@ -1498,10 +1498,10 @@ addEventListener('fetch', event => {});`
|
|
|
1498
1498
|
await runWrangler("publish");
|
|
1499
1499
|
|
|
1500
1500
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1501
|
-
"Reading
|
|
1502
|
-
Uploading as
|
|
1503
|
-
Reading
|
|
1504
|
-
Uploading as
|
|
1501
|
+
"Reading file-1.txt...
|
|
1502
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1503
|
+
Reading file-2.txt...
|
|
1504
|
+
Uploading as file-2.5938485188.txt...
|
|
1505
1505
|
↗️ Done syncing assets
|
|
1506
1506
|
Uploaded test-name (TIMINGS)
|
|
1507
1507
|
Published test-name (TIMINGS)
|
|
@@ -1512,8 +1512,8 @@ addEventListener('fetch', event => {});`
|
|
|
1512
1512
|
|
|
1513
1513
|
it("when using a module worker type, it should add an asset manifest module, and bind to a namespace", async () => {
|
|
1514
1514
|
const assets = [
|
|
1515
|
-
{ filePath: "
|
|
1516
|
-
{ filePath: "
|
|
1515
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1516
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1517
1517
|
];
|
|
1518
1518
|
const kvNamespace = {
|
|
1519
1519
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1537,7 +1537,7 @@ addEventListener('fetch', event => {});`
|
|
|
1537
1537
|
],
|
|
1538
1538
|
expectedModules: {
|
|
1539
1539
|
__STATIC_CONTENT_MANIFEST:
|
|
1540
|
-
'{"file-1.txt":"
|
|
1540
|
+
'{"file-1.txt":"file-1.2ca234f380.txt","file-2.txt":"file-2.5938485188.txt"}',
|
|
1541
1541
|
},
|
|
1542
1542
|
});
|
|
1543
1543
|
mockSubDomainRequest();
|
|
@@ -1548,10 +1548,10 @@ addEventListener('fetch', event => {});`
|
|
|
1548
1548
|
await runWrangler("publish");
|
|
1549
1549
|
|
|
1550
1550
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1551
|
-
"Reading
|
|
1552
|
-
Uploading as
|
|
1553
|
-
Reading
|
|
1554
|
-
Uploading as
|
|
1551
|
+
"Reading file-1.txt...
|
|
1552
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1553
|
+
Reading file-2.txt...
|
|
1554
|
+
Uploading as file-2.5938485188.txt...
|
|
1555
1555
|
↗️ Done syncing assets
|
|
1556
1556
|
Uploaded test-name (TIMINGS)
|
|
1557
1557
|
Published test-name (TIMINGS)
|
|
@@ -1563,8 +1563,8 @@ addEventListener('fetch', event => {});`
|
|
|
1563
1563
|
it("should make environment specific kv namespace for assets, even for service envs", async () => {
|
|
1564
1564
|
// This is the same test as the one before this, but with an env arg
|
|
1565
1565
|
const assets = [
|
|
1566
|
-
{ filePath: "
|
|
1567
|
-
{ filePath: "
|
|
1566
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1567
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1568
1568
|
];
|
|
1569
1569
|
const kvNamespace = {
|
|
1570
1570
|
title: "__test-name-some-env-workers_sites_assets",
|
|
@@ -1596,10 +1596,10 @@ addEventListener('fetch', event => {});`
|
|
|
1596
1596
|
await runWrangler("publish --env some-env --legacy-env false");
|
|
1597
1597
|
|
|
1598
1598
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1599
|
-
"Reading
|
|
1600
|
-
Uploading as
|
|
1601
|
-
Reading
|
|
1602
|
-
Uploading as
|
|
1599
|
+
"Reading file-1.txt...
|
|
1600
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1601
|
+
Reading file-2.txt...
|
|
1602
|
+
Uploading as file-2.5938485188.txt...
|
|
1603
1603
|
↗️ Done syncing assets
|
|
1604
1604
|
Uploaded test-name (some-env) (TIMINGS)
|
|
1605
1605
|
Published test-name (some-env) (TIMINGS)
|
|
@@ -1611,8 +1611,8 @@ addEventListener('fetch', event => {});`
|
|
|
1611
1611
|
it("should make environment specific kv namespace for assets, even for legacy envs", async () => {
|
|
1612
1612
|
// And this is the same test as the one before this, but with legacyEnv:true
|
|
1613
1613
|
const assets = [
|
|
1614
|
-
{ filePath: "
|
|
1615
|
-
{ filePath: "
|
|
1614
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1615
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1616
1616
|
];
|
|
1617
1617
|
const kvNamespace = {
|
|
1618
1618
|
title: "__test-name-some-env-workers_sites_assets",
|
|
@@ -1645,10 +1645,10 @@ addEventListener('fetch', event => {});`
|
|
|
1645
1645
|
await runWrangler("publish --env some-env --legacy-env true");
|
|
1646
1646
|
|
|
1647
1647
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1648
|
-
"Reading
|
|
1649
|
-
Uploading as
|
|
1650
|
-
Reading
|
|
1651
|
-
Uploading as
|
|
1648
|
+
"Reading file-1.txt...
|
|
1649
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1650
|
+
Reading file-2.txt...
|
|
1651
|
+
Uploading as file-2.5938485188.txt...
|
|
1652
1652
|
↗️ Done syncing assets
|
|
1653
1653
|
Uploaded test-name-some-env (TIMINGS)
|
|
1654
1654
|
Published test-name-some-env (TIMINGS)
|
|
@@ -1659,8 +1659,8 @@ addEventListener('fetch', event => {});`
|
|
|
1659
1659
|
|
|
1660
1660
|
it("should only upload files that are not already in the KV namespace", async () => {
|
|
1661
1661
|
const assets = [
|
|
1662
|
-
{ filePath: "
|
|
1663
|
-
{ filePath: "
|
|
1662
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1663
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1664
1664
|
];
|
|
1665
1665
|
const kvNamespace = {
|
|
1666
1666
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1678,21 +1678,19 @@ addEventListener('fetch', event => {});`
|
|
|
1678
1678
|
mockSubDomainRequest();
|
|
1679
1679
|
mockListKVNamespacesRequest(kvNamespace);
|
|
1680
1680
|
// Put file-1 in the KV namespace
|
|
1681
|
-
mockKeyListRequest(kvNamespace.id, [
|
|
1682
|
-
{ name: "assets/file-1.2ca234f380.txt" },
|
|
1683
|
-
]);
|
|
1681
|
+
mockKeyListRequest(kvNamespace.id, [{ name: "file-1.2ca234f380.txt" }]);
|
|
1684
1682
|
// Check we do not upload file-1
|
|
1685
1683
|
mockUploadAssetsToKVRequest(
|
|
1686
1684
|
kvNamespace.id,
|
|
1687
|
-
assets.filter((a) => a.filePath !== "
|
|
1685
|
+
assets.filter((a) => a.filePath !== "file-1.txt")
|
|
1688
1686
|
);
|
|
1689
1687
|
await runWrangler("publish");
|
|
1690
1688
|
|
|
1691
1689
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1692
|
-
"Reading
|
|
1690
|
+
"Reading file-1.txt...
|
|
1693
1691
|
Skipping - already uploaded.
|
|
1694
|
-
Reading
|
|
1695
|
-
Uploading as
|
|
1692
|
+
Reading file-2.txt...
|
|
1693
|
+
Uploading as file-2.5938485188.txt...
|
|
1696
1694
|
↗️ Done syncing assets
|
|
1697
1695
|
Uploaded test-name (TIMINGS)
|
|
1698
1696
|
Published test-name (TIMINGS)
|
|
@@ -1703,8 +1701,8 @@ addEventListener('fetch', event => {});`
|
|
|
1703
1701
|
|
|
1704
1702
|
it("should only upload files that match the `site-include` arg", async () => {
|
|
1705
1703
|
const assets = [
|
|
1706
|
-
{ filePath: "
|
|
1707
|
-
{ filePath: "
|
|
1704
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1705
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1708
1706
|
];
|
|
1709
1707
|
const kvNamespace = {
|
|
1710
1708
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1725,13 +1723,13 @@ addEventListener('fetch', event => {});`
|
|
|
1725
1723
|
// Check we only upload file-1
|
|
1726
1724
|
mockUploadAssetsToKVRequest(
|
|
1727
1725
|
kvNamespace.id,
|
|
1728
|
-
assets.filter((a) => a.filePath === "
|
|
1726
|
+
assets.filter((a) => a.filePath === "file-1.txt")
|
|
1729
1727
|
);
|
|
1730
1728
|
await runWrangler("publish --site-include file-1.txt");
|
|
1731
1729
|
|
|
1732
1730
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1733
|
-
"Reading
|
|
1734
|
-
Uploading as
|
|
1731
|
+
"Reading file-1.txt...
|
|
1732
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1735
1733
|
↗️ Done syncing assets
|
|
1736
1734
|
Uploaded test-name (TIMINGS)
|
|
1737
1735
|
Published test-name (TIMINGS)
|
|
@@ -1742,8 +1740,8 @@ addEventListener('fetch', event => {});`
|
|
|
1742
1740
|
|
|
1743
1741
|
it("should not upload files that match the `site-exclude` arg", async () => {
|
|
1744
1742
|
const assets = [
|
|
1745
|
-
{ filePath: "
|
|
1746
|
-
{ filePath: "
|
|
1743
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1744
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1747
1745
|
];
|
|
1748
1746
|
const kvNamespace = {
|
|
1749
1747
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1764,13 +1762,13 @@ addEventListener('fetch', event => {});`
|
|
|
1764
1762
|
// Check we only upload file-1
|
|
1765
1763
|
mockUploadAssetsToKVRequest(
|
|
1766
1764
|
kvNamespace.id,
|
|
1767
|
-
assets.filter((a) => a.filePath === "
|
|
1765
|
+
assets.filter((a) => a.filePath === "file-1.txt")
|
|
1768
1766
|
);
|
|
1769
1767
|
await runWrangler("publish --site-exclude file-2.txt");
|
|
1770
1768
|
|
|
1771
1769
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1772
|
-
"Reading
|
|
1773
|
-
Uploading as
|
|
1770
|
+
"Reading file-1.txt...
|
|
1771
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1774
1772
|
↗️ Done syncing assets
|
|
1775
1773
|
Uploaded test-name (TIMINGS)
|
|
1776
1774
|
Published test-name (TIMINGS)
|
|
@@ -1781,8 +1779,8 @@ addEventListener('fetch', event => {});`
|
|
|
1781
1779
|
|
|
1782
1780
|
it("should only upload files that match the `site.include` config", async () => {
|
|
1783
1781
|
const assets = [
|
|
1784
|
-
{ filePath: "
|
|
1785
|
-
{ filePath: "
|
|
1782
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1783
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1786
1784
|
];
|
|
1787
1785
|
const kvNamespace = {
|
|
1788
1786
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1804,13 +1802,13 @@ addEventListener('fetch', event => {});`
|
|
|
1804
1802
|
// Check we only upload file-1
|
|
1805
1803
|
mockUploadAssetsToKVRequest(
|
|
1806
1804
|
kvNamespace.id,
|
|
1807
|
-
assets.filter((a) => a.filePath === "
|
|
1805
|
+
assets.filter((a) => a.filePath === "file-1.txt")
|
|
1808
1806
|
);
|
|
1809
1807
|
await runWrangler("publish");
|
|
1810
1808
|
|
|
1811
1809
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1812
|
-
"Reading
|
|
1813
|
-
Uploading as
|
|
1810
|
+
"Reading file-1.txt...
|
|
1811
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1814
1812
|
↗️ Done syncing assets
|
|
1815
1813
|
Uploaded test-name (TIMINGS)
|
|
1816
1814
|
Published test-name (TIMINGS)
|
|
@@ -1821,8 +1819,8 @@ addEventListener('fetch', event => {});`
|
|
|
1821
1819
|
|
|
1822
1820
|
it("should not upload files that match the `site.exclude` config", async () => {
|
|
1823
1821
|
const assets = [
|
|
1824
|
-
{ filePath: "
|
|
1825
|
-
{ filePath: "
|
|
1822
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1823
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1826
1824
|
];
|
|
1827
1825
|
const kvNamespace = {
|
|
1828
1826
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1844,13 +1842,13 @@ addEventListener('fetch', event => {});`
|
|
|
1844
1842
|
// Check we only upload file-1
|
|
1845
1843
|
mockUploadAssetsToKVRequest(
|
|
1846
1844
|
kvNamespace.id,
|
|
1847
|
-
assets.filter((a) => a.filePath === "
|
|
1845
|
+
assets.filter((a) => a.filePath === "file-1.txt")
|
|
1848
1846
|
);
|
|
1849
1847
|
await runWrangler("publish");
|
|
1850
1848
|
|
|
1851
1849
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1852
|
-
"Reading
|
|
1853
|
-
Uploading as
|
|
1850
|
+
"Reading file-1.txt...
|
|
1851
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1854
1852
|
↗️ Done syncing assets
|
|
1855
1853
|
Uploaded test-name (TIMINGS)
|
|
1856
1854
|
Published test-name (TIMINGS)
|
|
@@ -1861,8 +1859,8 @@ addEventListener('fetch', event => {});`
|
|
|
1861
1859
|
|
|
1862
1860
|
it("should use `site-include` arg over `site.include` config", async () => {
|
|
1863
1861
|
const assets = [
|
|
1864
|
-
{ filePath: "
|
|
1865
|
-
{ filePath: "
|
|
1862
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1863
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1866
1864
|
];
|
|
1867
1865
|
const kvNamespace = {
|
|
1868
1866
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1884,13 +1882,13 @@ addEventListener('fetch', event => {});`
|
|
|
1884
1882
|
// Check we only upload file-1
|
|
1885
1883
|
mockUploadAssetsToKVRequest(
|
|
1886
1884
|
kvNamespace.id,
|
|
1887
|
-
assets.filter((a) => a.filePath === "
|
|
1885
|
+
assets.filter((a) => a.filePath === "file-1.txt")
|
|
1888
1886
|
);
|
|
1889
1887
|
await runWrangler("publish --site-include file-1.txt");
|
|
1890
1888
|
|
|
1891
1889
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1892
|
-
"Reading
|
|
1893
|
-
Uploading as
|
|
1890
|
+
"Reading file-1.txt...
|
|
1891
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1894
1892
|
↗️ Done syncing assets
|
|
1895
1893
|
Uploaded test-name (TIMINGS)
|
|
1896
1894
|
Published test-name (TIMINGS)
|
|
@@ -1901,8 +1899,8 @@ addEventListener('fetch', event => {});`
|
|
|
1901
1899
|
|
|
1902
1900
|
it("should use `site-exclude` arg over `site.exclude` config", async () => {
|
|
1903
1901
|
const assets = [
|
|
1904
|
-
{ filePath: "
|
|
1905
|
-
{ filePath: "
|
|
1902
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
1903
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
1906
1904
|
];
|
|
1907
1905
|
const kvNamespace = {
|
|
1908
1906
|
title: "__test-name-workers_sites_assets",
|
|
@@ -1912,7 +1910,7 @@ addEventListener('fetch', event => {});`
|
|
|
1912
1910
|
main: "./index.js",
|
|
1913
1911
|
site: {
|
|
1914
1912
|
bucket: "assets",
|
|
1915
|
-
exclude: ["
|
|
1913
|
+
exclude: ["file-1.txt"],
|
|
1916
1914
|
},
|
|
1917
1915
|
});
|
|
1918
1916
|
writeWorkerSource();
|
|
@@ -1924,13 +1922,13 @@ addEventListener('fetch', event => {});`
|
|
|
1924
1922
|
// Check we only upload file-1
|
|
1925
1923
|
mockUploadAssetsToKVRequest(
|
|
1926
1924
|
kvNamespace.id,
|
|
1927
|
-
assets.filter((a) => a.filePath.endsWith("
|
|
1925
|
+
assets.filter((a) => a.filePath.endsWith("file-1.txt"))
|
|
1928
1926
|
);
|
|
1929
1927
|
await runWrangler("publish --site-exclude file-2.txt");
|
|
1930
1928
|
|
|
1931
1929
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1932
|
-
"Reading
|
|
1933
|
-
Uploading as
|
|
1930
|
+
"Reading file-1.txt...
|
|
1931
|
+
Uploading as file-1.2ca234f380.txt...
|
|
1934
1932
|
↗️ Done syncing assets
|
|
1935
1933
|
Uploaded test-name (TIMINGS)
|
|
1936
1934
|
Published test-name (TIMINGS)
|
|
@@ -1942,11 +1940,11 @@ addEventListener('fetch', event => {});`
|
|
|
1942
1940
|
it("should walk directories except node_modules", async () => {
|
|
1943
1941
|
const assets = [
|
|
1944
1942
|
{
|
|
1945
|
-
filePath: "
|
|
1943
|
+
filePath: "directory-1/file-1.txt",
|
|
1946
1944
|
content: "Content of file-1",
|
|
1947
1945
|
},
|
|
1948
1946
|
{
|
|
1949
|
-
filePath: "
|
|
1947
|
+
filePath: "node_modules/file-2.txt",
|
|
1950
1948
|
content: "Content of file-2",
|
|
1951
1949
|
},
|
|
1952
1950
|
];
|
|
@@ -1971,8 +1969,8 @@ addEventListener('fetch', event => {});`
|
|
|
1971
1969
|
await runWrangler("publish");
|
|
1972
1970
|
|
|
1973
1971
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1974
|
-
"Reading
|
|
1975
|
-
Uploading as
|
|
1972
|
+
"Reading directory-1/file-1.txt...
|
|
1973
|
+
Uploading as directory-1/file-1.2ca234f380.txt...
|
|
1976
1974
|
↗️ Done syncing assets
|
|
1977
1975
|
Uploaded test-name (TIMINGS)
|
|
1978
1976
|
Published test-name (TIMINGS)
|
|
@@ -1984,15 +1982,15 @@ addEventListener('fetch', event => {});`
|
|
|
1984
1982
|
it("should skip hidden files and directories except `.well-known`", async () => {
|
|
1985
1983
|
const assets = [
|
|
1986
1984
|
{
|
|
1987
|
-
filePath: "
|
|
1985
|
+
filePath: ".hidden-file.txt",
|
|
1988
1986
|
content: "Content of hidden-file",
|
|
1989
1987
|
},
|
|
1990
1988
|
{
|
|
1991
|
-
filePath: "
|
|
1989
|
+
filePath: ".hidden/file-1.txt",
|
|
1992
1990
|
content: "Content of file-1",
|
|
1993
1991
|
},
|
|
1994
1992
|
{
|
|
1995
|
-
filePath: "
|
|
1993
|
+
filePath: ".well-known/file-2.txt",
|
|
1996
1994
|
content: "Content of file-2",
|
|
1997
1995
|
},
|
|
1998
1996
|
];
|
|
@@ -2017,8 +2015,8 @@ addEventListener('fetch', event => {});`
|
|
|
2017
2015
|
await runWrangler("publish");
|
|
2018
2016
|
|
|
2019
2017
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2020
|
-
"Reading
|
|
2021
|
-
Uploading as
|
|
2018
|
+
"Reading .well-known/file-2.txt...
|
|
2019
|
+
Uploading as .well-known/file-2.5938485188.txt...
|
|
2022
2020
|
↗️ Done syncing assets
|
|
2023
2021
|
Uploaded test-name (TIMINGS)
|
|
2024
2022
|
Published test-name (TIMINGS)
|
|
@@ -2030,12 +2028,12 @@ addEventListener('fetch', event => {});`
|
|
|
2030
2028
|
it("should error if the asset is over 25Mb", async () => {
|
|
2031
2029
|
const assets = [
|
|
2032
2030
|
{
|
|
2033
|
-
filePath: "
|
|
2031
|
+
filePath: "large-file.txt",
|
|
2034
2032
|
// This file is greater than 25MiB when base64 encoded but small enough to be uploaded.
|
|
2035
2033
|
content: "X".repeat(25 * 1024 * 1024 * 0.8 + 1),
|
|
2036
2034
|
},
|
|
2037
2035
|
{
|
|
2038
|
-
filePath: "
|
|
2036
|
+
filePath: "too-large-file.txt",
|
|
2039
2037
|
content: "X".repeat(25 * 1024 * 1024 + 1),
|
|
2040
2038
|
},
|
|
2041
2039
|
];
|
|
@@ -2047,7 +2045,7 @@ addEventListener('fetch', event => {});`
|
|
|
2047
2045
|
main: "./index.js",
|
|
2048
2046
|
site: {
|
|
2049
2047
|
bucket: "assets",
|
|
2050
|
-
exclude: ["
|
|
2048
|
+
exclude: ["file-1.txt"],
|
|
2051
2049
|
},
|
|
2052
2050
|
});
|
|
2053
2051
|
writeWorkerSource();
|
|
@@ -2060,25 +2058,131 @@ addEventListener('fetch', event => {});`
|
|
|
2060
2058
|
await expect(
|
|
2061
2059
|
runWrangler("publish")
|
|
2062
2060
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
2063
|
-
`"File
|
|
2061
|
+
`"File too-large-file.txt is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits"`
|
|
2064
2062
|
);
|
|
2065
2063
|
|
|
2066
2064
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2067
|
-
"Reading
|
|
2068
|
-
Uploading as
|
|
2065
|
+
"Reading large-file.txt...
|
|
2066
|
+
Uploading as large-file.0ea0637a45.txt...
|
|
2067
|
+
Reading too-large-file.txt...
|
|
2069
2068
|
|
|
2070
2069
|
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
2071
2070
|
`);
|
|
2072
2071
|
expect(std.err).toMatchInlineSnapshot(`
|
|
2073
|
-
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mFile
|
|
2072
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mFile too-large-file.txt is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits[0m
|
|
2074
2073
|
|
|
2075
2074
|
"
|
|
2076
2075
|
`);
|
|
2077
2076
|
});
|
|
2078
2077
|
|
|
2078
|
+
it("should batch assets in groups <100 mb", async () => {
|
|
2079
|
+
// Let's have 20 files, from size 1 - 20 mb
|
|
2080
|
+
const assets = Array.from({ length: 20 }, (_, index) => ({
|
|
2081
|
+
filePath: `file-${`${index}`.padStart(2, "0")}.txt`,
|
|
2082
|
+
content: "X".repeat(1024 * 1024 * (index + 1)),
|
|
2083
|
+
}));
|
|
2084
|
+
|
|
2085
|
+
const kvNamespace = {
|
|
2086
|
+
title: "__test-name-workers_sites_assets",
|
|
2087
|
+
id: "__test-name-workers_sites_assets-id",
|
|
2088
|
+
};
|
|
2089
|
+
writeWranglerToml({
|
|
2090
|
+
main: "./index.js",
|
|
2091
|
+
site: {
|
|
2092
|
+
bucket: "assets",
|
|
2093
|
+
},
|
|
2094
|
+
});
|
|
2095
|
+
writeWorkerSource();
|
|
2096
|
+
writeAssets(assets);
|
|
2097
|
+
mockUploadWorkerRequest();
|
|
2098
|
+
mockSubDomainRequest();
|
|
2099
|
+
mockListKVNamespacesRequest(kvNamespace);
|
|
2100
|
+
mockKeyListRequest(kvNamespace.id, []);
|
|
2101
|
+
|
|
2102
|
+
// We expect this to be uploaded in 3 batches
|
|
2103
|
+
// The first batch has 11 files (88mb)
|
|
2104
|
+
// The next batch has 5 files (93mb)
|
|
2105
|
+
// And the last one has 4 files (98mb)
|
|
2106
|
+
|
|
2107
|
+
// Since the bulk upload api endpoint stays the same
|
|
2108
|
+
// We're going to have to clear the mock as soon as it's resolved
|
|
2109
|
+
// And immediately add a mock for another one
|
|
2110
|
+
// Welcome to a callback pyramid in 2022
|
|
2111
|
+
|
|
2112
|
+
const removeFirstBulkUploadMockFn = mockUploadAssetsToKVRequest(
|
|
2113
|
+
kvNamespace.id,
|
|
2114
|
+
assets.slice(0, 11),
|
|
2115
|
+
() => {
|
|
2116
|
+
removeFirstBulkUploadMockFn();
|
|
2117
|
+
const removeSecondBulkUploadMockFn = mockUploadAssetsToKVRequest(
|
|
2118
|
+
kvNamespace.id,
|
|
2119
|
+
assets.slice(11, 16),
|
|
2120
|
+
() => {
|
|
2121
|
+
removeSecondBulkUploadMockFn();
|
|
2122
|
+
mockUploadAssetsToKVRequest(kvNamespace.id, assets.slice(16, 20));
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
);
|
|
2127
|
+
|
|
2128
|
+
await runWrangler("publish");
|
|
2129
|
+
|
|
2130
|
+
expect(std).toMatchInlineSnapshot(`
|
|
2131
|
+
Object {
|
|
2132
|
+
"debug": "",
|
|
2133
|
+
"err": "",
|
|
2134
|
+
"out": "Reading file-00.txt...
|
|
2135
|
+
Uploading as file-00.be5be5dd26.txt...
|
|
2136
|
+
Reading file-01.txt...
|
|
2137
|
+
Uploading as file-01.4842d35994.txt...
|
|
2138
|
+
Reading file-02.txt...
|
|
2139
|
+
Uploading as file-02.990572ec63.txt...
|
|
2140
|
+
Reading file-03.txt...
|
|
2141
|
+
Uploading as file-03.9d7dda9045.txt...
|
|
2142
|
+
Reading file-04.txt...
|
|
2143
|
+
Uploading as file-04.2b6fac6382.txt...
|
|
2144
|
+
Reading file-05.txt...
|
|
2145
|
+
Uploading as file-05.55762dc758.txt...
|
|
2146
|
+
Reading file-06.txt...
|
|
2147
|
+
Uploading as file-06.f408a6b020.txt...
|
|
2148
|
+
Reading file-07.txt...
|
|
2149
|
+
Uploading as file-07.64c051715b.txt...
|
|
2150
|
+
Reading file-08.txt...
|
|
2151
|
+
Uploading as file-08.d286789adb.txt...
|
|
2152
|
+
Reading file-09.txt...
|
|
2153
|
+
Uploading as file-09.6838c183a8.txt...
|
|
2154
|
+
Reading file-10.txt...
|
|
2155
|
+
Uploading as file-10.6e03221d2a.txt...
|
|
2156
|
+
Reading file-11.txt...
|
|
2157
|
+
Uploading as file-11.37d3fb2eff.txt...
|
|
2158
|
+
Reading file-12.txt...
|
|
2159
|
+
Uploading as file-12.b3556942f8.txt...
|
|
2160
|
+
Reading file-13.txt...
|
|
2161
|
+
Uploading as file-13.680caf51b1.txt...
|
|
2162
|
+
Reading file-14.txt...
|
|
2163
|
+
Uploading as file-14.51e88468f0.txt...
|
|
2164
|
+
Reading file-15.txt...
|
|
2165
|
+
Uploading as file-15.8e3fedb394.txt...
|
|
2166
|
+
Reading file-16.txt...
|
|
2167
|
+
Uploading as file-16.c81c5e426f.txt...
|
|
2168
|
+
Reading file-17.txt...
|
|
2169
|
+
Uploading as file-17.4b2ae3c47b.txt...
|
|
2170
|
+
Reading file-18.txt...
|
|
2171
|
+
Uploading as file-18.07f245e02b.txt...
|
|
2172
|
+
Reading file-19.txt...
|
|
2173
|
+
Uploading as file-19.f0d69f705d.txt...
|
|
2174
|
+
↗️ Done syncing assets
|
|
2175
|
+
Uploaded test-name (TIMINGS)
|
|
2176
|
+
Published test-name (TIMINGS)
|
|
2177
|
+
test-name.test-sub-domain.workers.dev",
|
|
2178
|
+
"warn": "",
|
|
2179
|
+
}
|
|
2180
|
+
`);
|
|
2181
|
+
});
|
|
2182
|
+
|
|
2079
2183
|
it("should error if the asset key is over 512 characters", async () => {
|
|
2080
2184
|
const longFilePathAsset = {
|
|
2081
|
-
filePath: "
|
|
2185
|
+
filePath: "folder/".repeat(100) + "file.txt",
|
|
2082
2186
|
content: "content of file",
|
|
2083
2187
|
};
|
|
2084
2188
|
const kvNamespace = {
|
|
@@ -2101,16 +2205,16 @@ addEventListener('fetch', event => {});`
|
|
|
2101
2205
|
await expect(
|
|
2102
2206
|
runWrangler("publish")
|
|
2103
2207
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
2104
|
-
`"The asset path key \\"
|
|
2208
|
+
`"The asset path key \\"folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/file.3da0d0cd12.txt\\" exceeds the maximum key size limit of 512. See https://developers.cloudflare.com/workers/platform/limits#kv-limits\\","`
|
|
2105
2209
|
);
|
|
2106
2210
|
|
|
2107
2211
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2108
|
-
"Reading
|
|
2212
|
+
"Reading folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/file.txt...
|
|
2109
2213
|
|
|
2110
2214
|
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
2111
2215
|
`);
|
|
2112
2216
|
expect(std.err).toMatchInlineSnapshot(`
|
|
2113
|
-
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mThe asset path key \\"
|
|
2217
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mThe asset path key \\"folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/folder/file.3da0d0cd12.txt\\" exceeds the maximum key size limit of 512. See https://developers.cloudflare.com/workers/platform/limits#kv-limits\\",[0m
|
|
2114
2218
|
|
|
2115
2219
|
"
|
|
2116
2220
|
`);
|
|
@@ -2118,8 +2222,8 @@ addEventListener('fetch', event => {});`
|
|
|
2118
2222
|
|
|
2119
2223
|
it("should delete uploaded assets that aren't included anymore", async () => {
|
|
2120
2224
|
const assets = [
|
|
2121
|
-
{ filePath: "
|
|
2122
|
-
{ filePath: "
|
|
2225
|
+
{ filePath: "file-1.txt", content: "Content of file-1" },
|
|
2226
|
+
{ filePath: "file-2.txt", content: "Content of file-2" },
|
|
2123
2227
|
];
|
|
2124
2228
|
const kvNamespace = {
|
|
2125
2229
|
title: "__test-name-workers_sites_assets",
|
|
@@ -2138,32 +2242,33 @@ addEventListener('fetch', event => {});`
|
|
|
2138
2242
|
mockListKVNamespacesRequest(kvNamespace);
|
|
2139
2243
|
mockKeyListRequest(kvNamespace.id, [
|
|
2140
2244
|
// Put file-1 in the KV namespace
|
|
2141
|
-
{ name: "
|
|
2245
|
+
{ name: "file-1.2ca234f380.txt" },
|
|
2142
2246
|
// As well as a couple from a previous upload
|
|
2143
|
-
{ name: "
|
|
2144
|
-
{ name: "
|
|
2247
|
+
{ name: "file-3.somehash.txt" },
|
|
2248
|
+
{ name: "file-4.anotherhash.txt" },
|
|
2145
2249
|
]);
|
|
2146
2250
|
|
|
2147
2251
|
// we upload only file-1.txt
|
|
2148
|
-
mockUploadAssetsToKVRequest(
|
|
2149
|
-
|
|
2150
|
-
|
|
2252
|
+
mockUploadAssetsToKVRequest(
|
|
2253
|
+
kvNamespace.id,
|
|
2254
|
+
assets.filter((a) => a.filePath !== "file-1.txt")
|
|
2255
|
+
);
|
|
2151
2256
|
|
|
2152
2257
|
// and mark file-3 and file-4 for deletion
|
|
2153
2258
|
mockDeleteUnusedAssetsRequest(kvNamespace.id, [
|
|
2154
|
-
"
|
|
2155
|
-
"
|
|
2259
|
+
"file-3.somehash.txt",
|
|
2260
|
+
"file-4.anotherhash.txt",
|
|
2156
2261
|
]);
|
|
2157
2262
|
|
|
2158
2263
|
await runWrangler("publish");
|
|
2159
2264
|
|
|
2160
2265
|
expect(std.out).toMatchInlineSnapshot(`
|
|
2161
|
-
"Reading
|
|
2266
|
+
"Reading file-1.txt...
|
|
2162
2267
|
Skipping - already uploaded.
|
|
2163
|
-
Reading
|
|
2164
|
-
Uploading as
|
|
2165
|
-
Deleting
|
|
2166
|
-
Deleting
|
|
2268
|
+
Reading file-2.txt...
|
|
2269
|
+
Uploading as file-2.5938485188.txt...
|
|
2270
|
+
Deleting file-3.somehash.txt from the asset store...
|
|
2271
|
+
Deleting file-4.anotherhash.txt from the asset store...
|
|
2167
2272
|
↗️ Done syncing assets
|
|
2168
2273
|
Uploaded test-name (TIMINGS)
|
|
2169
2274
|
Published test-name (TIMINGS)
|
|
@@ -5135,10 +5240,16 @@ addEventListener('fetch', event => {});`
|
|
|
5135
5240
|
});
|
|
5136
5241
|
|
|
5137
5242
|
/** Write mock assets to the file system so they can be uploaded. */
|
|
5138
|
-
function writeAssets(
|
|
5243
|
+
function writeAssets(
|
|
5244
|
+
assets: { filePath: string; content: string }[],
|
|
5245
|
+
destination = "assets"
|
|
5246
|
+
) {
|
|
5139
5247
|
for (const asset of assets) {
|
|
5140
|
-
|
|
5141
|
-
fs.
|
|
5248
|
+
const filePathDestination = path.join(destination, asset.filePath);
|
|
5249
|
+
fs.mkdirSync(path.dirname(filePathDestination), {
|
|
5250
|
+
recursive: true,
|
|
5251
|
+
});
|
|
5252
|
+
fs.writeFileSync(filePathDestination, asset.content);
|
|
5142
5253
|
}
|
|
5143
5254
|
}
|
|
5144
5255
|
|
|
@@ -5462,9 +5573,10 @@ function mockUploadAssetsToKVRequest(
|
|
|
5462
5573
|
content: string;
|
|
5463
5574
|
expiration?: number;
|
|
5464
5575
|
expiration_ttl?: number;
|
|
5465
|
-
}[]
|
|
5576
|
+
}[],
|
|
5577
|
+
onUpload?: () => void
|
|
5466
5578
|
) {
|
|
5467
|
-
setMockResponse(
|
|
5579
|
+
return setMockResponse(
|
|
5468
5580
|
"/accounts/:accountId/storage/kv/namespaces/:namespaceId/bulk",
|
|
5469
5581
|
"PUT",
|
|
5470
5582
|
([_url, accountId, namespaceId], { body }) => {
|
|
@@ -5494,6 +5606,7 @@ function mockUploadAssetsToKVRequest(
|
|
|
5494
5606
|
expect(upload.expiration).toEqual(asset.expiration);
|
|
5495
5607
|
expect(upload.expiration_ttl).toEqual(asset.expiration_ttl);
|
|
5496
5608
|
}
|
|
5609
|
+
onUpload?.();
|
|
5497
5610
|
return null;
|
|
5498
5611
|
}
|
|
5499
5612
|
);
|