wrangler 2.12.2 → 2.12.3
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 +4 -3
- package/src/__tests__/d1/execute.test.ts +2 -0
- package/src/__tests__/d1/migrate.test.ts +2 -0
- package/src/__tests__/delete.test.ts +6 -0
- package/src/__tests__/dev.test.tsx +71 -56
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/init.test.ts +127 -96
- package/src/__tests__/kv.test.ts +9 -9
- package/src/__tests__/middleware.scheduled.test.ts +2 -2
- package/src/__tests__/middleware.test.ts +2 -2
- package/src/__tests__/pages/deployment-list.test.ts +2 -0
- 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 +69 -69
- package/src/__tests__/publish.test.ts +138 -97
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/worker-namespace.test.ts +1 -0
- package/src/d1/backups.tsx +15 -11
- package/src/d1/create.tsx +20 -16
- package/src/d1/execute.tsx +21 -18
- package/src/d1/list.tsx +2 -2
- package/src/d1/migrations/apply.tsx +33 -28
- package/src/d1/migrations/create.tsx +15 -12
- package/src/d1/migrations/list.tsx +10 -7
- package/src/pages/deployments.tsx +3 -5
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/projects.tsx +2 -5
- package/src/pages/upload.tsx +29 -9
- package/src/utils/render.ts +93 -0
- package/templates/d1-beta-facade.js +3 -0
- package/wrangler-dist/cli.js +225 -146
|
@@ -129,6 +129,7 @@ describe("init", () => {
|
|
|
129
129
|
Object {
|
|
130
130
|
"debug": "",
|
|
131
131
|
"err": "",
|
|
132
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
132
133
|
"out": "✨ Created wrangler.toml
|
|
133
134
|
✨ Initialized git repository
|
|
134
135
|
✨ Created package.json
|
|
@@ -211,13 +212,14 @@ describe("init", () => {
|
|
|
211
212
|
});
|
|
212
213
|
|
|
213
214
|
expect(std).toMatchInlineSnapshot(`
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
Object {
|
|
216
|
+
"debug": "",
|
|
217
|
+
"err": "",
|
|
218
|
+
"info": "",
|
|
219
|
+
"out": "✨ Created wrangler.toml",
|
|
220
|
+
"warn": "",
|
|
221
|
+
}
|
|
222
|
+
`);
|
|
221
223
|
});
|
|
222
224
|
|
|
223
225
|
it("should create a wrangler.toml and a directory for a named Worker ", async () => {
|
|
@@ -245,13 +247,14 @@ describe("init", () => {
|
|
|
245
247
|
});
|
|
246
248
|
|
|
247
249
|
expect(std).toMatchInlineSnapshot(`
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
Object {
|
|
251
|
+
"debug": "",
|
|
252
|
+
"err": "",
|
|
253
|
+
"info": "",
|
|
254
|
+
"out": "✨ Created my-worker/wrangler.toml",
|
|
255
|
+
"warn": "",
|
|
256
|
+
}
|
|
257
|
+
`);
|
|
255
258
|
});
|
|
256
259
|
|
|
257
260
|
it("should display warning when wrangler.toml already exists, and exit if user does not want to carry on", async () => {
|
|
@@ -283,15 +286,16 @@ describe("init", () => {
|
|
|
283
286
|
});
|
|
284
287
|
|
|
285
288
|
expect(std).toMatchInlineSnapshot(`
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
Object {
|
|
290
|
+
"debug": "",
|
|
291
|
+
"err": "",
|
|
292
|
+
"info": "",
|
|
293
|
+
"out": "",
|
|
294
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mwrangler.toml already exists![0m
|
|
295
|
+
|
|
296
|
+
",
|
|
297
|
+
}
|
|
298
|
+
`);
|
|
295
299
|
});
|
|
296
300
|
|
|
297
301
|
it("should display warning when wrangler.toml already exists in the target directory, and exit if user does not want to carry on", async () => {
|
|
@@ -323,6 +327,7 @@ describe("init", () => {
|
|
|
323
327
|
Object {
|
|
324
328
|
"debug": "",
|
|
325
329
|
"err": "",
|
|
330
|
+
"info": "",
|
|
326
331
|
"out": "",
|
|
327
332
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mpath/to/worker/wrangler.toml already exists![0m
|
|
328
333
|
|
|
@@ -418,6 +423,7 @@ describe("init", () => {
|
|
|
418
423
|
Object {
|
|
419
424
|
"debug": "",
|
|
420
425
|
"err": "",
|
|
426
|
+
"info": "",
|
|
421
427
|
"out": "",
|
|
422
428
|
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mwrangler.toml already exists![0m
|
|
423
429
|
|
|
@@ -541,14 +547,15 @@ describe("init", () => {
|
|
|
541
547
|
},
|
|
542
548
|
});
|
|
543
549
|
expect(std).toMatchInlineSnapshot(`
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
550
|
+
Object {
|
|
551
|
+
"debug": "",
|
|
552
|
+
"err": "",
|
|
553
|
+
"info": "",
|
|
554
|
+
"out": "✨ Created wrangler.toml
|
|
555
|
+
✨ Initialized git repository",
|
|
556
|
+
"warn": "",
|
|
557
|
+
}
|
|
558
|
+
`);
|
|
552
559
|
expect((await execa("git", ["branch", "--show-current"])).stdout).toEqual(
|
|
553
560
|
getDefaultBranchName()
|
|
554
561
|
);
|
|
@@ -576,6 +583,7 @@ describe("init", () => {
|
|
|
576
583
|
Object {
|
|
577
584
|
"debug": "",
|
|
578
585
|
"err": "",
|
|
586
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
579
587
|
"out": "✨ Created wrangler.toml
|
|
580
588
|
✨ Created package.json
|
|
581
589
|
✨ Created tsconfig.json
|
|
@@ -603,6 +611,7 @@ describe("init", () => {
|
|
|
603
611
|
Object {
|
|
604
612
|
"debug": "",
|
|
605
613
|
"err": "",
|
|
614
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
606
615
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
607
616
|
✨ Created path/to/worker/my-worker/package.json
|
|
608
617
|
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
@@ -639,6 +648,7 @@ describe("init", () => {
|
|
|
639
648
|
Object {
|
|
640
649
|
"debug": "",
|
|
641
650
|
"err": "",
|
|
651
|
+
"info": "",
|
|
642
652
|
"out": "✨ Created wrangler.toml
|
|
643
653
|
✨ Initialized git repository",
|
|
644
654
|
"warn": "",
|
|
@@ -693,14 +703,15 @@ describe("init", () => {
|
|
|
693
703
|
});
|
|
694
704
|
expect(mockPackageManager.install).toHaveBeenCalled();
|
|
695
705
|
expect(std).toMatchInlineSnapshot(`
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
706
|
+
Object {
|
|
707
|
+
"debug": "",
|
|
708
|
+
"err": "",
|
|
709
|
+
"info": "",
|
|
710
|
+
"out": "✨ Created wrangler.toml
|
|
711
|
+
✨ Created package.json",
|
|
712
|
+
"warn": "",
|
|
713
|
+
}
|
|
714
|
+
`);
|
|
704
715
|
});
|
|
705
716
|
|
|
706
717
|
it("should create a package.json, with the specified name, if none is found and user confirms", async () => {
|
|
@@ -744,14 +755,15 @@ describe("init", () => {
|
|
|
744
755
|
},
|
|
745
756
|
});
|
|
746
757
|
expect(std).toMatchInlineSnapshot(`
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
758
|
+
Object {
|
|
759
|
+
"debug": "",
|
|
760
|
+
"err": "",
|
|
761
|
+
"info": "",
|
|
762
|
+
"out": "✨ Created my-worker/wrangler.toml
|
|
763
|
+
✨ Created my-worker/package.json",
|
|
764
|
+
"warn": "",
|
|
765
|
+
}
|
|
766
|
+
`);
|
|
755
767
|
});
|
|
756
768
|
|
|
757
769
|
it("should not touch an existing package.json in the same directory", async () => {
|
|
@@ -793,6 +805,7 @@ describe("init", () => {
|
|
|
793
805
|
Object {
|
|
794
806
|
"debug": "",
|
|
795
807
|
"err": "",
|
|
808
|
+
"info": "",
|
|
796
809
|
"out": "✨ Created wrangler.toml",
|
|
797
810
|
"warn": "",
|
|
798
811
|
}
|
|
@@ -846,6 +859,7 @@ describe("init", () => {
|
|
|
846
859
|
Object {
|
|
847
860
|
"debug": "",
|
|
848
861
|
"err": "",
|
|
862
|
+
"info": "",
|
|
849
863
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
850
864
|
✨ Created path/to/worker/my-worker/package.json",
|
|
851
865
|
"warn": "",
|
|
@@ -896,14 +910,15 @@ describe("init", () => {
|
|
|
896
910
|
`wrangler@${wranglerVersion}`
|
|
897
911
|
);
|
|
898
912
|
expect(std).toMatchInlineSnapshot(`
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
913
|
+
Object {
|
|
914
|
+
"debug": "",
|
|
915
|
+
"err": "",
|
|
916
|
+
"info": "",
|
|
917
|
+
"out": "✨ Created wrangler.toml
|
|
918
|
+
✨ Installed wrangler into devDependencies",
|
|
919
|
+
"warn": "",
|
|
920
|
+
}
|
|
921
|
+
`);
|
|
907
922
|
});
|
|
908
923
|
|
|
909
924
|
it("should offer to install wrangler into a package.json relative to the target directory, if no name is provided", async () => {
|
|
@@ -956,14 +971,15 @@ describe("init", () => {
|
|
|
956
971
|
);
|
|
957
972
|
expect(mockPackageManager.cwd).toBe(process.cwd());
|
|
958
973
|
expect(std).toMatchInlineSnapshot(`
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
974
|
+
Object {
|
|
975
|
+
"debug": "",
|
|
976
|
+
"err": "",
|
|
977
|
+
"info": "",
|
|
978
|
+
"out": "✨ Created wrangler.toml
|
|
979
|
+
✨ Installed wrangler into devDependencies",
|
|
980
|
+
"warn": "",
|
|
981
|
+
}
|
|
982
|
+
`);
|
|
967
983
|
});
|
|
968
984
|
|
|
969
985
|
it("should not touch an existing package.json in an ancestor directory", async () => {
|
|
@@ -1015,6 +1031,7 @@ describe("init", () => {
|
|
|
1015
1031
|
Object {
|
|
1016
1032
|
"debug": "",
|
|
1017
1033
|
"err": "",
|
|
1034
|
+
"info": "",
|
|
1018
1035
|
"out": "✨ Created wrangler.toml",
|
|
1019
1036
|
"warn": "",
|
|
1020
1037
|
}
|
|
@@ -1070,17 +1087,18 @@ describe("init", () => {
|
|
|
1070
1087
|
},
|
|
1071
1088
|
});
|
|
1072
1089
|
expect(std).toMatchInlineSnapshot(`
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1090
|
+
Object {
|
|
1091
|
+
"debug": "",
|
|
1092
|
+
"err": "",
|
|
1093
|
+
"info": "",
|
|
1094
|
+
"out": "✨ Created wrangler.toml
|
|
1095
|
+
✨ Created src/index.js
|
|
1078
1096
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1097
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1098
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
1099
|
+
"warn": "",
|
|
1100
|
+
}
|
|
1101
|
+
`);
|
|
1084
1102
|
});
|
|
1085
1103
|
|
|
1086
1104
|
it("should offer to create a worker in a typescript project", async () => {
|
|
@@ -1129,6 +1147,7 @@ describe("init", () => {
|
|
|
1129
1147
|
Object {
|
|
1130
1148
|
"debug": "",
|
|
1131
1149
|
"err": "",
|
|
1150
|
+
"info": "",
|
|
1132
1151
|
"out": "✨ Created wrangler.toml
|
|
1133
1152
|
✨ Created tsconfig.json
|
|
1134
1153
|
✨ Created src/index.ts
|
|
@@ -1308,6 +1327,7 @@ describe("init", () => {
|
|
|
1308
1327
|
Object {
|
|
1309
1328
|
"debug": "",
|
|
1310
1329
|
"err": "",
|
|
1330
|
+
"info": "",
|
|
1311
1331
|
"out": "✨ Created wrangler.toml
|
|
1312
1332
|
✨ Created tsconfig.json
|
|
1313
1333
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
@@ -1352,6 +1372,7 @@ describe("init", () => {
|
|
|
1352
1372
|
Object {
|
|
1353
1373
|
"debug": "",
|
|
1354
1374
|
"err": "",
|
|
1375
|
+
"info": "",
|
|
1355
1376
|
"out": "✨ Created my-worker/wrangler.toml
|
|
1356
1377
|
✨ Created my-worker/package.json
|
|
1357
1378
|
✨ Created my-worker/tsconfig.json
|
|
@@ -1408,6 +1429,7 @@ describe("init", () => {
|
|
|
1408
1429
|
Object {
|
|
1409
1430
|
"debug": "",
|
|
1410
1431
|
"err": "",
|
|
1432
|
+
"info": "",
|
|
1411
1433
|
"out": "✨ Created wrangler.toml
|
|
1412
1434
|
✨ Created package.json
|
|
1413
1435
|
✨ Created tsconfig.json
|
|
@@ -1462,6 +1484,7 @@ describe("init", () => {
|
|
|
1462
1484
|
Object {
|
|
1463
1485
|
"debug": "",
|
|
1464
1486
|
"err": "",
|
|
1487
|
+
"info": "",
|
|
1465
1488
|
"out": "✨ Created wrangler.toml
|
|
1466
1489
|
✨ Created src/index.ts
|
|
1467
1490
|
✨ Created src/index.test.ts
|
|
@@ -1533,6 +1556,7 @@ describe("init", () => {
|
|
|
1533
1556
|
Object {
|
|
1534
1557
|
"debug": "",
|
|
1535
1558
|
"err": "",
|
|
1559
|
+
"info": "",
|
|
1536
1560
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
1537
1561
|
✨ Created path/to/worker/my-worker/package.json
|
|
1538
1562
|
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
@@ -1594,15 +1618,16 @@ describe("init", () => {
|
|
|
1594
1618
|
"@cloudflare/workers-types"
|
|
1595
1619
|
);
|
|
1596
1620
|
expect(std).toMatchInlineSnapshot(`
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1621
|
+
Object {
|
|
1622
|
+
"debug": "",
|
|
1623
|
+
"err": "",
|
|
1624
|
+
"info": "",
|
|
1625
|
+
"out": "✨ Created wrangler.toml
|
|
1626
|
+
✨ Installed @cloudflare/workers-types into devDependencies
|
|
1627
|
+
🚨 Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1628
|
+
"warn": "",
|
|
1629
|
+
}
|
|
1630
|
+
`);
|
|
1606
1631
|
});
|
|
1607
1632
|
|
|
1608
1633
|
it("should not touch an existing tsconfig.json in an ancestor directory", async () => {
|
|
@@ -1652,6 +1677,7 @@ describe("init", () => {
|
|
|
1652
1677
|
Object {
|
|
1653
1678
|
"debug": "",
|
|
1654
1679
|
"err": "",
|
|
1680
|
+
"info": "",
|
|
1655
1681
|
"out": "✨ Created wrangler.toml
|
|
1656
1682
|
✨ Created src/index.ts
|
|
1657
1683
|
✨ Created src/index.test.ts
|
|
@@ -1942,13 +1968,14 @@ describe("init", () => {
|
|
|
1942
1968
|
},
|
|
1943
1969
|
});
|
|
1944
1970
|
expect(std).toMatchInlineSnapshot(`
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1971
|
+
Object {
|
|
1972
|
+
"debug": "",
|
|
1973
|
+
"err": "",
|
|
1974
|
+
"info": "",
|
|
1975
|
+
"out": "✨ Created wrangler.toml",
|
|
1976
|
+
"warn": "",
|
|
1977
|
+
}
|
|
1978
|
+
`);
|
|
1952
1979
|
});
|
|
1953
1980
|
|
|
1954
1981
|
it("should not offer to create a worker in a non-ts named worker project if a file already exists at the location", async () => {
|
|
@@ -1988,13 +2015,14 @@ describe("init", () => {
|
|
|
1988
2015
|
},
|
|
1989
2016
|
});
|
|
1990
2017
|
expect(std).toMatchInlineSnapshot(`
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2018
|
+
Object {
|
|
2019
|
+
"debug": "",
|
|
2020
|
+
"err": "",
|
|
2021
|
+
"info": "",
|
|
2022
|
+
"out": "✨ Created my-worker/wrangler.toml",
|
|
2023
|
+
"warn": "",
|
|
2024
|
+
}
|
|
2025
|
+
`);
|
|
1998
2026
|
});
|
|
1999
2027
|
});
|
|
2000
2028
|
|
|
@@ -2042,6 +2070,7 @@ describe("init", () => {
|
|
|
2042
2070
|
Object {
|
|
2043
2071
|
"debug": "",
|
|
2044
2072
|
"err": "",
|
|
2073
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
2045
2074
|
"out": "✨ Created wrangler.toml
|
|
2046
2075
|
✨ Initialized git repository
|
|
2047
2076
|
✨ Created package.json
|
|
@@ -2073,6 +2102,7 @@ describe("init", () => {
|
|
|
2073
2102
|
Object {
|
|
2074
2103
|
"debug": "",
|
|
2075
2104
|
"err": "",
|
|
2105
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
2076
2106
|
"out": "✨ Created path/to/worker/wrangler.toml
|
|
2077
2107
|
✨ Initialized git repository at path/to/worker
|
|
2078
2108
|
✨ Created path/to/worker/package.json
|
|
@@ -2104,6 +2134,7 @@ describe("init", () => {
|
|
|
2104
2134
|
Object {
|
|
2105
2135
|
"debug": "",
|
|
2106
2136
|
"err": "",
|
|
2137
|
+
"info": "Your project will use Vitest to run your tests.",
|
|
2107
2138
|
"out": "✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/wrangler.toml
|
|
2108
2139
|
✨ Initialized git repository at WEIRD_w0rkr_N4m3.js.tsx.tar.gz
|
|
2109
2140
|
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/package.json
|
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -972,13 +972,14 @@ describe("wrangler", () => {
|
|
|
972
972
|
);
|
|
973
973
|
expect(proc.write).not.toEqual(Buffer.from("my-value"));
|
|
974
974
|
expect(std).toMatchInlineSnapshot(`
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
975
|
+
Object {
|
|
976
|
+
"debug": "",
|
|
977
|
+
"err": "",
|
|
978
|
+
"info": "",
|
|
979
|
+
"out": "my-value",
|
|
980
|
+
"warn": "",
|
|
981
|
+
}
|
|
982
|
+
`);
|
|
982
983
|
});
|
|
983
984
|
|
|
984
985
|
it("should get a binary and decode as utf8 text, resulting in improper decoding", async () => {
|
|
@@ -997,7 +998,7 @@ describe("wrangler", () => {
|
|
|
997
998
|
);
|
|
998
999
|
expect(proc.write).not.toEqual(buf);
|
|
999
1000
|
expect(JSON.stringify(std)).toMatchInlineSnapshot(
|
|
1000
|
-
`"{\\"debug\\":\\"\\",\\"out\\":\\"�PNG\\\\n\\\\u001a\\\\n\\\\u0000\\\\u0000\\\\u0000\\\\rIHDR\\\\u0000\\\\u0000\\\\u0000\\\\n\\\\u0000\\\\u0000\\\\u0000\\\\n\\\\b\\\\u0006\\\\u0000\\\\u0000\\\\u0000�2Ͻ\\\\u0000\\\\u0000\\\\u0000\\\\tpHYs\\\\u0000\\\\u0000\\\\u000b\\\\u0013\\\\u0000\\\\u0000\\\\u000b\\\\u0013\\\\u0001\\\\u0000��\\\\u0018\\\\u0000\\\\u0000\\\\u0000\\\\u0001sRGB\\\\u0000��\\\\u001c�\\\\u0000\\\\u0000\\\\u0000\\\\u0004gAMA\\\\u0000\\\\u0000��\\\\u000b�a\\\\u0005\\\\u0000\\\\u0000\\\\u0000\\\\\\"IDATx\\\\u0001��1\\\\u0011\\\\u0000\\\\u0000\\\\b���π\\\\u0003:tl.����\\\\u0005z�\\\\u0002=�\\\\u0002\\\\u0012\\\\u0005O�1\\\\u0000\\\\u0000\\\\u0000\\\\u0000IEND�B\`�\\",\\"err\\":\\"\\",\\"warn\\":\\"\\"}"`
|
|
1001
|
+
`"{\\"debug\\":\\"\\",\\"out\\":\\"�PNG\\\\n\\\\u001a\\\\n\\\\u0000\\\\u0000\\\\u0000\\\\rIHDR\\\\u0000\\\\u0000\\\\u0000\\\\n\\\\u0000\\\\u0000\\\\u0000\\\\n\\\\b\\\\u0006\\\\u0000\\\\u0000\\\\u0000�2Ͻ\\\\u0000\\\\u0000\\\\u0000\\\\tpHYs\\\\u0000\\\\u0000\\\\u000b\\\\u0013\\\\u0000\\\\u0000\\\\u000b\\\\u0013\\\\u0001\\\\u0000��\\\\u0018\\\\u0000\\\\u0000\\\\u0000\\\\u0001sRGB\\\\u0000��\\\\u001c�\\\\u0000\\\\u0000\\\\u0000\\\\u0004gAMA\\\\u0000\\\\u0000��\\\\u000b�a\\\\u0005\\\\u0000\\\\u0000\\\\u0000\\\\\\"IDATx\\\\u0001��1\\\\u0011\\\\u0000\\\\u0000\\\\b���π\\\\u0003:tl.����\\\\u0005z�\\\\u0002=�\\\\u0002\\\\u0012\\\\u0005O�1\\\\u0000\\\\u0000\\\\u0000\\\\u0000IEND�B\`�\\",\\"info\\":\\"\\",\\"err\\":\\"\\",\\"warn\\":\\"\\"}"`
|
|
1001
1002
|
);
|
|
1002
1003
|
});
|
|
1003
1004
|
|
|
@@ -1718,7 +1719,6 @@ function setMockFetchKVGetValue(
|
|
|
1718
1719
|
rest.get(
|
|
1719
1720
|
"*/accounts/:accountId/storage/kv/namespaces/:namespaceId/values/:key",
|
|
1720
1721
|
(req, res, ctx) => {
|
|
1721
|
-
console.dir(req.params);
|
|
1722
1722
|
expect(req.params.accountId).toEqual(accountId);
|
|
1723
1723
|
expect(req.params.namespaceId).toEqual(namespaceId);
|
|
1724
1724
|
// Getting the key from params decodes it so we need to grab the encoded key from the URL
|
|
@@ -19,7 +19,7 @@ describe("run scheduled events with middleware", () => {
|
|
|
19
19
|
return new Response("Hello world!");
|
|
20
20
|
},
|
|
21
21
|
scheduled(controller, env, ctx) {
|
|
22
|
-
|
|
22
|
+
// Doing something scheduled in modules...
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
`;
|
|
@@ -80,7 +80,7 @@ describe("run scheduled events with middleware", () => {
|
|
|
80
80
|
beforeEach(() => {
|
|
81
81
|
const scriptContent = `
|
|
82
82
|
addEventListener("scheduled", (event) => {
|
|
83
|
-
|
|
83
|
+
// Doing something scheduled in service worker...
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
addEventListener("fetch", (event) => {
|
|
@@ -51,7 +51,7 @@ describe("workers change behaviour with middleware with wrangler dev", () => {
|
|
|
51
51
|
export default {
|
|
52
52
|
middleware: [middleware],
|
|
53
53
|
scheduled(controller, env, ctx) {
|
|
54
|
-
|
|
54
|
+
// Scheduled worker called
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
@@ -178,7 +178,7 @@ describe("workers change behaviour with middleware with wrangler dev", () => {
|
|
|
178
178
|
addMiddleware(middleware);
|
|
179
179
|
|
|
180
180
|
addEventListener("scheduled", (event) => {
|
|
181
|
-
|
|
181
|
+
// Scheduled worker called
|
|
182
182
|
});
|
|
183
183
|
`;
|
|
184
184
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
2
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
3
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
3
4
|
import { mockAccountId, mockApiToken } from "./../helpers/mock-account-id";
|
|
4
5
|
import { msw } from "./../helpers/msw";
|
|
5
6
|
import { runInTempDir } from "./../helpers/run-in-tmp";
|
|
@@ -10,6 +11,7 @@ describe("deployment list", () => {
|
|
|
10
11
|
runInTempDir();
|
|
11
12
|
mockAccountId();
|
|
12
13
|
mockApiToken();
|
|
14
|
+
mockConsoleMethods();
|
|
13
15
|
|
|
14
16
|
afterEach(async () => {
|
|
15
17
|
// Force a tick to ensure that all promises resolve
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
2
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
3
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
3
4
|
import { mockAccountId, mockApiToken } from "./../helpers/mock-account-id";
|
|
4
5
|
import { msw } from "./../helpers/msw";
|
|
5
6
|
import { runInTempDir } from "./../helpers/run-in-tmp";
|
|
@@ -8,6 +9,7 @@ import type { Project } from "./../../pages/types";
|
|
|
8
9
|
|
|
9
10
|
describe("project list", () => {
|
|
10
11
|
runInTempDir();
|
|
12
|
+
mockConsoleMethods();
|
|
11
13
|
mockAccountId();
|
|
12
14
|
mockApiToken();
|
|
13
15
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
1
|
+
// /* eslint-disable no-shadow */
|
|
2
2
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { rest } from "msw";
|
|
4
4
|
import { endEventLoop } from "../helpers/end-event-loop";
|
|
5
|
+
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id";
|
|
6
|
+
import { mockConsoleMethods } from "../helpers/mock-console";
|
|
5
7
|
import { mockGetUploadTokenRequest } from "../helpers/mock-get-pages-upload-token";
|
|
6
8
|
import { mockSetTimeout } from "../helpers/mock-set-timeout";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { runWrangler } from "./../helpers/run-wrangler";
|
|
12
|
-
import type { UploadPayloadFile } from "./../../pages/types";
|
|
9
|
+
import { msw } from "../helpers/msw";
|
|
10
|
+
import { runInTempDir } from "../helpers/run-in-tmp";
|
|
11
|
+
import { runWrangler } from "../helpers/run-wrangler";
|
|
12
|
+
import type { UploadPayloadFile } from "../../pages/types";
|
|
13
13
|
import type { RestRequest } from "msw";
|
|
14
14
|
|
|
15
15
|
describe("project upload", () => {
|
|
@@ -92,11 +92,11 @@ describe("project upload", () => {
|
|
|
92
92
|
|
|
93
93
|
await runWrangler("pages project upload .");
|
|
94
94
|
|
|
95
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
96
|
-
|
|
95
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
96
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
✨ Upload complete!"
|
|
99
|
+
`);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it("should avoid uploading some files", async () => {
|
|
@@ -172,7 +172,7 @@ describe("project upload", () => {
|
|
|
172
172
|
|
|
173
173
|
const requestMap = resolvedRequests.reduce<{
|
|
174
174
|
[key: string]: UploadPayloadFile;
|
|
175
|
-
}>((
|
|
175
|
+
}>((map, req) => Object.assign(map, { [req.key]: req }), {});
|
|
176
176
|
|
|
177
177
|
for (const req of requests) {
|
|
178
178
|
expect(req.headers.get("Authorization")).toBe(
|
|
@@ -209,11 +209,11 @@ describe("project upload", () => {
|
|
|
209
209
|
value: "ZnVuYw==",
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
213
|
-
|
|
212
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
213
|
+
"✨ Success! Uploaded 3 files (TIMINGS)
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
✨ Upload complete!"
|
|
216
|
+
`);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
it("should retry uploads", async () => {
|
|
@@ -296,11 +296,11 @@ describe("project upload", () => {
|
|
|
296
296
|
]);
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
300
|
-
|
|
299
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
300
|
+
"✨ Success! Uploaded 1 files (TIMINGS)
|
|
301
301
|
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
✨ Upload complete!"
|
|
303
|
+
`);
|
|
304
304
|
});
|
|
305
305
|
|
|
306
306
|
it("should try to use multiple buckets (up to the max concurrency)", async () => {
|
|
@@ -402,11 +402,11 @@ describe("project upload", () => {
|
|
|
402
402
|
])
|
|
403
403
|
);
|
|
404
404
|
|
|
405
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
406
|
-
|
|
405
|
+
expect(normalizeProgressSteps(std.out)).toMatchInlineSnapshot(`
|
|
406
|
+
"✨ Success! Uploaded 4 files (TIMINGS)
|
|
407
407
|
|
|
408
|
-
|
|
409
|
-
|
|
408
|
+
✨ Upload complete!"
|
|
409
|
+
`);
|
|
410
410
|
});
|
|
411
411
|
|
|
412
412
|
it("should not error when directory names contain periods and houses a extensionless file", async () => {
|
|
@@ -479,3 +479,22 @@ describe("project upload", () => {
|
|
|
479
479
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
480
480
|
});
|
|
481
481
|
});
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* When uploading assets we print out progress messages that look like:
|
|
485
|
+
*
|
|
486
|
+
* Uploading... (1/4)
|
|
487
|
+
* Uploading... (2/4)
|
|
488
|
+
* Uploading... (4/4)
|
|
489
|
+
*
|
|
490
|
+
* Note that we don't always get a progress message for every item uploaded.
|
|
491
|
+
* These upload counts are not deterministic and can change from test run to test run.
|
|
492
|
+
*
|
|
493
|
+
* Also if you run the tests in --runInBand mode then we never see any of
|
|
494
|
+
* these progress messages in the tests!!
|
|
495
|
+
*
|
|
496
|
+
* So this helper removes these message from the snapshots to keep them consistent.
|
|
497
|
+
*/
|
|
498
|
+
export function normalizeProgressSteps(str: string): string {
|
|
499
|
+
return str.replace(/Uploading... \(\d\/\d\)\r?\n?/g, "");
|
|
500
|
+
}
|