create-cloudflare 0.0.0-5dd95736 → 0.0.0-5e0f3d07

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
@@ -1715,16 +1715,17 @@ var init_cli = __esm({
1715
1715
  // current default for backcompat -- TODO: change default to shapes.bar once all callees have been updated
1716
1716
  shape = shapes.corners.bl,
1717
1717
  // current default for backcompat -- TODO: change default to true once all callees have been updated
1718
- multiline = false
1718
+ multiline = false,
1719
+ newlineBefore = true
1719
1720
  } = {}) => {
1720
1721
  logRaw(
1721
1722
  format(msg, {
1722
1723
  firstLinePrefix: gray(shape) + space() + status.warning,
1723
1724
  linePrefix: gray(shapes.bar),
1724
- newlineBefore: true,
1725
1725
  formatLine: (line) => dim(line),
1726
1726
  // for backcompat but it's not ideal for this to be "dim"
1727
- multiline
1727
+ multiline,
1728
+ newlineBefore
1728
1729
  })
1729
1730
  );
1730
1731
  };
@@ -3902,7 +3903,7 @@ var init_args = __esm({
3902
3903
  var version;
3903
3904
  var init_package = __esm({
3904
3905
  "package.json"() {
3905
- version = "0.0.0-5dd95736";
3906
+ version = "0.0.0-5e0f3d07";
3906
3907
  }
3907
3908
  });
3908
3909
 
@@ -24714,20 +24715,20 @@ var init_package2 = __esm({
24714
24715
  "additionally it also contains a map that maps frameworks to their respective clis"
24715
24716
  ],
24716
24717
  dependencies: {
24717
- "create-astro": "4.7.5",
24718
- "create-analog": "1.2.0",
24719
- "@angular/create": "17.3.7",
24720
- "create-docusaurus": "3.1.1",
24721
- "create-hono": "0.7.0",
24718
+ "create-astro": "4.8.0",
24719
+ "create-analog": "1.3.1",
24720
+ "@angular/create": "18.0.4",
24721
+ "create-docusaurus": "3.4.0",
24722
+ "create-hono": "0.8.1",
24722
24723
  "create-next-app": "14.1.0",
24723
- "create-qwik": "1.5.4",
24724
+ "create-qwik": "1.5.7",
24724
24725
  "create-react-app": "5.0.1",
24725
- "create-remix": "2.8.1",
24726
- "create-solid": "0.5.5",
24727
- "create-svelte": "6.0.10",
24728
- "create-vue": "3.10.2",
24729
- gatsby: "5.13.4",
24730
- nuxi: "3.11.1"
24726
+ "create-remix": "2.9.2",
24727
+ "create-solid": "0.5.11",
24728
+ "create-svelte": "6.3.1",
24729
+ "create-vue": "3.10.3",
24730
+ gatsby: "5.13.6",
24731
+ nuxi: "3.12.0"
24731
24732
  },
24732
24733
  frameworkCliMap: {
24733
24734
  analog: "create-analog",
@@ -24757,6 +24758,7 @@ var init_frameworks = __esm({
24757
24758
  init_colors();
24758
24759
  init_command();
24759
24760
  init_packageManagers();
24761
+ init_git();
24760
24762
  init_package2();
24761
24763
  getFrameworkCli = (ctx, withVersion = true) => {
24762
24764
  if (!ctx.template) {
@@ -24782,6 +24784,223 @@ var init_frameworks = __esm({
24782
24784
  );
24783
24785
  logRaw("");
24784
24786
  await runCommand(cmd, { env: env2 });
24787
+ if (process.env.SAVE_DIFFS) {
24788
+ const cmdEnv = {
24789
+ silent: true,
24790
+ cwd: ctx.project.path
24791
+ };
24792
+ if (!isInsideGitRepo(ctx.project.path)) {
24793
+ await runCommand(["git", "init"], cmdEnv);
24794
+ await runCommand(["git", "add", "."], cmdEnv);
24795
+ const commitMessage = `Initial commit by ${cli}`;
24796
+ await runCommand(["git", "commit", "-m", commitMessage], cmdEnv);
24797
+ }
24798
+ }
24799
+ };
24800
+ }
24801
+ });
24802
+
24803
+ // ../wrangler/package.json
24804
+ var version2;
24805
+ var init_package3 = __esm({
24806
+ "../wrangler/package.json"() {
24807
+ version2 = "0.0.0-5e0f3d07";
24808
+ }
24809
+ });
24810
+
24811
+ // src/git.ts
24812
+ async function getGitVersion() {
24813
+ try {
24814
+ const rawGitVersion = await runCommand(["git", "--version"], {
24815
+ useSpinner: false,
24816
+ silent: true
24817
+ });
24818
+ const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
24819
+ return gitVersion;
24820
+ } catch {
24821
+ return null;
24822
+ }
24823
+ }
24824
+ async function isGitInstalled() {
24825
+ return await getGitVersion() !== null;
24826
+ }
24827
+ async function isGitConfigured() {
24828
+ try {
24829
+ const userName = await runCommand(["git", "config", "user.name"], {
24830
+ useSpinner: false,
24831
+ silent: true
24832
+ });
24833
+ if (!userName) {
24834
+ return false;
24835
+ }
24836
+ const email = await runCommand(["git", "config", "user.email"], {
24837
+ useSpinner: false,
24838
+ silent: true
24839
+ });
24840
+ if (!email) {
24841
+ return false;
24842
+ }
24843
+ return true;
24844
+ } catch {
24845
+ return false;
24846
+ }
24847
+ }
24848
+ async function isInsideGitRepo(cwd) {
24849
+ try {
24850
+ const output = await runCommand(["git", "status"], {
24851
+ cwd,
24852
+ useSpinner: false,
24853
+ silent: true,
24854
+ captureOutput: true
24855
+ });
24856
+ return output.includes("not a git repository") === false;
24857
+ } catch (err) {
24858
+ return false;
24859
+ }
24860
+ }
24861
+ async function initializeGit(cwd) {
24862
+ const s = spinner();
24863
+ s.start("Initializing git repo");
24864
+ try {
24865
+ const defaultBranchName = await runCommand(
24866
+ ["git", "config", "--get", "init.defaultBranch"],
24867
+ { useSpinner: false, silent: true, cwd }
24868
+ );
24869
+ await runCommand(
24870
+ ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
24871
+ // branch names can't contain spaces, so this is safe
24872
+ { useSpinner: false, silent: true, cwd }
24873
+ );
24874
+ } catch {
24875
+ await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
24876
+ } finally {
24877
+ s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
24878
+ }
24879
+ }
24880
+ async function getProductionBranch(cwd) {
24881
+ try {
24882
+ const productionBranch = await runCommand(
24883
+ ["git", "branch", "--show-current"],
24884
+ {
24885
+ silent: true,
24886
+ cwd,
24887
+ useSpinner: false,
24888
+ captureOutput: true
24889
+ }
24890
+ );
24891
+ return productionBranch.trim();
24892
+ } catch (err) {
24893
+ }
24894
+ return "main";
24895
+ }
24896
+ var offerGit, gitCommit, createCommitMessage;
24897
+ var init_git = __esm({
24898
+ "src/git.ts"() {
24899
+ init_cli();
24900
+ init_args();
24901
+ init_colors();
24902
+ init_interactive();
24903
+ init_frameworks();
24904
+ init_cli2();
24905
+ init_command();
24906
+ init_packageManagers();
24907
+ init_package3();
24908
+ init_package();
24909
+ offerGit = async (ctx) => {
24910
+ const gitInstalled = await isGitInstalled();
24911
+ if (!gitInstalled) {
24912
+ if (ctx.args.git) {
24913
+ updateStatus(
24914
+ "Couldn't find `git` installed on your machine. Continuing without git."
24915
+ );
24916
+ }
24917
+ ctx.args.git = false;
24918
+ return;
24919
+ }
24920
+ const gitConfigured = await isGitConfigured();
24921
+ if (!gitConfigured) {
24922
+ if (ctx.args.git) {
24923
+ updateStatus(
24924
+ "Must configure `user.name` and user.email` to use git. Continuing without git."
24925
+ );
24926
+ }
24927
+ ctx.args.git = false;
24928
+ return;
24929
+ }
24930
+ const insideGitRepo = await isInsideGitRepo(ctx.project.path);
24931
+ if (insideGitRepo) {
24932
+ ctx.args.git = true;
24933
+ return;
24934
+ }
24935
+ ctx.args.git = await processArgument(ctx.args, "git", {
24936
+ type: "confirm",
24937
+ question: "Do you want to use git for version control?",
24938
+ label: "git",
24939
+ defaultValue: C3_DEFAULTS.git
24940
+ });
24941
+ if (ctx.args.git) {
24942
+ await initializeGit(ctx.project.path);
24943
+ }
24944
+ };
24945
+ gitCommit = async (ctx) => {
24946
+ const commitMessage = await createCommitMessage(ctx);
24947
+ if (!ctx.args.git) {
24948
+ return;
24949
+ }
24950
+ if (ctx.gitRepoAlreadyExisted) {
24951
+ return;
24952
+ }
24953
+ const gitInstalled = await isGitInstalled();
24954
+ const gitInitialized = await isInsideGitRepo(ctx.project.path);
24955
+ if (!gitInstalled || !gitInitialized) {
24956
+ return;
24957
+ }
24958
+ const s = spinner();
24959
+ s.start("Committing new files");
24960
+ await runCommand(["git", "add", "."], {
24961
+ silent: true,
24962
+ cwd: ctx.project.path
24963
+ });
24964
+ await runCommand(["git", "commit", "-m", commitMessage], {
24965
+ silent: true,
24966
+ cwd: ctx.project.path
24967
+ });
24968
+ s.stop(`${brandColor("git")} ${dim(`commit`)}`);
24969
+ };
24970
+ createCommitMessage = async (ctx) => {
24971
+ const isPages = ctx.template.platform === "pages";
24972
+ const header = isPages ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
24973
+ const packageManager = detectPackageManager();
24974
+ const gitVersion = await getGitVersion();
24975
+ const insideRepo = await isInsideGitRepo(ctx.project.path);
24976
+ const showFramework = isPages || ctx.template.id === "hono";
24977
+ const details = [
24978
+ { key: "C3", value: `create-cloudflare@${version}` },
24979
+ { key: "project name", value: ctx.project.name },
24980
+ ...showFramework ? [{ key: "framework", value: ctx.template.id }] : [],
24981
+ ...showFramework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
24982
+ {
24983
+ key: "package manager",
24984
+ value: `${packageManager.name}@${packageManager.version}`
24985
+ },
24986
+ {
24987
+ key: "wrangler",
24988
+ value: `wrangler@${version2}`
24989
+ },
24990
+ {
24991
+ key: "git",
24992
+ value: insideRepo ? gitVersion : "N/A"
24993
+ }
24994
+ ];
24995
+ const body = `Details:
24996
+ ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
24997
+ `;
24998
+ const commitMessage = `${header}
24999
+
25000
+ ${body}
25001
+ `;
25002
+ ctx.commitMessage = commitMessage;
25003
+ return commitMessage;
24785
25004
  };
24786
25005
  }
24787
25006
  });
@@ -70590,7 +70809,7 @@ var require_typescript2 = __commonJS({
70590
70809
  });
70591
70810
 
70592
70811
  // src/helpers/codemod.ts
70593
- var import_fs11, import_path12, recast, esprimaParser, typescriptParser, parseFile, transformFile, loadSnippets, loadTemplateSnippets;
70812
+ var import_fs11, import_path12, recast, esprimaParser, typescriptParser, parseFile, transformFile, loadSnippets, loadTemplateSnippets, mergeObjectProperties, getPropertyName;
70594
70813
  var init_codemod = __esm({
70595
70814
  "src/helpers/codemod.ts"() {
70596
70815
  import_fs11 = require("fs");
@@ -70642,6 +70861,33 @@ var init_codemod = __esm({
70642
70861
  loadTemplateSnippets = (ctx) => {
70643
70862
  return loadSnippets(getTemplatePath(ctx));
70644
70863
  };
70864
+ mergeObjectProperties = (sourceObject, newProperties) => {
70865
+ newProperties.forEach((newProp) => {
70866
+ const newPropName = getPropertyName(newProp);
70867
+ if (!newPropName) {
70868
+ return false;
70869
+ }
70870
+ const indexOfExisting = sourceObject.properties.findIndex(
70871
+ (p2) => p2.type === "ObjectProperty" && getPropertyName(p2) === newPropName
70872
+ );
70873
+ const existing = sourceObject.properties[indexOfExisting];
70874
+ if (!existing) {
70875
+ sourceObject.properties.push(newProp);
70876
+ return;
70877
+ }
70878
+ if (existing.type === "ObjectProperty" && existing.value.type === "ObjectExpression" && newProp.value.type === "ObjectExpression") {
70879
+ mergeObjectProperties(
70880
+ existing.value,
70881
+ newProp.value.properties
70882
+ );
70883
+ return;
70884
+ }
70885
+ sourceObject.properties[indexOfExisting] = newProp;
70886
+ });
70887
+ };
70888
+ getPropertyName = (newProp) => {
70889
+ return newProp.key.type === "Identifier" ? newProp.key.name : newProp.key.type === "StringLiteral" ? newProp.key.value : null;
70890
+ };
70645
70891
  }
70646
70892
  });
70647
70893
 
@@ -71386,9 +71632,10 @@ var init_c38 = __esm({
71386
71632
  visitCallExpression: function(n2) {
71387
71633
  const callee = n2.node.callee;
71388
71634
  if (callee.name === "defineNuxtConfig") {
71389
- const obj = n2.node.arguments[0];
71390
- obj.properties.push(presetDef);
71391
- obj.properties.push(moduleDef);
71635
+ mergeObjectProperties(
71636
+ n2.node.arguments[0],
71637
+ [presetDef, moduleDef]
71638
+ );
71392
71639
  }
71393
71640
  return this.traverse(n2);
71394
71641
  }
@@ -71673,8 +71920,9 @@ var init_c312 = __esm({
71673
71920
  return this.traverse(n2);
71674
71921
  }
71675
71922
  const b2 = recast6.types.builders;
71676
- n2.node.arguments = [
71677
- b2.objectExpression([
71923
+ mergeObjectProperties(
71924
+ n2.node.arguments[0],
71925
+ [
71678
71926
  b2.objectProperty(
71679
71927
  b2.identifier("server"),
71680
71928
  b2.objectExpression([
@@ -71693,8 +71941,8 @@ var init_c312 = __esm({
71693
71941
  )
71694
71942
  ])
71695
71943
  )
71696
- ])
71697
- ];
71944
+ ]
71945
+ );
71698
71946
  return false;
71699
71947
  }
71700
71948
  });
@@ -71921,18 +72169,18 @@ var init_c316 = __esm({
71921
72169
  }
71922
72170
  });
71923
72171
 
71924
- // templates/hello-world-durable-object/c3.ts
72172
+ // templates/common/c3.ts
71925
72173
  var c3_exports17 = {};
71926
72174
  __export(c3_exports17, {
71927
72175
  default: () => c3_default17
71928
72176
  });
71929
72177
  var c3_default17;
71930
72178
  var init_c317 = __esm({
71931
- "templates/hello-world-durable-object/c3.ts"() {
72179
+ "templates/common/c3.ts"() {
71932
72180
  c3_default17 = {
71933
72181
  configVersion: 1,
71934
- id: "hello-world-durable-object",
71935
- displayName: '"Hello World" Durable Object',
72182
+ id: "common",
72183
+ displayName: "Example router & proxy Worker",
71936
72184
  platform: "workers",
71937
72185
  copyFiles: {
71938
72186
  variants: {
@@ -71948,18 +72196,18 @@ var init_c317 = __esm({
71948
72196
  }
71949
72197
  });
71950
72198
 
71951
- // templates/common/c3.ts
72199
+ // templates/scheduled/c3.ts
71952
72200
  var c3_exports18 = {};
71953
72201
  __export(c3_exports18, {
71954
72202
  default: () => c3_default18
71955
72203
  });
71956
72204
  var c3_default18;
71957
72205
  var init_c318 = __esm({
71958
- "templates/common/c3.ts"() {
72206
+ "templates/scheduled/c3.ts"() {
71959
72207
  c3_default18 = {
71960
72208
  configVersion: 1,
71961
- id: "common",
71962
- displayName: "Example router & proxy Worker",
72209
+ id: "scheduled",
72210
+ displayName: "Scheduled Worker (Cron Trigger)",
71963
72211
  platform: "workers",
71964
72212
  copyFiles: {
71965
72213
  variants: {
@@ -71975,18 +72223,18 @@ var init_c318 = __esm({
71975
72223
  }
71976
72224
  });
71977
72225
 
71978
- // templates/scheduled/c3.ts
72226
+ // templates/queues/c3.ts
71979
72227
  var c3_exports19 = {};
71980
72228
  __export(c3_exports19, {
71981
72229
  default: () => c3_default19
71982
72230
  });
71983
72231
  var c3_default19;
71984
72232
  var init_c319 = __esm({
71985
- "templates/scheduled/c3.ts"() {
72233
+ "templates/queues/c3.ts"() {
71986
72234
  c3_default19 = {
71987
72235
  configVersion: 1,
71988
- id: "scheduled",
71989
- displayName: "Scheduled Worker (Cron Trigger)",
72236
+ id: "queues",
72237
+ displayName: "Queue consumer & producer Worker",
71990
72238
  platform: "workers",
71991
72239
  copyFiles: {
71992
72240
  variants: {
@@ -71997,23 +72245,33 @@ var init_c319 = __esm({
71997
72245
  path: "./ts"
71998
72246
  }
71999
72247
  }
72248
+ },
72249
+ bindings: {
72250
+ queues: [
72251
+ {
72252
+ boundVariable: "MY_QUEUE",
72253
+ defaultValue: "my-queue",
72254
+ producer: true,
72255
+ consumer: true
72256
+ }
72257
+ ]
72000
72258
  }
72001
72259
  };
72002
72260
  }
72003
72261
  });
72004
72262
 
72005
- // templates/queues/c3.ts
72263
+ // templates/hello-world-durable-object/c3.ts
72006
72264
  var c3_exports20 = {};
72007
72265
  __export(c3_exports20, {
72008
72266
  default: () => c3_default20
72009
72267
  });
72010
72268
  var c3_default20;
72011
72269
  var init_c320 = __esm({
72012
- "templates/queues/c3.ts"() {
72270
+ "templates/hello-world-durable-object/c3.ts"() {
72013
72271
  c3_default20 = {
72014
72272
  configVersion: 1,
72015
- id: "queues",
72016
- displayName: "Queue consumer & producer Worker",
72273
+ id: "hello-world-durable-object",
72274
+ displayName: "Co-ordination / multiplayer API (using Durable Objects)",
72017
72275
  platform: "workers",
72018
72276
  copyFiles: {
72019
72277
  variants: {
@@ -72024,16 +72282,6 @@ var init_c320 = __esm({
72024
72282
  path: "./ts"
72025
72283
  }
72026
72284
  }
72027
- },
72028
- bindings: {
72029
- queues: [
72030
- {
72031
- boundVariable: "MY_QUEUE",
72032
- defaultValue: "my-queue",
72033
- producer: true,
72034
- consumer: true
72035
- }
72036
- ]
72037
72285
  }
72038
72286
  };
72039
72287
  }
@@ -72206,12 +72454,12 @@ var init_templates = __esm({
72206
72454
  return {
72207
72455
  "hello-world": (await Promise.resolve().then(() => (init_c315(), c3_exports15))).default,
72208
72456
  "hello-world-python": (await Promise.resolve().then(() => (init_c316(), c3_exports16))).default,
72209
- "hello-world-durable-object": (await Promise.resolve().then(() => (init_c317(), c3_exports17))).default,
72210
72457
  // Dummy record -- actual template config resolved in `selectFramework`
72211
72458
  "web-framework": { displayName: "Website or web app" },
72212
- common: (await Promise.resolve().then(() => (init_c318(), c3_exports18))).default,
72213
- scheduled: (await Promise.resolve().then(() => (init_c319(), c3_exports19))).default,
72214
- queues: (await Promise.resolve().then(() => (init_c320(), c3_exports20))).default,
72459
+ common: (await Promise.resolve().then(() => (init_c317(), c3_exports17))).default,
72460
+ scheduled: (await Promise.resolve().then(() => (init_c318(), c3_exports18))).default,
72461
+ queues: (await Promise.resolve().then(() => (init_c319(), c3_exports19))).default,
72462
+ "hello-world-durable-object": (await Promise.resolve().then(() => (init_c320(), c3_exports20))).default,
72215
72463
  openapi: (await Promise.resolve().then(() => (init_c321(), c3_exports21))).default,
72216
72464
  // Dummy record -- actual template config resolved in `processRemoteTemplate`
72217
72465
  "remote-template": {
@@ -77948,200 +78196,7 @@ init_colors();
77948
78196
  init_cli2();
77949
78197
  init_command();
77950
78198
  init_packageManagers();
77951
-
77952
- // src/git.ts
77953
- init_cli();
77954
- init_args();
77955
- init_colors();
77956
- init_interactive();
77957
- init_frameworks();
77958
- init_cli2();
77959
- init_command();
77960
- init_packageManagers();
77961
-
77962
- // ../wrangler/package.json
77963
- var version2 = "0.0.0-5dd95736";
77964
-
77965
- // src/git.ts
77966
- init_package();
77967
- var offerGit = async (ctx) => {
77968
- const gitInstalled = await isGitInstalled();
77969
- if (!gitInstalled) {
77970
- if (ctx.args.git) {
77971
- updateStatus(
77972
- "Couldn't find `git` installed on your machine. Continuing without git."
77973
- );
77974
- }
77975
- ctx.args.git = false;
77976
- return;
77977
- }
77978
- const gitConfigured = await isGitConfigured();
77979
- if (!gitConfigured) {
77980
- if (ctx.args.git) {
77981
- updateStatus(
77982
- "Must configure `user.name` and user.email` to use git. Continuing without git."
77983
- );
77984
- }
77985
- ctx.args.git = false;
77986
- return;
77987
- }
77988
- const insideGitRepo = await isInsideGitRepo(ctx.project.path);
77989
- if (insideGitRepo) {
77990
- return;
77991
- }
77992
- ctx.args.git = await processArgument(ctx.args, "git", {
77993
- type: "confirm",
77994
- question: "Do you want to use git for version control?",
77995
- label: "git",
77996
- defaultValue: C3_DEFAULTS.git
77997
- });
77998
- if (ctx.args.git) {
77999
- await initializeGit(ctx.project.path);
78000
- }
78001
- };
78002
- var gitCommit = async (ctx) => {
78003
- const commitMessage = await createCommitMessage(ctx);
78004
- if (ctx.gitRepoAlreadyExisted) {
78005
- return;
78006
- }
78007
- const gitInstalled = await isGitInstalled();
78008
- const gitInitialized = await isInsideGitRepo(ctx.project.path);
78009
- if (!gitInstalled || !gitInitialized) {
78010
- return;
78011
- }
78012
- const s = spinner();
78013
- s.start("Committing new files");
78014
- await runCommand(["git", "add", "."], {
78015
- silent: true,
78016
- cwd: ctx.project.path
78017
- });
78018
- await runCommand(["git", "commit", "-m", commitMessage], {
78019
- silent: true,
78020
- cwd: ctx.project.path
78021
- });
78022
- s.stop(`${brandColor("git")} ${dim(`commit`)}`);
78023
- };
78024
- var createCommitMessage = async (ctx) => {
78025
- const isPages = ctx.template.platform === "pages";
78026
- const header = isPages ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
78027
- const packageManager = detectPackageManager();
78028
- const gitVersion = await getGitVersion();
78029
- const insideRepo = await isInsideGitRepo(ctx.project.path);
78030
- const showFramework = isPages || ctx.template.id === "hono";
78031
- const details = [
78032
- { key: "C3", value: `create-cloudflare@${version}` },
78033
- { key: "project name", value: ctx.project.name },
78034
- ...showFramework ? [{ key: "framework", value: ctx.template.id }] : [],
78035
- ...showFramework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
78036
- {
78037
- key: "package manager",
78038
- value: `${packageManager.name}@${packageManager.version}`
78039
- },
78040
- {
78041
- key: "wrangler",
78042
- value: `wrangler@${version2}`
78043
- },
78044
- {
78045
- key: "git",
78046
- value: insideRepo ? gitVersion : "N/A"
78047
- }
78048
- ];
78049
- const body = `Details:
78050
- ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
78051
- `;
78052
- const commitMessage = `${header}
78053
-
78054
- ${body}
78055
- `;
78056
- ctx.commitMessage = commitMessage;
78057
- return commitMessage;
78058
- };
78059
- async function getGitVersion() {
78060
- try {
78061
- const rawGitVersion = await runCommand(["git", "--version"], {
78062
- useSpinner: false,
78063
- silent: true
78064
- });
78065
- const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
78066
- return gitVersion;
78067
- } catch {
78068
- return null;
78069
- }
78070
- }
78071
- async function isGitInstalled() {
78072
- return await getGitVersion() !== null;
78073
- }
78074
- async function isGitConfigured() {
78075
- try {
78076
- const userName = await runCommand(["git", "config", "user.name"], {
78077
- useSpinner: false,
78078
- silent: true
78079
- });
78080
- if (!userName) {
78081
- return false;
78082
- }
78083
- const email = await runCommand(["git", "config", "user.email"], {
78084
- useSpinner: false,
78085
- silent: true
78086
- });
78087
- if (!email) {
78088
- return false;
78089
- }
78090
- return true;
78091
- } catch {
78092
- return false;
78093
- }
78094
- }
78095
- async function isInsideGitRepo(cwd) {
78096
- try {
78097
- const output = await runCommand(["git", "status"], {
78098
- cwd,
78099
- useSpinner: false,
78100
- silent: true,
78101
- captureOutput: true
78102
- });
78103
- return output.includes("not a git repository") === false;
78104
- } catch (err) {
78105
- return false;
78106
- }
78107
- }
78108
- async function initializeGit(cwd) {
78109
- const s = spinner();
78110
- s.start("Initializing git repo");
78111
- try {
78112
- const defaultBranchName = await runCommand(
78113
- ["git", "config", "--get", "init.defaultBranch"],
78114
- { useSpinner: false, silent: true, cwd }
78115
- );
78116
- await runCommand(
78117
- ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
78118
- // branch names can't contain spaces, so this is safe
78119
- { useSpinner: false, silent: true, cwd }
78120
- );
78121
- } catch {
78122
- await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
78123
- } finally {
78124
- s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
78125
- }
78126
- }
78127
- async function getProductionBranch(cwd) {
78128
- try {
78129
- const productionBranch = await runCommand(
78130
- ["git", "branch", "--show-current"],
78131
- {
78132
- silent: true,
78133
- cwd,
78134
- useSpinner: false,
78135
- captureOutput: true
78136
- }
78137
- );
78138
- return productionBranch.trim();
78139
- } catch (err) {
78140
- }
78141
- return "main";
78142
- }
78143
-
78144
- // src/deploy.ts
78199
+ init_git();
78145
78200
  init_accounts();
78146
78201
 
78147
78202
  // src/wrangler/config.ts
@@ -79344,6 +79399,9 @@ var runDeploy = async (ctx) => {
79344
79399
  }
79345
79400
  };
79346
79401
 
79402
+ // src/cli.ts
79403
+ init_git();
79404
+
79347
79405
  // src/pages.ts
79348
79406
  init_cli();
79349
79407
  init_colors();
@@ -79369,6 +79427,7 @@ var retry = async (config14, fn) => {
79369
79427
  };
79370
79428
 
79371
79429
  // src/pages.ts
79430
+ init_git();
79372
79431
  var CREATE_PROJECT_RETRIES = 3;
79373
79432
  var VERIFY_PROJECT_RETRIES = 3;
79374
79433
  var { npx } = detectPackageManager();