create-cloudflare 0.0.0-6b9735389 → 0.0.0-6ba590320

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
@@ -24815,8 +24815,8 @@ var require_index_688c5d50 = __commonJS({
24815
24815
  var pathReservations = () => {
24816
24816
  const queues = /* @__PURE__ */ new Map();
24817
24817
  const reservations = /* @__PURE__ */ new Map();
24818
- const { join: join7 } = path__default["default"];
24819
- const getDirs = (path7) => join7(path7).split(/[\\/]/).slice(0, -1).reduce((set, path8) => set.length ? set.concat(join7(set[set.length - 1], path8)) : [path8], []);
24818
+ const { join: join8 } = path__default["default"];
24819
+ const getDirs = (path7) => join8(path7).split(/[\\/]/).slice(0, -1).reduce((set, path8) => set.length ? set.concat(join8(set[set.length - 1], path8)) : [path8], []);
24820
24820
  const running = /* @__PURE__ */ new Set();
24821
24821
  const getQueues = (fn) => {
24822
24822
  const res = reservations.get(fn);
@@ -38609,7 +38609,7 @@ var require_util8 = __commonJS({
38609
38609
  return path6;
38610
38610
  }
38611
38611
  exports2.normalize = normalize2;
38612
- function join7(aRoot, aPath) {
38612
+ function join8(aRoot, aPath) {
38613
38613
  if (aRoot === "") {
38614
38614
  aRoot = ".";
38615
38615
  }
@@ -38641,7 +38641,7 @@ var require_util8 = __commonJS({
38641
38641
  }
38642
38642
  return joined;
38643
38643
  }
38644
- exports2.join = join7;
38644
+ exports2.join = join8;
38645
38645
  exports2.isAbsolute = function(aPath) {
38646
38646
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
38647
38647
  };
@@ -38814,7 +38814,7 @@ var require_util8 = __commonJS({
38814
38814
  parsed.path = parsed.path.substring(0, index + 1);
38815
38815
  }
38816
38816
  }
38817
- sourceURL = join7(urlGenerate(parsed), sourceURL);
38817
+ sourceURL = join8(urlGenerate(parsed), sourceURL);
38818
38818
  }
38819
38819
  return normalize2(sourceURL);
38820
38820
  }
@@ -67118,7 +67118,7 @@ var logRaw = (msg) => {
67118
67118
  `);
67119
67119
  };
67120
67120
  var log = (msg) => {
67121
- const lines = msg.split("\n").map((ln) => `${gray(shapes.bar)} ${white(ln)}`);
67121
+ const lines = msg.split("\n").map((ln) => `${gray(shapes.bar)}${ln.length > 0 ? " " + white(ln) : ""}`);
67122
67122
  logRaw(lines.join("\n"));
67123
67123
  };
67124
67124
  var newline = () => {
@@ -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") {
@@ -68813,7 +68818,10 @@ var spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
68813
68818
  start(msg, helpText) {
68814
68819
  helpText ||= ``;
68815
68820
  currentMsg = msg;
68816
- startMsg = `${currentMsg} ${dim(helpText)}`;
68821
+ startMsg = currentMsg;
68822
+ if (helpText !== void 0 && helpText.length > 0) {
68823
+ startMsg += ` ${dim(helpText)}`;
68824
+ }
68817
68825
  if (isInteractive()) {
68818
68826
  let index = 0;
68819
68827
  clearLoop();
@@ -68826,7 +68834,7 @@ var spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
68826
68834
  }
68827
68835
  }, frameRate);
68828
68836
  } else {
68829
- logUpdate2(`${leftT} ${startMsg}`);
68837
+ logRaw(`${leftT} ${startMsg}`);
68830
68838
  }
68831
68839
  },
68832
68840
  update(msg) {
@@ -68844,17 +68852,20 @@ ${grayBar} ${msg}`);
68844
68852
  clearLoop();
68845
68853
  } else {
68846
68854
  if (msg !== void 0) {
68847
- logUpdate2(`
68848
- ${grayBar} ${msg}`);
68855
+ logRaw(`${grayBar} ${msg}`);
68849
68856
  }
68850
68857
  newline();
68851
68858
  }
68852
68859
  }
68853
68860
  };
68854
68861
  };
68855
- var isInteractive = () => {
68856
- return process.stdin.isTTY;
68857
- };
68862
+ function isInteractive() {
68863
+ try {
68864
+ return Boolean(process.stdin.isTTY && process.stdout.isTTY);
68865
+ } catch {
68866
+ return false;
68867
+ }
68868
+ }
68858
68869
 
68859
68870
  // ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/lib/platform-shims/esm.mjs
68860
68871
  var import_assert = require("assert");
@@ -73714,7 +73725,7 @@ var Yargs = YargsFactory(esm_default);
73714
73725
  var yargs_default = Yargs;
73715
73726
 
73716
73727
  // package.json
73717
- var version = "0.0.0-6b9735389";
73728
+ var version = "0.0.0-6ba590320";
73718
73729
 
73719
73730
  // src/metrics.ts
73720
73731
  var import_node_async_hooks = require("node:async_hooks");
@@ -73994,7 +74005,7 @@ var detectPmMismatch = (ctx) => {
73994
74005
  case "pnpm":
73995
74006
  return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "pnpm-lock.yaml"));
