wrangler 2.0.24 → 2.0.27
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/miniflare-dist/index.mjs +142 -16
- package/package.json +3 -3
- package/src/__tests__/configuration.test.ts +7 -3
- package/src/__tests__/dev.test.tsx +26 -4
- package/src/__tests__/generate.test.ts +2 -4
- package/src/__tests__/helpers/mock-cfetch.ts +35 -2
- package/src/__tests__/init.test.ts +537 -359
- package/src/__tests__/jest.setup.ts +7 -0
- package/src/__tests__/metrics.test.ts +1 -1
- package/src/__tests__/pages.test.ts +14 -0
- package/src/__tests__/r2.test.ts +22 -3
- package/src/__tests__/tail.test.ts +112 -42
- package/src/__tests__/user.test.ts +11 -0
- package/src/api/dev.ts +7 -0
- package/src/bundle.ts +3 -2
- package/src/cfetch/internal.ts +56 -0
- package/src/config/config.ts +1 -1
- package/src/config/validation-helpers.ts +19 -6
- package/src/config/validation.ts +9 -3
- package/src/config-cache.ts +2 -1
- package/src/dev/dev.tsx +16 -2
- package/src/dev/local.tsx +69 -5
- package/src/dev/use-esbuild.ts +3 -0
- package/src/dev-registry.tsx +3 -0
- package/src/dev.tsx +28 -19
- package/src/generate.ts +1 -1
- package/src/index.tsx +51 -21
- package/src/init.ts +111 -38
- package/src/inspect.ts +1 -4
- package/src/{metrics/is-ci.ts → is-ci.ts} +0 -0
- package/src/metrics/metrics-config.ts +1 -1
- package/src/miniflare-cli/assets.ts +27 -16
- package/src/miniflare-cli/index.ts +124 -2
- package/src/pages/build.tsx +75 -41
- package/src/pages/constants.ts +4 -0
- package/src/pages/deployments.tsx +9 -9
- package/src/pages/dev.tsx +178 -64
- package/src/pages/errors.ts +22 -0
- package/src/pages/functions/buildPlugin.ts +4 -0
- package/src/pages/functions/buildWorker.ts +4 -0
- package/src/pages/functions/routes-consolidation.test.ts +250 -0
- package/src/pages/functions/routes-consolidation.ts +73 -0
- package/src/pages/functions/routes-transformation.test.ts +271 -0
- package/src/pages/functions/routes-transformation.ts +122 -0
- package/src/pages/functions.tsx +96 -0
- package/src/pages/index.tsx +65 -55
- package/src/pages/projects.tsx +9 -3
- package/src/pages/publish.tsx +75 -22
- package/src/pages/types.ts +9 -0
- package/src/pages/upload.tsx +6 -8
- package/src/proxy.ts +10 -0
- package/src/r2.ts +17 -4
- package/src/tail/filters.ts +3 -1
- package/src/tail/index.ts +15 -2
- package/src/tail/printing.ts +43 -3
- package/src/user/user.tsx +6 -4
- package/src/whoami.tsx +5 -5
- package/templates/pages-template-plugin.ts +16 -4
- package/templates/pages-template-worker.ts +16 -5
- package/templates/service-bindings-module-facade.js +10 -7
- package/templates/service-bindings-sw-facade.js +10 -7
- package/wrangler-dist/cli.d.ts +7 -0
- package/wrangler-dist/cli.js +1681 -1091
|
@@ -5,6 +5,8 @@ import { execa, execaSync } from "execa";
|
|
|
5
5
|
import { parseConfigFileTextToJson } from "typescript";
|
|
6
6
|
import { version as wranglerVersion } from "../../package.json";
|
|
7
7
|
import { getPackageManager } from "../package-manager";
|
|
8
|
+
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
9
|
+
import { setMockFetchDashScript, unsetAllMocks } from "./helpers/mock-cfetch";
|
|
8
10
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
9
11
|
import {
|
|
10
12
|
mockConfirm,
|
|
@@ -62,16 +64,16 @@ describe("init", () => {
|
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
expect(std.out).toMatchInlineSnapshot(`
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
"✨ Created wrangler.toml
|
|
68
|
+
✨ Initialized git repository
|
|
69
|
+
✨ Created package.json
|
|
70
|
+
✨ Created tsconfig.json
|
|
71
|
+
✨ Created src/index.ts
|
|
72
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
73
|
+
|
|
74
|
+
To start developing your Worker, run \`npm start\`
|
|
75
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
76
|
+
`);
|
|
75
77
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
76
78
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
77
79
|
});
|
|
@@ -93,16 +95,16 @@ describe("init", () => {
|
|
|
93
95
|
});
|
|
94
96
|
|
|
95
97
|
expect(std.out).toMatchInlineSnapshot(`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
"✨ Created my-worker/wrangler.toml
|
|
99
|
+
✨ Initialized git repository at my-worker
|
|
100
|
+
✨ Created my-worker/package.json
|
|
101
|
+
✨ Created my-worker/tsconfig.json
|
|
102
|
+
✨ Created my-worker/src/index.ts
|
|
103
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
104
|
+
|
|
105
|
+
To start developing your Worker, run \`cd my-worker && npm start\`
|
|
106
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
107
|
+
`);
|
|
106
108
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
107
109
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
108
110
|
});
|
|
@@ -121,21 +123,21 @@ describe("init", () => {
|
|
|
121
123
|
});
|
|
122
124
|
|
|
123
125
|
expect(std).toMatchInlineSnapshot(`
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
Object {
|
|
127
|
+
"debug": "",
|
|
128
|
+
"err": "",
|
|
129
|
+
"out": "✨ Created wrangler.toml
|
|
130
|
+
✨ Initialized git repository
|
|
131
|
+
✨ Created package.json
|
|
132
|
+
✨ Created tsconfig.json
|
|
133
|
+
✨ Created src/index.ts
|
|
134
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
135
|
+
|
|
136
|
+
To start developing your Worker, run \`npm start\`
|
|
137
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
138
|
+
"warn": "",
|
|
139
|
+
}
|
|
140
|
+
`);
|
|
139
141
|
});
|
|
140
142
|
|
|
141
143
|
it("should error if `--type javascript` is used", async () => {
|
|
@@ -204,13 +206,13 @@ describe("init", () => {
|
|
|
204
206
|
});
|
|
205
207
|
|
|
206
208
|
expect(std).toMatchInlineSnapshot(`
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
Object {
|
|
210
|
+
"debug": "",
|
|
211
|
+
"err": "",
|
|
212
|
+
"out": "✨ Created wrangler.toml",
|
|
213
|
+
"warn": "",
|
|
214
|
+
}
|
|
215
|
+
`);
|
|
214
216
|
});
|
|
215
217
|
|
|
216
218
|
it("should create a wrangler.toml and a directory for a named Worker ", async () => {
|
|
@@ -238,13 +240,13 @@ describe("init", () => {
|
|
|
238
240
|
});
|
|
239
241
|
|
|
240
242
|
expect(std).toMatchInlineSnapshot(`
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
Object {
|
|
244
|
+
"debug": "",
|
|
245
|
+
"err": "",
|
|
246
|
+
"out": "✨ Created my-worker/wrangler.toml",
|
|
247
|
+
"warn": "",
|
|
248
|
+
}
|
|
249
|
+
`);
|
|
248
250
|
});
|
|
249
251
|
|
|
250
252
|
it("should display warning when wrangler.toml already exists, and exit if user does not want to carry on", async () => {
|
|
@@ -276,15 +278,15 @@ describe("init", () => {
|
|
|
276
278
|
});
|
|
277
279
|
|
|
278
280
|
expect(std).toMatchInlineSnapshot(`
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
Object {
|
|
282
|
+
"debug": "",
|
|
283
|
+
"err": "",
|
|
284
|
+
"out": "",
|
|
285
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mwrangler.toml already exists![0m
|
|
286
|
+
|
|
287
|
+
",
|
|
288
|
+
}
|
|
289
|
+
`);
|
|
288
290
|
});
|
|
289
291
|
|
|
290
292
|
it("should display warning when wrangler.toml already exists in the target directory, and exit if user does not want to carry on", async () => {
|
|
@@ -313,15 +315,15 @@ describe("init", () => {
|
|
|
313
315
|
},
|
|
314
316
|
});
|
|
315
317
|
expect(std).toMatchInlineSnapshot(`
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
Object {
|
|
319
|
+
"debug": "",
|
|
320
|
+
"err": "",
|
|
321
|
+
"out": "",
|
|
322
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mpath/to/worker/wrangler.toml already exists![0m
|
|
323
|
+
|
|
324
|
+
",
|
|
325
|
+
}
|
|
326
|
+
`);
|
|
325
327
|
});
|
|
326
328
|
|
|
327
329
|
it("should not overwrite an existing wrangler.toml, after agreeing to other prompts", async () => {
|
|
@@ -401,15 +403,15 @@ describe("init", () => {
|
|
|
401
403
|
},
|
|
402
404
|
});
|
|
403
405
|
expect(std).toMatchInlineSnapshot(`
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
406
|
+
Object {
|
|
407
|
+
"debug": "",
|
|
408
|
+
"err": "",
|
|
409
|
+
"out": "",
|
|
410
|
+
"warn": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mwrangler.toml already exists![0m
|
|
411
|
+
|
|
412
|
+
",
|
|
413
|
+
}
|
|
414
|
+
`);
|
|
413
415
|
});
|
|
414
416
|
|
|
415
417
|
it("should not add a Cron Trigger to wrangler.toml when creating a Scheduled Worker if wrangler.toml already exists", async () => {
|
|
@@ -513,14 +515,14 @@ describe("init", () => {
|
|
|
513
515
|
},
|
|
514
516
|
});
|
|
515
517
|
expect(std).toMatchInlineSnapshot(`
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
518
|
+
Object {
|
|
519
|
+
"debug": "",
|
|
520
|
+
"err": "",
|
|
521
|
+
"out": "✨ Created wrangler.toml
|
|
522
|
+
✨ Initialized git repository",
|
|
523
|
+
"warn": "",
|
|
524
|
+
}
|
|
525
|
+
`);
|
|
524
526
|
expect((await execa("git", ["branch", "--show-current"])).stdout).toEqual(
|
|
525
527
|
"main"
|
|
526
528
|
);
|
|
@@ -545,20 +547,20 @@ describe("init", () => {
|
|
|
545
547
|
|
|
546
548
|
// Note the lack of "✨ Initialized git repository" in the log
|
|
547
549
|
expect(std).toMatchInlineSnapshot(`
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
550
|
+
Object {
|
|
551
|
+
"debug": "",
|
|
552
|
+
"err": "",
|
|
553
|
+
"out": "✨ Created wrangler.toml
|
|
554
|
+
✨ Created package.json
|
|
555
|
+
✨ Created tsconfig.json
|
|
556
|
+
✨ Created src/index.ts
|
|
557
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
558
|
+
|
|
559
|
+
To start developing your Worker, run \`npm start\`
|
|
560
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
561
|
+
"warn": "",
|
|
562
|
+
}
|
|
563
|
+
`);
|
|
562
564
|
});
|
|
563
565
|
|
|
564
566
|
it("should not offer to initialize a git repo if it's already inside one (when using a path as name)", async () => {
|
|
@@ -570,20 +572,20 @@ describe("init", () => {
|
|
|
570
572
|
|
|
571
573
|
// Note the lack of "✨ Initialized git repository" in the log
|
|
572
574
|
expect(std).toMatchInlineSnapshot(`
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
575
|
+
Object {
|
|
576
|
+
"debug": "",
|
|
577
|
+
"err": "",
|
|
578
|
+
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
579
|
+
✨ Created path/to/worker/my-worker/package.json
|
|
580
|
+
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
581
|
+
✨ Created path/to/worker/my-worker/src/index.ts
|
|
582
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
583
|
+
|
|
584
|
+
To start developing your Worker, run \`cd path/to/worker/my-worker && npm start\`
|
|
585
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
586
|
+
"warn": "",
|
|
587
|
+
}
|
|
588
|
+
`);
|
|
587
589
|
});
|
|
588
590
|
|
|
589
591
|
// I... don't know how to test this lol
|
|
@@ -604,14 +606,14 @@ describe("init", () => {
|
|
|
604
606
|
);
|
|
605
607
|
await runWrangler("init");
|
|
606
608
|
expect(std).toMatchInlineSnapshot(`
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
609
|
+
Object {
|
|
610
|
+
"debug": "",
|
|
611
|
+
"err": "",
|
|
612
|
+
"out": "✨ Created wrangler.toml
|
|
613
|
+
✨ Initialized git repository",
|
|
614
|
+
"warn": "",
|
|
615
|
+
}
|
|
616
|
+
`);
|
|
615
617
|
|
|
616
618
|
expect(execaSync("git", ["symbolic-ref", "HEAD"]).stdout).toEqual(
|
|
617
619
|
"refs/heads/main"
|
|
@@ -658,14 +660,14 @@ describe("init", () => {
|
|
|
658
660
|
});
|
|
659
661
|
expect(mockPackageManager.install).toHaveBeenCalled();
|
|
660
662
|
expect(std).toMatchInlineSnapshot(`
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
663
|
+
Object {
|
|
664
|
+
"debug": "",
|
|
665
|
+
"err": "",
|
|
666
|
+
"out": "✨ Created wrangler.toml
|
|
667
|
+
✨ Created package.json",
|
|
668
|
+
"warn": "",
|
|
669
|
+
}
|
|
670
|
+
`);
|
|
669
671
|
});
|
|
670
672
|
|
|
671
673
|
it("should create a package.json, with the specified name, if none is found and user confirms", async () => {
|
|
@@ -705,14 +707,14 @@ describe("init", () => {
|
|
|
705
707
|
},
|
|
706
708
|
});
|
|
707
709
|
expect(std).toMatchInlineSnapshot(`
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
710
|
+
Object {
|
|
711
|
+
"debug": "",
|
|
712
|
+
"err": "",
|
|
713
|
+
"out": "✨ Created my-worker/wrangler.toml
|
|
714
|
+
✨ Created my-worker/package.json",
|
|
715
|
+
"warn": "",
|
|
716
|
+
}
|
|
717
|
+
`);
|
|
716
718
|
});
|
|
717
719
|
|
|
718
720
|
it("should not touch an existing package.json in the same directory", async () => {
|
|
@@ -748,13 +750,13 @@ describe("init", () => {
|
|
|
748
750
|
},
|
|
749
751
|
});
|
|
750
752
|
expect(std).toMatchInlineSnapshot(`
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
753
|
+
Object {
|
|
754
|
+
"debug": "",
|
|
755
|
+
"err": "",
|
|
756
|
+
"out": "✨ Created wrangler.toml",
|
|
757
|
+
"warn": "",
|
|
758
|
+
}
|
|
759
|
+
`);
|
|
758
760
|
});
|
|
759
761
|
|
|
760
762
|
it("should not touch an existing package.json in an ancestor directory, when a name is passed", async () => {
|
|
@@ -798,14 +800,14 @@ describe("init", () => {
|
|
|
798
800
|
},
|
|
799
801
|
});
|
|
800
802
|
expect(std).toMatchInlineSnapshot(`
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
803
|
+
Object {
|
|
804
|
+
"debug": "",
|
|
805
|
+
"err": "",
|
|
806
|
+
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
807
|
+
✨ Created path/to/worker/my-worker/package.json",
|
|
808
|
+
"warn": "",
|
|
809
|
+
}
|
|
810
|
+
`);
|
|
809
811
|
});
|
|
810
812
|
|
|
811
813
|
it("should offer to install wrangler into an existing package.json", async () => {
|
|
@@ -848,14 +850,14 @@ describe("init", () => {
|
|
|
848
850
|
`wrangler@${wranglerVersion}`
|
|
849
851
|
);
|
|
850
852
|
expect(std).toMatchInlineSnapshot(`
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
853
|
+
Object {
|
|
854
|
+
"debug": "",
|
|
855
|
+
"err": "",
|
|
856
|
+
"out": "✨ Created wrangler.toml
|
|
857
|
+
✨ Installed wrangler into devDependencies",
|
|
858
|
+
"warn": "",
|
|
859
|
+
}
|
|
860
|
+
`);
|
|
859
861
|
});
|
|
860
862
|
|
|
861
863
|
it("should offer to install wrangler into a package.json relative to the target directory, if no name is provided", async () => {
|
|
@@ -902,14 +904,14 @@ describe("init", () => {
|
|
|
902
904
|
);
|
|
903
905
|
expect(mockPackageManager.cwd).toBe(process.cwd());
|
|
904
906
|
expect(std).toMatchInlineSnapshot(`
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
907
|
+
Object {
|
|
908
|
+
"debug": "",
|
|
909
|
+
"err": "",
|
|
910
|
+
"out": "✨ Created wrangler.toml
|
|
911
|
+
✨ Installed wrangler into devDependencies",
|
|
912
|
+
"warn": "",
|
|
913
|
+
}
|
|
914
|
+
`);
|
|
913
915
|
});
|
|
914
916
|
|
|
915
917
|
it("should not touch an existing package.json in an ancestor directory", async () => {
|
|
@@ -951,13 +953,13 @@ describe("init", () => {
|
|
|
951
953
|
},
|
|
952
954
|
});
|
|
953
955
|
expect(std).toMatchInlineSnapshot(`
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
956
|
+
Object {
|
|
957
|
+
"debug": "",
|
|
958
|
+
"err": "",
|
|
959
|
+
"out": "✨ Created wrangler.toml",
|
|
960
|
+
"warn": "",
|
|
961
|
+
}
|
|
962
|
+
`);
|
|
961
963
|
});
|
|
962
964
|
});
|
|
963
965
|
|
|
@@ -1002,17 +1004,17 @@ describe("init", () => {
|
|
|
1002
1004
|
},
|
|
1003
1005
|
});
|
|
1004
1006
|
expect(std).toMatchInlineSnapshot(`
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1007
|
+
Object {
|
|
1008
|
+
"debug": "",
|
|
1009
|
+
"err": "",
|
|
1010
|
+
"out": "✨ Created wrangler.toml
|
|
1011
|
+
✨ Created src/index.js
|
|
1012
|
+
|
|
1013
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1014
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
1015
|
+
"warn": "",
|
|
1016
|
+
}
|
|
1017
|
+
`);
|
|
1016
1018
|
});
|
|
1017
1019
|
|
|
1018
1020
|
it("should offer to create a worker in a typescript project", async () => {
|
|
@@ -1051,19 +1053,19 @@ describe("init", () => {
|
|
|
1051
1053
|
},
|
|
1052
1054
|
});
|
|
1053
1055
|
expect(std).toMatchInlineSnapshot(`
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1056
|
+
Object {
|
|
1057
|
+
"debug": "",
|
|
1058
|
+
"err": "",
|
|
1059
|
+
"out": "✨ Created wrangler.toml
|
|
1060
|
+
✨ Created tsconfig.json
|
|
1061
|
+
✨ Created src/index.ts
|
|
1062
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1063
|
+
|
|
1064
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1065
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
1066
|
+
"warn": "",
|
|
1067
|
+
}
|
|
1068
|
+
`);
|
|
1067
1069
|
});
|
|
1068
1070
|
|
|
1069
1071
|
it("should add scripts for a typescript project with .ts extension", async () => {
|
|
@@ -1109,15 +1111,15 @@ describe("init", () => {
|
|
|
1109
1111
|
},
|
|
1110
1112
|
});
|
|
1111
1113
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1114
|
+
"✨ Created wrangler.toml
|
|
1115
|
+
✨ Created package.json
|
|
1116
|
+
✨ Created tsconfig.json
|
|
1117
|
+
✨ Created src/index.ts
|
|
1118
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1119
|
+
|
|
1120
|
+
To start developing your Worker, run \`npm start\`
|
|
1121
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1122
|
+
`);
|
|
1121
1123
|
});
|
|
1122
1124
|
|
|
1123
1125
|
it("should not overwrite package.json scripts for a typescript project", async () => {
|
|
@@ -1169,14 +1171,14 @@ describe("init", () => {
|
|
|
1169
1171
|
},
|
|
1170
1172
|
});
|
|
1171
1173
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1174
|
+
"✨ Created wrangler.toml
|
|
1175
|
+
✨ Created tsconfig.json
|
|
1176
|
+
✨ Created src/index.ts
|
|
1177
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1178
|
+
|
|
1179
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1180
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`"
|
|
1181
|
+
`);
|
|
1180
1182
|
});
|
|
1181
1183
|
|
|
1182
1184
|
it("should not offer to create a worker in a ts project if a file already exists at the location", async () => {
|
|
@@ -1211,15 +1213,15 @@ describe("init", () => {
|
|
|
1211
1213
|
},
|
|
1212
1214
|
});
|
|
1213
1215
|
expect(std).toMatchInlineSnapshot(`
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1216
|
+
Object {
|
|
1217
|
+
"debug": "",
|
|
1218
|
+
"err": "",
|
|
1219
|
+
"out": "✨ Created wrangler.toml
|
|
1220
|
+
✨ Created tsconfig.json
|
|
1221
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
1222
|
+
"warn": "",
|
|
1223
|
+
}
|
|
1224
|
+
`);
|
|
1223
1225
|
});
|
|
1224
1226
|
|
|
1225
1227
|
it("should not offer to create a worker in a ts project for a named worker if a file already exists at the location", async () => {
|
|
@@ -1258,16 +1260,16 @@ describe("init", () => {
|
|
|
1258
1260
|
},
|
|
1259
1261
|
});
|
|
1260
1262
|
expect(std).toMatchInlineSnapshot(`
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1263
|
+
Object {
|
|
1264
|
+
"debug": "",
|
|
1265
|
+
"err": "",
|
|
1266
|
+
"out": "✨ Created my-worker/wrangler.toml
|
|
1267
|
+
✨ Created my-worker/package.json
|
|
1268
|
+
✨ Created my-worker/tsconfig.json
|
|
1269
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
1270
|
+
"warn": "",
|
|
1271
|
+
}
|
|
1272
|
+
`);
|
|
1271
1273
|
});
|
|
1272
1274
|
|
|
1273
1275
|
it("should create a tsconfig.json and install `workers-types` if none is found and user confirms", async () => {
|
|
@@ -1311,16 +1313,16 @@ describe("init", () => {
|
|
|
1311
1313
|
"typescript"
|
|
1312
1314
|
);
|
|
1313
1315
|
expect(std).toMatchInlineSnapshot(`
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1316
|
+
Object {
|
|
1317
|
+
"debug": "",
|
|
1318
|
+
"err": "",
|
|
1319
|
+
"out": "✨ Created wrangler.toml
|
|
1320
|
+
✨ Created package.json
|
|
1321
|
+
✨ Created tsconfig.json
|
|
1322
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies",
|
|
1323
|
+
"warn": "",
|
|
1324
|
+
}
|
|
1325
|
+
`);
|
|
1324
1326
|
});
|
|
1325
1327
|
|
|
1326
1328
|
it("should not touch an existing tsconfig.json in the same directory", async () => {
|
|
@@ -1358,17 +1360,17 @@ describe("init", () => {
|
|
|
1358
1360
|
},
|
|
1359
1361
|
});
|
|
1360
1362
|
expect(std).toMatchInlineSnapshot(`
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1363
|
+
Object {
|
|
1364
|
+
"debug": "",
|
|
1365
|
+
"err": "",
|
|
1366
|
+
"out": "✨ Created wrangler.toml
|
|
1367
|
+
✨ Created src/index.ts
|
|
1368
|
+
|
|
1369
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1370
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
1371
|
+
"warn": "",
|
|
1372
|
+
}
|
|
1373
|
+
`);
|
|
1372
1374
|
});
|
|
1373
1375
|
|
|
1374
1376
|
it("should not touch an existing tsconfig.json in the ancestor of a target directory, if a name is passed", async () => {
|
|
@@ -1416,20 +1418,20 @@ describe("init", () => {
|
|
|
1416
1418
|
},
|
|
1417
1419
|
});
|
|
1418
1420
|
expect(std).toMatchInlineSnapshot(`
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1421
|
+
Object {
|
|
1422
|
+
"debug": "",
|
|
1423
|
+
"err": "",
|
|
1424
|
+
"out": "✨ Created path/to/worker/my-worker/wrangler.toml
|
|
1425
|
+
✨ Created path/to/worker/my-worker/package.json
|
|
1426
|
+
✨ Created path/to/worker/my-worker/tsconfig.json
|
|
1427
|
+
✨ Created path/to/worker/my-worker/src/index.ts
|
|
1428
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1429
|
+
|
|
1430
|
+
To start developing your Worker, run \`cd path/to/worker/my-worker && npm start\`
|
|
1431
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1432
|
+
"warn": "",
|
|
1433
|
+
}
|
|
1434
|
+
`);
|
|
1433
1435
|
});
|
|
1434
1436
|
|
|
1435
1437
|
it("should offer to install type definitions in an existing typescript project", async () => {
|
|
@@ -1475,15 +1477,15 @@ describe("init", () => {
|
|
|
1475
1477
|
"@cloudflare/workers-types"
|
|
1476
1478
|
);
|
|
1477
1479
|
expect(std).toMatchInlineSnapshot(`
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1480
|
+
Object {
|
|
1481
|
+
"debug": "",
|
|
1482
|
+
"err": "",
|
|
1483
|
+
"out": "✨ Created wrangler.toml
|
|
1484
|
+
✨ Installed @cloudflare/workers-types into devDependencies
|
|
1485
|
+
🚨 Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
|
|
1486
|
+
"warn": "",
|
|
1487
|
+
}
|
|
1488
|
+
`);
|
|
1487
1489
|
});
|
|
1488
1490
|
|
|
1489
1491
|
it("should not touch an existing tsconfig.json in an ancestor directory", async () => {
|
|
@@ -1523,17 +1525,17 @@ describe("init", () => {
|
|
|
1523
1525
|
},
|
|
1524
1526
|
});
|
|
1525
1527
|
expect(std).toMatchInlineSnapshot(`
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1528
|
+
Object {
|
|
1529
|
+
"debug": "",
|
|
1530
|
+
"err": "",
|
|
1531
|
+
"out": "✨ Created wrangler.toml
|
|
1532
|
+
✨ Created src/index.ts
|
|
1533
|
+
|
|
1534
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1535
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`",
|
|
1536
|
+
"warn": "",
|
|
1537
|
+
}
|
|
1538
|
+
`);
|
|
1537
1539
|
});
|
|
1538
1540
|
});
|
|
1539
1541
|
|
|
@@ -1581,13 +1583,13 @@ describe("init", () => {
|
|
|
1581
1583
|
},
|
|
1582
1584
|
});
|
|
1583
1585
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1586
|
+
"✨ Created wrangler.toml
|
|
1587
|
+
✨ Created package.json
|
|
1588
|
+
✨ Created src/index.js
|
|
1587
1589
|
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1590
|
+
To start developing your Worker, run \`npm start\`
|
|
1591
|
+
To publish your Worker to the Internet, run \`npm run deploy\`"
|
|
1592
|
+
`);
|
|
1591
1593
|
});
|
|
1592
1594
|
|
|
1593
1595
|
it("should not overwrite package.json scripts for a non-ts project with .js extension", async () => {
|
|
@@ -1639,12 +1641,12 @@ describe("init", () => {
|
|
|
1639
1641
|
},
|
|
1640
1642
|
});
|
|
1641
1643
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
+
"✨ Created wrangler.toml
|
|
1645
|
+
✨ Created src/index.js
|
|
1644
1646
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1647
|
+
To start developing your Worker, run \`npx wrangler dev\`
|
|
1648
|
+
To publish your Worker to the Internet, run \`npx wrangler publish\`"
|
|
1649
|
+
`);
|
|
1648
1650
|
});
|
|
1649
1651
|
|
|
1650
1652
|
it("should not offer to create a worker in a non-ts project if a file already exists at the location", async () => {
|
|
@@ -1679,13 +1681,13 @@ describe("init", () => {
|
|
|
1679
1681
|
},
|
|
1680
1682
|
});
|
|
1681
1683
|
expect(std).toMatchInlineSnapshot(`
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1684
|
+
Object {
|
|
1685
|
+
"debug": "",
|
|
1686
|
+
"err": "",
|
|
1687
|
+
"out": "✨ Created wrangler.toml",
|
|
1688
|
+
"warn": "",
|
|
1689
|
+
}
|
|
1690
|
+
`);
|
|
1689
1691
|
});
|
|
1690
1692
|
|
|
1691
1693
|
it("should not offer to create a worker in a non-ts named worker project if a file already exists at the location", async () => {
|
|
@@ -1722,13 +1724,13 @@ describe("init", () => {
|
|
|
1722
1724
|
},
|
|
1723
1725
|
});
|
|
1724
1726
|
expect(std).toMatchInlineSnapshot(`
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1727
|
+
Object {
|
|
1728
|
+
"debug": "",
|
|
1729
|
+
"err": "",
|
|
1730
|
+
"out": "✨ Created my-worker/wrangler.toml",
|
|
1731
|
+
"warn": "",
|
|
1732
|
+
}
|
|
1733
|
+
`);
|
|
1732
1734
|
});
|
|
1733
1735
|
});
|
|
1734
1736
|
|
|
@@ -1759,21 +1761,21 @@ describe("init", () => {
|
|
|
1759
1761
|
},
|
|
1760
1762
|
});
|
|
1761
1763
|
expect(std).toMatchInlineSnapshot(`
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1764
|
+
Object {
|
|
1765
|
+
"debug": "",
|
|
1766
|
+
"err": "",
|
|
1767
|
+
"out": "✨ Created wrangler.toml
|
|
1768
|
+
✨ Initialized git repository
|
|
1769
|
+
✨ Created package.json
|
|
1770
|
+
✨ Created tsconfig.json
|
|
1771
|
+
✨ Created src/index.ts
|
|
1772
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1773
|
+
|
|
1774
|
+
To start developing your Worker, run \`npm start\`
|
|
1775
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1776
|
+
"warn": "",
|
|
1777
|
+
}
|
|
1778
|
+
`);
|
|
1777
1779
|
});
|
|
1778
1780
|
|
|
1779
1781
|
it('should create a worker in a nested directory if "name" is path/to/worker', async () => {
|
|
@@ -1788,21 +1790,21 @@ describe("init", () => {
|
|
|
1788
1790
|
},
|
|
1789
1791
|
});
|
|
1790
1792
|
expect(std).toMatchInlineSnapshot(`
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1793
|
+
Object {
|
|
1794
|
+
"debug": "",
|
|
1795
|
+
"err": "",
|
|
1796
|
+
"out": "✨ Created path/to/worker/wrangler.toml
|
|
1797
|
+
✨ Initialized git repository at path/to/worker
|
|
1798
|
+
✨ Created path/to/worker/package.json
|
|
1799
|
+
✨ Created path/to/worker/tsconfig.json
|
|
1800
|
+
✨ Created path/to/worker/src/index.ts
|
|
1801
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1802
|
+
|
|
1803
|
+
To start developing your Worker, run \`cd path/to/worker && npm start\`
|
|
1804
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1805
|
+
"warn": "",
|
|
1806
|
+
}
|
|
1807
|
+
`);
|
|
1806
1808
|
});
|
|
1807
1809
|
|
|
1808
1810
|
it("should normalize characters that aren't lowercase alphanumeric, underscores, or dashes", async () => {
|
|
@@ -1817,21 +1819,21 @@ describe("init", () => {
|
|
|
1817
1819
|
},
|
|
1818
1820
|
});
|
|
1819
1821
|
expect(std).toMatchInlineSnapshot(`
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1822
|
+
Object {
|
|
1823
|
+
"debug": "",
|
|
1824
|
+
"err": "",
|
|
1825
|
+
"out": "✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/wrangler.toml
|
|
1826
|
+
✨ Initialized git repository at WEIRD_w0rkr_N4m3.js.tsx.tar.gz
|
|
1827
|
+
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/package.json
|
|
1828
|
+
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json
|
|
1829
|
+
✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/src/index.ts
|
|
1830
|
+
✨ Installed @cloudflare/workers-types and typescript into devDependencies
|
|
1831
|
+
|
|
1832
|
+
To start developing your Worker, run \`cd WEIRD_w0rkr_N4m3.js.tsx.tar.gz && npm start\`
|
|
1833
|
+
To publish your Worker to the Internet, run \`npm run deploy\`",
|
|
1834
|
+
"warn": "",
|
|
1835
|
+
}
|
|
1836
|
+
`);
|
|
1835
1837
|
});
|
|
1836
1838
|
|
|
1837
1839
|
it("should ignore ancestor files (such as wrangler.toml, package.json and tsconfig.json) if a name/path is given", async () => {
|
|
@@ -1900,6 +1902,182 @@ describe("init", () => {
|
|
|
1900
1902
|
});
|
|
1901
1903
|
});
|
|
1902
1904
|
});
|
|
1905
|
+
|
|
1906
|
+
describe("from dashboard", () => {
|
|
1907
|
+
mockApiToken();
|
|
1908
|
+
mockAccountId({ accountId: "LCARS" });
|
|
1909
|
+
afterEach(() => {
|
|
1910
|
+
unsetAllMocks();
|
|
1911
|
+
});
|
|
1912
|
+
const mockDashboardScript = `
|
|
1913
|
+
export default {
|
|
1914
|
+
async fetch(request, env, ctx) {
|
|
1915
|
+
return new Response("Hello World!");
|
|
1916
|
+
},
|
|
1917
|
+
};
|
|
1918
|
+
`;
|
|
1919
|
+
|
|
1920
|
+
//TODO: Tests for a case when a worker name doesn't exist - JACOB & CASS
|
|
1921
|
+
it("should download source script from dashboard w/ positional <name> in TypeScript project", async () => {
|
|
1922
|
+
setMockFetchDashScript({
|
|
1923
|
+
accountId: "LCARS",
|
|
1924
|
+
fromDashScriptName: "memory-crystal",
|
|
1925
|
+
mockResponse: mockDashboardScript,
|
|
1926
|
+
});
|
|
1927
|
+
mockConfirm(
|
|
1928
|
+
{
|
|
1929
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1930
|
+
result: false,
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
text: "Would you like to use TypeScript?",
|
|
1934
|
+
result: true,
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
text: "No package.json found. Would you like to create one?",
|
|
1938
|
+
result: true,
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1942
|
+
result: true,
|
|
1943
|
+
}
|
|
1944
|
+
);
|
|
1945
|
+
|
|
1946
|
+
await runWrangler(
|
|
1947
|
+
"init isolinear-optical-chip --from-dash memory-crystal"
|
|
1948
|
+
);
|
|
1949
|
+
|
|
1950
|
+
checkFiles({
|
|
1951
|
+
items: {
|
|
1952
|
+
"isolinear-optical-chip/src/index.js": false,
|
|
1953
|
+
"isolinear-optical-chip/src/index.ts": {
|
|
1954
|
+
contents: mockDashboardScript,
|
|
1955
|
+
},
|
|
1956
|
+
"isolinear-optical-chip/package.json": {
|
|
1957
|
+
contents: expect.objectContaining({
|
|
1958
|
+
name: "isolinear-optical-chip",
|
|
1959
|
+
}),
|
|
1960
|
+
},
|
|
1961
|
+
"isolinear-optical-chip/tsconfig.json": true,
|
|
1962
|
+
"isolinear-optical-chip/wrangler.toml": wranglerToml({
|
|
1963
|
+
...MINIMAL_WRANGLER_TOML,
|
|
1964
|
+
name: "isolinear-optical-chip",
|
|
1965
|
+
}),
|
|
1966
|
+
},
|
|
1967
|
+
});
|
|
1968
|
+
});
|
|
1969
|
+
|
|
1970
|
+
it("should download source script from dashboard w/ out positional <name>", async () => {
|
|
1971
|
+
setMockFetchDashScript({
|
|
1972
|
+
accountId: "LCARS",
|
|
1973
|
+
fromDashScriptName: "isolinear-optical-chip",
|
|
1974
|
+
mockResponse: mockDashboardScript,
|
|
1975
|
+
});
|
|
1976
|
+
mockConfirm(
|
|
1977
|
+
{
|
|
1978
|
+
text: "Would you like to use git to manage this Worker?",
|
|
1979
|
+
result: false,
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
text: "Would you like to use TypeScript?",
|
|
1983
|
+
result: true,
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
text: "No package.json found. Would you like to create one?",
|
|
1987
|
+
result: true,
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
1991
|
+
result: true,
|
|
1992
|
+
}
|
|
1993
|
+
);
|
|
1994
|
+
|
|
1995
|
+
await runWrangler("init --from-dash isolinear-optical-chip");
|
|
1996
|
+
|
|
1997
|
+
checkFiles({
|
|
1998
|
+
items: {
|
|
1999
|
+
"isolinear-optical-chip/src/index.js": false,
|
|
2000
|
+
"isolinear-optical-chip/src/index.ts": {
|
|
2001
|
+
contents: mockDashboardScript,
|
|
2002
|
+
},
|
|
2003
|
+
"isolinear-optical-chip/package.json": {
|
|
2004
|
+
contents: expect.objectContaining({
|
|
2005
|
+
name: "isolinear-optical-chip",
|
|
2006
|
+
}),
|
|
2007
|
+
},
|
|
2008
|
+
"isolinear-optical-chip/tsconfig.json": true,
|
|
2009
|
+
"isolinear-optical-chip/wrangler.toml": wranglerToml({
|
|
2010
|
+
...MINIMAL_WRANGLER_TOML,
|
|
2011
|
+
name: "isolinear-optical-chip",
|
|
2012
|
+
}),
|
|
2013
|
+
},
|
|
2014
|
+
});
|
|
2015
|
+
});
|
|
2016
|
+
|
|
2017
|
+
it("should download source script from dashboard as plain JavaScript", async () => {
|
|
2018
|
+
setMockFetchDashScript({
|
|
2019
|
+
accountId: "LCARS",
|
|
2020
|
+
fromDashScriptName: "isolinear-optical-chip",
|
|
2021
|
+
mockResponse: mockDashboardScript,
|
|
2022
|
+
});
|
|
2023
|
+
mockConfirm(
|
|
2024
|
+
{
|
|
2025
|
+
text: "Would you like to use git to manage this Worker?",
|
|
2026
|
+
result: false,
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
text: "Would you like to use TypeScript?",
|
|
2030
|
+
result: false,
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
text: "No package.json found. Would you like to create one?",
|
|
2034
|
+
result: true,
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
text: "Would you like to install the type definitions for Workers into your package.json?",
|
|
2038
|
+
result: true,
|
|
2039
|
+
}
|
|
2040
|
+
);
|
|
2041
|
+
|
|
2042
|
+
await runWrangler("init --from-dash isolinear-optical-chip");
|
|
2043
|
+
|
|
2044
|
+
checkFiles({
|
|
2045
|
+
items: {
|
|
2046
|
+
"isolinear-optical-chip/src/index.js": {
|
|
2047
|
+
contents: mockDashboardScript,
|
|
2048
|
+
},
|
|
2049
|
+
"isolinear-optical-chip/src/index.ts": false,
|
|
2050
|
+
"isolinear-optical-chip/package.json": {
|
|
2051
|
+
contents: expect.objectContaining({
|
|
2052
|
+
name: "isolinear-optical-chip",
|
|
2053
|
+
}),
|
|
2054
|
+
},
|
|
2055
|
+
"isolinear-optical-chip/tsconfig.json": false,
|
|
2056
|
+
"isolinear-optical-chip/wrangler.toml": wranglerToml({
|
|
2057
|
+
...MINIMAL_WRANGLER_TOML,
|
|
2058
|
+
name: "isolinear-optical-chip",
|
|
2059
|
+
}),
|
|
2060
|
+
},
|
|
2061
|
+
});
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
it("should not continue if no worker name is provided", async () => {
|
|
2065
|
+
await expect(
|
|
2066
|
+
runWrangler("init --from-dash")
|
|
2067
|
+
).rejects.toMatchInlineSnapshot(
|
|
2068
|
+
`[YError: Not enough arguments following: from-dash]`
|
|
2069
|
+
);
|
|
2070
|
+
checkFiles({
|
|
2071
|
+
items: {
|
|
2072
|
+
"isolinear-optical-chip/src/index.js": false,
|
|
2073
|
+
"isolinear-optical-chip/src/index.ts": false,
|
|
2074
|
+
"isolinear-optical-chip/package.json": false,
|
|
2075
|
+
"isolinear-optical-chip/tsconfig.json": false,
|
|
2076
|
+
"isolinear-optical-chip/wrangler.toml": false,
|
|
2077
|
+
},
|
|
2078
|
+
});
|
|
2079
|
+
});
|
|
2080
|
+
});
|
|
1903
2081
|
});
|
|
1904
2082
|
|
|
1905
2083
|
/**
|