wrangler 0.0.32 → 2.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "0.0.32",
3
+ "version": "2.0.0",
4
4
  "author": "wrangler@cloudflare.com",
5
5
  "description": "Command-line interface for all things Cloudflare Workers",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  import { confirm, prompt } from "../../dialogs";
2
+ import { normalizeSlashes } from "./mock-console";
2
3
 
3
4
  /**
4
5
  * The expected values for a confirmation request.
@@ -20,7 +21,7 @@ export interface ConfirmExpectation {
20
21
  export function mockConfirm(...expectations: ConfirmExpectation[]) {
21
22
  (confirm as jest.Mock).mockImplementation((text: string) => {
22
23
  for (const { text: expectedText, result } of expectations) {
23
- if (text === expectedText) {
24
+ if (normalizeSlashes(text) === normalizeSlashes(expectedText)) {
24
25
  return Promise.resolve(result);
25
26
  }
26
27
  }
@@ -43,7 +43,7 @@ describe("init", () => {
43
43
  expect(fs.existsSync("./package.json")).toBe(true);
44
44
  expect(fs.existsSync("./wrangler.toml")).toBe(true);
45
45
  expect(std.out).toMatchInlineSnapshot(`
46
- "✨ Successfully created wrangler.toml
46
+ "✨ Created wrangler.toml
47
47
  ✨ Initialized git repository
48
48
  ✨ Created package.json
49
49
  ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
@@ -69,11 +69,11 @@ describe("init", () => {
69
69
  );
70
70
  expect(parsedWranglerToml.main).toEqual("src/index.ts");
71
71
  expect(std.out).toMatchInlineSnapshot(`
72
- "✨ Successfully created wrangler.toml
73
- ✨ Initialized git repository
74
- ✨ Created package.json
75
- ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
76
- ✨ Created src/index.ts
72
+ "✨ Created my-worker/wrangler.toml
73
+ ✨ Initialized git repository at my-worker
74
+ ✨ Created my-worker/package.json
75
+ ✨ Created my-worker/tsconfig.json, installed @cloudflare/workers-types into devDependencies
76
+ ✨ Created my-worker/src/index.ts
77
77
 
78
78
  To start developing your Worker, run \`cd my-worker && npm start\`
79
79
  To publish your Worker to the Internet, run \`npm run publish\`"
@@ -94,7 +94,7 @@ describe("init", () => {
94
94
  Object {
95
95
  "debug": "",
96
96
  "err": "",
97
- "out": "✨ Successfully created wrangler.toml
97
+ "out": "✨ Created wrangler.toml
98
98
  ✨ Initialized git repository
99
99
  ✨ Created package.json
100
100
  ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
@@ -166,6 +166,14 @@ describe("init", () => {
166
166
  expect(parsed.name).toContain("wrangler-tests");
167
167
  expect(fs.existsSync("./package.json")).toBe(false);
168
168
  expect(fs.existsSync("./tsconfig.json")).toBe(false);
169
+ expect(std).toMatchInlineSnapshot(`
170
+ Object {
171
+ "debug": "",
172
+ "err": "",
173
+ "out": "✨ Created wrangler.toml",
174
+ "warn": "",
175
+ }
176
+ `);
169
177
  });
170
178
 
171
179
  it("should create a wrangler.toml and a directory for a named Worker ", async () => {
@@ -187,6 +195,15 @@ describe("init", () => {
187
195
  expect(parsed.name).toBe("my-worker");
188
196
  expect(fs.existsSync("./my-worker/package.json")).toBe(false);
189
197
  expect(fs.existsSync("./my-worker/tsconfig.json")).toBe(false);
198
+
199
+ expect(std).toMatchInlineSnapshot(`
200
+ Object {
201
+ "debug": "",
202
+ "err": "",
203
+ "out": "✨ Created my-worker/wrangler.toml",
204
+ "warn": "",
205
+ }
206
+ `);
190
207
  });
191
208
 
192
209
  it("should display warning when wrangler.toml already exists, and exit if user does not want to carry on", async () => {
@@ -200,9 +217,49 @@ describe("init", () => {
200
217
  result: false,
201
218
  });
202
219
  await runWrangler("init");
203
- expect(std.warn).toContain("wrangler.toml file already exists!");
220
+ expect(std.warn).toContain("wrangler.toml already exists!");
204
221
  const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
205
222
  expect(parsed.compatibility_date).toBe("something-else");
223
+
224
+ expect(std).toMatchInlineSnapshot(`
225
+ Object {
226
+ "debug": "",
227
+ "err": "",
228
+ "out": "",
229
+ "warn": "▲ [WARNING] wrangler.toml already exists!
230
+
231
+ ",
232
+ }
233
+ `);
234
+ });
235
+
236
+ it("should display warning when wrangler.toml already exists in the target directory, and exit if user does not want to carry on", async () => {
237
+ fs.mkdirSync("path/to/worker", { recursive: true });
238
+ fs.writeFileSync(
239
+ "path/to/worker/wrangler.toml",
240
+ 'compatibility_date="something-else"', // use a fake value to make sure the file is not overwritten
241
+ "utf-8"
242
+ );
243
+ mockConfirm({
244
+ text: "Do you want to continue initializing this project?",
245
+ result: false,
246
+ });
247
+ await runWrangler("init path/to/worker");
248
+ expect(std.warn).toContain("wrangler.toml already exists!");
249
+ const parsed = TOML.parse(
250
+ await fsp.readFile("path/to/worker/wrangler.toml", "utf-8")
251
+ );
252
+ expect(parsed.compatibility_date).toBe("something-else");
253
+ expect(std).toMatchInlineSnapshot(`
254
+ Object {
255
+ "debug": "",
256
+ "err": "",
257
+ "out": "",
258
+ "warn": "▲ [WARNING] path/to/worker/wrangler.toml already exists!
259
+
260
+ ",
261
+ }
262
+ `);
206
263
  });
207
264
 
208
265
  it("should not overwrite an existing wrangler.toml, after agreeing to other prompts", async () => {
@@ -261,9 +318,19 @@ describe("init", () => {
261
318
  }
262
319
  );
263
320
  await runWrangler("init");
264
- expect(std.warn).toContain("wrangler.toml file already exists!");
321
+ expect(std.warn).toContain("wrangler.toml already exists!");
265
322
  const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
266
323
  expect(parsed.compatibility_date).toBe("something-else");
324
+ expect(std).toMatchInlineSnapshot(`
325
+ Object {
326
+ "debug": "",
327
+ "err": "",
328
+ "out": "",
329
+ "warn": "▲ [WARNING] wrangler.toml already exists!
330
+
331
+ ",
332
+ }
333
+ `);
267
334
  });
268
335
  });
269
336
 
@@ -284,7 +351,7 @@ describe("init", () => {
284
351
  Object {
285
352
  "debug": "",
286
353
  "err": "",
287
- "out": "✨ Successfully created wrangler.toml
354
+ "out": "✨ Created wrangler.toml
288
355
  ✨ Initialized git repository",
289
356
  "warn": "",
290
357
  }
@@ -304,8 +371,7 @@ describe("init", () => {
304
371
  Object {
305
372
  "debug": "",
306
373
  "err": "",
307
- "out": "✨ Successfully created wrangler.toml
308
- ✨ Initialized git repository
374
+ "out": "✨ Created wrangler.toml
309
375
  ✨ Created package.json
310
376
  ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
311
377
  ✨ Created src/index.ts
@@ -317,6 +383,30 @@ describe("init", () => {
317
383
  `);
318
384
  });
319
385
 
386
+ it("should not offer to initialize a git repo if it's already inside one (when using a path as name)", async () => {
387
+ fs.mkdirSync("path/to/worker", { recursive: true });
388
+ await execa("git", ["init"], { cwd: "path/to/worker" });
389
+ expect(fs.lstatSync("path/to/worker/.git").isDirectory()).toBe(true);
390
+
391
+ await runWrangler("init path/to/worker/my-worker -y");
392
+
393
+ // Note the lack of "✨ Initialized git repository" in the log
394
+ expect(std).toMatchInlineSnapshot(`
395
+ Object {
396
+ "debug": "",
397
+ "err": "",
398
+ "out": "✨ Created path/to/worker/my-worker/wrangler.toml
399
+ ✨ Created path/to/worker/my-worker/package.json
400
+ ✨ Created path/to/worker/my-worker/tsconfig.json, installed @cloudflare/workers-types into devDependencies
401
+ ✨ Created path/to/worker/my-worker/src/index.ts
402
+
403
+ 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 publish\`",
405
+ "warn": "",
406
+ }
407
+ `);
408
+ });
409
+
320
410
  it.todo(
321
411
  "should not offer to initialize a git repo if git is not installed"
322
412
  );
@@ -355,6 +445,15 @@ describe("init", () => {
355
445
  });
356
446
  expect(fs.existsSync("./tsconfig.json")).toBe(false);
357
447
  expect(mockPackageManager.install).toHaveBeenCalled();
448
+ expect(std).toMatchInlineSnapshot(`
449
+ Object {
450
+ "debug": "",
451
+ "err": "",
452
+ "out": "✨ Created wrangler.toml
453
+ ✨ Created package.json",
454
+ "warn": "",
455
+ }
456
+ `);
358
457
  });
359
458
 
360
459
  it("should create a package.json, with the specified name, if none is found and user confirms", async () => {
@@ -372,7 +471,7 @@ describe("init", () => {
372
471
  result: false,
373
472
  },
374
473
  {
375
- text: "Would you like to create a Worker at src/index.js?",
474
+ text: "Would you like to create a Worker at my-worker/src/index.js?",
376
475
  result: false,
377
476
  }
378
477
  );
@@ -381,6 +480,15 @@ describe("init", () => {
381
480
  fs.readFileSync("./my-worker/package.json", "utf-8")
382
481
  );
383
482
  expect(packageJson.name).toBe("my-worker");
483
+ expect(std).toMatchInlineSnapshot(`
484
+ Object {
485
+ "debug": "",
486
+ "err": "",
487
+ "out": "✨ Created my-worker/wrangler.toml
488
+ ✨ Created my-worker/package.json",
489
+ "warn": "",
490
+ }
491
+ `);
384
492
  });
385
493
 
386
494
  it("should not touch an existing package.json in the same directory", async () => {
@@ -390,7 +498,7 @@ describe("init", () => {
390
498
  result: false,
391
499
  },
392
500
  {
393
- text: "Would you like to install wrangler into your package.json?",
501
+ text: "Would you like to install wrangler into package.json?",
394
502
  result: false,
395
503
  },
396
504
  {
@@ -415,6 +523,57 @@ describe("init", () => {
415
523
  );
416
524
  expect(packageJson.name).toEqual("test");
417
525
  expect(packageJson.version).toEqual("1.0.0");
526
+ expect(std).toMatchInlineSnapshot(`
527
+ Object {
528
+ "debug": "",
529
+ "err": "",
530
+ "out": "✨ Created wrangler.toml",
531
+ "warn": "",
532
+ }
533
+ `);
534
+ });
535
+
536
+ it("should not touch an existing package.json in a target directory", async () => {
537
+ mockConfirm(
538
+ {
539
+ text: "Would you like to use git to manage this Worker?",
540
+ result: false,
541
+ },
542
+ {
543
+ text: "Would you like to install wrangler into path/to/worker/package.json?",
544
+ result: false,
545
+ },
546
+ {
547
+ text: "Would you like to use TypeScript?",
548
+ 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
+ }
554
+ );
555
+
556
+ fs.mkdirSync("path/to/worker", { recursive: true });
557
+ fs.writeFileSync(
558
+ "path/to/worker/package.json",
559
+ JSON.stringify({ name: "test", version: "1.0.0" }),
560
+ "utf-8"
561
+ );
562
+
563
+ await runWrangler("init path/to/worker/my-worker");
564
+ const packageJson = JSON.parse(
565
+ fs.readFileSync("path/to/worker/package.json", "utf-8")
566
+ );
567
+ expect(packageJson.name).toEqual("test");
568
+ expect(packageJson.version).toEqual("1.0.0");
569
+ expect(std).toMatchInlineSnapshot(`
570
+ Object {
571
+ "debug": "",
572
+ "err": "",
573
+ "out": "✨ Created path/to/worker/my-worker/wrangler.toml",
574
+ "warn": "",
575
+ }
576
+ `);
418
577
  });
419
578
 
420
579
  it("should offer to install wrangler into an existing package.json", async () => {
@@ -424,7 +583,7 @@ describe("init", () => {
424
583
  result: false,
425
584
  },
426
585
  {
427
- text: "Would you like to install wrangler into your package.json?",
586
+ text: "Would you like to install wrangler into package.json?",
428
587
  result: true,
429
588
  },
430
589
  {
@@ -452,6 +611,63 @@ describe("init", () => {
452
611
  expect(mockPackageManager.addDevDeps).toHaveBeenCalledWith(
453
612
  `wrangler@${wranglerVersion}`
454
613
  );
614
+ expect(std).toMatchInlineSnapshot(`
615
+ Object {
616
+ "debug": "",
617
+ "err": "",
618
+ "out": "✨ Created wrangler.toml
619
+ ✨ Installed wrangler",
620
+ "warn": "",
621
+ }
622
+ `);
623
+ });
624
+
625
+ it("should offer to install wrangler into a package.json relative to the target directory", async () => {
626
+ mockConfirm(
627
+ {
628
+ text: "Would you like to use git to manage this Worker?",
629
+ result: false,
630
+ },
631
+ {
632
+ text: "Would you like to install wrangler into path/to/worker/package.json?",
633
+ result: true,
634
+ },
635
+ {
636
+ text: "Would you like to use TypeScript?",
637
+ 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
+ }
643
+ );
644
+
645
+ fs.mkdirSync("path/to/worker", { recursive: true });
646
+ fs.writeFileSync(
647
+ "path/to/worker/package.json",
648
+ JSON.stringify({ name: "test", version: "1.0.0" }),
649
+ "utf-8"
650
+ );
651
+
652
+ await runWrangler("init path/to/worker/my-worker");
653
+ const packageJson = JSON.parse(
654
+ fs.readFileSync("path/to/worker/package.json", "utf-8")
655
+ );
656
+ expect(packageJson.name).toEqual("test");
657
+ expect(packageJson.version).toEqual("1.0.0");
658
+ expect(mockPackageManager.addDevDeps).toHaveBeenCalledWith(
659
+ `wrangler@${wranglerVersion}`
660
+ );
661
+ expect(mockPackageManager.cwd).toBe(process.cwd());
662
+ expect(std).toMatchInlineSnapshot(`
663
+ Object {
664
+ "debug": "",
665
+ "err": "",
666
+ "out": "✨ Created path/to/worker/my-worker/wrangler.toml
667
+ ✨ Installed wrangler",
668
+ "warn": "",
669
+ }
670
+ `);
455
671
  });
456
672
 
457
673
  it("should not touch an existing package.json in an ancestor directory", async () => {
@@ -461,7 +677,7 @@ describe("init", () => {
461
677
  result: false,
462
678
  },
463
679
  {
464
- text: "Would you like to install wrangler into your package.json?",
680
+ text: "Would you like to install wrangler into ../../package.json?",
465
681
  result: false,
466
682
  },
467
683
  {
@@ -496,6 +712,14 @@ describe("init", () => {
496
712
  "version": "1.0.0",
497
713
  }
498
714
  `);
715
+ expect(std).toMatchInlineSnapshot(`
716
+ Object {
717
+ "debug": "",
718
+ "err": "",
719
+ "out": "✨ Created wrangler.toml",
720
+ "warn": "",
721
+ }
722
+ `);
499
723
  });
500
724
  });
501
725
 
@@ -507,7 +731,7 @@ describe("init", () => {
507
731
  result: false,
508
732
  },
509
733
  {
510
- text: "Would you like to install wrangler into your package.json?",
734
+ text: "Would you like to install wrangler into package.json?",
511
735
  result: false,
512
736
  },
513
737
  {
@@ -529,6 +753,18 @@ describe("init", () => {
529
753
  await runWrangler("init");
530
754
  expect(fs.existsSync("./src/index.js")).toBe(true);
531
755
  expect(fs.existsSync("./src/index.ts")).toBe(false);
756
+ expect(std).toMatchInlineSnapshot(`
757
+ Object {
758
+ "debug": "",
759
+ "err": "",
760
+ "out": "✨ Created wrangler.toml
761
+ ✨ Created src/index.js
762
+
763
+ To start developing your Worker, run \`npx wrangler dev\`
764
+ To publish your Worker to the Internet, run \`npx wrangler publish\`",
765
+ "warn": "",
766
+ }
767
+ `);
532
768
  });
533
769
 
534
770
  it("should offer to create a worker in a typescript project", async () => {
@@ -538,7 +774,7 @@ describe("init", () => {
538
774
  result: false,
539
775
  },
540
776
  {
541
- text: "Would you like to install wrangler into your package.json?",
777
+ text: "Would you like to install wrangler into package.json?",
542
778
  result: false,
543
779
  },
544
780
  {
@@ -560,6 +796,19 @@ describe("init", () => {
560
796
  await runWrangler("init");
561
797
  expect(fs.existsSync("./src/index.js")).toBe(false);
562
798
  expect(fs.existsSync("./src/index.ts")).toBe(true);
799
+ expect(std).toMatchInlineSnapshot(`
800
+ Object {
801
+ "debug": "",
802
+ "err": "",
803
+ "out": "✨ Created wrangler.toml
804
+ ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
805
+ ✨ Created src/index.ts
806
+
807
+ To start developing your Worker, run \`npx wrangler dev\`
808
+ To publish your Worker to the Internet, run \`npx wrangler publish\`",
809
+ "warn": "",
810
+ }
811
+ `);
563
812
  });
564
813
 
565
814
  it("should add scripts for a typescript project with .ts extension", async () => {
@@ -573,7 +822,7 @@ describe("init", () => {
573
822
  result: true,
574
823
  },
575
824
  {
576
- text: "Would you like to install wrangler into your package.json?",
825
+ text: "Would you like to install wrangler into package.json?",
577
826
  result: false,
578
827
  },
579
828
  {
@@ -600,7 +849,7 @@ describe("init", () => {
600
849
  expect(packageJson.name).toContain("wrangler-tests");
601
850
  expect(packageJson.version).toEqual("0.0.0");
602
851
  expect(std.out).toMatchInlineSnapshot(`
603
- "✨ Successfully created wrangler.toml
852
+ "✨ Created wrangler.toml
604
853
  ✨ Created package.json
605
854
  ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
606
855
  ✨ Created src/index.ts
@@ -617,7 +866,7 @@ describe("init", () => {
617
866
  result: false,
618
867
  },
619
868
  {
620
- text: "Would you like to install wrangler into your package.json?",
869
+ text: "Would you like to install wrangler into package.json?",
621
870
  result: false,
622
871
  },
623
872
  {
@@ -649,7 +898,7 @@ describe("init", () => {
649
898
  expect(packageJson.scripts.start).toBe("test-start");
650
899
  expect(packageJson.scripts.publish).toBe("test-publish");
651
900
  expect(std.out).toMatchInlineSnapshot(`
652
- "✨ Successfully created wrangler.toml
901
+ "✨ Created wrangler.toml
653
902
  ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
654
903
  ✨ Created src/index.ts
655
904
 
@@ -665,7 +914,7 @@ describe("init", () => {
665
914
  result: false,
666
915
  },
667
916
  {
668
- text: "Would you like to install wrangler into your package.json?",
917
+ text: "Would you like to install wrangler into package.json?",
669
918
  result: false,
670
919
  },
671
920
  {
@@ -686,6 +935,56 @@ describe("init", () => {
686
935
  await runWrangler("init");
687
936
  expect(fs.existsSync("./src/index.js")).toBe(false);
688
937
  expect(fs.readFileSync("./src/index.ts", "utf-8")).toBe(PLACEHOLDER);
938
+ expect(std).toMatchInlineSnapshot(`
939
+ Object {
940
+ "debug": "",
941
+ "err": "",
942
+ "out": "✨ Created wrangler.toml
943
+ ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies",
944
+ "warn": "",
945
+ }
946
+ `);
947
+ });
948
+
949
+ 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 () => {
950
+ mockConfirm(
951
+ {
952
+ text: "Would you like to use git to manage this Worker?",
953
+ result: false,
954
+ },
955
+ {
956
+ text: "Would you like to install wrangler into package.json?",
957
+ result: false,
958
+ },
959
+ {
960
+ text: "Would you like to use TypeScript?",
961
+ result: true,
962
+ }
963
+ );
964
+
965
+ fs.writeFileSync(
966
+ "./package.json",
967
+ JSON.stringify({ name: "test", version: "1.0.0" }),
968
+ "utf-8"
969
+ );
970
+ fs.mkdirSync("./my-worker/src", { recursive: true });
971
+ const PLACEHOLDER = "/* placeholder text */";
972
+ fs.writeFileSync("./my-worker/src/index.ts", PLACEHOLDER, "utf-8");
973
+
974
+ await runWrangler("init my-worker");
975
+ expect(fs.existsSync("./my-worker/src/index.js")).toBe(false);
976
+ expect(fs.readFileSync("./my-worker/src/index.ts", "utf-8")).toBe(
977
+ PLACEHOLDER
978
+ );
979
+ expect(std).toMatchInlineSnapshot(`
980
+ Object {
981
+ "debug": "",
982
+ "err": "",
983
+ "out": "✨ Created my-worker/wrangler.toml
984
+ ✨ Created my-worker/tsconfig.json, installed @cloudflare/workers-types into devDependencies",
985
+ "warn": "",
986
+ }
987
+ `);
689
988
  });