73996
74007
  case "bun":
73997
- return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb"));
74008
+ return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb")) && !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lock"));
73998
74009
  }
73999
74010
  };
74000
74011
 
@@ -74461,189 +74472,6 @@ var usesEslint = (ctx) => {
74461
74472
  // templates-experimental/angular/c3.ts
74462
74473
  var import_node_path3 = require("node:path");
74463
74474
 
74464
- // ../wrangler/package.json
74465
- var version2 = "0.0.0-6b9735389";
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
74475
  // src/frameworks/package.json
74648
74476
  var package_default = {
74649
74477
  name: "frameworks_clis_info",
@@ -74652,20 +74480,20 @@ var package_default = {
74652
74480
  "so that we can use dependabot to update these dependencies automatically."
74653
74481
  ],
74654
74482
  dependencies: {
74655
- "create-astro": "4.8.0",
74483
+ "create-astro": "4.10.0",
74656
74484
  "create-analog": "1.8.1",
74657
- "@angular/create": "18.2.8",
74658
- "create-docusaurus": "3.5.2",
74659
- "create-hono": "0.14.1",
74485
+ "@angular/create": "19.0.0",
74486
+ "create-docusaurus": "3.6.1",
74487
+ "create-hono": "0.14.2",
74660
74488
  "create-next-app": "14.2.5",
74661
74489
  "create-qwik": "1.9.1",
74662
- "create-vite": "5.5.3",
74663
- "create-remix": "2.13.1",
74490
+ "create-vite": "5.5.5",
74491
+ "create-remix": "2.14.0",
74664
74492
  "create-solid": "0.5.13",
74665
- "create-svelte": "6.4.0",
74666
- "create-vue": "3.11.1",
74667
- gatsby: "5.13.7",
74668
- nuxi: "3.12.0"
74493
+ "create-vue": "3.12.1",
74494
+ gatsby: "5.14.0",
74495
+ nuxi: "3.15.0",
74496
+ sv: "0.6.1"
74669
74497
  }
74670
74498
  };
74671
74499
 
@@ -74693,18 +74521,6 @@ var runFrameworkGenerator = async (ctx, args) => {
74693
74521
  );
74694
74522
  logRaw("");
74695
74523
  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
74524
  };
74709
74525
 
74710
74526
  // templates-experimental/angular/c3.ts
@@ -75417,7 +75233,7 @@ var generate9 = async (ctx) => {
75417
75233
  await runFrameworkGenerator(ctx, [
75418
75234
  ctx.project.name,
75419
75235
  "--template",
75420
- "https://github.com/remix-run/remix/tree/main/templates/cloudflare"
75236
+ "https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers"
75421
75237
  ]);
75422
75238
  logRaw("");
75423
75239
  };
@@ -75427,19 +75243,6 @@ var configure6 = async () => {
75427
75243
  startText: "Updating the Wrangler version",
75428
75244
  doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`
75429
75245
  });
75430
- const typeDefsPath = "load-context.ts";
75431
- const s = spinner();
75432
- s.start(`Updating \`${typeDefsPath}\``);
75433
- transformFile(typeDefsPath, {
75434
- visitTSInterfaceDeclaration(n2) {
75435
- if (n2.node.id.type === "Identifier" && n2.node.id.name !== "Env") {
75436
- return this.traverse(n2);
75437
- }
75438
- n2.replace();
75439
- return false;
75440
- }
75441
- });
75442
- s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
75443
75246
  };
