wrangler 2.0.7 → 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/README.md +1 -1
- package/bin/wrangler.js +16 -4
- package/package.json +2 -2
- package/src/__tests__/configuration.test.ts +165 -70
- package/src/__tests__/dev.test.tsx +158 -66
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/init.test.ts +191 -111
- package/src/__tests__/kv.test.ts +8 -8
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +115 -18
- package/src/__tests__/publish.test.ts +431 -140
- package/src/__tests__/secret.test.ts +4 -4
- package/src/__tests__/whoami.test.tsx +34 -0
- package/src/cfetch/index.ts +17 -2
- package/src/cfetch/internal.ts +12 -9
- package/src/config/config.ts +1 -1
- package/src/config/validation-helpers.ts +10 -1
- package/src/config/validation.ts +59 -33
- package/src/create-worker-preview.ts +15 -15
- package/src/dev/dev.tsx +4 -15
- package/src/dev/remote.tsx +26 -16
- package/src/dialogs.tsx +48 -0
- package/src/index.tsx +181 -167
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +298 -228
- package/src/publish.ts +148 -15
- package/src/sites.tsx +52 -14
- package/src/user.tsx +12 -1
- package/src/whoami.tsx +3 -2
- package/src/worker.ts +2 -1
- package/src/zones.ts +73 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/wrangler-dist/cli.js +707 -407
|
@@ -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", () => {
|
|
@@ -361,6 +435,9 @@ describe("init", () => {
|
|
|
361
435
|
`);
|
|
362
436
|
expect(fs.lstatSync(".git").isDirectory()).toBe(true);
|
|
363
437
|
expect(fs.lstatSync(".gitignore").isFile()).toBe(true);
|
|
438
|
+
expect((await execa("git", ["branch", "--show-current"])).stdout).toEqual(
|
|
439
|
+
"main"
|
|
440
|
+
);
|
|
364
441
|
});
|
|
365
442
|
|
|
366
443
|
it("should not offer to initialize a git repo if it's already inside one", async () => {
|
|
@@ -381,7 +458,7 @@ describe("init", () => {
|
|
|
381
458
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
382
459
|
|
|
383
460
|
To start developing your Worker, run \`npm start\`
|
|
384
|
-
To publish your Worker to the Internet, run \`npm run
|
|
461
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
385
462
|
"warn": "",
|
|
386
463
|
}
|
|
387
464
|
`);
|
|
@@ -406,7 +483,7 @@ describe("init", () => {
|
|
|
406
483
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
407
484
|
|
|
408
485
|
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
|
|
486
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
410
487
|
"warn": "",
|
|
411
488
|
}
|
|
412
489
|
`);
|
|
@@ -459,12 +536,12 @@ describe("init", () => {
|
|
|
459
536
|
{
|
|
460
537
|
text: "Would you like to use TypeScript?",
|
|
461
538
|
result: false,
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
465
|
-
result: false,
|
|
466
539
|
}
|
|
467
540
|
);
|
|
541
|
+
mockSelect({
|
|
542
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
543
|
+
result: "none",
|
|
544
|
+
});
|
|
468
545
|
await runWrangler("init");
|
|
469
546
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
470
547
|
const packageJson = JSON.parse(
|
|
@@ -501,12 +578,12 @@ describe("init", () => {
|
|
|
501
578
|
{
|
|
502
579
|
text: "Would you like to use TypeScript?",
|
|
503
580
|
result: false,
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
507
|
-
result: false,
|
|
508
581
|
}
|
|
509
582
|
);
|
|
583
|
+
mockSelect({
|
|
584
|
+
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
585
|
+
result: "none",
|
|
586
|
+
});
|
|
510
587
|
await runWrangler("init my-worker");
|
|
511
588
|
const packageJson = JSON.parse(
|
|
512
589
|
fs.readFileSync("./my-worker/package.json", "utf-8")
|
|
@@ -536,12 +613,12 @@ describe("init", () => {
|
|
|
536
613
|
{
|
|
537
614
|
text: "Would you like to use TypeScript?",
|
|
538
615
|
result: false,
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
542
|
-
result: false,
|
|
543
616
|
}
|
|
544
617
|
);
|
|
618
|
+
mockSelect({
|
|
619
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
620
|
+
result: "none",
|
|
621
|
+
});
|
|
545
622
|
|
|
546
623
|
fs.writeFileSync(
|
|
547
624
|
"./package.json",
|
|
@@ -578,13 +655,14 @@ describe("init", () => {
|
|
|
578
655
|
{
|
|
579
656
|
text: "Would you like to use TypeScript?",
|
|
580
657
|
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
658
|
}
|
|
586
659
|
);
|
|
587
660
|
|
|
661
|
+
mockSelect({
|
|
662
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
663
|
+
result: "none",
|
|
664
|
+
});
|
|
665
|
+
|
|
588
666
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
589
667
|
fs.writeFileSync(
|
|
590
668
|
"path/to/worker/package.json",
|
|
@@ -621,13 +699,14 @@ describe("init", () => {
|
|
|
621
699
|
{
|
|
622
700
|
text: "Would you like to use TypeScript?",
|
|
623
701
|
result: false,
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
627
|
-
result: false,
|
|
628
702
|
}
|
|
629
703
|
);
|
|
630
704
|
|
|
705
|
+
mockSelect({
|
|
706
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
707
|
+
result: "none",
|
|
708
|
+
});
|
|
709
|
+
|
|
631
710
|
fs.writeFileSync(
|
|
632
711
|
"./package.json",
|
|
633
712
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -667,13 +746,14 @@ describe("init", () => {
|
|
|
667
746
|
{
|
|
668
747
|
text: "Would you like to use TypeScript?",
|
|
669
748
|
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
749
|
}
|
|
675
750
|
);
|
|
676
751
|
|
|
752
|
+
mockSelect({
|
|
753
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
754
|
+
result: "none",
|
|
755
|
+
});
|
|
756
|
+
|
|
677
757
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
678
758
|
fs.writeFileSync(
|
|
679
759
|
"path/to/worker/package.json",
|
|
@@ -715,13 +795,14 @@ describe("init", () => {
|
|
|
715
795
|
{
|
|
716
796
|
text: "Would you like to use TypeScript?",
|
|
717
797
|
result: false,
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
721
|
-
result: false,
|
|
722
798
|
}
|
|
723
799
|
);
|
|
724
800
|
|
|
801
|
+
mockSelect({
|
|
802
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
803
|
+
result: "none",
|
|
804
|
+
});
|
|
805
|
+
|
|
725
806
|
fs.writeFileSync(
|
|
726
807
|
"./package.json",
|
|
727
808
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -769,13 +850,14 @@ describe("init", () => {
|
|
|
769
850
|
{
|
|
770
851
|
text: "Would you like to use TypeScript?",
|
|
771
852
|
result: false,
|
|
772
|
-
},
|
|
773
|
-
{
|
|
774
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
775
|
-
result: true,
|
|
776
853
|
}
|
|
777
854
|
);
|
|
778
855
|
|
|
856
|
+
mockSelect({
|
|
857
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
858
|
+
result: "fetch",
|
|
859
|
+
});
|
|
860
|
+
|
|
779
861
|
fs.writeFileSync(
|
|
780
862
|
"./package.json",
|
|
781
863
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -812,13 +894,14 @@ describe("init", () => {
|
|
|
812
894
|
{
|
|
813
895
|
text: "Would you like to use TypeScript?",
|
|
814
896
|
result: true,
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
818
|
-
result: true,
|
|
819
897
|
}
|
|
820
898
|
);
|
|
821
899
|
|
|
900
|
+
mockSelect({
|
|
901
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
902
|
+
result: "fetch",
|
|
903
|
+
});
|
|
904
|
+
|
|
822
905
|
fs.writeFileSync(
|
|
823
906
|
"./package.json",
|
|
824
907
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -861,12 +944,12 @@ describe("init", () => {
|
|
|
861
944
|
{
|
|
862
945
|
text: "Would you like to use TypeScript?",
|
|
863
946
|
result: true,
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
867
|
-
result: true,
|
|
868
947
|
}
|
|
869
948
|
);
|
|
949
|
+
mockSelect({
|
|
950
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
951
|
+
result: "fetch",
|
|
952
|
+
});
|
|
870
953
|
await runWrangler("init");
|
|
871
954
|
|
|
872
955
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -878,7 +961,7 @@ describe("init", () => {
|
|
|
878
961
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
879
962
|
|
|
880
963
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
881
|
-
expect(packageJson.scripts.
|
|
964
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
882
965
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
883
966
|
expect(packageJson.version).toEqual("0.0.0");
|
|
884
967
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -889,7 +972,7 @@ describe("init", () => {
|
|
|
889
972
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
890
973
|
|
|
891
974
|
To start developing your Worker, run \`npm start\`
|
|
892
|
-
To publish your Worker to the Internet, run \`npm run
|
|
975
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
893
976
|
`);
|
|
894
977
|
});
|
|
895
978
|
|
|
@@ -906,18 +989,18 @@ describe("init", () => {
|
|
|
906
989
|
{
|
|
907
990
|
text: "Would you like to use TypeScript?",
|
|
908
991
|
result: true,
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
912
|
-
result: true,
|
|
913
992
|
}
|
|
914
993
|
);
|
|
994
|
+
mockSelect({
|
|
995
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
996
|
+
result: "fetch",
|
|
997
|
+
});
|
|
915
998
|
await fsp.writeFile(
|
|
916
999
|
"./package.json",
|
|
917
1000
|
JSON.stringify({
|
|
918
1001
|
scripts: {
|
|
919
1002
|
start: "test-start",
|
|
920
|
-
|
|
1003
|
+
deploy: "test-publish",
|
|
921
1004
|
},
|
|
922
1005
|
})
|
|
923
1006
|
);
|
|
@@ -930,7 +1013,7 @@ describe("init", () => {
|
|
|
930
1013
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
931
1014
|
|
|
932
1015
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
933
|
-
expect(packageJson.scripts.
|
|
1016
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
934
1017
|
expect(std.out).toMatchInlineSnapshot(`
|
|
935
1018
|
"✨ Created wrangler.toml
|
|
936
1019
|
✨ Created tsconfig.json
|
|
@@ -1037,12 +1120,12 @@ describe("init", () => {
|
|
|
1037
1120
|
{
|
|
1038
1121
|
text: "Would you like to use TypeScript?",
|
|
1039
1122
|
result: true,
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1043
|
-
result: false,
|
|
1044
1123
|
}
|
|
1045
1124
|
);
|
|
1125
|
+
mockSelect({
|
|
1126
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1127
|
+
result: "none",
|
|
1128
|
+
});
|
|
1046
1129
|
await runWrangler("init");
|
|
1047
1130
|
expect(fs.existsSync("./tsconfig.json")).toBe(true);
|
|
1048
1131
|
const { config: tsconfigJson, error: tsConfigParseError } =
|
|
@@ -1090,16 +1173,15 @@ describe("init", () => {
|
|
|
1090
1173
|
"utf-8"
|
|
1091
1174
|
);
|
|
1092
1175
|
|
|
1093
|
-
mockConfirm(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
);
|
|
1176
|
+
mockConfirm({
|
|
1177
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1178
|
+
result: false,
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
mockSelect({
|
|
1182
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1183
|
+
result: "fetch",
|
|
1184
|
+
});
|
|
1103
1185
|
|
|
1104
1186
|
await runWrangler("init");
|
|
1105
1187
|
const tsconfigJson = JSON.parse(
|
|
@@ -1140,16 +1222,15 @@ describe("init", () => {
|
|
|
1140
1222
|
"utf-8"
|
|
1141
1223
|
);
|
|
1142
1224
|
|
|
1143
|
-
mockConfirm(
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
);
|
|
1225
|
+
mockConfirm({
|
|
1226
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1227
|
+
result: false,
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
mockSelect({
|
|
1231
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.ts?",
|
|
1232
|
+
result: "fetch",
|
|
1233
|
+
});
|
|
1153
1234
|
|
|
1154
1235
|
await runWrangler("init path/to/worker/my-worker");
|
|
1155
1236
|
const tsconfigJson = JSON.parse(
|
|
@@ -1183,12 +1264,12 @@ describe("init", () => {
|
|
|
1183
1264
|
{
|
|
1184
1265
|
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1185
1266
|
result: true,
|
|
1186
|
-
},
|
|
1187
|
-
{
|
|
1188
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1189
|
-
result: false,
|
|
1190
1267
|
}
|
|
1191
1268
|
);
|
|
1269
|
+
mockSelect({
|
|
1270
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1271
|
+
result: "none",
|
|
1272
|
+
});
|
|
1192
1273
|
fs.writeFileSync(
|
|
1193
1274
|
"./package.json",
|
|
1194
1275
|
JSON.stringify({
|
|
@@ -1243,16 +1324,15 @@ describe("init", () => {
|
|
|
1243
1324
|
"utf-8"
|
|
1244
1325
|
);
|
|
1245
1326
|
|
|
1246
|
-
mockConfirm(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
);
|
|
1327
|
+
mockConfirm({
|
|
1328
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1329
|
+
result: false,
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
mockSelect({
|
|
1333
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1334
|
+
result: "fetch",
|
|
1335
|
+
});
|
|
1256
1336
|
|
|
1257
1337
|
fs.mkdirSync("./sub-1/sub-2", { recursive: true });
|
|
1258
1338
|
process.chdir("./sub-1/sub-2");
|
|
@@ -1299,12 +1379,12 @@ describe("init", () => {
|
|
|
1299
1379
|
{
|
|
1300
1380
|
text: "Would you like to use TypeScript?",
|
|
1301
1381
|
result: false,
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1305
|
-
result: true,
|
|
1306
1382
|
}
|
|
1307
1383
|
);
|
|
1384
|
+
mockSelect({
|
|
1385
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1386
|
+
result: "fetch",
|
|
1387
|
+
});
|
|
1308
1388
|
await runWrangler("init");
|
|
1309
1389
|
|
|
1310
1390
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -1316,7 +1396,7 @@ describe("init", () => {
|
|
|
1316
1396
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1317
1397
|
|
|
1318
1398
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
1319
|
-
expect(packageJson.scripts.
|
|
1399
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
1320
1400
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
1321
1401
|
expect(packageJson.version).toEqual("0.0.0");
|
|
1322
1402
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1325,7 +1405,7 @@ describe("init", () => {
|
|
|
1325
1405
|
✨ Created src/index.js
|
|
1326
1406
|
|
|
1327
1407
|
To start developing your Worker, run \`npm start\`
|
|
1328
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1408
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1329
1409
|
`);
|
|
1330
1410
|
});
|
|
1331
1411
|
|
|
@@ -1342,18 +1422,18 @@ describe("init", () => {
|
|
|
1342
1422
|
{
|
|
1343
1423
|
text: "Would you like to use TypeScript?",
|
|
1344
1424
|
result: false,
|
|
1345
|
-
},
|
|
1346
|
-
{
|
|
1347
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1348
|
-
result: true,
|
|
1349
1425
|
}
|
|
1350
1426
|
);
|
|
1427
|
+
mockSelect({
|
|
1428
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1429
|
+
result: "fetch",
|
|
1430
|
+
});
|
|
1351
1431
|
await fsp.writeFile(
|
|
1352
1432
|
"./package.json",
|
|
1353
1433
|
JSON.stringify({
|
|
1354
1434
|
scripts: {
|
|
1355
1435
|
start: "test-start",
|
|
1356
|
-
|
|
1436
|
+
deploy: "test-publish",
|
|
1357
1437
|
},
|
|
1358
1438
|
})
|
|
1359
1439
|
);
|
|
@@ -1366,7 +1446,7 @@ describe("init", () => {
|
|
|
1366
1446
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1367
1447
|
|
|
1368
1448
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
1369
|
-
expect(packageJson.scripts.
|
|
1449
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
1370
1450
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1371
1451
|
"✨ Created wrangler.toml
|
|
1372
1452
|
✨ Created src/index.js
|
|
@@ -1488,7 +1568,7 @@ describe("init", () => {
|
|
|
1488
1568
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1489
1569
|
|
|
1490
1570
|
To start developing your Worker, run \`npm start\`
|
|
1491
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1571
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1492
1572
|
"warn": "",
|
|
1493
1573
|
}
|
|
1494
1574
|
`);
|
|
@@ -1517,7 +1597,7 @@ describe("init", () => {
|
|
|
1517
1597
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1518
1598
|
|
|
1519
1599
|
To start developing your Worker, run \`cd path/to/worker && npm start\`
|
|
1520
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1600
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1521
1601
|
"warn": "",
|
|
1522
1602
|
}
|
|
1523
1603
|
`);
|
|
@@ -1548,7 +1628,7 @@ describe("init", () => {
|
|
|
1548
1628
|
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1549
1629
|
|
|
1550
1630
|
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
|
|
1631
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1552
1632
|
"warn": "",
|
|
1553
1633
|
}
|
|
1554
1634
|
`);
|
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
|
});
|