create-cloudflare 2.30.0 → 2.31.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/dist/cli.js CHANGED
@@ -68447,7 +68447,12 @@ var inputPrompt = async (promptConfig) => {
68447
68447
  };
68448
68448
  let prompt;
68449
68449
  const dispatchRender = (props, p2) => {
68450
- const renderedLines = renderers[props.state](props, p2);
68450
+ let state = props.state;
68451
+ if (state === "initial" && promptConfig.initialErrorMessage) {
68452
+ state = "error";
68453
+ props.error = promptConfig.initialErrorMessage;
68454
+ }
68455
+ const renderedLines = renderers[state](props, p2);
68451
68456
  return renderedLines.join("\n");
68452
68457
  };
68453
68458
  if (promptConfig.type === "select") {
@@ -73714,7 +73719,7 @@ var Yargs = YargsFactory(esm_default);
73714
73719
  var yargs_default = Yargs;
73715
73720
 
73716
73721
  // package.json
73717
- var version = "2.30.0";
73722
+ var version = "2.31.0";
73718
73723
 
73719
73724
  // src/metrics.ts
73720
73725
  var import_node_async_hooks = require("node:async_hooks");
@@ -74461,189 +74466,6 @@ var usesEslint = (ctx) => {
74461
74466
  // templates-experimental/angular/c3.ts
74462
74467
  var import_node_path3 = require("node:path");
74463
74468
 
74464
- // ../wrangler/package.json
74465
- var version2 = "3.81.0";
74466
-
74467
- // src/git.ts
74468
- var offerGit = async (ctx) => {
74469
- const gitInstalled = await isGitInstalled();
74470
- if (!gitInstalled) {
74471
- if (ctx.args.git) {
74472
- updateStatus(
74473
- "Couldn't find `git` installed on your machine. Continuing without git."
74474
- );
74475
- }
74476
- ctx.args.git = false;
74477
- return;
74478
- }
74479
- const insideGitRepo = await isInsideGitRepo(ctx.project.path);
74480
- if (insideGitRepo) {
74481
- ctx.args.git = true;
74482
- return;
74483
- }
74484
- ctx.args.git = await processArgument(ctx.args, "git", {
74485
- type: "confirm",
74486
- question: "Do you want to use git for version control?",
74487
- label: "git",
74488
- defaultValue: C3_DEFAULTS.git
74489
- });
74490
- if (!ctx.args.git) {
74491
- return;
74492
- }
74493
- const gitConfigured = await isGitConfigured();
74494
- if (!gitConfigured) {
74495
- updateStatus(
74496
- "Must configure `user.name` and user.email` to use git. Continuing without git."
74497
- );
74498
- ctx.args.git = false;
74499
- return;
74500
- }
74501
- await initializeGit(ctx.project.path);
74502
- };
74503
- var gitCommit = async (ctx) => {
74504
- const commitMessage = await createCommitMessage(ctx);
74505
- if (!ctx.args.git) {
74506
- return;
74507
- }
74508
- if (ctx.gitRepoAlreadyExisted) {
74509
- return;
74510
- }
74511
- const gitInstalled = await isGitInstalled();
74512
- const gitInitialized = await isInsideGitRepo(ctx.project.path);
74513
- if (!gitInstalled || !gitInitialized) {
74514
- return;
74515
- }
74516
- const s = spinner();
74517
- s.start("Committing new files");
74518
- await runCommand(["git", "add", "."], {
74519
- silent: true,
74520
- cwd: ctx.project.path
74521
- });
74522
- await runCommand(["git", "commit", "-m", commitMessage], {
74523
- silent: true,
74524
- cwd: ctx.project.path
74525
- });
74526
- s.stop(`${brandColor("git")} ${dim(`commit`)}`);
74527
- };
74528
- var createCommitMessage = async (ctx) => {
74529
- const framework = ctx.template.frameworkCli;
74530
- const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
74531
- const packageManager = detectPackageManager();
74532
- const gitVersion = await getGitVersion();
74533
- const insideRepo = await isInsideGitRepo(ctx.project.path);
74534
- const details = [
74535
- { key: "C3", value: `create-cloudflare@${version}` },
74536
- { key: "project name", value: ctx.project.name },
74537
- ...framework ? [{ key: "framework", value: ctx.template.id }] : [],
74538
- ...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
74539
- {
74540
- key: "package manager",
74541
- value: `${packageManager.name}@${packageManager.version}`
74542
- },
74543
- {
74544
- key: "wrangler",
74545
- value: `wrangler@${version2}`
74546
- },
74547
- {
74548
- key: "git",
74549
- value: insideRepo ? gitVersion : "N/A"
74550
- }
74551
- ];
74552
- const body = `Details:
74553
- ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
74554
- `;
74555
- const commitMessage = `${header}
74556
-
74557
- ${body}
74558
- `;
74559
- ctx.commitMessage = commitMessage;
74560
- return commitMessage;
74561
- };
74562
- async function getGitVersion() {
74563
- try {
74564
- const rawGitVersion = await runCommand(["git", "--version"], {
74565
- useSpinner: false,
74566
- silent: true
74567
- });
74568
- const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
74569
- return gitVersion;
74570
- } catch {
74571
- return null;
74572
- }
74573
- }
74574
- async function isGitInstalled() {
74575
- return await getGitVersion() !== null;
74576
- }
74577
- async function isGitConfigured() {
74578
- try {
74579
- const userName = await runCommand(["git", "config", "user.name"], {
74580
- useSpinner: false,
74581
- silent: true
74582
- });
74583
- if (!userName) {
74584
- return false;
74585
- }
74586
- const email = await runCommand(["git", "config", "user.email"], {
74587
- useSpinner: false,
74588
- silent: true
74589
- });
74590
- if (!email) {
74591
- return false;
74592
- }
74593
- return true;
74594
- } catch {
74595
- return false;
74596
- }
74597
- }
74598
- async function isInsideGitRepo(cwd) {
74599
- try {
74600
- const output = await runCommand(["git", "status"], {
74601
- cwd,
74602
- useSpinner: false,
74603
- silent: true,
74604
- captureOutput: true
74605
- });
74606
- return output.includes("not a git repository") === false;
74607
- } catch (err) {
74608
- return false;
74609
- }
74610
- }
74611
- async function initializeGit(cwd) {
74612
- const s = spinner();
74613
- s.start("Initializing git repo");
74614
- try {
74615
- const defaultBranchName = await runCommand(
74616
- ["git", "config", "--get", "init.defaultBranch"],
74617
- { useSpinner: false, silent: true, cwd }
74618
- );
74619
- await runCommand(
74620
- ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
74621
- // branch names can't contain spaces, so this is safe
74622
- { useSpinner: false, silent: true, cwd }
74623
- );
74624
- } catch {
74625
- await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
74626
- } finally {
74627
- s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
74628
- }
74629
- }
74630
- async function getProductionBranch(cwd) {
74631
- try {
74632
- const productionBranch = await runCommand(
74633
- ["git", "branch", "--show-current"],
74634
- {
74635
- silent: true,
74636
- cwd,
74637
- useSpinner: false,
74638
- captureOutput: true
74639
- }
74640
- );
74641
- return productionBranch.trim();
74642
- } catch (err) {
74643
- }
74644
- return "main";
74645
- }
74646
-
74647
74469
  // src/frameworks/package.json
74648
74470
  var package_default = {
74649
74471
  name: "frameworks_clis_info",
@@ -74656,16 +74478,16 @@ var package_default = {
74656
74478
  "create-analog": "1.8.1",
74657
74479
  "@angular/create": "18.2.8",
74658
74480
  "create-docusaurus": "3.5.2",
74659
- "create-hono": "0.14.1",
74481
+ "create-hono": "0.14.2",
74660
74482
  "create-next-app": "14.2.5",
74661
74483
  "create-qwik": "1.9.1",
74662
- "create-vite": "5.5.3",
74484
+ "create-vite": "5.5.4",
74663
74485
  "create-remix": "2.13.1",
74664
74486
  "create-solid": "0.5.13",
74665
- "create-svelte": "6.4.0",
74666
- "create-vue": "3.10.4",
74487
+ "create-vue": "3.11.1",
74667
74488
  gatsby: "5.13.7",
74668
- nuxi: "3.12.0"
74489
+ nuxi: "3.12.0",
74490
+ sv: "0.5.11"
74669
74491
  }
74670
74492
  };
74671
74493
 
@@ -74693,18 +74515,6 @@ var runFrameworkGenerator = async (ctx, args) => {
74693
74515
  );
74694
74516
  logRaw("");
74695
74517
  await runCommand(cmd, { env: env3 });
74696
- if (process.env.SAVE_DIFFS) {
74697
- const cmdEnv = {
74698
- silent: true,
74699
- cwd: ctx.project.path
74700
- };
74701
- if (!isInsideGitRepo(ctx.project.path)) {
74702
- await runCommand(["git", "init"], cmdEnv);
74703
- await runCommand(["git", "add", "."], cmdEnv);
74704
- const commitMessage = `Initial commit by ${cli}`;
74705
- await runCommand(["git", "commit", "-m", commitMessage], cmdEnv);
74706
- }
74707
- }
74708
74518
  };
74709
74519
 
74710
74520
  // templates-experimental/angular/c3.ts
@@ -75590,7 +75400,7 @@ var import_node_os3 = require("node:os");
75590
75400
  var recast6 = __toESM(require_main3());
75591
75401
  var { npm: npm8 } = detectPackageManager();
75592
75402
  var generate11 = async (ctx) => {
75593
- await runFrameworkGenerator(ctx, [ctx.project.name]);
75403
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
75594
75404
  logRaw("");
75595
75405
  };
75596
75406
  var configure8 = async (ctx) => {
@@ -75655,7 +75465,7 @@ var updateTypeDefinitions = (ctx) => {
75655
75465
  var config12 = {
75656
75466
  configVersion: 1,
75657
75467
  id: "svelte",
75658
- frameworkCli: "create-svelte",
75468
+ frameworkCli: "sv",
75659
75469
  displayName: "Svelte",
75660
75470
  platform: "workers",
75661
75471
  copyFiles: {
@@ -76514,7 +76324,6 @@ var isLoggedIn = async () => {
76514
76324
  // templates/pre-existing/c3.ts
76515
76325
  async function copyExistingWorkerFiles(ctx) {
76516
76326
  const { dlx } = detectPackageManager();
76517
- await chooseAccount(ctx);
76518
76327
  if (ctx.args.existingScript === void 0) {
76519
76328
  ctx.args.existingScript = await processArgument(
76520
76329
  ctx.args,
@@ -76568,11 +76377,23 @@ var c3_default27 = {
76568
76377
  copyFiles: {
76569
76378
  path: "./js"
76570
76379
  },
76571
- configure: async (ctx) => {
76572
- await copyExistingWorkerFiles(ctx);
76573
- ctx.args.deploy = false;
76574
- }
76380
+ configure: buildConfigure({
76381
+ login: wranglerLogin,
76382
+ chooseAccount,
76383
+ copyFiles: copyExistingWorkerFiles
76384
+ })
76575
76385
  };
76386
+ function buildConfigure(params) {
76387
+ return async function configure20(ctx) {
76388
+ const loginSuccess = await params.login(ctx);
76389
+ if (!loginSuccess) {
76390
+ throw new Error("Failed to login to Cloudflare");
76391
+ }
76392
+ await params.chooseAccount(ctx);
76393
+ await params.copyFiles(ctx);
76394
+ ctx.args.deploy = false;
76395
+ };
76396
+ }
76576
76397
 
76577
76398
  // templates/queues/c3.ts
76578
76399
  var c3_default28 = {
@@ -76903,7 +76724,7 @@ var import_node_os4 = require("node:os");
76903
76724
  var recast12 = __toESM(require_main3());
76904
76725
  var { npm: npm19 } = detectPackageManager();
76905
76726
  var generate24 = async (ctx) => {
76906
- await runFrameworkGenerator(ctx, [ctx.project.name]);
76727
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
76907
76728
  logRaw("");
76908
76729
  };
76909
76730
  var configure18 = async (ctx) => {
@@ -76968,7 +76789,7 @@ var updateTypeDefinitions2 = (ctx) => {
76968
76789
  var config24 = {
76969
76790
  configVersion: 1,
76970
76791
  id: "svelte",
76971
- frameworkCli: "create-svelte",
76792
+ frameworkCli: "sv",
76972
76793
  displayName: "Svelte",
76973
76794
  platform: "pages",
76974
76795
  copyFiles: {
@@ -77023,6 +76844,189 @@ var config25 = {
77023
76844
  };
77024
76845
  var c3_default35 = config25;
77025
76846
 
76847
+ // ../wrangler/package.json
76848
+ var version2 = "3.84.0";
76849
+
76850
+ // src/git.ts
76851
+ var offerGit = async (ctx) => {
76852
+ const gitInstalled = await isGitInstalled();
76853
+ if (!gitInstalled) {
76854
+ if (ctx.args.git) {
76855
+ updateStatus(
76856
+ "Couldn't find `git` installed on your machine. Continuing without git."
76857
+ );
76858
+ }
76859
+ ctx.args.git = false;
76860
+ return;
76861
+ }
76862
+ const insideGitRepo = await isInsideGitRepo(ctx.project.path);
76863
+ if (insideGitRepo) {
76864
+ ctx.args.git = true;
76865
+ return;
76866
+ }
76867
+ ctx.args.git = await processArgument(ctx.args, "git", {
76868
+ type: "confirm",
76869
+ question: "Do you want to use git for version control?",
76870
+ label: "git",
76871
+ defaultValue: C3_DEFAULTS.git
76872
+ });
76873
+ if (!ctx.args.git) {
76874
+ return;
76875
+ }
76876
+ const gitConfigured = await isGitConfigured();
76877
+ if (!gitConfigured) {
76878
+ updateStatus(
76879
+ "Must configure `user.name` and user.email` to use git. Continuing without git."
76880
+ );
76881
+ ctx.args.git = false;
76882
+ return;
76883
+ }
76884
+ await initializeGit(ctx.project.path);
76885
+ };
76886
+ var gitCommit = async (ctx) => {
76887
+ const commitMessage = await createCommitMessage(ctx);
76888
+ if (!ctx.args.git) {
76889
+ return;
76890
+ }
76891
+ if (ctx.gitRepoAlreadyExisted) {
76892
+ return;
76893
+ }
76894
+ const gitInstalled = await isGitInstalled();
76895
+ const gitInitialized = await isInsideGitRepo(ctx.project.path);
76896
+ if (!gitInstalled || !gitInitialized) {
76897
+ return;
76898
+ }
76899
+ const s = spinner();
76900
+ s.start("Committing new files");
76901
+ await runCommand(["git", "add", "."], {
76902
+ silent: true,
76903
+ cwd: ctx.project.path
76904
+ });
76905
+ await runCommand(["git", "commit", "-m", commitMessage], {
76906
+ silent: true,
76907
+ cwd: ctx.project.path
76908
+ });
76909
+ s.stop(`${brandColor("git")} ${dim(`commit`)}`);
76910
+ };
76911
+ var createCommitMessage = async (ctx) => {
76912
+ const framework = ctx.template.frameworkCli;
76913
+ const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
76914
+ const packageManager = detectPackageManager();
76915
+ const gitVersion = await getGitVersion();
76916
+ const insideRepo = await isInsideGitRepo(ctx.project.path);
76917
+ const details = [
76918
+ { key: "C3", value: `create-cloudflare@${version}` },
76919
+ { key: "project name", value: ctx.project.name },
76920
+ ...framework ? [{ key: "framework", value: ctx.template.id }] : [],
76921
+ ...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
76922
+ {
76923
+ key: "package manager",
76924
+ value: `${packageManager.name}@${packageManager.version}`
76925
+ },
76926
+ {
76927
+ key: "wrangler",
76928
+ value: `wrangler@${version2}`
76929
+ },
76930
+ {
76931
+ key: "git",
76932
+ value: insideRepo ? gitVersion : "N/A"
76933
+ }
76934
+ ];
76935
+ const body = `Details:
76936
+ ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
76937
+ `;
76938
+ const commitMessage = `${header}
76939
+
76940
+ ${body}
76941
+ `;
76942
+ ctx.commitMessage = commitMessage;
76943
+ return commitMessage;
76944
+ };
76945
+ async function getGitVersion() {
76946
+ try {
76947
+ const rawGitVersion = await runCommand(["git", "--version"], {
76948
+ useSpinner: false,
76949
+ silent: true
76950
+ });
76951
+ const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
76952
+ return gitVersion;
76953
+ } catch {
76954
+ return null;
76955
+ }
76956
+ }
76957
+ async function isGitInstalled() {
76958
+ return await getGitVersion() !== null;
76959
+ }
76960
+ async function isGitConfigured() {
76961
+ try {
76962
+ const userName = await runCommand(["git", "config", "user.name"], {
76963
+ useSpinner: false,
76964
+ silent: true
76965
+ });
76966
+ if (!userName) {
76967
+ return false;
76968
+ }
76969
+ const email = await runCommand(["git", "config", "user.email"], {
76970
+ useSpinner: false,
76971
+ silent: true
76972
+ });
76973
+ if (!email) {
76974
+ return false;
76975
+ }
76976
+ return true;
76977
+ } catch {
76978
+ return false;
76979
+ }
76980
+ }
76981
+ async function isInsideGitRepo(cwd) {
76982
+ try {
76983
+ const output = await runCommand(["git", "status"], {
76984
+ cwd,
76985
+ useSpinner: false,
76986
+ silent: true,
76987
+ captureOutput: true
76988
+ });
76989
+ return output.includes("not a git repository") === false;
76990
+ } catch (err) {
76991
+ return false;
76992
+ }
76993
+ }
76994
+ async function initializeGit(cwd) {
76995
+ const s = spinner();
76996
+ s.start("Initializing git repo");
76997
+ try {
76998
+ const defaultBranchName = await runCommand(
76999
+ ["git", "config", "--get", "init.defaultBranch"],
77000
+ { useSpinner: false, silent: true, cwd }
77001
+ );
77002
+ await runCommand(
77003
+ ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
77004
+ // branch names can't contain spaces, so this is safe
77005
+ { useSpinner: false, silent: true, cwd }
77006
+ );
77007
+ } catch {
77008
+ await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
77009
+ } finally {
77010
+ s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
77011
+ }
77012
+ }
77013
+ async function getProductionBranch(cwd) {
77014
+ try {
77015
+ const productionBranch = await runCommand(
77016
+ ["git", "branch", "--show-current"],
77017
+ {
77018
+ silent: true,
77019
+ cwd,
77020
+ useSpinner: false,
77021
+ captureOutput: true
77022
+ }
77023
+ );
77024
+ return productionBranch.trim();
77025
+ } catch (err) {
77026
+ }
77027
+ return "main";
77028
+ }
77029
+
77026
77030
  // src/validators.ts
77027
77031
  var import_fs10 = require("fs");
77028
77032
  var import_path12 = require("path");
@@ -77912,11 +77916,13 @@ var processArgument = async (args, key, promptConfig) => {
77912
77916
  disableTelemetry: args[key] !== void 0,
77913
77917
  async promise() {
77914
77918
  const value = args[key];
77919
+ const error2 = promptConfig.validate?.(value) ?? null;
77915
77920
  const result = await inputPrompt({
77916
77921
  ...promptConfig,
77917
77922
  // Accept the default value if the arg is already set
77918
- acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
77923
+ acceptDefault: promptConfig.acceptDefault ?? (value !== void 0 && !error2),
77919
77924
  defaultValue: value ?? promptConfig.defaultValue,
77925
+ initialErrorMessage: error2,
77920
77926
  throwOnError: true
77921
77927
  });
77922
77928
  args[key] = result;
@@ -79347,6 +79353,7 @@ var printSummary = (ctx) => {
79347
79353
  ]);
79348
79354
  const documentationUrl = `https://developers.cloudflare.com/${ctx.template.platform}`;
79349
79355
  const discordUrl = `https://discord.cloudflare.com`;
79356
+ const reportIssueUrl = "https://github.com/cloudflare/workers-sdk/issues/new/choose";
79350
79357
  const lines = [
79351
79358
  `\u{1F389} ${bgGreen(" SUCCESS ")} Application ${ctx.deployment.url ? "deployed" : "created"} successfully!`,
79352
79359
  ``
@@ -79368,6 +79375,9 @@ var printSummary = (ctx) => {
79368
79375
  `\u{1F4D6} Explore Documentation`,
79369
79376
  `${blue.underline(hyperlink(documentationUrl))}`,
79370
79377
  ``,
79378
+ `\u{1F41B} Report an Issue`,
79379
+ `${blue.underline(hyperlink(reportIssueUrl))}`,
79380
+ ``,
79371
79381
  `\u{1F4AC} Join our Community`,
79372
79382
  `${blue.underline(hyperlink(discordUrl))}`
79373
79383
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.30.0",
3
+ "version": "2.31.0",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -30,7 +30,7 @@
30
30
  "@babel/parser": "^7.21.3",
31
31
  "@babel/types": "^7.21.4",
32
32
  "@clack/prompts": "^0.6.3",
33
- "@cloudflare/workers-types": "^4.20241011.0",
33
+ "@cloudflare/workers-types": "^4.20241022.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -38,7 +38,7 @@
38
38
  "@types/degit": "^2.8.6",
39
39
  "@types/dns2": "^2.0.3",
40
40
  "@types/esprima": "^4.0.3",
41
- "@types/node": "20.8.3",
41
+ "@types/node": "^18.19.59",
42
42
  "@types/semver": "^7.5.1",
43
43
  "@types/which-pm-runs": "^1.0.0",
44
44
  "@types/yargs": "^17.0.22",
@@ -68,8 +68,8 @@
68
68
  "yargs": "^17.7.2",
69
69
  "@cloudflare/cli": "1.1.1",
70
70
  "@cloudflare/eslint-config-worker": "1.1.0",
71
- "wrangler": "3.81.0",
72
- "@cloudflare/workers-tsconfig": "0.0.0"
71
+ "@cloudflare/workers-tsconfig": "0.0.0",
72
+ "wrangler": "3.84.0"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=18.14.1"
@@ -5,14 +5,12 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
5
5
  import { processArgument } from "helpers/args";
6
6
  import { runCommand } from "helpers/command";
7
7
  import { detectPackageManager } from "helpers/packageManagers";
8
- import { chooseAccount } from "../../src/wrangler/accounts";
8
+ import { chooseAccount, wranglerLogin } from "../../src/wrangler/accounts";
9
9
  import type { C3Context } from "types";
10
10
 
11
11
  export async function copyExistingWorkerFiles(ctx: C3Context) {
12
12
  const { dlx } = detectPackageManager();
13
13
 
14
- await chooseAccount(ctx);
15
-
16
14
  if (ctx.args.existingScript === undefined) {
17
15
  ctx.args.existingScript = await processArgument(
18
16
  ctx.args,
@@ -74,10 +72,31 @@ export default {
74
72
  copyFiles: {
75
73
  path: "./js",
76
74
  },
77
- configure: async (ctx: C3Context) => {
78
- await copyExistingWorkerFiles(ctx);
75
+ configure: buildConfigure({
76
+ login: wranglerLogin,
77
+ chooseAccount,
78
+ copyFiles: copyExistingWorkerFiles,
79
+ }),
80
+ };
81
+
82
+ export interface ConfigureParams {
83
+ login: (ctx: C3Context) => Promise<boolean>;
84
+ chooseAccount: (ctx: C3Context) => Promise<void>;
85
+ copyFiles: (ctx: C3Context) => Promise<void>;
86
+ }
87
+
88
+ export function buildConfigure(params: ConfigureParams) {
89
+ return async function configure(ctx: C3Context) {
90
+ const loginSuccess = await params.login(ctx);
91
+
92
+ if (!loginSuccess) {
93
+ throw new Error("Failed to login to Cloudflare");
94
+ }
95
+
96
+ await params.chooseAccount(ctx);
97
+ await params.copyFiles(ctx);
79
98
 
80
99
  // Force no-deploy since the worker is already deployed
81
100
  ctx.args.deploy = false;
82
- },
83
- };
101
+ };
102
+ }
@@ -13,7 +13,7 @@ import type { C3Context, PackageJson } from "types";
13
13
  const { npm } = detectPackageManager();
14
14
 
15
15
  const generate = async (ctx: C3Context) => {
16
- await runFrameworkGenerator(ctx, [ctx.project.name]);
16
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
17
17
 
18
18
  logRaw("");
19
19
  };
@@ -97,7 +97,7 @@ const updateTypeDefinitions = (ctx: C3Context) => {
97
97
  const config: TemplateConfig = {
98
98
  configVersion: 1,
99
99
  id: "svelte",
100
- frameworkCli: "create-svelte",
100
+ frameworkCli: "sv",
101
101
  displayName: "Svelte",
102
102
  platform: "pages",
103
103
  copyFiles: {
@@ -13,7 +13,7 @@ import type { C3Context, PackageJson } from "types";
13
13
  const { npm } = detectPackageManager();
14
14
 
15
15
  const generate = async (ctx: C3Context) => {
16
- await runFrameworkGenerator(ctx, [ctx.project.name]);
16
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
17
17
 
18
18
  logRaw("");
19
19
  };
@@ -97,7 +97,7 @@ const updateTypeDefinitions = (ctx: C3Context) => {
97
97
  const config: TemplateConfig = {
98
98
  configVersion: 1,
99
99
  id: "svelte",
100
- frameworkCli: "create-svelte",
100
+ frameworkCli: "sv",
101
101
  displayName: "Svelte",
102
102
  platform: "workers",
103
103
  copyFiles: {