wrangler 2.0.7 → 2.0.8
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/README.md +1 -1
- package/bin/wrangler.js +16 -4
- package/package.json +2 -2
- package/src/__tests__/configuration.test.ts +131 -70
- package/src/__tests__/dev.test.tsx +97 -8
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/init.test.ts +188 -111
- package/src/__tests__/kv.test.ts +8 -8
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +17 -17
- package/src/__tests__/publish.test.ts +71 -13
- package/src/__tests__/secret.test.ts +4 -4
- package/src/cfetch/index.ts +17 -2
- package/src/cfetch/internal.ts +6 -0
- package/src/config/validation.ts +59 -33
- package/src/dev/dev.tsx +0 -3
- package/src/dialogs.tsx +48 -0
- package/src/index.tsx +159 -84
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +4 -0
- package/src/sites.tsx +6 -1
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/wrangler-dist/cli.js +307 -175
|
@@ -7,9 +7,15 @@ import { parseConfigFileTextToJson } from "typescript";
|
|
|
7
7
|
import { version as wranglerVersion } from "../../package.json";
|
|
8
8
|
import { getPackageManager } from "../package-manager";
|
|
9
9
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
mockConfirm,
|
|
12
|
+
clearConfirmMocks,
|
|
13
|
+
mockSelect,
|
|
14
|
+
clearSelectMocks,
|
|
15
|
+
} from "./helpers/mock-dialogs";
|
|
11
16
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
12
17
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
18
|
+
import type { RawConfig } from "../config";
|
|
13
19
|
import type { PackageManager } from "../package-manager";
|
|
14
20
|
|
|
15
21
|
describe("init", () => {
|
|
@@ -29,6 +35,7 @@ describe("init", () => {
|
|
|
29
35
|
|
|
30
36
|
afterEach(() => {
|
|
31
37
|
clearConfirmMocks();
|
|
38
|
+
clearSelectMocks();
|
|
32
39
|
});
|
|
33
40
|
|
|
34
41
|
const std = mockConsoleMethods();
|
|
@@ -51,7 +58,7 @@ describe("init", () => {
|
|
|
51
58
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
52
59
|
|
|
53
60
|
To start developing your Worker, run \`npm start\`
|
|
54
|
-
To publish your Worker to the Internet, run \`npm run
|
|
61
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
55
62
|
`);
|
|
56
63
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
57
64
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -78,7 +85,7 @@ describe("init", () => {
|
|
|
78
85
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
79
86
|
|
|
80
87
|
To start developing your Worker, run \`cd my-worker && npm start\`
|
|
81
|
-
To publish your Worker to the Internet, run \`npm run
|
|
88
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
82
89
|
`);
|
|
83
90
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
84
91
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -104,7 +111,7 @@ describe("init", () => {
|
|
|
104
111
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
105
112
|
|
|
106
113
|
To start developing your Worker, run \`npm start\`
|
|
107
|
-
To publish your Worker to the Internet, run \`npm run
|
|
114
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
108
115
|
"warn": "",
|
|
109
116
|
}
|
|
110
117
|
`);
|
|
@@ -287,13 +294,14 @@ describe("init", () => {
|
|
|
287
294
|
{
|
|
288
295
|
text: "Would you like to use TypeScript?",
|
|
289
296
|
result: true,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
293
|
-
result: true,
|
|
294
297
|
}
|
|
295
298
|
);
|
|
296
299
|
|
|
300
|
+
mockSelect({
|
|
301
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
302
|
+
result: "fetch",
|
|
303
|
+
});
|
|
304
|
+
|
|
297
305
|
await runWrangler("init");
|
|
298
306
|
expect(fs.readFileSync("./wrangler.toml", "utf-8")).toMatchInlineSnapshot(
|
|
299
307
|
`"compatibility_date=\\"something-else\\""`
|
|
@@ -335,6 +343,72 @@ describe("init", () => {
|
|
|
335
343
|
}
|
|
336
344
|
`);
|
|
337
345
|
});
|
|
346
|
+
|
|
347
|
+
it("should not add a Cron Trigger to wrangler.toml when creating a Scheduled Worker if wrangler.toml already exists", async () => {
|
|
348
|
+
fs.writeFileSync(
|
|
349
|
+
"./wrangler.toml",
|
|
350
|
+
'compatibility_date="something-else"', // use a fake value to make sure the file is not overwritten
|
|
351
|
+
"utf-8"
|
|
352
|
+
);
|
|
353
|
+
mockConfirm(
|
|
354
|
+
{
|
|
355
|
+
text: "Would you like to use git to manage this Worker?",
|
|
356
|
+
result: true,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
text: "Do you want to continue initializing this project?",
|
|
360
|
+
result: true,
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
text: "No package.json found. Would you like to create one?",
|
|
364
|
+
result: true,
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
text: "Would you like to use TypeScript?",
|
|
368
|
+
result: true,
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
mockSelect({
|
|
373
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
374
|
+
result: "scheduled",
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
await runWrangler("init");
|
|
378
|
+
expect(fs.readFileSync("./wrangler.toml", "utf-8")).toMatchInlineSnapshot(
|
|
379
|
+
`"compatibility_date=\\"something-else\\""`
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("should add a Cron Trigger to wrangler.toml when creating a Scheduled Worker, but only if wrangler.toml is being created during init", async () => {
|
|
384
|
+
mockConfirm(
|
|
385
|
+
{
|
|
386
|
+
text: "Would you like to use git to manage this Worker?",
|
|
387
|
+
result: true,
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
text: "No package.json found. Would you like to create one?",
|
|
391
|
+
result: true,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
text: "Would you like to use TypeScript?",
|
|
395
|
+
result: true,
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
mockSelect({
|
|
400
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
401
|
+
result: "scheduled",
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
await runWrangler("init");
|
|
405
|
+
const parsed = TOML.parse(
|
|
406
|
+
await fsp.readFile("./wrangler.toml", "utf-8")
|
|
407
|
+
) as RawConfig;
|
|
408
|
+
expect(typeof parsed.compatibility_date).toBe("string");
|
|
409
|
+
expect(parsed.name).toContain("wrangler-tests");
|
|
410
|
+
expect(parsed?.triggers?.crons[0]).toEqual("1 * * * *");
|
|
411
|
+
});
|
|
338
412
|
});
|
|
339
413
|
|
|
340
414
|
describe("git init", () => {
|
|
@@ -381,7 +455,7 @@ describe("init", () => {
|
|
|
381
455
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
382
456
|
|
|
383
457
|
To start developing your Worker, run \`npm start\`
|
|
384
|
-
To publish your Worker to the Internet, run \`npm run
|
|
458
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
385
459
|
"warn": "",
|
|
386
460
|
}
|
|
387
461
|
`);
|
|
@@ -406,7 +480,7 @@ describe("init", () => {
|
|
|
406
480
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
407
481
|
|
|
408
482
|
To start developing your Worker, run \`cd path/to/worker/my-worker && npm start\`
|
|
409
|
-
To publish your Worker to the Internet, run \`npm run
|
|
483
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
410
484
|
"warn": "",
|
|
411
485
|
}
|
|
412
486
|
`);
|
|
@@ -459,12 +533,12 @@ describe("init", () => {
|
|
|
459
533
|
{
|
|
460
534
|
text: "Would you like to use TypeScript?",
|
|
461
535
|
result: false,
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
465
|
-
result: false,
|
|
466
536
|
}
|
|
467
537
|
);
|
|
538
|
+
mockSelect({
|
|
539
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
540
|
+
result: "none",
|
|
541
|
+
});
|
|
468
542
|
await runWrangler("init");
|
|
469
543
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
470
544
|
const packageJson = JSON.parse(
|
|
@@ -501,12 +575,12 @@ describe("init", () => {
|
|
|
501
575
|
{
|
|
502
576
|
text: "Would you like to use TypeScript?",
|
|
503
577
|
result: false,
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
507
|
-
result: false,
|
|
508
578
|
}
|
|
509
579
|
);
|
|
580
|
+
mockSelect({
|
|
581
|
+
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
582
|
+
result: "none",
|
|
583
|
+
});
|
|
510
584
|
await runWrangler("init my-worker");
|
|
511
585
|
const packageJson = JSON.parse(
|
|
512
586
|
fs.readFileSync("./my-worker/package.json", "utf-8")
|
|
@@ -536,12 +610,12 @@ describe("init", () => {
|
|
|
536
610
|
{
|
|
537
611
|
text: "Would you like to use TypeScript?",
|
|
538
612
|
result: false,
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
542
|
-
result: false,
|
|
543
613
|
}
|
|
544
614
|
);
|
|
615
|
+
mockSelect({
|
|
616
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
617
|
+
result: "none",
|
|
618
|
+
});
|
|
545
619
|
|
|
546
620
|
fs.writeFileSync(
|
|
547
621
|
"./package.json",
|
|
@@ -578,13 +652,14 @@ describe("init", () => {
|
|
|
578
652
|
{
|
|
579
653
|
text: "Would you like to use TypeScript?",
|
|
580
654
|
result: false,
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
584
|
-
result: false,
|
|
585
655
|
}
|
|
586
656
|
);
|
|
587
657
|
|
|
658
|
+
mockSelect({
|
|
659
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
660
|
+
result: "none",
|
|
661
|
+
});
|
|
662
|
+
|
|
588
663
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
589
664
|
fs.writeFileSync(
|
|
590
665
|
"path/to/worker/package.json",
|
|
@@ -621,13 +696,14 @@ describe("init", () => {
|
|
|
621
696
|
{
|
|
622
697
|
text: "Would you like to use TypeScript?",
|
|
623
698
|
result: false,
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
627
|
-
result: false,
|
|
628
699
|
}
|
|
629
700
|
);
|
|
630
701
|
|
|
702
|
+
mockSelect({
|
|
703
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
704
|
+
result: "none",
|
|
705
|
+
});
|
|
706
|
+
|
|
631
707
|
fs.writeFileSync(
|
|
632
708
|
"./package.json",
|
|
633
709
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -667,13 +743,14 @@ describe("init", () => {
|
|
|
667
743
|
{
|
|
668
744
|
text: "Would you like to use TypeScript?",
|
|
669
745
|
result: false,
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
673
|
-
result: false,
|
|
674
746
|
}
|
|
675
747
|
);
|
|
676
748
|
|
|
749
|
+
mockSelect({
|
|
750
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
751
|
+
result: "none",
|
|
752
|
+
});
|
|
753
|
+
|
|
677
754
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
678
755
|
fs.writeFileSync(
|
|
679
756
|
"path/to/worker/package.json",
|
|
@@ -715,13 +792,14 @@ describe("init", () => {
|
|
|
715
792
|
{
|
|
716
793
|
text: "Would you like to use TypeScript?",
|
|
717
794
|
result: false,
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
721
|
-
result: false,
|
|
722
795
|
}
|
|
723
796
|
);
|
|
724
797
|
|
|
798
|
+
mockSelect({
|
|
799
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
800
|
+
result: "none",
|
|
801
|
+
});
|
|
802
|
+
|
|
725
803
|
fs.writeFileSync(
|
|
726
804
|
"./package.json",
|
|
727
805
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -769,13 +847,14 @@ describe("init", () => {
|
|
|
769
847
|
{
|
|
770
848
|
text: "Would you like to use TypeScript?",
|
|
771
849
|
result: false,
|
|
772
|
-
},
|
|
773
|
-
{
|
|
774
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
775
|
-
result: true,
|
|
776
850
|
}
|
|
777
851
|
);
|
|
778
852
|
|
|
853
|
+
mockSelect({
|
|
854
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
855
|
+
result: "fetch",
|
|
856
|
+
});
|
|
857
|
+
|
|
779
858
|
fs.writeFileSync(
|
|
780
859
|
"./package.json",
|
|
781
860
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -812,13 +891,14 @@ describe("init", () => {
|
|
|
812
891
|
{
|
|
813
892
|
text: "Would you like to use TypeScript?",
|
|
814
893
|
result: true,
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
818
|
-
result: true,
|
|
819
894
|
}
|
|
820
895
|
);
|
|
821
896
|
|
|
897
|
+
mockSelect({
|
|
898
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
899
|
+
result: "fetch",
|
|
900
|
+
});
|
|
901
|
+
|
|
822
902
|
fs.writeFileSync(
|
|
823
903
|
"./package.json",
|
|
824
904
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -861,12 +941,12 @@ describe("init", () => {
|
|
|
861
941
|
{
|
|
862
942
|
text: "Would you like to use TypeScript?",
|
|
863
943
|
result: true,
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
867
|
-
result: true,
|
|
868
944
|
}
|
|
869
945
|
);
|
|
946
|
+
mockSelect({
|
|
947
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
948
|
+
result: "fetch",
|
|
949
|
+
});
|
|
870
950
|
await runWrangler("init");
|
|
871
951
|
|
|
872
952
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -878,7 +958,7 @@ describe("init", () => {
|
|
|
878
958
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
879
959
|
|
|
880
960
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
881
|
-
expect(packageJson.scripts.
|
|
961
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
882
962
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
883
963
|
expect(packageJson.version).toEqual("0.0.0");
|
|
884
964
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -889,7 +969,7 @@ describe("init", () => {
|
|
|
889
969
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
890
970
|
|
|
891
971
|
To start developing your Worker, run \`npm start\`
|
|
892
|
-
To publish your Worker to the Internet, run \`npm run
|
|
972
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
893
973
|
`);
|
|
894
974
|
});
|
|
895
975
|
|
|
@@ -906,18 +986,18 @@ describe("init", () => {
|
|
|
906
986
|
{
|
|
907
987
|
text: "Would you like to use TypeScript?",
|
|
908
988
|
result: true,
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
912
|
-
result: true,
|
|
913
989
|
}
|
|
914
990
|
);
|
|
991
|
+
mockSelect({
|
|
992
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
993
|
+
result: "fetch",
|
|
994
|
+
});
|
|
915
995
|
await fsp.writeFile(
|
|
916
996
|
"./package.json",
|
|
917
997
|
JSON.stringify({
|
|
918
998
|
scripts: {
|
|
919
999
|
start: "test-start",
|
|
920
|
-
|
|
1000
|
+
deploy: "test-publish",
|
|
921
1001
|
},
|
|
922
1002
|
})
|
|
923
1003
|
);
|
|
@@ -930,7 +1010,7 @@ describe("init", () => {
|
|
|
930
1010
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
931
1011
|
|
|
932
1012
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
933
|
-
expect(packageJson.scripts.
|
|
1013
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
934
1014
|
expect(std.out).toMatchInlineSnapshot(`
|
|
935
1015
|
"✨ Created wrangler.toml
|
|
936
1016
|
✨ Created tsconfig.json
|
|
@@ -1037,12 +1117,12 @@ describe("init", () => {
|
|
|
1037
1117
|
{
|
|
1038
1118
|
text: "Would you like to use TypeScript?",
|
|
1039
1119
|
result: true,
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1043
|
-
result: false,
|
|
1044
1120
|
}
|
|
1045
1121
|
);
|
|
1122
|
+
mockSelect({
|
|
1123
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1124
|
+
result: "none",
|
|
1125
|
+
});
|
|
1046
1126
|
await runWrangler("init");
|
|
1047
1127
|
expect(fs.existsSync("./tsconfig.json")).toBe(true);
|
|
1048
1128
|
const { config: tsconfigJson, error: tsConfigParseError } =
|
|
@@ -1090,16 +1170,15 @@ describe("init", () => {
|
|
|
1090
1170
|
"utf-8"
|
|
1091
1171
|
);
|
|
1092
1172
|
|
|
1093
|
-
mockConfirm(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
);
|
|
1173
|
+
mockConfirm({
|
|
1174
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1175
|
+
result: false,
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
mockSelect({
|
|
1179
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1180
|
+
result: "fetch",
|
|
1181
|
+
});
|
|
1103
1182
|
|
|
1104
1183
|
await runWrangler("init");
|
|
1105
1184
|
const tsconfigJson = JSON.parse(
|
|
@@ -1140,16 +1219,15 @@ describe("init", () => {
|
|
|
1140
1219
|
"utf-8"
|
|
1141
1220
|
);
|
|
1142
1221
|
|
|
1143
|
-
mockConfirm(
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
);
|
|
1222
|
+
mockConfirm({
|
|
1223
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1224
|
+
result: false,
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
mockSelect({
|
|
1228
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.ts?",
|
|
1229
|
+
result: "fetch",
|
|
1230
|
+
});
|
|
1153
1231
|
|
|
1154
1232
|
await runWrangler("init path/to/worker/my-worker");
|
|
1155
1233
|
const tsconfigJson = JSON.parse(
|
|
@@ -1183,12 +1261,12 @@ describe("init", () => {
|
|
|
1183
1261
|
{
|
|
1184
1262
|
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1185
1263
|
result: true,
|
|
1186
|
-
},
|
|
1187
|
-
{
|
|
1188
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1189
|
-
result: false,
|
|
1190
1264
|
}
|
|
1191
1265
|
);
|
|
1266
|
+
mockSelect({
|
|
1267
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1268
|
+
result: "none",
|
|
1269
|
+
});
|
|
1192
1270
|
fs.writeFileSync(
|
|
1193
1271
|
"./package.json",
|
|
1194
1272
|
JSON.stringify({
|
|
@@ -1243,16 +1321,15 @@ describe("init", () => {
|
|
|
1243
1321
|
"utf-8"
|
|
1244
1322
|
);
|
|
1245
1323
|
|
|
1246
|
-
mockConfirm(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
);
|
|
1324
|
+
mockConfirm({
|
|
1325
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1326
|
+
result: false,
|
|
1327
|
+
});
|
|
1328
|
+
|
|
1329
|
+
mockSelect({
|
|
1330
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1331
|
+
result: "fetch",
|
|
1332
|
+
});
|
|
1256
1333
|
|
|
1257
1334
|
fs.mkdirSync("./sub-1/sub-2", { recursive: true });
|
|
1258
1335
|
process.chdir("./sub-1/sub-2");
|
|
@@ -1299,12 +1376,12 @@ describe("init", () => {
|
|
|
1299
1376
|
{
|
|
1300
1377
|
text: "Would you like to use TypeScript?",
|
|
1301
1378
|
result: false,
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1305
|
-
result: true,
|
|
1306
1379
|
}
|
|
1307
1380
|
);
|
|
1381
|
+
mockSelect({
|
|
1382
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1383
|
+
result: "fetch",
|
|
1384
|
+
});
|
|
1308
1385
|
await runWrangler("init");
|
|
1309
1386
|
|
|
1310
1387
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -1316,7 +1393,7 @@ describe("init", () => {
|
|
|
1316
1393
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1317
1394
|
|
|
1318
1395
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
1319
|
-
expect(packageJson.scripts.
|
|
1396
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
1320
1397
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
1321
1398
|
expect(packageJson.version).toEqual("0.0.0");
|
|
1322
1399
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1325,7 +1402,7 @@ describe("init", () => {
|
|
|
1325
1402
|
✨ Created src/index.js
|
|
1326
1403
|
|
|
1327
1404
|
To start developing your Worker, run \`npm start\`
|
|
1328
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1405
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1329
1406
|
`);
|
|
1330
1407
|
});
|
|
1331
1408
|
|
|
@@ -1342,18 +1419,18 @@ describe("init", () => {
|
|
|
1342
1419
|
{
|
|
1343
1420
|
text: "Would you like to use TypeScript?",
|
|
1344
1421
|
result: false,
|
|
1345
|
-
},
|
|
1346
|
-
{
|
|
1347
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1348
|
-
result: true,
|
|
1349
1422
|
}
|
|
1350
1423
|
);
|
|
1424
|
+
mockSelect({
|
|
1425
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1426
|
+
result: "fetch",
|
|
1427
|
+
});
|
|
1351
1428
|
await fsp.writeFile(
|
|
1352
1429
|
"./package.json",
|
|
1353
1430
|
JSON.stringify({
|
|
1354
1431
|
scripts: {
|
|
1355
1432
|
start: "test-start",
|
|
1356
|
-
|
|
1433
|
+
deploy: "test-publish",
|
|
1357
1434
|
},
|
|
1358
1435
|
})
|
|
1359
1436
|
);
|
|
@@ -1366,7 +1443,7 @@ describe("init", () => {
|
|
|
1366
1443
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1367
1444
|
|
|
1368
1445
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
1369
|
-
expect(packageJson.scripts.
|
|
1446
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
1370
1447
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1371
1448
|
"✨ Created wrangler.toml
|
|
1372
1449
|
✨ Created src/index.js
|
|
@@ -1488,7 +1565,7 @@ describe("init", () => {
|
|
|
1488
1565
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1489
1566
|
|
|
1490
1567
|
To start developing your Worker, run \`npm start\`
|
|
1491
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1568
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1492
1569
|
"warn": "",
|
|
1493
1570
|
}
|
|
1494
1571
|
`);
|
|
@@ -1517,7 +1594,7 @@ describe("init", () => {
|
|
|
1517
1594
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1518
1595
|
|
|
1519
1596
|
To start developing your Worker, run \`cd path/to/worker && npm start\`
|
|
1520
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1597
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1521
1598
|
"warn": "",
|
|
1522
1599
|
}
|
|
1523
1600
|
`);
|
|
@@ -1548,7 +1625,7 @@ describe("init", () => {
|
|
|
1548
1625
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1549
1626
|
|
|
1550
1627
|
To start developing your Worker, run \`cd WEIRD_w0rkr_N4m3.js.tsx.tar.gz && npm start\`
|
|
1551
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1628
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1552
1629
|
"warn": "",
|
|
1553
1630
|
}
|
|
1554
1631
|
`);
|
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -663,7 +663,7 @@ describe("wrangler", () => {
|
|
|
663
663
|
|
|
664
664
|
expect(std.out).toMatchInlineSnapshot(`
|
|
665
665
|
"
|
|
666
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
666
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
667
667
|
`);
|
|
668
668
|
expect(std.err).toMatchInlineSnapshot(`
|
|
669
669
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mA namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".[0m
|
|
@@ -685,7 +685,7 @@ describe("wrangler", () => {
|
|
|
685
685
|
);
|
|
686
686
|
expect(std.out).toMatchInlineSnapshot(`
|
|
687
687
|
"
|
|
688
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
688
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
689
689
|
`);
|
|
690
690
|
expect(std.err).toMatchInlineSnapshot(`
|
|
691
691
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1msomeBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace.[0m
|
|
@@ -856,7 +856,7 @@ describe("wrangler", () => {
|
|
|
856
856
|
`);
|
|
857
857
|
expect(std.out).toMatchInlineSnapshot(`
|
|
858
858
|
"
|
|
859
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
859
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
860
860
|
`);
|
|
861
861
|
});
|
|
862
862
|
});
|
|
@@ -1044,7 +1044,7 @@ describe("wrangler", () => {
|
|
|
1044
1044
|
);
|
|
1045
1045
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1046
1046
|
"
|
|
1047
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1047
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1048
1048
|
`);
|
|
1049
1049
|
expect(std.err).toMatchInlineSnapshot(`
|
|
1050
1050
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mA namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".[0m
|
|
@@ -1226,7 +1226,7 @@ describe("wrangler", () => {
|
|
|
1226
1226
|
`);
|
|
1227
1227
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1228
1228
|
"
|
|
1229
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1229
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1230
1230
|
`);
|
|
1231
1231
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1232
1232
|
});
|
|
@@ -1288,7 +1288,7 @@ describe("wrangler", () => {
|
|
|
1288
1288
|
|
|
1289
1289
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1290
1290
|
"
|
|
1291
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1291
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1292
1292
|
`);
|
|
1293
1293
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
1294
1294
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUnexpected key-value properties in \\"keys.json\\".[0m
|
|
@@ -1429,7 +1429,7 @@ describe("wrangler", () => {
|
|
|
1429
1429
|
`);
|
|
1430
1430
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1431
1431
|
"
|
|
1432
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1432
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1433
1433
|
`);
|
|
1434
1434
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1435
1435
|
});
|
|
@@ -1454,7 +1454,7 @@ describe("wrangler", () => {
|
|
|
1454
1454
|
`);
|
|
1455
1455
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1456
1456
|
"
|
|
1457
|
-
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new
|
|
1457
|
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m"
|
|
1458
1458
|
`);
|
|
1459
1459
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
1460
1460
|
});
|