wrangler 2.0.5 → 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 +6 -4
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +13 -0
- package/src/__tests__/configuration.test.ts +335 -86
- package/src/__tests__/dev.test.tsx +166 -15
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +30 -16
- package/src/__tests__/init.test.ts +249 -131
- package/src/__tests__/kv.test.ts +101 -101
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +369 -39
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +556 -84
- package/src/__tests__/r2.test.ts +47 -24
- package/src/__tests__/secret.test.ts +39 -4
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +32 -1
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +14 -9
- package/src/config/environment.ts +40 -14
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +179 -64
- package/src/create-worker-preview.ts +17 -7
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +2 -4
- 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/index.tsx +314 -144
- package/src/inspect.ts +39 -0
- package/src/kv.ts +77 -13
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +210 -65
- package/src/parse.ts +21 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +227 -113
- package/src/sites.tsx +11 -9
- 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 +35466 -22362
|
@@ -2,14 +2,20 @@ 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";
|
|
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();
|
|
@@ -46,11 +53,12 @@ describe("init", () => {
|
|
|
46
53
|
"✨ Created wrangler.toml
|
|
47
54
|
✨ Initialized git repository
|
|
48
55
|
✨ Created package.json
|
|
49
|
-
✨ Created tsconfig.json
|
|
56
|
+
✨ Created tsconfig.json
|
|
50
57
|
✨ Created src/index.ts
|
|
58
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
51
59
|
|
|
52
60
|
To start developing your Worker, run \`npm start\`
|
|
53
|
-
To publish your Worker to the Internet, run \`npm run
|
|
61
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
54
62
|
`);
|
|
55
63
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
56
64
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -72,11 +80,12 @@ describe("init", () => {
|
|
|
72
80
|
"✨ Created my-worker/wrangler.toml
|
|
73
81
|
✨ Initialized git repository at my-worker
|
|
74
82
|
✨ Created my-worker/package.json
|
|
75
|
-
✨ Created my-worker/tsconfig.json
|
|
83
|
+
✨ Created my-worker/tsconfig.json
|
|
76
84
|
✨ Created my-worker/src/index.ts
|
|
85
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
77
86
|
|
|
78
87
|
To start developing your Worker, run \`cd my-worker && npm start\`
|
|
79
|
-
To publish your Worker to the Internet, run \`npm run
|
|
88
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
80
89
|
`);
|
|
81
90
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
82
91
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
@@ -97,11 +106,12 @@ describe("init", () => {
|
|
|
97
106
|
"out": "✨ Created wrangler.toml
|
|
98
107
|
✨ Initialized git repository
|
|
99
108
|
✨ Created package.json
|
|
100
|
-
✨ Created tsconfig.json
|
|
109
|
+
✨ Created tsconfig.json
|
|
101
110
|
✨ Created src/index.ts
|
|
111
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
102
112
|
|
|
103
113
|
To start developing your Worker, run \`npm start\`
|
|
104
|
-
To publish your Worker to the Internet, run \`npm run
|
|
114
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
105
115
|
"warn": "",
|
|
106
116
|
}
|
|
107
117
|
`);
|
|
@@ -284,13 +294,14 @@ describe("init", () => {
|
|
|
284
294
|
{
|
|
285
295
|
text: "Would you like to use TypeScript?",
|
|
286
296
|
result: true,
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
290
|
-
result: true,
|
|
291
297
|
}
|
|
292
298
|
);
|
|
293
299
|
|
|
300
|
+
mockSelect({
|
|
301
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
302
|
+
result: "fetch",
|
|
303
|
+
});
|
|
304
|
+
|
|
294
305
|
await runWrangler("init");
|
|
295
306
|
expect(fs.readFileSync("./wrangler.toml", "utf-8")).toMatchInlineSnapshot(
|
|
296
307
|
`"compatibility_date=\\"something-else\\""`
|
|
@@ -332,6 +343,72 @@ describe("init", () => {
|
|
|
332
343
|
}
|
|
333
344
|
`);
|
|
334
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
|
+
});
|
|
335
412
|
});
|
|
336
413
|
|
|
337
414
|
describe("git init", () => {
|
|
@@ -373,11 +450,12 @@ describe("init", () => {
|
|
|
373
450
|
"err": "",
|
|
374
451
|
"out": "✨ Created wrangler.toml
|
|
375
452
|
✨ Created package.json
|
|
376
|
-
✨ Created tsconfig.json
|
|
453
|
+
✨ Created tsconfig.json
|
|
377
454
|
✨ Created src/index.ts
|
|
455
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
378
456
|
|
|
379
457
|
To start developing your Worker, run \`npm start\`
|
|
380
|
-
To publish your Worker to the Internet, run \`npm run
|
|
458
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
381
459
|
"warn": "",
|
|
382
460
|
}
|
|
383
461
|
`);
|
|
@@ -397,20 +475,48 @@ describe("init", () => {
|
|
|
397
475
|
"err": "",
|
|
398
476
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
399
477
|
✨ Created path/to/worker/my-worker/package.json
|
|
400
|
-
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
478
|
+
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
401
479
|
✨ Created path/to/worker/my-worker/src/index.ts
|
|
480
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
402
481
|
|
|
403
482
|
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
|
|
483
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
405
484
|
"warn": "",
|
|
406
485
|
}
|
|
407
486
|
`);
|
|
408
487
|
});
|
|
409
488
|
|
|
489
|
+
// I... don't know how to test this lol
|
|
410
490
|
it.todo(
|
|
411
491
|
"should not offer to initialize a git repo if git is not installed"
|
|
412
492
|
);
|
|
413
|
-
|
|
493
|
+
|
|
494
|
+
it("should initialize git repo with `main` default branch", async () => {
|
|
495
|
+
mockConfirm(
|
|
496
|
+
{
|
|
497
|
+
text: "Would you like to use git to manage this Worker?",
|
|
498
|
+
result: true,
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
text: "No package.json found. Would you like to create one?",
|
|
502
|
+
result: false,
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
await runWrangler("init");
|
|
506
|
+
expect(std).toMatchInlineSnapshot(`
|
|
507
|
+
Object {
|
|
508
|
+
"debug": "",
|
|
509
|
+
"err": "",
|
|
510
|
+
"out": "✨ Created wrangler.toml
|
|
511
|
+
✨ Initialized git repository",
|
|
512
|
+
"warn": "",
|
|
513
|
+
}
|
|
514
|
+
`);
|
|
515
|
+
|
|
516
|
+
expect(execaSync("git", ["symbolic-ref", "HEAD"]).stdout).toEqual(
|
|
517
|
+
"refs/heads/main"
|
|
518
|
+
);
|
|
519
|
+
});
|
|
414
520
|
});
|
|
415
521
|
|
|
416
522
|
describe("package.json", () => {
|
|
@@ -427,12 +533,12 @@ describe("init", () => {
|
|
|
427
533
|
{
|
|
428
534
|
text: "Would you like to use TypeScript?",
|
|
429
535
|
result: false,
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
433
|
-
result: false,
|
|
434
536
|
}
|
|
435
537
|
);
|
|
538
|
+
mockSelect({
|
|
539
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
540
|
+
result: "none",
|
|
541
|
+
});
|
|
436
542
|
await runWrangler("init");
|
|
437
543
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
438
544
|
const packageJson = JSON.parse(
|
|
@@ -469,12 +575,12 @@ describe("init", () => {
|
|
|
469
575
|
{
|
|
470
576
|
text: "Would you like to use TypeScript?",
|
|
471
577
|
result: false,
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
475
|
-
result: false,
|
|
476
578
|
}
|
|
477
579
|
);
|
|
580
|
+
mockSelect({
|
|
581
|
+
text: "Would you like to create a Worker at my-worker/src/index.js?",
|
|
582
|
+
result: "none",
|
|
583
|
+
});
|
|
478
584
|
await runWrangler("init my-worker");
|
|
479
585
|
const packageJson = JSON.parse(
|
|
480
586
|
fs.readFileSync("./my-worker/package.json", "utf-8")
|
|
@@ -504,12 +610,12 @@ describe("init", () => {
|
|
|
504
610
|
{
|
|
505
611
|
text: "Would you like to use TypeScript?",
|
|
506
612
|
result: false,
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
510
|
-
result: false,
|
|
511
613
|
}
|
|
512
614
|
);
|
|
615
|
+
mockSelect({
|
|
616
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
617
|
+
result: "none",
|
|
618
|
+
});
|
|
513
619
|
|
|
514
620
|
fs.writeFileSync(
|
|
515
621
|
"./package.json",
|
|
@@ -546,13 +652,14 @@ describe("init", () => {
|
|
|
546
652
|
{
|
|
547
653
|
text: "Would you like to use TypeScript?",
|
|
548
654
|
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
655
|
}
|
|
554
656
|
);
|
|
555
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
|
+
|
|
556
663
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
557
664
|
fs.writeFileSync(
|
|
558
665
|
"path/to/worker/package.json",
|
|
@@ -589,13 +696,14 @@ describe("init", () => {
|
|
|
589
696
|
{
|
|
590
697
|
text: "Would you like to use TypeScript?",
|
|
591
698
|
result: false,
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
595
|
-
result: false,
|
|
596
699
|
}
|
|
597
700
|
);
|
|
598
701
|
|
|
702
|
+
mockSelect({
|
|
703
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
704
|
+
result: "none",
|
|
705
|
+
});
|
|
706
|
+
|
|
599
707
|
fs.writeFileSync(
|
|
600
708
|
"./package.json",
|
|
601
709
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -616,7 +724,7 @@ describe("init", () => {
|
|
|
616
724
|
"debug": "",
|
|
617
725
|
"err": "",
|
|
618
726
|
"out": "✨ Created wrangler.toml
|
|
619
|
-
✨ Installed wrangler",
|
|
727
|
+
✨ Installed wrangler into devDependencies",
|
|
620
728
|
"warn": "",
|
|
621
729
|
}
|
|
622
730
|
`);
|
|
@@ -635,13 +743,14 @@ describe("init", () => {
|
|
|
635
743
|
{
|
|
636
744
|
text: "Would you like to use TypeScript?",
|
|
637
745
|
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
746
|
}
|
|
643
747
|
);
|
|
644
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
|
+
|
|
645
754
|
fs.mkdirSync("path/to/worker", { recursive: true });
|
|
646
755
|
fs.writeFileSync(
|
|
647
756
|
"path/to/worker/package.json",
|
|
@@ -664,7 +773,7 @@ describe("init", () => {
|
|
|
664
773
|
"debug": "",
|
|
665
774
|
"err": "",
|
|
666
775
|
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
667
|
-
✨ Installed wrangler",
|
|
776
|
+
✨ Installed wrangler into devDependencies",
|
|
668
777
|
"warn": "",
|
|
669
778
|
}
|
|
670
779
|
`);
|
|
@@ -683,13 +792,14 @@ describe("init", () => {
|
|
|
683
792
|
{
|
|
684
793
|
text: "Would you like to use TypeScript?",
|
|
685
794
|
result: false,
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
689
|
-
result: false,
|
|
690
795
|
}
|
|
691
796
|
);
|
|
692
797
|
|
|
798
|
+
mockSelect({
|
|
799
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
800
|
+
result: "none",
|
|
801
|
+
});
|
|
802
|
+
|
|
693
803
|
fs.writeFileSync(
|
|
694
804
|
"./package.json",
|
|
695
805
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -737,13 +847,14 @@ describe("init", () => {
|
|
|
737
847
|
{
|
|
738
848
|
text: "Would you like to use TypeScript?",
|
|
739
849
|
result: false,
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
743
|
-
result: true,
|
|
744
850
|
}
|
|
745
851
|
);
|
|
746
852
|
|
|
853
|
+
mockSelect({
|
|
854
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
855
|
+
result: "fetch",
|
|
856
|
+
});
|
|
857
|
+
|
|
747
858
|
fs.writeFileSync(
|
|
748
859
|
"./package.json",
|
|
749
860
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -780,13 +891,14 @@ describe("init", () => {
|
|
|
780
891
|
{
|
|
781
892
|
text: "Would you like to use TypeScript?",
|
|
782
893
|
result: true,
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
786
|
-
result: true,
|
|
787
894
|
}
|
|
788
895
|
);
|
|
789
896
|
|
|
897
|
+
mockSelect({
|
|
898
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
899
|
+
result: "fetch",
|
|
900
|
+
});
|
|
901
|
+
|
|
790
902
|
fs.writeFileSync(
|
|
791
903
|
"./package.json",
|
|
792
904
|
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
@@ -801,8 +913,9 @@ describe("init", () => {
|
|
|
801
913
|
"debug": "",
|
|
802
914
|
"err": "",
|
|
803
915
|
"out": "✨ Created wrangler.toml
|
|
804
|
-
✨ Created tsconfig.json
|
|
916
|
+
✨ Created tsconfig.json
|
|
805
917
|
✨ Created src/index.ts
|
|
918
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
806
919
|
|
|
807
920
|
To start developing your Worker, run \`npx wrangler dev\`
|
|
808
921
|
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
@@ -828,12 +941,12 @@ describe("init", () => {
|
|
|
828
941
|
{
|
|
829
942
|
text: "Would you like to use TypeScript?",
|
|
830
943
|
result: true,
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
834
|
-
result: true,
|
|
835
944
|
}
|
|
836
945
|
);
|
|
946
|
+
mockSelect({
|
|
947
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
948
|
+
result: "fetch",
|
|
949
|
+
});
|
|
837
950
|
await runWrangler("init");
|
|
838
951
|
|
|
839
952
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -845,17 +958,18 @@ describe("init", () => {
|
|
|
845
958
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
846
959
|
|
|
847
960
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
848
|
-
expect(packageJson.scripts.
|
|
961
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
849
962
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
850
963
|
expect(packageJson.version).toEqual("0.0.0");
|
|
851
964
|
expect(std.out).toMatchInlineSnapshot(`
|
|
852
965
|
"✨ Created wrangler.toml
|
|
853
966
|
✨ Created package.json
|
|
854
|
-
✨ Created tsconfig.json
|
|
967
|
+
✨ Created tsconfig.json
|
|
855
968
|
✨ Created src/index.ts
|
|
969
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
856
970
|
|
|
857
971
|
To start developing your Worker, run \`npm start\`
|
|
858
|
-
To publish your Worker to the Internet, run \`npm run
|
|
972
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
859
973
|
`);
|
|
860
974
|
});
|
|
861
975
|
|
|
@@ -872,18 +986,18 @@ describe("init", () => {
|
|
|
872
986
|
{
|
|
873
987
|
text: "Would you like to use TypeScript?",
|
|
874
988
|
result: true,
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
878
|
-
result: true,
|
|
879
989
|
}
|
|
880
990
|
);
|
|
991
|
+
mockSelect({
|
|
992
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
993
|
+
result: "fetch",
|
|
994
|
+
});
|
|
881
995
|
await fsp.writeFile(
|
|
882
996
|
"./package.json",
|
|
883
997
|
JSON.stringify({
|
|
884
998
|
scripts: {
|
|
885
999
|
start: "test-start",
|
|
886
|
-
|
|
1000
|
+
deploy: "test-publish",
|
|
887
1001
|
},
|
|
888
1002
|
})
|
|
889
1003
|
);
|
|
@@ -896,11 +1010,12 @@ describe("init", () => {
|
|
|
896
1010
|
expect(fs.existsSync("./src/index.ts")).toBe(true);
|
|
897
1011
|
|
|
898
1012
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
899
|
-
expect(packageJson.scripts.
|
|
1013
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
900
1014
|
expect(std.out).toMatchInlineSnapshot(`
|
|
901
1015
|
"✨ Created wrangler.toml
|
|
902
|
-
✨ Created tsconfig.json
|
|
1016
|
+
✨ Created tsconfig.json
|
|
903
1017
|
✨ Created src/index.ts
|
|
1018
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
904
1019
|
|
|
905
1020
|
To start developing your Worker, run \`npx wrangler dev\`
|
|
906
1021
|
To publish your Worker to the Internet, run \`npx wrangler publish\`"
|
|
@@ -940,7 +1055,8 @@ describe("init", () => {
|
|
|
940
1055
|
"debug": "",
|
|
941
1056
|
"err": "",
|
|
942
1057
|
"out": "✨ Created wrangler.toml
|
|
943
|
-
✨ Created tsconfig.json
|
|
1058
|
+
✨ Created tsconfig.json
|
|
1059
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
944
1060
|
"warn": "",
|
|
945
1061
|
}
|
|
946
1062
|
`);
|
|
@@ -981,7 +1097,8 @@ describe("init", () => {
|
|
|
981
1097
|
"debug": "",
|
|
982
1098
|
"err": "",
|
|
983
1099
|
"out": "✨ Created my-worker/wrangler.toml
|
|
984
|
-
✨ Created my-worker/tsconfig.json
|
|
1100
|
+
✨ Created my-worker/tsconfig.json
|
|
1101
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
985
1102
|
"warn": "",
|
|
986
1103
|
}
|
|
987
1104
|
`);
|
|
@@ -1000,12 +1117,12 @@ describe("init", () => {
|
|
|
1000
1117
|
{
|
|
1001
1118
|
text: "Would you like to use TypeScript?",
|
|
1002
1119
|
result: true,
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1006
|
-
result: false,
|
|
1007
1120
|
}
|
|
1008
1121
|
);
|
|
1122
|
+
mockSelect({
|
|
1123
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1124
|
+
result: "none",
|
|
1125
|
+
});
|
|
1009
1126
|
await runWrangler("init");
|
|
1010
1127
|
expect(fs.existsSync("./tsconfig.json")).toBe(true);
|
|
1011
1128
|
const { config: tsconfigJson, error: tsConfigParseError } =
|
|
@@ -1027,7 +1144,8 @@ describe("init", () => {
|
|
|
1027
1144
|
"err": "",
|
|
1028
1145
|
"out": "✨ Created wrangler.toml
|
|
1029
1146
|
✨ Created package.json
|
|
1030
|
-
✨ Created tsconfig.json
|
|
1147
|
+
✨ Created tsconfig.json
|
|
1148
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
1031
1149
|
"warn": "",
|
|
1032
1150
|
}
|
|
1033
1151
|
`);
|
|
@@ -1052,16 +1170,15 @@ describe("init", () => {
|
|
|
1052
1170
|
"utf-8"
|
|
1053
1171
|
);
|
|
1054
1172
|
|
|
1055
|
-
mockConfirm(
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
);
|
|
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
|
+
});
|
|
1065
1182
|
|
|
1066
1183
|
await runWrangler("init");
|
|
1067
1184
|
const tsconfigJson = JSON.parse(
|
|
@@ -1102,16 +1219,15 @@ describe("init", () => {
|
|
|
1102
1219
|
"utf-8"
|
|
1103
1220
|
);
|
|
1104
1221
|
|
|
1105
|
-
mockConfirm(
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
);
|
|
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
|
+
});
|
|
1115
1231
|
|
|
1116
1232
|
await runWrangler("init path/to/worker/my-worker");
|
|
1117
1233
|
const tsconfigJson = JSON.parse(
|
|
@@ -1145,12 +1261,12 @@ describe("init", () => {
|
|
|
1145
1261
|
{
|
|
1146
1262
|
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1147
1263
|
result: true,
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
text: "Would you like to create a Worker at src/index.ts?",
|
|
1151
|
-
result: false,
|
|
1152
1264
|
}
|
|
1153
1265
|
);
|
|
1266
|
+
mockSelect({
|
|
1267
|
+
text: "Would you like to create a Worker at src/index.ts?",
|
|
1268
|
+
result: "none",
|
|
1269
|
+
});
|
|
1154
1270
|
fs.writeFileSync(
|
|
1155
1271
|
"./package.json",
|
|
1156
1272
|
JSON.stringify({
|
|
@@ -1179,8 +1295,8 @@ describe("init", () => {
|
|
|
1179
1295
|
"debug": "",
|
|
1180
1296
|
"err": "",
|
|
1181
1297
|
"out": "✨ Created wrangler.toml
|
|
1182
|
-
✨ Installed @cloudflare/workers-types
|
|
1183
|
-
Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1298
|
+
✨ Installed @cloudflare/workers-types into devDependencies
|
|
1299
|
+
🚨 Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1184
1300
|
"warn": "",
|
|
1185
1301
|
}
|
|
1186
1302
|
`);
|
|
@@ -1205,16 +1321,15 @@ describe("init", () => {
|
|
|
1205
1321
|
"utf-8"
|
|
1206
1322
|
);
|
|
1207
1323
|
|
|
1208
|
-
mockConfirm(
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
);
|
|
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
|
+
});
|
|
1218
1333
|
|
|
1219
1334
|
fs.mkdirSync("./sub-1/sub-2", { recursive: true });
|
|
1220
1335
|
process.chdir("./sub-1/sub-2");
|
|
@@ -1261,12 +1376,12 @@ describe("init", () => {
|
|
|
1261
1376
|
{
|
|
1262
1377
|
text: "Would you like to use TypeScript?",
|
|
1263
1378
|
result: false,
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1267
|
-
result: true,
|
|
1268
1379
|
}
|
|
1269
1380
|
);
|
|
1381
|
+
mockSelect({
|
|
1382
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1383
|
+
result: "fetch",
|
|
1384
|
+
});
|
|
1270
1385
|
await runWrangler("init");
|
|
1271
1386
|
|
|
1272
1387
|
expect(fs.existsSync("./package.json")).toBe(true);
|
|
@@ -1278,7 +1393,7 @@ describe("init", () => {
|
|
|
1278
1393
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1279
1394
|
|
|
1280
1395
|
expect(packageJson.scripts.start).toBe("wrangler dev");
|
|
1281
|
-
expect(packageJson.scripts.
|
|
1396
|
+
expect(packageJson.scripts.deploy).toBe("wrangler publish");
|
|
1282
1397
|
expect(packageJson.name).toContain("wrangler-tests");
|
|
1283
1398
|
expect(packageJson.version).toEqual("0.0.0");
|
|
1284
1399
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1287,7 +1402,7 @@ describe("init", () => {
|
|
|
1287
1402
|
✨ Created src/index.js
|
|
1288
1403
|
|
|
1289
1404
|
To start developing your Worker, run \`npm start\`
|
|
1290
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1405
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1291
1406
|
`);
|
|
1292
1407
|
});
|
|
1293
1408
|
|
|
@@ -1304,18 +1419,18 @@ describe("init", () => {
|
|
|
1304
1419
|
{
|
|
1305
1420
|
text: "Would you like to use TypeScript?",
|
|
1306
1421
|
result: false,
|
|
1307
|
-
},
|
|
1308
|
-
{
|
|
1309
|
-
text: "Would you like to create a Worker at src/index.js?",
|
|
1310
|
-
result: true,
|
|
1311
1422
|
}
|
|
1312
1423
|
);
|
|
1424
|
+
mockSelect({
|
|
1425
|
+
text: "Would you like to create a Worker at src/index.js?",
|
|
1426
|
+
result: "fetch",
|
|
1427
|
+
});
|
|
1313
1428
|
await fsp.writeFile(
|
|
1314
1429
|
"./package.json",
|
|
1315
1430
|
JSON.stringify({
|
|
1316
1431
|
scripts: {
|
|
1317
1432
|
start: "test-start",
|
|
1318
|
-
|
|
1433
|
+
deploy: "test-publish",
|
|
1319
1434
|
},
|
|
1320
1435
|
})
|
|
1321
1436
|
);
|
|
@@ -1328,7 +1443,7 @@ describe("init", () => {
|
|
|
1328
1443
|
expect(fs.existsSync("./src/index.ts")).toBe(false);
|
|
1329
1444
|
|
|
1330
1445
|
expect(packageJson.scripts.start).toBe("test-start");
|
|
1331
|
-
expect(packageJson.scripts.
|
|
1446
|
+
expect(packageJson.scripts.deploy).toBe("test-publish");
|
|
1332
1447
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1333
1448
|
"✨ Created wrangler.toml
|
|
1334
1449
|
✨ Created src/index.js
|
|
@@ -1445,11 +1560,12 @@ describe("init", () => {
|
|
|
1445
1560
|
"out": "✨ Created wrangler.toml
|
|
1446
1561
|
✨ Initialized git repository
|
|
1447
1562
|
✨ Created package.json
|
|
1448
|
-
✨ Created tsconfig.json
|
|
1563
|
+
✨ Created tsconfig.json
|
|
1449
1564
|
✨ Created src/index.ts
|
|
1565
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1450
1566
|
|
|
1451
1567
|
To start developing your Worker, run \`npm start\`
|
|
1452
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1568
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1453
1569
|
"warn": "",
|
|
1454
1570
|
}
|
|
1455
1571
|
`);
|
|
@@ -1473,11 +1589,12 @@ describe("init", () => {
|
|
|
1473
1589
|
"out": "✨ Created path/to/worker/wrangler.toml
|
|
1474
1590
|
✨ Initialized git repository at path/to/worker
|
|
1475
1591
|
✨ Created path/to/worker/package.json
|
|
1476
|
-
✨ Created path/to/worker/tsconfig.json
|
|
1592
|
+
✨ Created path/to/worker/tsconfig.json
|
|
1477
1593
|
✨ Created path/to/worker/src/index.ts
|
|
1594
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1478
1595
|
|
|
1479
1596
|
To start developing your Worker, run \`cd path/to/worker && npm start\`
|
|
1480
|
-
To publish your Worker to the Internet, run \`npm run
|
|
1597
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1481
1598
|
"warn": "",
|
|
1482
1599
|
}
|
|
1483
1600
|
`);
|
|
@@ -1503,11 +1620,12 @@ describe("init", () => {
|
|
|
1503
1620
|
"out": "✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/wrangler.toml
|
|
1504
1621
|
✨ Initialized git repository at WEIRD_w0rkr_N4m3.js.tsx.tar.gz
|
|
1505
1622
|
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/package.json
|
|
1506
|
-
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json
|
|
1623
|
+
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json
|
|
1507
1624
|
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/src/index.ts
|
|
1625
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1508
1626
|
|
|
1509
1627
|
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
|
|
1628
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1511
1629
|
"warn": "",
|
|
1512
1630
|
}
|
|
1513
1631
|
`);
|