690
989
 
691
990
  it("should create a tsconfig.json and install `workers-types` if none is found and user confirms", async () => {
@@ -722,6 +1021,16 @@ describe("init", () => {
722
1021
  "@cloudflare/workers-types",
723
1022
  "typescript"
724
1023
  );
1024
+ expect(std).toMatchInlineSnapshot(`
1025
+ Object {
1026
+ "debug": "",
1027
+ "err": "",
1028
+ "out": "✨ Created wrangler.toml
1029
+ ✨ Created package.json
1030
+ ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies",
1031
+ "warn": "",
1032
+ }
1033
+ `);
725
1034
  });
726
1035
 
727
1036
  it("should not touch an existing tsconfig.json in the same directory", async () => {
@@ -759,6 +1068,68 @@ describe("init", () => {
759
1068
  fs.readFileSync("./tsconfig.json", "utf-8")
760
1069
  );
761
1070
  expect(tsconfigJson.compilerOptions).toEqual({});
1071
+ expect(std).toMatchInlineSnapshot(`
1072
+ Object {
1073
+ "debug": "",
1074
+ "err": "",
1075
+ "out": "✨ Created wrangler.toml
1076
+ ✨ Created src/index.ts
1077
+
1078
+ To start developing your Worker, run \`npx wrangler dev\`
1079
+ To publish your Worker to the Internet, run \`npx wrangler publish\`",
1080
+ "warn": "",
1081
+ }
1082
+ `);
1083
+ });
1084
+
1085
+ it("should not touch an existing tsconfig.json in the ancestor of a target directory", async () => {
1086
+ fs.mkdirSync("path/to/worker", { recursive: true });
1087
+ fs.writeFileSync(
1088
+ "path/to/worker/package.json",
1089
+ JSON.stringify({
1090
+ name: "test",
1091
+ version: "1.0.0",
1092
+ devDependencies: {
1093
+ wrangler: "0.0.0",
1094
+ "@cloudflare/workers-types": "0.0.0",
1095
+ },
1096
+ }),
1097
+ "utf-8"
1098
+ );
1099
+ fs.writeFileSync(
1100
+ "path/to/worker/tsconfig.json",
1101
+ JSON.stringify({ compilerOptions: {} }),
1102
+ "utf-8"
1103
+ );
1104
+
1105
+ mockConfirm(
1106
+ {
1107
+ text: "Would you like to use git to manage this Worker?",
1108
+ result: false,
1109
+ },
1110
+ {
1111
+ text: "Would you like to create a Worker at path/to/worker/my-worker/src/index.ts?",
1112
+ result: true,
1113
+ }
1114
+ );
1115
+
1116
+ await runWrangler("init path/to/worker/my-worker");
1117
+ const tsconfigJson = JSON.parse(
1118
+ fs.readFileSync("path/to/worker/tsconfig.json", "utf-8")
1119
+ );
1120
+ expect(tsconfigJson.compilerOptions).toEqual({});
1121
+ expect(std).toMatchInlineSnapshot(`
1122
+ Object {
1123
+ "debug": "",
1124
+ "err": "",
1125
+ "out": "✨ Created path/to/worker/my-worker/wrangler.toml
1126
+ ✨ Created path/to/worker/my-worker/src/index.ts
1127
+
1128
+ To start developing your Worker, run \`npx wrangler dev\`
1129
+ To publish your Worker to the Internet, run \`npx wrangler publish\`",
1130
+ "warn": "",
1131
+ }
1132
+ `);
762
1133
  });
763
1134
 
764
1135
  it("should offer to install type definitions in an existing typescript project", async () => {
@@ -768,7 +1139,7 @@ describe("init", () => {
768
1139
  result: false,
769
1140
  },
770
1141
  {
771
- text: "Would you like to install wrangler into your package.json?",
1142
+ text: "Would you like to install wrangler into package.json?",
772
1143
  result: false,
773
1144
  },
774
1145
  {
@@ -803,6 +1174,16 @@ describe("init", () => {
803
1174
  expect(mockPackageManager.addDevDeps).toHaveBeenCalledWith(
804
1175
  "@cloudflare/workers-types"
805
1176
  );
1177
+ expect(std).toMatchInlineSnapshot(`
1178
+ Object {
1179
+ "debug": "",
1180
+ "err": "",
1181
+ "out": "✨ Created wrangler.toml
1182
+ ✨ Installed @cloudflare/workers-types.
1183
+ Please add \\"@cloudflare/workers-types\\" to compilerOptions.types in tsconfig.json",
1184
+ "warn": "",
1185
+ }
1186
+ `);
806
1187
  });
807
1188
 
808
1189
  it("should not touch an existing tsconfig.json in an ancestor directory", async () => {
@@ -851,7 +1232,7 @@ describe("init", () => {
851
1232
  Object {
852
1233
  "debug": "",
853
1234
  "err": "",
854
- "out": "✨ Successfully created wrangler.toml
1235
+ "out": "✨ Created wrangler.toml
855
1236
  ✨ Created src/index.ts
856
1237
 
857
1238
  To start developing your Worker, run \`npx wrangler dev\`
@@ -874,7 +1255,7 @@ describe("init", () => {
874
1255
  result: true,
875
1256
  },
876
1257
  {
877
- text: "Would you like to install wrangler into your package.json?",
1258
+ text: "Would you like to install wrangler into package.json?",
878
1259
  result: false,
879
1260
  },
880
1261
  {
@@ -901,7 +1282,7 @@ describe("init", () => {
901
1282
  expect(packageJson.name).toContain("wrangler-tests");
902
1283
  expect(packageJson.version).toEqual("0.0.0");
903
1284
  expect(std.out).toMatchInlineSnapshot(`
904
- "✨ Successfully created wrangler.toml
1285
+ "✨ Created wrangler.toml
905
1286
  ✨ Created package.json
906
1287
  ✨ Created src/index.js
907
1288
 
@@ -917,7 +1298,7 @@ describe("init", () => {
917
1298
  result: false,
918
1299
  },
919
1300
  {
920
- text: "Would you like to install wrangler into your package.json?",
1301
+ text: "Would you like to install wrangler into package.json?",
921
1302
  result: false,
922
1303
  },
923
1304
  {
@@ -949,7 +1330,7 @@ describe("init", () => {
949
1330
  expect(packageJson.scripts.start).toBe("test-start");
950
1331
  expect(packageJson.scripts.publish).toBe("test-publish");
951
1332
  expect(std.out).toMatchInlineSnapshot(`
952
- "✨ Successfully created wrangler.toml
1333
+ "✨ Created wrangler.toml
953
1334
  ✨ Created src/index.js
954
1335
 
955
1336
  To start developing your Worker, run \`npx wrangler dev\`
@@ -964,7 +1345,7 @@ describe("init", () => {
964
1345
  result: false,
965
1346
  },
966
1347
  {
967
- text: "Would you like to install wrangler into your package.json?",
1348
+ text: "Would you like to install wrangler into package.json?",
968
1349
  result: false,
969
1350
  },
970
1351
  {
@@ -985,6 +1366,54 @@ describe("init", () => {
985
1366
  await runWrangler("init");
986
1367
  expect(fs.readFileSync("./src/index.js", "utf-8")).toBe(PLACEHOLDER);
987
1368
  expect(fs.existsSync("./src/index.ts")).toBe(false);
1369
+ expect(std).toMatchInlineSnapshot(`
1370
+ Object {
1371
+ "debug": "",
1372
+ "err": "",
1373
+ "out": "✨ Created wrangler.toml",
1374
+ "warn": "",
1375
+ }
1376
+ `);
1377
+ });
1378
+
1379
+ it("should not offer to create a worker in a non-ts named worker project if a file already exists at the location", async () => {
1380
+ mockConfirm(
1381
+ {
1382
+ text: "Would you like to use git to manage this Worker?",
1383
+ result: false,
1384
+ },
1385
+ {
1386
+ text: "Would you like to install wrangler into package.json?",
1387
+ result: false,
1388
+ },
1389
+ {
1390
+ text: "Would you like to use TypeScript?",
1391
+ result: false,
1392
+ }
1393
+ );
1394
+
1395
+ fs.writeFileSync(
1396
+ "./package.json",
1397
+ JSON.stringify({ name: "test", version: "1.0.0" }),
1398
+ "utf-8"
1399
+ );
1400
+ fs.mkdirSync("./my-worker/src", { recursive: true });
1401
+ const PLACEHOLDER = "/* placeholder text */";
1402
+ fs.writeFileSync("./my-worker/src/index.js", PLACEHOLDER, "utf-8");
1403
+
1404
+ await runWrangler("init my-worker");
1405
+ expect(fs.readFileSync("./my-worker/src/index.js", "utf-8")).toBe(
1406
+ PLACEHOLDER
1407
+ );
1408
+ expect(fs.existsSync("./my-worker/src/index.ts")).toBe(false);
1409
+ expect(std).toMatchInlineSnapshot(`
1410
+ Object {
1411
+ "debug": "",
1412
+ "err": "",
1413
+ "out": "✨ Created my-worker/wrangler.toml",
1414
+ "warn": "",
1415
+ }
1416
+ `);
988
1417
  });
989
1418
  });
990
1419
 
@@ -1009,6 +1438,21 @@ describe("init", () => {
1009
1438
  expect(parsed.name).toBe(path.basename(process.cwd()).toLowerCase());
1010
1439
  expect(fs.existsSync("./my-worker/package.json")).toBe(false);
1011
1440
  expect(fs.existsSync("./my-worker/tsconfig.json")).toBe(false);
1441
+ expect(std).toMatchInlineSnapshot(`
1442
+ Object {
1443
+ "debug": "",
1444
+ "err": "",
1445
+ "out": "✨ Created wrangler.toml
1446
+ ✨ Initialized git repository
1447
+ ✨ Created package.json
1448
+ ✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
1449
+ ✨ Created src/index.ts
1450
+
1451
+ To start developing your Worker, run \`npm start\`
1452
+ To publish your Worker to the Internet, run \`npm run publish\`",
1453
+ "warn": "",
1454
+ }
1455
+ `);
1012
1456
  });
1013
1457
 
1014
1458
  it('should create a worker in a nested directory if "name" is path/to/worker', async () => {
@@ -1022,6 +1466,21 @@ describe("init", () => {
1022
1466
  expect(parsed.name).toBe("worker");
1023
1467
  expect(fs.existsSync("./my-worker/package.json")).toBe(false);
1024
1468
  expect(fs.existsSync("./my-worker/tsconfig.json")).toBe(false);
1469
+ expect(std).toMatchInlineSnapshot(`
1470
+ Object {
1471
+ "debug": "",
1472
+ "err": "",
1473
+ "out": "✨ Created path/to/worker/wrangler.toml
1474
+ ✨ Initialized git repository at path/to/worker
1475
+ ✨ Created path/to/worker/package.json
1476
+ ✨ Created path/to/worker/tsconfig.json, installed @cloudflare/workers-types into devDependencies
1477
+ ✨ Created path/to/worker/src/index.ts
1478
+
1479
+ To start developing your Worker, run \`cd path/to/worker && npm start\`
1480
+ To publish your Worker to the Internet, run \`npm run publish\`",
1481
+ "warn": "",
1482
+ }
1483
+ `);
1025
1484
  });
1026
1485
 
1027
1486
  it("should normalize characters that aren't lowercase alphanumeric, underscores, or dashes", async () => {
@@ -1037,6 +1496,21 @@ describe("init", () => {
1037
1496
  expect(parsed.name).toBe("weird_w0rkr_n4m3-js-tsx-tar-gz");
1038
1497
  expect(fs.existsSync("./my-worker/package.json")).toBe(false);
1039
1498
  expect(fs.existsSync("./my-worker/tsconfig.json")).toBe(false);
1499
+ expect(std).toMatchInlineSnapshot(`
1500
+ Object {
1501
+ "debug": "",
1502
+ "err": "",
1503
+ "out": "✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/wrangler.toml
1504
+ ✨ Initialized git repository at WEIRD_w0rkr_N4m3.js.tsx.tar.gz
1505
+ ✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/package.json
1506
+ ✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/tsconfig.json, installed @cloudflare/workers-types into devDependencies
1507
+ ✨ Created WEIRD_w0rkr_N4m3.js.tsx.tar.gz/src/index.ts
1508
+
1509
+ 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 publish\`",
1511
+ "warn": "",
1512
+ }
1513
+ `);
1040
1514
  });
1041
1515
  });
1042
1516
  });
package/src/index.tsx CHANGED
@@ -359,7 +359,12 @@ export async function main(argv: string[]): Promise<void> {
359
359
  let justCreatedWranglerToml = false;
360
360
 
361
361
  if (fs.existsSync(wranglerTomlDestination)) {
362
- logger.warn(`${wranglerTomlDestination} file already exists!`);
362
+ logger.warn(
363
+ `${path.relative(
364
+ process.cwd(),
365
+ wranglerTomlDestination
366
+ )} already exists!`
367
+ );
363
368
  const shouldContinue = await confirm(
364
369
  "Do you want to continue initializing this project?"
365
370
  );
@@ -379,18 +384,28 @@ export async function main(argv: string[]): Promise<void> {
379
384
  }) + "\n"
380
385
  );
381
386
 
382
- logger.log(`✨ Successfully created wrangler.toml`);
387
+ logger.log(
388
+ `✨ Created ${path.relative(
389
+ process.cwd(),
390
+ wranglerTomlDestination
391
+ )}`
392
+ );
383
393
  justCreatedWranglerToml = true;
384
394
  } catch (err) {
385
395
  throw new Error(
386
- `Failed to create wrangler.toml.\n${(err as Error).message ?? err}`
396
+ `Failed to create ${path.relative(
397
+ process.cwd(),
398
+ wranglerTomlDestination
399
+ )}.\n${(err as Error).message ?? err}`
387
400
  );
388
401
  }
389
402
  }
390
403
 
391
404
  const yesFlag = args.yes ?? false;
392
405
 
393
- const isInsideGitProject = Boolean(await findUp(".git"));
406
+ const isInsideGitProject = Boolean(
407
+ await findUp(".git", { cwd: creationDirectory, type: "directory" })
408
+ );
394
409
  const isGitInstalled = (await execa("git", ["--version"])).exitCode === 0;
395
410
  if (!isInsideGitProject && isGitInstalled) {
396
411
  const shouldInitGit =
@@ -402,11 +417,20 @@ export async function main(argv: string[]): Promise<void> {
402
417
  path.join(creationDirectory, ".gitignore"),
403
418
  readFileSync(path.join(__dirname, "../templates/gitignore"))
404
419
  );
405
- logger.log(`✨ Initialized git repository`);
420
+ logger.log(
421
+ args.name && args.name !== "."
422
+ ? `✨ Initialized git repository at ${path.relative(
423
+ process.cwd(),
424
+ creationDirectory
425
+ )}`
426
+ : `✨ Initialized git repository`
427
+ );
406
428
  }
407
429
  }
408
430
 
409
- let pathToPackageJson = await findUp("package.json");
431
+ let pathToPackageJson = await findUp("package.json", {
432
+ cwd: creationDirectory,
433
+ });
410
434
  let shouldCreatePackageJson = false;
411
435
 
412
436
  if (!pathToPackageJson) {
@@ -435,8 +459,10 @@ export async function main(argv: string[]): Promise<void> {
435
459
  );
436
460
 
437
461
  await packageManager.install();
438
- logger.log(`✨ Created package.json`);
439
462
  pathToPackageJson = path.join(creationDirectory, "package.json");
463
+ logger.log(
464
+ `✨ Created ${path.relative(process.cwd(), pathToPackageJson)}`
465
+ );
440
466
  } else {
441
467
  return;
442
468
  }
@@ -456,7 +482,10 @@ export async function main(argv: string[]): Promise<void> {
456
482
  const shouldInstall =
457
483
  yesFlag ||
458
484
  (await confirm(
459
- "Would you like to install wrangler into your package.json?"
485
+ `Would you like to install wrangler into ${path.relative(
486
+ process.cwd(),
487
+ pathToPackageJson
488
+ )}?`
460
489
  ));
461
490
  if (shouldInstall) {
462
491
  await packageManager.addDevDeps(`wrangler@${wranglerVersion}`);
@@ -466,7 +495,9 @@ export async function main(argv: string[]): Promise<void> {
466
495
  }
467
496
 
468
497
  let isTypescriptProject = false;
469
- let pathToTSConfig = await findUp("tsconfig.json");
498
+ let pathToTSConfig = await findUp("tsconfig.json", {
499
+ cwd: creationDirectory,
500
+ });
470
501
  if (!pathToTSConfig) {
471
502
  // If there's no tsconfig, offer to create one
472
503
  // and install @cloudflare/workers-types
@@ -480,11 +511,13 @@ export async function main(argv: string[]): Promise<void> {
480
511
  "@cloudflare/workers-types",
481
512
  "typescript"
482
513
  );
483
-
514
+ pathToTSConfig = path.join(creationDirectory, "tsconfig.json");
484
515
  logger.log(
485
- `✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies`
516
+ `✨ Created ${path.relative(
517
+ process.cwd(),
518
+ pathToTSConfig
519
+ )}, installed @cloudflare/workers-types into devDependencies`
486
520
  );
487
- pathToTSConfig = path.join(creationDirectory, "tsconfig.json");
488
521
  }
489
522
  } else {
490
523
  isTypescriptProject = true;
@@ -510,7 +543,10 @@ export async function main(argv: string[]): Promise<void> {
510
543
  // and we don't want to break them. Instead, we simply
511
544
  // tell the user that they need to update their tsconfig.json
512
545
  logger.log(
513
- `✨ Installed @cloudflare/workers-types.\nPlease add "@cloudflare/workers-types" to compilerOptions.types in your tsconfig.json`
546
+ `✨ Installed @cloudflare/workers-types.\nPlease add "@cloudflare/workers-types" to compilerOptions.types in ${path.relative(
547
+ process.cwd(),
548
+ pathToTSConfig
549
+ )}`
514
550
  );
515
551
  }
516
552
  }
@@ -592,12 +628,13 @@ export async function main(argv: string[]): Promise<void> {
592
628
 
593
629
  if (isTypescriptProject) {
594
630
  if (!fs.existsSync(path.join(creationDirectory, "./src/index.ts"))) {
595
- let shouldCreateSource = false;
596
-
597
- shouldCreateSource =
631
+ const shouldCreateSource =
598
632
  yesFlag ||
599
633
  (await confirm(
600
- `Would you like to create a Worker at src/index.ts?`
634
+ `Would you like to create a Worker at ${path.relative(
635
+ process.cwd(),
636
+ path.join(creationDirectory, "./src/index.ts")
637
+ )}?`
601
638
  ));
602
639
 
603
640
  if (shouldCreateSource) {
@@ -609,7 +646,12 @@ export async function main(argv: string[]): Promise<void> {
609
646
  readFileSync(path.join(__dirname, "../templates/new-worker.ts"))
610
647
  );
611
648
 
612
- logger.log(`✨ Created src/index.ts`);
649
+ logger.log(
650
+ `✨ Created ${path.relative(
651
+ process.cwd(),
652
+ path.join(creationDirectory, "./src/index.ts")
653
+ )}`
654
+ );
613
655
 
614
656
  await writePackageJsonScriptsAndUpdateWranglerToml(
615
657
  shouldWritePackageJsonScripts,
@@ -620,20 +662,31 @@ export async function main(argv: string[]): Promise<void> {
620
662
  }
621
663
  }
622
664
  } else {
623
- if (!fs.existsSync("./src/index.js")) {
624
- const shouldCreateSource = await confirm(
625
- `Would you like to create a Worker at src/index.js?`
626
- );
665
+ if (!fs.existsSync(path.join(creationDirectory, "./src/index.js"))) {
666
+ const shouldCreateSource =
667
+ yesFlag ||
668
+ (await confirm(
669
+ `Would you like to create a Worker at ${path.relative(
670
+ process.cwd(),
671
+ path.join(creationDirectory, "./src/index.js")
672
+ )}?`
673
+ ));
674
+
627
675
  if (shouldCreateSource) {
628
676
  await mkdir(path.join(creationDirectory, "./src"), {
629
677
  recursive: true,
630
678
  });
631
679
  await writeFile(
632
- path.join(path.join(creationDirectory, "./src/index.js")),
680
+ path.join(creationDirectory, "./src/index.js"),
633
681
  readFileSync(path.join(__dirname, "../templates/new-worker.js"))
634
682
  );
635
683
 
636
- logger.log(`✨ Created src/index.js`);
684
+ logger.log(
685
+ `✨ Created ${path.relative(
686
+ process.cwd(),
687
+ path.join(creationDirectory, "./src/index.js")
688
+ )}`
689
+ );
637
690
 
638
691
  await writePackageJsonScriptsAndUpdateWranglerToml(
639
692
  shouldWritePackageJsonScripts,
@@ -104810,7 +104810,7 @@ var yargs_default = Yargs;
104810
104810
 
104811
104811
  // package.json
104812
104812
  var name = "wrangler";
104813
- var version = "0.0.32";
104813
+ var version = "2.0.0";
104814
104814
  var author = "wrangler@cloudflare.com";
104815
104815
  var description = "Command-line interface for all things Cloudflare Workers";
104816
104816
  var bin = {
@@ -111787,7 +111787,7 @@ Have you considered using Cloudflare Pages instead? See https://pages.cloudflare
111787
111787
  const wranglerTomlDestination = import_node_path21.default.join(creationDirectory, "./wrangler.toml");
111788
111788
  let justCreatedWranglerToml = false;
111789
111789
  if (fs8.existsSync(wranglerTomlDestination)) {
111790
- logger.warn(`${wranglerTomlDestination} file already exists!`);
111790
+ logger.warn(`${import_node_path21.default.relative(process.cwd(), wranglerTomlDestination)} already exists!`);
111791
111791
  const shouldContinue = await confirm("Do you want to continue initializing this project?");
111792
111792
  if (!shouldContinue) {
111793
111793
  return;
@@ -111800,25 +111800,27 @@ Have you considered using Cloudflare Pages instead? See https://pages.cloudflare
111800
111800
  name: workerName,
111801
111801
  compatibility_date: compatibilityDate
111802
111802
  }) + "\n");
111803
- logger.log(`\u2728 Successfully created wrangler.toml`);
111803
+ logger.log(`\u2728 Created ${import_node_path21.default.relative(process.cwd(), wranglerTomlDestination)}`);
111804
111804
  justCreatedWranglerToml = true;
111805
111805
  } catch (err2) {
111806
- throw new Error(`Failed to create wrangler.toml.
111806
+ throw new Error(`Failed to create ${import_node_path21.default.relative(process.cwd(), wranglerTomlDestination)}.
111807
111807
  ${err2.message ?? err2}`);
111808
111808
  }
111809
111809
  }
111810
111810
  const yesFlag = args.yes ?? false;
111811
- const isInsideGitProject = Boolean(await findUp(".git"));
111811
+ const isInsideGitProject = Boolean(await findUp(".git", { cwd: creationDirectory, type: "directory" }));
111812
111812
  const isGitInstalled = (await execa("git", ["--version"])).exitCode === 0;
111813
111813
  if (!isInsideGitProject && isGitInstalled) {
111814
111814
  const shouldInitGit = yesFlag || await confirm("Would you like to use git to manage this Worker?");
111815
111815
  if (shouldInitGit) {
111816
111816
  await execa("git", ["init"], { cwd: creationDirectory });
111817
111817
  await (0, import_promises10.writeFile)(import_node_path21.default.join(creationDirectory, ".gitignore"), readFileSync5(import_node_path21.default.join(__dirname, "../templates/gitignore")));
111818
- logger.log(`\u2728 Initialized git repository`);
111818
+ logger.log(args.name && args.name !== "." ? `\u2728 Initialized git repository at ${import_node_path21.default.relative(process.cwd(), creationDirectory)}` : `\u2728 Initialized git repository`);
111819
111819
  }
111820
111820
  }
111821
- let pathToPackageJson = await findUp("package.json");
111821
+ let pathToPackageJson = await findUp("package.json", {
111822
+ cwd: creationDirectory
111823
+ });
111822
111824
  let shouldCreatePackageJson = false;
111823
111825
  if (!pathToPackageJson) {
111824
111826
  shouldCreatePackageJson = yesFlag || await confirm("No package.json found. Would you like to create one?");
@@ -111832,15 +111834,15 @@ ${err2.message ?? err2}`);
111832
111834
  private: true
111833
111835
  }, null, " ") + "\n");
111834
111836
  await packageManager.install();
111835
- logger.log(`\u2728 Created package.json`);
111836
111837
  pathToPackageJson = import_node_path21.default.join(creationDirectory, "package.json");
111838
+ logger.log(`\u2728 Created ${import_node_path21.default.relative(process.cwd(), pathToPackageJson)}`);
111837
111839
  } else {
111838
111840
  return;
111839
111841
  }
111840
111842
  } else {
111841
111843
  const packageJson = parseJSON(readFileSync5(pathToPackageJson), pathToPackageJson);
111842
111844
  if (!(packageJson.devDependencies?.wrangler || packageJson.dependencies?.wrangler)) {
111843
- const shouldInstall = yesFlag || await confirm("Would you like to install wrangler into your package.json?");
111845
+ const shouldInstall = yesFlag || await confirm(`Would you like to install wrangler into ${import_node_path21.default.relative(process.cwd(), pathToPackageJson)}?`);
111844
111846
  if (shouldInstall) {
111845
111847
  await packageManager.addDevDeps(`wrangler@${version}`);
111846
111848
  logger.log(`\u2728 Installed wrangler`);
@@ -111848,14 +111850,16 @@ ${err2.message ?? err2}`);
111848
111850
  }
111849
111851
  }
111850
111852
  let isTypescriptProject = false;
111851
- let pathToTSConfig = await findUp("tsconfig.json");
111853
+ let pathToTSConfig = await findUp("tsconfig.json", {
111854
+ cwd: creationDirectory
111855
+ });
111852
111856
  if (!pathToTSConfig) {
111853
111857
  if (yesFlag || await confirm("Would you like to use TypeScript?")) {
111854
111858
  isTypescriptProject = true;
111855
111859
  await (0, import_promises10.writeFile)(import_node_path21.default.join(creationDirectory, "./tsconfig.json"), readFileSync5(import_node_path21.default.join(__dirname, "../templates/tsconfig.json")));
111856
111860
  await packageManager.addDevDeps("@cloudflare/workers-types", "typescript");
111857
- logger.log(`\u2728 Created tsconfig.json, installed @cloudflare/workers-types into devDependencies`);
111858
111861
  pathToTSConfig = import_node_path21.default.join(creationDirectory, "tsconfig.json");
111862
+ logger.log(`\u2728 Created ${import_node_path21.default.relative(process.cwd(), pathToTSConfig)}, installed @cloudflare/workers-types into devDependencies`);
111859
111863
  }
111860
111864
  } else {
111861
111865
  isTypescriptProject = true;
@@ -111865,7 +111869,7 @@ ${err2.message ?? err2}`);
111865
111869
  if (shouldInstall) {
111866
111870
  await packageManager.addDevDeps("@cloudflare/workers-types");
111867
111871
  logger.log(`\u2728 Installed @cloudflare/workers-types.
111868
- Please add "@cloudflare/workers-types" to compilerOptions.types in your tsconfig.json`);
111872
+ Please add "@cloudflare/workers-types" to compilerOptions.types in ${import_node_path21.default.relative(process.cwd(), pathToTSConfig)}`);
111869
111873
  }
111870
111874
  }
111871
111875
  }
@@ -111901,26 +111905,25 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
111901
111905
  }
111902
111906
  if (isTypescriptProject) {
111903
111907
  if (!fs8.existsSync(import_node_path21.default.join(creationDirectory, "./src/index.ts"))) {
111904
- let shouldCreateSource = false;
111905
- shouldCreateSource = yesFlag || await confirm(`Would you like to create a Worker at src/index.ts?`);
111908
+ const shouldCreateSource = yesFlag || await confirm(`Would you like to create a Worker at ${import_node_path21.default.relative(process.cwd(), import_node_path21.default.join(creationDirectory, "./src/index.ts"))}?`);
111906
111909
  if (shouldCreateSource) {
111907
111910
  await (0, import_promises10.mkdir)(import_node_path21.default.join(creationDirectory, "./src"), {
111908
111911
  recursive: true
111909
111912
  });
111910
111913
  await (0, import_promises10.writeFile)(import_node_path21.default.join(creationDirectory, "./src/index.ts"), readFileSync5(import_node_path21.default.join(__dirname, "../templates/new-worker.ts")));
111911
- logger.log(`\u2728 Created src/index.ts`);
111914
+ logger.log(`\u2728 Created ${import_node_path21.default.relative(process.cwd(), import_node_path21.default.join(creationDirectory, "./src/index.ts"))}`);
111912
111915
  await writePackageJsonScriptsAndUpdateWranglerToml(shouldWritePackageJsonScripts, justCreatedWranglerToml, pathToPackageJson, "src/index.ts");
111913
111916
  }
111914
111917
  }
111915
111918
  } else {
111916
- if (!fs8.existsSync("./src/index.js")) {
111917
- const shouldCreateSource = await confirm(`Would you like to create a Worker at src/index.js?`);
111919
+ if (!fs8.existsSync(import_node_path21.default.join(creationDirectory, "./src/index.js"))) {
111920
+ const shouldCreateSource = yesFlag || await confirm(`Would you like to create a Worker at ${import_node_path21.default.relative(process.cwd(), import_node_path21.default.join(creationDirectory, "./src/index.js"))}?`);
111918
111921
  if (shouldCreateSource) {
111919
111922
  await (0, import_promises10.mkdir)(import_node_path21.default.join(creationDirectory, "./src"), {
111920
111923
  recursive: true
111921
111924
  });
111922
- await (0, import_promises10.writeFile)(import_node_path21.default.join(import_node_path21.default.join(creationDirectory, "./src/index.js")), readFileSync5(import_node_path21.default.join(__dirname, "../templates/new-worker.js")));
111923
- logger.log(`\u2728 Created src/index.js`);
111925
+ await (0, import_promises10.writeFile)(import_node_path21.default.join(creationDirectory, "./src/index.js"), readFileSync5(import_node_path21.default.join(__dirname, "../templates/new-worker.js")));
111926
+ logger.log(`\u2728 Created ${import_node_path21.default.relative(process.cwd(), import_node_path21.default.join(creationDirectory, "./src/index.js"))}`);
111924
111927
  await writePackageJsonScriptsAndUpdateWranglerToml(shouldWritePackageJsonScripts, justCreatedWranglerToml, pathToPackageJson, "src/index.js");
111925
111928
  }
111926
111929
  }