75444
75247
  var config10 = {
75445
75248
  configVersion: 1,
@@ -75455,7 +75258,6 @@ var config10 = {
75455
75258
  configure: configure6,
75456
75259
  transformPackageJson: async () => ({
75457
75260
  scripts: {
75458
- build: "remix vite:build && wrangler pages functions build --outdir build/worker",
75459
75261
  deploy: `${npm6} run build && wrangler deploy`,
75460
75262
  preview: `${npm6} run build && wrangler dev`,
75461
75263
  "cf-typegen": `wrangler types`
@@ -75500,7 +75302,7 @@ var configure7 = async (ctx) => {
75500
75302
  // preset: "cloudflare-pages"
75501
75303
  b2.objectProperty(
75502
75304
  b2.identifier("preset"),
75503
- b2.stringLiteral("./cloudflare-pages")
75305
+ b2.stringLiteral("cloudflare-pages")
75504
75306
  ),
75505
75307
  // output: {
75506
75308
  // dir: "{{ rootDir }}/dist",
@@ -75590,7 +75392,7 @@ var import_node_os3 = require("node:os");
75590
75392
  var recast6 = __toESM(require_main3());
75591
75393
  var { npm: npm8 } = detectPackageManager();
75592
75394
  var generate11 = async (ctx) => {
75593
- await runFrameworkGenerator(ctx, [ctx.project.name]);
75395
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
75594
75396
  logRaw("");
75595
75397
  };
75596
75398
  var configure8 = async (ctx) => {
@@ -75655,8 +75457,8 @@ var updateTypeDefinitions = (ctx) => {
75655
75457
  var config12 = {
75656
75458
  configVersion: 1,
75657
75459
  id: "svelte",
75658
- frameworkCli: "create-svelte",
75659
- displayName: "Svelte",
75460
+ frameworkCli: "sv",
75461
+ displayName: "SvelteKit",
75660
75462
  platform: "workers",
75661
75463
  copyFiles: {
75662
75464
  variants: {
@@ -75794,7 +75596,11 @@ var c3_default15 = config13;
75794
75596
  var import_node_path4 = require("node:path");
75795
75597
  var { npm: npm10 } = detectPackageManager();
75796
75598
  var generate13 = async (ctx) => {
75797
- await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
75599
+ await runFrameworkGenerator(ctx, [
75600
+ ctx.project.name,
75601
+ "--ssr",
75602
+ "--server-routing"
75603
+ ]);
75798
75604
  logRaw("");
75799
75605
  };
75800
75606
  var configure10 = async (ctx) => {
@@ -75823,10 +75629,17 @@ async function updateAppCode2() {
75823
75629
  );
75824
75630
  writeFile2((0, import_node_path4.resolve)(appConfigPath), newAppConfig);
75825
75631
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
75632
+ const appServerRoutesPath = "src/app/app.routes.server.ts";
75633
+ const appRoutes = readFile((0, import_node_path4.resolve)(appServerRoutesPath));
75634
+ const newAppRoutes = appRoutes.replace(
75635
+ "RenderMode.Prerender",
75636
+ "RenderMode.Server"
75637
+ );
75638
+ writeFile2((0, import_node_path4.resolve)(appServerRoutesPath), newAppRoutes);
75639
+ s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
75826
75640
  s.start(`Updating package.json`);
75827
75641
  const packageJsonPath = (0, import_node_path4.resolve)("package.json");
75828
75642
  const packageManifest = readJSON(packageJsonPath);
75829
- delete packageManifest["dependencies"]["@angular/ssr"];
75830
75643
  delete packageManifest["dependencies"]["express"];
75831
75644
  delete packageManifest["devDependencies"]["@types/express"];
75832
75645
  writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
@@ -75838,6 +75651,8 @@ function updateAngularJson2(ctx) {
75838
75651
  const angularJson = readJSON((0, import_node_path4.resolve)("angular.json"));
75839
75652
  const architectSection = angularJson.projects[ctx.project.name].architect;
75840
75653
  architectSection.build.options.outputPath = "dist";
75654
+ architectSection.build.options.outputMode = "server";
75655
+ architectSection.build.options.ssr.experimentalPlatform = "neutral";
75841
75656
  architectSection.build.options.assets.push("src/_routes.json");
75842
75657
  writeFile2((0, import_node_path4.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
75843
75658
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
@@ -75859,7 +75674,7 @@ var config14 = {
75859
75674
  scripts: {
75860
75675
  start: `${npm10} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
75861
75676
  build: `ng build && ${npm10} run process`,
75862
- process: "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
75677
+ process: "node ./tools/copy-files.mjs",
75863
75678
  deploy: `${npm10} run build && wrangler pages deploy dist/cloudflare`
75864
75679
  }
75865
75680
  })
@@ -76914,7 +76729,7 @@ var import_node_os4 = require("node:os");
76914
76729
  var recast12 = __toESM(require_main3());
76915
76730
  var { npm: npm19 } = detectPackageManager();
76916
76731
  var generate24 = async (ctx) => {
76917
- await runFrameworkGenerator(ctx, [ctx.project.name]);
76732
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
76918
76733
  logRaw("");
76919
76734
  };
76920
76735
  var configure18 = async (ctx) => {
@@ -76979,8 +76794,8 @@ var updateTypeDefinitions2 = (ctx) => {
76979
76794
  var config24 = {
76980
76795
  configVersion: 1,
76981
76796
  id: "svelte",
76982
- frameworkCli: "create-svelte",
76983
- displayName: "Svelte",
76797
+ frameworkCli: "sv",
76798
+ displayName: "SvelteKit",
76984
76799
  platform: "pages",
76985
76800
  copyFiles: {
76986
76801
  variants: {
@@ -77034,6 +76849,189 @@ var config25 = {
77034
76849
  };
77035
76850
  var c3_default35 = config25;
77036
76851
 
76852
+ // ../wrangler/package.json
76853
+ var version2 = "0.0.0-6ba590320";
76854
+
76855
+ // src/git.ts
76856
+ var offerGit = async (ctx) => {
76857
+ const gitInstalled = await isGitInstalled();
76858
+ if (!gitInstalled) {
76859
+ if (ctx.args.git) {
76860
+ updateStatus(
76861
+ "Couldn't find `git` installed on your machine. Continuing without git."
76862
+ );
76863
+ }
76864
+ ctx.args.git = false;
76865
+ return;
76866
+ }
76867
+ const insideGitRepo = await isInsideGitRepo(ctx.project.path);
76868
+ if (insideGitRepo) {
76869
+ ctx.args.git = true;
76870
+ return;
76871
+ }
76872
+ ctx.args.git = await processArgument(ctx.args, "git", {
76873
+ type: "confirm",
76874
+ question: "Do you want to use git for version control?",
76875
+ label: "git",
76876
+ defaultValue: C3_DEFAULTS.git
76877
+ });
76878
+ if (!ctx.args.git) {
76879
+ return;
76880
+ }
76881
+ const gitConfigured = await isGitConfigured();
76882
+ if (!gitConfigured) {
76883
+ updateStatus(
76884
+ "Must configure `user.name` and user.email` to use git. Continuing without git."
76885
+ );
76886
+ ctx.args.git = false;
76887
+ return;
76888
+ }
76889
+ await initializeGit(ctx.project.path);
76890
+ };
76891
+ var gitCommit = async (ctx) => {
76892
+ const commitMessage = await createCommitMessage(ctx);
76893
+ if (!ctx.args.git) {
76894
+ return;
76895
+ }
76896
+ if (ctx.gitRepoAlreadyExisted) {
76897
+ return;
76898
+ }
76899
+ const gitInstalled = await isGitInstalled();
76900
+ const gitInitialized = await isInsideGitRepo(ctx.project.path);
76901
+ if (!gitInstalled || !gitInitialized) {
76902
+ return;
76903
+ }
76904
+ const s = spinner();
76905
+ s.start("Committing new files");
76906
+ await runCommand(["git", "add", "."], {
76907
+ silent: true,
76908
+ cwd: ctx.project.path
76909
+ });
76910
+ await runCommand(["git", "commit", "-m", commitMessage], {
76911
+ silent: true,
76912
+ cwd: ctx.project.path
76913
+ });
76914
+ s.stop(`${brandColor("git")} ${dim(`commit`)}`);
76915
+ };
76916
+ var createCommitMessage = async (ctx) => {
76917
+ const framework = ctx.template.frameworkCli;
76918
+ const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
76919
+ const packageManager = detectPackageManager();
76920
+ const gitVersion = await getGitVersion();
76921
+ const insideRepo = await isInsideGitRepo(ctx.project.path);
76922
+ const details = [
76923
+ { key: "C3", value: `create-cloudflare@${version}` },
76924
+ { key: "project name", value: ctx.project.name },
76925
+ ...framework ? [{ key: "framework", value: ctx.template.id }] : [],
76926
+ ...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
76927
+ {
76928
+ key: "package manager",
76929
+ value: `${packageManager.name}@${packageManager.version}`
76930
+ },
76931
+ {
76932
+ key: "wrangler",
76933
+ value: `wrangler@${version2}`
76934
+ },
76935
+ {
76936
+ key: "git",
76937
+ value: insideRepo ? gitVersion : "N/A"
76938
+ }
76939
+ ];
76940
+ const body = `Details:
76941
+ ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
76942
+ `;
76943
+ const commitMessage = `${header}
76944
+
76945
+ ${body}
76946
+ `;
76947
+ ctx.commitMessage = commitMessage;
76948
+ return commitMessage;
76949
+ };
76950
+ async function getGitVersion() {
76951
+ try {
76952
+ const rawGitVersion = await runCommand(["git", "--version"], {
76953
+ useSpinner: false,
76954
+ silent: true
76955
+ });
76956
+ const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
76957
+ return gitVersion;
76958
+ } catch {
76959
+ return null;
76960
+ }
76961
+ }
76962
+ async function isGitInstalled() {
76963
+ return await getGitVersion() !== null;
76964
+ }
76965
+ async function isGitConfigured() {
76966
+ try {
76967
+ const userName = await runCommand(["git", "config", "user.name"], {
76968
+ useSpinner: false,
76969
+ silent: true
76970
+ });
76971
+ if (!userName) {
76972
+ return false;
76973
+ }
76974
+ const email = await runCommand(["git", "config", "user.email"], {
76975
+ useSpinner: false,
76976
+ silent: true
76977
+ });
76978
+ if (!email) {
76979
+ return false;
76980
+ }
76981
+ return true;
76982
+ } catch {
76983
+ return false;
76984
+ }
76985
+ }
76986
+ async function isInsideGitRepo(cwd) {
76987
+ try {
76988
+ const output = await runCommand(["git", "status"], {
76989
+ cwd,
76990
+ useSpinner: false,
76991
+ silent: true,
76992
+ captureOutput: true
76993
+ });
76994
+ return output.includes("not a git repository") === false;
76995
+ } catch (err) {
76996
+ return false;
76997
+ }
76998
+ }
76999
+ async function initializeGit(cwd) {
77000
+ const s = spinner();
77001
+ s.start("Initializing git repo");
77002
+ try {
77003
+ const defaultBranchName = await runCommand(
77004
+ ["git", "config", "--get", "init.defaultBranch"],
77005
+ { useSpinner: false, silent: true, cwd }
77006
+ );
77007
+ await runCommand(
77008
+ ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
77009
+ // branch names can't contain spaces, so this is safe
77010
+ { useSpinner: false, silent: true, cwd }
77011
+ );
77012
+ } catch {
77013
+ await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
77014
+ } finally {
77015
+ s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
77016
+ }
77017
+ }
77018
+ async function getProductionBranch(cwd) {
77019
+ try {
77020
+ const productionBranch = await runCommand(
77021
+ ["git", "branch", "--show-current"],
77022
+ {
77023
+ silent: true,
77024
+ cwd,
77025
+ useSpinner: false,
77026
+ captureOutput: true
77027
+ }
77028
+ );
77029
+ return productionBranch.trim();
77030
+ } catch (err) {
77031
+ }
77032
+ return "main";
77033
+ }
77034
+
77037
77035
  // src/validators.ts
77038
77036
  var import_fs10 = require("fs");
77039
77037
  var import_path12 = require("path");
@@ -77923,11 +77921,13 @@ var processArgument = async (args, key, promptConfig) => {
77923
77921
  disableTelemetry: args[key] !== void 0,
77924
77922
  async promise() {
77925
77923
  const value = args[key];
77924
+ const error2 = promptConfig.validate?.(value) ?? null;
77926
77925
  const result = await inputPrompt({
77927
77926
  ...promptConfig,
77928
77927
  // Accept the default value if the arg is already set
77929
- acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
77928
+ acceptDefault: promptConfig.acceptDefault ?? (value !== void 0 && !error2),
77930
77929
  defaultValue: value ?? promptConfig.defaultValue,
77930
+ initialErrorMessage: error2,
77931
77931
  throwOnError: true
77932
77932
  });
77933
77933
  args[key] = result;
@@ -77939,6 +77939,9 @@ var processArgument = async (args, key, promptConfig) => {
77939
77939
  };
77940
77940
 
77941
77941
  // src/deploy.ts
77942
+ var import_promises4 = require("node:fs/promises");
77943
+ var import_node_os5 = require("node:os");
77944
+ var import_node_path5 = require("node:path");
77942
77945
  var import_toml2 = __toESM(require_toml());
77943
77946
 
77944
77947
  // src/helpers/poll.ts
@@ -79257,23 +79260,34 @@ var runDeploy = async (ctx) => {
79257
79260
  JSON.stringify(ctx.commitMessage)
79258
79261
  ] : []
79259
79262
  ];
79260
- const result = await runCommand(deployCmd, {
79261
- silent: true,
79263
+ const outputFile = (0, import_node_path5.join)(
79264
+ await (0, import_promises4.mkdtemp)((0, import_node_path5.join)((0, import_node_os5.tmpdir)(), "c3-wrangler-deploy-")),
79265
+ "output.json"
79266
+ );
79267
+ await runCommand(deployCmd, {
79262
79268
  cwd: ctx.project.path,
79263
79269
  env: {
79264
79270
  CLOUDFLARE_ACCOUNT_ID: ctx.account.id,
79265
- NODE_ENV: "production"
79271
+ NODE_ENV: "production",
79272
+ WRANGLER_OUTPUT_FILE_PATH: outputFile
79266
79273
  },
79267
79274
  startText: "Deploying your application",
79268
79275
  doneText: `${brandColor("deployed")} ${dim(
79269
79276
  `via \`${quoteShellArgs(baseDeployCmd)}\``
79270
79277
  )}`
79271
79278
  });
79272
- const deployedUrlRegex = /https:\/\/.+\.(pages|workers)\.dev/;
79273
- const deployedUrlMatch = result.match(deployedUrlRegex);
79274
- if (deployedUrlMatch) {
79275
- ctx.deployment.url = deployedUrlMatch[0];
79276
- } else {
79279
+ try {
79280
+ const contents = readFile(outputFile);
79281
+ const entries = contents.split("\n").filter(Boolean).map((entry) => JSON.parse(entry));
79282
+ const url = entries.find((entry) => entry.type === "deploy")?.targets?.[0] ?? entries.find((entry) => entry.type === "pages-deploy")?.url;
79283
+ const deployedUrlRegex = /https:\/\/.+\.(pages|workers)\.dev/;
79284
+ const deployedUrlMatch = url?.match(deployedUrlRegex);
79285
+ if (deployedUrlMatch) {
79286
+ ctx.deployment.url = deployedUrlMatch[0];
79287
+ } else {
79288
+ throw new Error("Failed to find deployment url.");
79289
+ }
79290
+ } catch {
79277
79291
  throw new Error("Failed to find deployment url.");
79278
79292
  }
79279
79293
  if (ctx.deployment.url?.endsWith(".pages.dev")) {
@@ -79358,6 +79372,7 @@ var printSummary = (ctx) => {
79358
79372
  ]);
79359
79373
  const documentationUrl = `https://developers.cloudflare.com/${ctx.template.platform}`;
79360
79374
  const discordUrl = `https://discord.cloudflare.com`;
79375
+ const reportIssueUrl = "https://github.com/cloudflare/workers-sdk/issues/new/choose";
79361
79376
  const lines = [
79362
79377
  `\u{1F389} ${bgGreen(" SUCCESS ")} Application ${ctx.deployment.url ? "deployed" : "created"} successfully!`,
79363
79378
  ``
@@ -79379,6 +79394,9 @@ var printSummary = (ctx) => {
79379
79394
  `\u{1F4D6} Explore Documentation`,
79380
79395
  `${blue.underline(hyperlink(documentationUrl))}`,
79381
79396
  ``,
79397
+ `\u{1F41B} Report an Issue`,
79398
+ `${blue.underline(hyperlink(reportIssueUrl))}`,
79399
+ ``,
79382
79400
  `\u{1F4AC} Join our Community`,
79383
79401
  `${blue.underline(hyperlink(discordUrl))}`
79384
79402
  );