wrangler 0.0.0-e95e5a0 → 0.0.0-e978986
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/Cloudflare_CA.pem +18 -0
- package/README.md +3 -1
- package/bin/wrangler.js +36 -4
- package/package.json +11 -7
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +14 -1
- package/pages/functions/template-plugin.ts +3 -2
- package/src/__tests__/configuration.test.ts +336 -87
- package/src/__tests__/dev.test.tsx +243 -25
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +79 -72
- package/src/__tests__/init.test.ts +182 -131
- package/src/__tests__/jest.setup.ts +8 -0
- package/src/__tests__/kv.test.ts +173 -146
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +381 -53
- package/src/__tests__/parse.test.ts +8 -0
- package/src/__tests__/publish.test.ts +682 -89
- package/src/__tests__/r2.test.ts +55 -36
- package/src/__tests__/secret.test.ts +39 -4
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +33 -2
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +17 -9
- package/src/config/config.ts +1 -1
- package/src/config/environment.ts +40 -14
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +180 -65
- package/src/create-worker-preview.ts +17 -7
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +7 -6
- package/src/dev/local.tsx +6 -0
- package/src/dev/remote.tsx +15 -1
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/entry.ts +64 -9
- package/src/index.tsx +357 -177
- package/src/inspect.ts +39 -0
- package/src/kv.ts +114 -25
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +271 -110
- package/src/parse.ts +23 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +227 -113
- package/src/sites.tsx +19 -17
- package/src/user.tsx +11 -1
- package/src/worker.ts +8 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.ts +16 -1
- package/wrangler-dist/cli.js +36017 -22687
|
@@ -2,12 +2,17 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as fsp from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as TOML from "@iarna/toml";
|
|
5
|
-
import { execa } from "execa";
|
|
5
|
+
import { execa, execaSync } from "execa";
|
|
6
6
|
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";
|
|
13
18
|
import type { PackageManager } from "../package-manager";
|
|
@@ -29,6 +34,7 @@ describe("init", () => {
|
|
|
29
34
|
|
|
30
35
|
afterEach(() => {
|
|
31
36
|
clearConfirmMocks();
|
|
37
|
+
clearSelectMocks();
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
const std = mockConsoleMethods();
|
|
@@ -46,11 +52,12 @@ describe("init", () => {
|
|
|
46
52
|
"✨ Created wrangler.toml
|
|
47
53
|
✨ Initialized git repository
|
|
48
54
|
✨ Created package.json
|
|
49
|
-
✨ Created tsconfig.json
|
|
55
|
+
✨ Created tsconfig.json
|
|
50
56
|
✨ Created src/index.ts
|
|
57
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
51
58
|
|
|
52
59
|
To start developing your Worker, run \`npm start\`
|
|
53
|
-
To publish your Worker to the Internet, run \`npm run
|
|
60
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
54
61
|
`);
|
|
55
62
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
56
63
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -72,11 +79,12 @@ describe("init", () => {
|
|
|
72
79
|
"✨ Created my-worker/wrangler.toml
|
|
73
80
|
✨ Initialized git repository at my-worker
|
|
74
81
|
✨ Created my-worker/package.json
|
|
75
|
-
✨ Created my-worker/tsconfig.json
|
|
82
|
+
✨ Created my-worker/tsconfig.json
|
|
76
83
|
✨ Created my-worker/src/index.ts
|
|
84
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
77
85
|
|
|
78
86
|
To start developing your Worker, run \`cd my-worker && npm start\`
|
|
79
|
-
To publish your Worker to the Internet, run \`npm run
|
|
87
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
80
88
|
`);
|
|
81
89
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
82
90
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -97,11 +105,12 @@ describe("init", () => {
|
|
|
97
105
|
"out": "✨ Created wrangler.toml
|
|
98
106
|
✨ Initialized git repository
|
|
99
107
|
✨ Created package.json
|
|
100
|
-
✨ Created tsconfig.json
|
|
108
|
+
✨ Created tsconfig.json
|
|
101
109
|
✨ Created src/index.ts
|
|
110
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
102
111
|
|
|
103
112
|
To start developing your Worker, run \`npm start\`
|
|
104
|
-
To publish your Worker to the Internet, run \`npm run
|
|
113
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
105
114
|
"warn": "",
|
|
106
115
|
}
|
|
107
116
|
`);
|
|
@@ -284,13 +293,14 @@ describe("init", () => {
|
|
|
284
293
|
{
|
|
285
294
|
text: "Would you like to use TypeScript?",
|
|
286
295
|
result: true,
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
290
|
-
result: true,
|
|
291
296
|
}
|
|
292
297
|
);
|
|
293
298
|
|
|
299
|
+
mockSelect({
|
|
300
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
301
|
+
result: "fetch",
|
|
302
|
+
});
|
|
303
|
+
|
|
294
304
|
await runWrangler("init");
|
|
295
305
|
expect(fs.readFileSync("./wrangler.toml", "utf-8")).toMatchInlineSnapshot(
|
|
296
306
|
`"compatibility_date=\\"something-else\\""`
|
|
@@ -373,11 +383,12 @@ describe("init", () => {
|
|
|
373
383
|
"err": "",
|
|
374
384
|
"out": "✨ Created wrangler.toml
|
|
375
385
|
✨ Created package.json
|
|
376
|
-
✨ Created tsconfig.json
|
|
386
|
+
✨ Created tsconfig.json
|
|
377
387
|
✨ Created src/index.ts
|
|
388
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
378
389
|
|
|
379
390
|
To start developing your Worker, run \`npm start\`
|
|
380
|
-
To publish your Worker to the Internet, run \`npm run
|
|
391
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
381
392
|
"warn": "",
|
|
382
393
|
}
|
|
383
394
|
`);
|
|
@@ -397,20 +408,48 @@ describe("init", () => {
|
|
|
397
408
|
"err": "",
|
|
398
409
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
399
410
|
✨ Created path/to/worker/my-worker/package.json
|
|
400
|
-
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
411
|
+
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
401
412
|
✨ Created path/to/worker/my-worker/src/index.ts
|
|
413
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
402
414
|
|
|
403
415
|
To start developing your Worker, run \`cd path/to/worker/my-worker && npm start\`
|
|
404
|
-
To publish your Worker to the Internet, run \`npm run
|
|
416
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
405
417
|
"warn": "",
|
|
406
418
|
}
|
|
407
419
|
`);
|
|
408
420
|
});
|
|
409
421
|
|
|
422
|
+
// I... don't know how to test this lol
|
|
410
423
|
it.todo(
|
|
411
424
|
"should not offer to initialize a git repo if git is not installed"
|
|
412
425
|
);
|
|
413
|
-
|
|
426
|
+
|
|
427
|
+
it("should initialize git repo with `main` default branch", async () => {
|
|
428
|
+
mockConfirm(
|
|
429
|
+
{
|
|
430
|
+
text: "Would you like to use git to manage this Worker?",
|
|
431
|
+
result: true,
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
text: "No package.json found. Would you like to create one?",
|
|
435
|
+
result: false,
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
await runWrangler("init");
|
|
439
|
+
expect(std).toMatchInlineSnapshot(`
|
|
440
|
+
Object {
|
|
441
|
+
"debug": "",
|
|
442
|
+
"err": "",
|
|
443
|
+
"out": "✨ Created wrangler.toml
|
|
444
|
+
✨ Initialized git repository",
|
|
445
|
+
"warn": "",
|
|
446
|
+
}
|
|
447
|
+
`);
|
|
448
|
+
|
|
449
|
+
expect(execaSync("git", ["symbolic-ref", "HEAD"]).stdout).toEqual(
|
|
450
|
+
"refs/heads/main"
|
|
451
|
+
);
|
|
452
|
+
});
|
|
414
453
|
});
|
|
415
454
|
|
|
416
455
|
describe("package.json", () => {
|
|
@@ -427,12 +466,12 @@ describe("init", () => {
|
|
|
427
466
|
{
|
|
428
467
|
text: "Would you like to use TypeScript?",
|
|
429
468
|
result: false,
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
433
|
-
result: false,
|
|
434
469
|
}
|
|
435
470
|
);
|
|
471
|
+
mockSelect({
|
|
472
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
473
|
+
result: "none",
|
|
474
|
+
});
|
|
436
475
|
await runWrangler("init");
|
|
437
476
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
438
477
|
const packageJson = JSON.parse(
|
|
@@ -469,12 +508,12 @@ describe("init", () => {
|
|
|
469
508
|
{
|
|
470
509
|
text: "Would you like to use TypeScript?",
|
|
471
510
|
result: false,
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
475
|
-
result: false,
|
|
476
511
|
}
|
|
477
512
|
);
|
|
513
|
+
mockSelect({
|
|
514
|
+
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
515
|
+
result: "none",
|
|
516
|
+
});
|
|
478
517
|
await runWrangler("init my-worker");
|
|
479
518
|
const packageJson = JSON.parse(
|
|
480
519
|
fs.readFileSync("./my-worker/package.json", "utf-8")
|
|
@@ -504,12 +543,12 @@ describe("init", () => {
|
|
|
504
543
|
{
|
|
505
544
|
text: "Would you like to use TypeScript?",
|
|
506
545
|
result: false,
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
510
|
-
result: false,
|
|
511
546
|
}
|
|
512
547
|
);
|
|
548
|
+
mockSelect({
|
|
549
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
550
|
+
result: "none",
|
|
551
|
+
});
|
|
513
552
|
|
|
514
553
|
fs.writeFileSync(
|
|
515
554
|
"./package.json",
|
|
@@ -546,13 +585,14 @@ describe("init", () => {
|
|
|
546
585
|
{
|
|
547
586
|
text: "Would you like to use TypeScript?",
|
|
548
587
|
result: false,
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
552
|
-
result: false,
|
|
553
588
|
}
|
|
554
589
|
);
|
|
555
590
|
|
|
591
|
+
mockSelect({
|
|
592
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
593
|
+
result: "none",
|
|
594
|
+
});
|
|
595
|
+
|
|
556
596
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
557
597
|
fs.writeFileSync(
|
|
558
598
|
"path/to/worker/package.json",
|
|
@@ -589,13 +629,14 @@ describe("init", () => {
|
|
|
589
629
|
{
|
|
590
630
|
text: "Would you like to use TypeScript?",
|
|
591
631
|
result: false,
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
595
|
-
result: false,
|
|
596
632
|
}
|
|
597
633
|
);
|
|
598
634
|
|
|
635
|
+
mockSelect({
|
|
636
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
637
|
+
result: "none",
|
|
638
|
+
});
|
|
639
|
+
|
|
599
640
|
fs.writeFileSync(
|
|
600
641
|
"./package.json",
|
|
601
642
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -616,7 +657,7 @@ describe("init", () => {
|
|
|
616
657
|
"debug": "",
|
|
617
658
|
"err": "",
|
|
618
659
|
"out": "✨ Created wrangler.toml
|
|
619
|
-
✨ Installed wrangler",
|
|
660
|
+
✨ Installed wrangler into devDependencies",
|
|
620
661
|
"warn": "",
|
|
621
662
|
}
|
|
622
663
|
`);
|
|
@@ -635,13 +676,14 @@ describe("init", () => {
|
|
|
635
676
|
{
|
|
636
677
|
text: "Would you like to use TypeScript?",
|
|
637
678
|
result: false,
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
641
|
-
result: false,
|
|
642
679
|
}
|
|
643
680
|
);
|
|
644
681
|
|
|
682
|
+
mockSelect({
|
|
683
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.js?",
|
|
684
|
+
result: "none",
|
|
685
|
+
});
|
|
686
|
+
|
|
645
687
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
646
688
|
fs.writeFileSync(
|
|
647
689
|
"path/to/worker/package.json",
|
|
@@ -664,7 +706,7 @@ describe("init", () => {
|
|
|
664
706
|
"debug": "",
|
|
665
707
|
"err": "",
|
|
666
708
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
667
|
-
✨ Installed wrangler",
|
|
709
|
+
✨ Installed wrangler into devDependencies",
|
|
668
710
|
"warn": "",
|
|
669
711
|
}
|
|
670
712
|
`);
|
|
@@ -683,13 +725,14 @@ describe("init", () => {
|
|
|
683
725
|
{
|
|
684
726
|
text: "Would you like to use TypeScript?",
|
|
685
727
|
result: false,
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
689
|
-
result: false,
|
|
690
728
|
}
|
|
691
729
|
);
|
|
692
730
|
|
|
731
|
+
mockSelect({
|
|
732
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
733
|
+
result: "none",
|
|
734
|
+
});
|
|
735
|
+
|
|
693
736
|
fs.writeFileSync(
|
|
694
737
|
"./package.json",
|
|
695
738
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -737,13 +780,14 @@ describe("init", () => {
|
|
|
737
780
|
{
|
|
738
781
|
text: "Would you like to use TypeScript?",
|
|
739
782
|
result: false,
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
743
|
-
result: true,
|
|
744
783
|
}
|
|
745
784
|
);
|
|
746
785
|
|
|
786
|
+
mockSelect({
|
|
787
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
788
|
+
result: "fetch",
|
|
789
|
+
});
|
|
790
|
+
|
|
747
791
|
fs.writeFileSync(
|
|
748
792
|
"./package.json",
|
|
749
793
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -780,13 +824,14 @@ describe("init", () => {
|
|
|
780
824
|
{
|
|
781
825
|
text: "Would you like to use TypeScript?",
|
|
782
826
|
result: true,
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
786
|
-
result: true,
|
|
787
827
|
}
|
|
788
828
|
);
|
|
789
829
|
|
|
830
|
+
mockSelect({
|
|
831
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
832
|
+
result: "fetch",
|
|
833
|
+
});
|
|
834
|
+
|
|
790
835
|
fs.writeFileSync(
|
|
791
836
|
"./package.json",
|
|
792
837
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -801,8 +846,9 @@ describe("init", () => {
|
|
|
801
846
|
"debug": "",
|
|
802
847
|
"err": "",
|
|
803
848
|
"out": "✨ Created wrangler.toml
|
|
804
|
-
✨ Created tsconfig.json
|
|
849
|
+
✨ Created tsconfig.json
|
|
805
850
|
✨ Created src/index.ts
|
|
851
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
806
852
|
|
|
807
853
|
To start developing your Worker, run \`npx wrangler dev\`
|
|
808
854
|
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
@@ -828,12 +874,12 @@ describe("init", () => {
|
|
|
828
874
|
{
|
|
829
875
|
text: "Would you like to use TypeScript?",
|
|
830
876
|
result: true,
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
834
|
-
result: true,
|
|
835
877
|
}
|
|
836
878
|
);
|
|
879
|
+
mockSelect({
|
|
880
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
881
|
+
result: "fetch",
|
|
882
|
+
});
|
|
837
883
|
await runWrangler("init");
|
|
838
884
|
|
|
839
885
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -845,17 +891,18 @@ describe("init", () => {
|
|
|
845
891
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
846
892
|
|
|
847
893
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
848
|
-
expect(packageJson.scripts.
|
|
894
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
849
895
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
850
896
|
expect(packageJson.version).toEqual("0.0.0");
|
|
851
897
|
expect(std.out).toMatchInlineSnapshot(`
|
|
852
898
|
"✨ Created wrangler.toml
|
|
853
899
|
✨ Created package.json
|
|
854
|
-
✨ Created tsconfig.json
|
|
900
|
+
✨ Created tsconfig.json
|
|
855
901
|
✨ Created src/index.ts
|
|
902
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
856
903
|
|
|
857
904
|
To start developing your Worker, run \`npm start\`
|
|
858
|
-
To publish your Worker to the Internet, run \`npm run
|
|
905
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
859
906
|
`);
|
|
860
907
|
});
|
|
861
908
|
|
|
@@ -872,18 +919,18 @@ describe("init", () => {
|
|
|
872
919
|
{
|
|
873
920
|
text: "Would you like to use TypeScript?",
|
|
874
921
|
result: true,
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
878
|
-
result: true,
|
|
879
922
|
}
|
|
880
923
|
);
|
|
924
|
+
mockSelect({
|
|
925
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
926
|
+
result: "fetch",
|
|
927
|
+
});
|
|
881
928
|
await fsp.writeFile(
|
|
882
929
|
"./package.json",
|
|
883
930
|
JSON.stringify({
|
|
884
931
|
scripts: {
|
|
885
932
|
start: "test-start",
|
|
886
|
-
|
|
933
|
+
deploy: "test-publish",
|
|
887
934
|
},
|
|
888
935
|
})
|
|
889
936
|
);
|
|
@@ -896,11 +943,12 @@ describe("init", () => {
|
|
|
896
943
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
897
944
|
|
|
898
945
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
899
|
-
expect(packageJson.scripts.
|
|
946
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
900
947
|
expect(std.out).toMatchInlineSnapshot(`
|
|
901
948
|
"✨ Created wrangler.toml
|
|
902
|
-
✨ Created tsconfig.json
|
|
949
|
+
✨ Created tsconfig.json
|
|
903
950
|
✨ Created src/index.ts
|
|
951
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
904
952
|
|
|
905
953
|
To start developing your Worker, run \`npx wrangler dev\`
|
|
906
954
|
To publish your Worker to the Internet, run \`npx wrangler publish\`"
|
|
@@ -940,7 +988,8 @@ describe("init", () => {
|
|
|
940
988
|
"debug": "",
|
|
941
989
|
"err": "",
|
|
942
990
|
"out": "✨ Created wrangler.toml
|
|
943
|
-
✨ Created tsconfig.json
|
|
991
|
+
✨ Created tsconfig.json
|
|
992
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
944
993
|
"warn": "",
|
|
945
994
|
}
|
|
946
995
|
`);
|
|
@@ -981,7 +1030,8 @@ describe("init", () => {
|
|
|
981
1030
|
"debug": "",
|
|
982
1031
|
"err": "",
|
|
983
1032
|
"out": "✨ Created my-worker/wrangler.toml
|
|
984
|
-
✨ Created my-worker/tsconfig.json
|
|
1033
|
+
✨ Created my-worker/tsconfig.json
|
|
1034
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
985
1035
|
"warn": "",
|
|
986
1036
|
}
|
|
987
1037
|
`);
|
|
@@ -1000,12 +1050,12 @@ describe("init", () => {
|
|
|
1000
1050
|
{
|
|
1001
1051
|
text: "Would you like to use TypeScript?",
|
|
1002
1052
|
result: true,
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1006
|
-
result: false,
|
|
1007
1053
|
}
|
|
1008
1054
|
);
|
|
1055
|
+
mockSelect({
|
|
1056
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1057
|
+
result: "none",
|
|
1058
|
+
});
|
|
1009
1059
|
await runWrangler("init");
|
|
1010
1060
|
expect(fs.existsSync("./tsconfig.json")).toBe(true);
|
|
1011
1061
|
const { config: tsconfigJson, error: tsConfigParseError } =
|
|
@@ -1027,7 +1077,8 @@ describe("init", () => {
|
|
|
1027
1077
|
"err": "",
|
|
1028
1078
|
"out": "✨ Created wrangler.toml
|
|
1029
1079
|
✨ Created package.json
|
|
1030
|
-
✨ Created tsconfig.json
|
|
1080
|
+
✨ Created tsconfig.json
|
|
1081
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
1031
1082
|
"warn": "",
|
|
1032
1083
|
}
|
|
1033
1084
|
`);
|
|
@@ -1052,16 +1103,15 @@ describe("init", () => {
|
|
|
1052
1103
|
"utf-8"
|
|
1053
1104
|
);
|
|
1054
1105
|
|
|
1055
|
-
mockConfirm(
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
);
|
|
1106
|
+
mockConfirm({
|
|
1107
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1108
|
+
result: false,
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
mockSelect({
|
|
1112
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1113
|
+
result: "fetch",
|
|
1114
|
+
});
|
|
1065
1115
|
|
|
1066
1116
|
await runWrangler("init");
|
|
1067
1117
|
const tsconfigJson = JSON.parse(
|
|
@@ -1102,16 +1152,15 @@ describe("init", () => {
|
|
|
1102
1152
|
"utf-8"
|
|
1103
1153
|
);
|
|
1104
1154
|
|
|
1105
|
-
mockConfirm(
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
);
|
|
1155
|
+
mockConfirm({
|
|
1156
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1157
|
+
result: false,
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
mockSelect({
|
|
1161
|
+
text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.ts?",
|
|
1162
|
+
result: "fetch",
|
|
1163
|
+
});
|
|
1115
1164
|
|
|
1116
1165
|
await runWrangler("init path/to/worker/my-worker");
|
|
1117
1166
|
const tsconfigJson = JSON.parse(
|
|
@@ -1145,12 +1194,12 @@ describe("init", () => {
|
|
|
1145
1194
|
{
|
|
1146
1195
|
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1147
1196
|
result: true,
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1151
|
-
result: false,
|
|
1152
1197
|
}
|
|
1153
1198
|
);
|
|
1199
|
+
mockSelect({
|
|
1200
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1201
|
+
result: "none",
|
|
1202
|
+
});
|
|
1154
1203
|
fs.writeFileSync(
|
|
1155
1204
|
"./package.json",
|
|
1156
1205
|
JSON.stringify({
|
|
@@ -1179,8 +1228,8 @@ describe("init", () => {
|
|
|
1179
1228
|
"debug": "",
|
|
1180
1229
|
"err": "",
|
|
1181
1230
|
"out": "✨ Created wrangler.toml
|
|
1182
|
-
✨ Installed @cloudflare/workers-types
|
|
1183
|
-
Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1231
|
+
✨ Installed @cloudflare/workers-types into devDependencies
|
|
1232
|
+
🚨 Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1184
1233
|
"warn": "",
|
|
1185
1234
|
}
|
|
1186
1235
|
`);
|
|
@@ -1205,16 +1254,15 @@ describe("init", () => {
|
|
|
1205
1254
|
"utf-8"
|
|
1206
1255
|
);
|
|
1207
1256
|
|
|
1208
|
-
mockConfirm(
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
);
|
|
1257
|
+
mockConfirm({
|
|
1258
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1259
|
+
result: false,
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
mockSelect({
|
|
1263
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1264
|
+
result: "fetch",
|
|
1265
|
+
});
|
|
1218
1266
|
|
|
1219
1267
|
fs.mkdirSync("./sub-1/sub-2", { recursive: true });
|
|
1220
1268
|
process.chdir("./sub-1/sub-2");
|
|
@@ -1261,12 +1309,12 @@ describe("init", () => {
|
|
|
1261
1309
|
{
|
|
1262
1310
|
text: "Would you like to use TypeScript?",
|
|
1263
1311
|
result: false,
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1267
|
-
result: true,
|
|
1268
1312
|
}
|
|
1269
1313
|
);
|
|
1314
|
+
mockSelect({
|
|
1315
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1316
|
+
result: "fetch",
|
|
1317
|
+
});
|
|
1270
1318
|
await runWrangler("init");
|
|
1271
1319
|
|
|
1272
1320
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -1278,7 +1326,7 @@ describe("init", () => {
|
|
|
1278
1326
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1279
1327
|
|
|
1280
1328
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
1281
|
-
expect(packageJson.scripts.
|
|
1329
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
1282
1330
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
1283
1331
|
expect(packageJson.version).toEqual("0.0.0");
|
|
1284
1332
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1287,7 +1335,7 @@ describe("init", () => {
|
|
|
1287
1335
|
✨ Created src/index.js
|
|
1288
1336
|
|
|
1289
1337
|
To start developing your Worker, run \`npm start\`
|
|
1290
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1338
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1291
1339
|
`);
|
|
1292
1340
|
});
|
|
1293
1341
|
|
|
@@ -1304,18 +1352,18 @@ describe("init", () => {
|
|
|
1304
1352
|
{
|
|
1305
1353
|
text: "Would you like to use TypeScript?",
|
|
1306
1354
|
result: false,
|
|
1307
|
-
},
|
|
1308
|
-
{
|
|
1309
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1310
|
-
result: true,
|
|
1311
1355
|
}
|
|
1312
1356
|
);
|
|
1357
|
+
mockSelect({
|
|
1358
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1359
|
+
result: "fetch",
|
|
1360
|
+
});
|
|
1313
1361
|
await fsp.writeFile(
|
|
1314
1362
|
"./package.json",
|
|
1315
1363
|
JSON.stringify({
|
|
1316
1364
|
scripts: {
|
|
1317
1365
|
start: "test-start",
|
|
1318
|
-
|
|
1366
|
+
deploy: "test-publish",
|
|
1319
1367
|
},
|
|
1320
1368
|
})
|
|
1321
1369
|
);
|
|
@@ -1328,7 +1376,7 @@ describe("init", () => {
|
|
|
1328
1376
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1329
1377
|
|
|
1330
1378
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
1331
|
-
expect(packageJson.scripts.
|
|
1379
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
1332
1380
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1333
1381
|
"✨ Created wrangler.toml
|
|
1334
1382
|
✨ Created src/index.js
|
|
@@ -1445,11 +1493,12 @@ describe("init", () => {
|
|
|
1445
1493
|
"out": "✨ Created wrangler.toml
|
|
1446
1494
|
✨ Initialized git repository
|
|
1447
1495
|
✨ Created package.json
|
|
1448
|
-
✨ Created tsconfig.json
|
|
1496
|
+
✨ Created tsconfig.json
|
|
1449
1497
|
✨ Created src/index.ts
|
|
1498
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1450
1499
|
|
|
1451
1500
|
To start developing your Worker, run \`npm start\`
|
|
1452
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1501
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1453
1502
|
"warn": "",
|
|
1454
1503
|
}
|
|
1455
1504
|
`);
|
|
@@ -1473,11 +1522,12 @@ describe("init", () => {
|
|
|
1473
1522
|
"out": "✨ Created path/to/worker/wrangler.toml
|
|
1474
1523
|
✨ Initialized git repository at path/to/worker
|
|
1475
1524
|
✨ Created path/to/worker/package.json
|
|
1476
|
-
✨ Created path/to/worker/tsconfig.json
|
|
1525
|
+
✨ Created path/to/worker/tsconfig.json
|
|
1477
1526
|
✨ Created path/to/worker/src/index.ts
|
|
1527
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1478
1528
|
|
|
1479
1529
|
To start developing your Worker, run \`cd path/to/worker && npm start\`
|
|
1480
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1530
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1481
1531
|
"warn": "",
|
|
1482
1532
|
}
|
|
1483
1533
|
`);
|
|
@@ -1503,11 +1553,12 @@ describe("init", () => {
|
|
|
1503
1553
|
"out": "✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/wrangler.toml
|
|
1504
1554
|
✨ Initialized git repository at WEIRD_w0rkr_N4m3.js.tsx.tar.gz
|
|
1505
1555
|
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/package.json
|
|
1506
|
-
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json
|
|
1556
|
+
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json
|
|
1507
1557
|
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/src/index.ts
|
|
1558
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1508
1559
|
|
|
1509
1560
|
To start developing your Worker, run \`cd WEIRD_w0rkr_N4m3.js.tsx.tar.gz && npm start\`
|
|
1510
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1561
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1511
1562
|
"warn": "",
|
|
1512
1563
|
}
|
|
1513
1564
|
`);
|