create-cloudflare 2.29.3 → 2.30.1

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
@@ -73714,7 +73714,7 @@ var Yargs = YargsFactory(esm_default);
73714
73714
  var yargs_default = Yargs;
73715
73715
 
73716
73716
  // package.json
73717
- var version = "2.29.3";
73717
+ var version = "2.30.1";
73718
73718
 
73719
73719
  // src/metrics.ts
73720
73720
  var import_node_async_hooks = require("node:async_hooks");
@@ -74461,189 +74461,6 @@ var usesEslint = (ctx) => {
74461
74461
  // templates-experimental/angular/c3.ts
74462
74462
  var import_node_path3 = require("node:path");
74463
74463
 
74464
- // ../wrangler/package.json
74465
- var version2 = "3.80.5";
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
74464
  // src/frameworks/package.json
74648
74465
  var package_default = {
74649
74466
  name: "frameworks_clis_info",
@@ -74656,14 +74473,14 @@ var package_default = {
74656
74473
  "create-analog": "1.8.1",
74657
74474
  "@angular/create": "18.2.8",
74658
74475
  "create-docusaurus": "3.5.2",
74659
- "create-hono": "0.12.0",
74476
+ "create-hono": "0.14.2",
74660
74477
  "create-next-app": "14.2.5",
74661
- "create-qwik": "1.9.0",
74662
- "create-vite": "5.2.3",
74663
- "create-remix": "2.12.0",
74478
+ "create-qwik": "1.9.1",
74479
+ "create-vite": "5.5.3",
74480
+ "create-remix": "2.13.1",
74664
74481
  "create-solid": "0.5.13",
74665
74482
  "create-svelte": "6.4.0",
74666
- "create-vue": "3.10.4",
74483
+ "create-vue": "3.11.1",
74667
74484
  gatsby: "5.13.7",
74668
74485
  nuxi: "3.12.0"
74669
74486
  }
@@ -74693,18 +74510,6 @@ var runFrameworkGenerator = async (ctx, args) => {
74693
74510
  );
74694
74511
  logRaw("");
74695
74512
  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
74513
  };
74709
74514
 
74710
74515
  // templates-experimental/angular/c3.ts
@@ -76514,7 +76319,6 @@ var isLoggedIn = async () => {
76514
76319
  // templates/pre-existing/c3.ts
76515
76320
  async function copyExistingWorkerFiles(ctx) {
76516
76321
  const { dlx } = detectPackageManager();
76517
- await chooseAccount(ctx);
76518
76322
  if (ctx.args.existingScript === void 0) {
76519
76323
  ctx.args.existingScript = await processArgument(
76520
76324
  ctx.args,
@@ -76568,11 +76372,23 @@ var c3_default27 = {
76568
76372
  copyFiles: {
76569
76373
  path: "./js"
76570
76374
  },
76571
- configure: async (ctx) => {
76572
- await copyExistingWorkerFiles(ctx);
76573
- ctx.args.deploy = false;
76574
- }
76375
+ configure: buildConfigure({
76376
+ login: wranglerLogin,
76377
+ chooseAccount,
76378
+ copyFiles: copyExistingWorkerFiles
76379
+ })
76575
76380
  };
76381
+ function buildConfigure(params) {
76382
+ return async function configure20(ctx) {
76383
+ const loginSuccess = await params.login(ctx);
76384
+ if (!loginSuccess) {
76385
+ throw new Error("Failed to login to Cloudflare");
76386
+ }
76387
+ await params.chooseAccount(ctx);
76388
+ await params.copyFiles(ctx);
76389
+ ctx.args.deploy = false;
76390
+ };
76391
+ }
76576
76392
 
76577
76393
  // templates/queues/c3.ts
76578
76394
  var c3_default28 = {
@@ -77023,6 +76839,189 @@ var config25 = {
77023
76839
  };
77024
76840
  var c3_default35 = config25;
77025
76841
 
76842
+ // ../wrangler/package.json
76843
+ var version2 = "3.82.0";
76844
+
76845
+ // src/git.ts
76846
+ var offerGit = async (ctx) => {
76847
+ const gitInstalled = await isGitInstalled();
76848
+ if (!gitInstalled) {
76849
+ if (ctx.args.git) {
76850
+ updateStatus(
76851
+ "Couldn't find `git` installed on your machine. Continuing without git."
76852
+ );
76853
+ }
76854
+ ctx.args.git = false;
76855
+ return;
76856
+ }
76857
+ const insideGitRepo = await isInsideGitRepo(ctx.project.path);
76858
+ if (insideGitRepo) {
76859
+ ctx.args.git = true;
76860
+ return;
76861
+ }
76862
+ ctx.args.git = await processArgument(ctx.args, "git", {
76863
+ type: "confirm",
76864
+ question: "Do you want to use git for version control?",
76865
+ label: "git",
76866
+ defaultValue: C3_DEFAULTS.git
76867
+ });
76868
+ if (!ctx.args.git) {
76869
+ return;
76870
+ }
76871
+ const gitConfigured = await isGitConfigured();
76872
+ if (!gitConfigured) {
76873
+ updateStatus(
76874
+ "Must configure `user.name` and user.email` to use git. Continuing without git."
76875
+ );
76876
+ ctx.args.git = false;
76877
+ return;
76878
+ }
76879
+ await initializeGit(ctx.project.path);
76880
+ };
76881
+ var gitCommit = async (ctx) => {
76882
+ const commitMessage = await createCommitMessage(ctx);
76883
+ if (!ctx.args.git) {
76884
+ return;
76885
+ }
76886
+ if (ctx.gitRepoAlreadyExisted) {
76887
+ return;
76888
+ }
76889
+ const gitInstalled = await isGitInstalled();
76890
+ const gitInitialized = await isInsideGitRepo(ctx.project.path);
76891
+ if (!gitInstalled || !gitInitialized) {
76892
+ return;
76893
+ }
76894
+ const s = spinner();
76895
+ s.start("Committing new files");
76896
+ await runCommand(["git", "add", "."], {
76897
+ silent: true,
76898
+ cwd: ctx.project.path
76899
+ });
76900
+ await runCommand(["git", "commit", "-m", commitMessage], {
76901
+ silent: true,
76902
+ cwd: ctx.project.path
76903
+ });
76904
+ s.stop(`${brandColor("git")} ${dim(`commit`)}`);
76905
+ };
76906
+ var createCommitMessage = async (ctx) => {
76907
+ const framework = ctx.template.frameworkCli;
76908
+ const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
76909
+ const packageManager = detectPackageManager();
76910
+ const gitVersion = await getGitVersion();
76911
+ const insideRepo = await isInsideGitRepo(ctx.project.path);
76912
+ const details = [
76913
+ { key: "C3", value: `create-cloudflare@${version}` },
76914
+ { key: "project name", value: ctx.project.name },
76915
+ ...framework ? [{ key: "framework", value: ctx.template.id }] : [],
76916
+ ...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
76917
+ {
76918
+ key: "package manager",
76919
+ value: `${packageManager.name}@${packageManager.version}`
76920
+ },
76921
+ {
76922
+ key: "wrangler",
76923
+ value: `wrangler@${version2}`
76924
+ },
76925
+ {
76926
+ key: "git",
76927
+ value: insideRepo ? gitVersion : "N/A"
76928
+ }
76929
+ ];
76930
+ const body = `Details:
76931
+ ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
76932
+ `;
76933
+ const commitMessage = `${header}
76934
+
76935
+ ${body}
76936
+ `;
76937
+ ctx.commitMessage = commitMessage;
76938
+ return commitMessage;
76939
+ };
76940
+ async function getGitVersion() {
76941
+ try {
76942
+ const rawGitVersion = await runCommand(["git", "--version"], {
76943
+ useSpinner: false,
76944
+ silent: true
76945
+ });
76946
+ const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
76947
+ return gitVersion;
76948
+ } catch {
76949
+ return null;
76950
+ }
76951
+ }
76952
+ async function isGitInstalled() {
76953
+ return await getGitVersion() !== null;
76954
+ }
76955
+ async function isGitConfigured() {
76956
+ try {
76957
+ const userName = await runCommand(["git", "config", "user.name"], {
76958
+ useSpinner: false,
76959
+ silent: true
76960
+ });
76961
+ if (!userName) {
76962
+ return false;
76963
+ }
76964
+ const email = await runCommand(["git", "config", "user.email"], {
76965
+ useSpinner: false,
76966
+ silent: true
76967
+ });
76968
+ if (!email) {
76969
+ return false;
76970
+ }
76971
+ return true;
76972
+ } catch {
76973
+ return false;
76974
+ }
76975
+ }
76976
+ async function isInsideGitRepo(cwd) {
76977
+ try {
76978
+ const output = await runCommand(["git", "status"], {
76979
+ cwd,
76980
+ useSpinner: false,
76981
+ silent: true,
76982
+ captureOutput: true
76983
+ });
76984
+ return output.includes("not a git repository") === false;
76985
+ } catch (err) {
76986
+ return false;
76987
+ }
76988
+ }
76989
+ async function initializeGit(cwd) {
76990
+ const s = spinner();
76991
+ s.start("Initializing git repo");
76992
+ try {
76993
+ const defaultBranchName = await runCommand(
76994
+ ["git", "config", "--get", "init.defaultBranch"],
76995
+ { useSpinner: false, silent: true, cwd }
76996
+ );
76997
+ await runCommand(
76998
+ ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
76999
+ // branch names can't contain spaces, so this is safe
77000
+ { useSpinner: false, silent: true, cwd }
77001
+ );
77002
+ } catch {
77003
+ await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
77004
+ } finally {
77005
+ s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
77006
+ }
77007
+ }
77008
+ async function getProductionBranch(cwd) {
77009
+ try {
77010
+ const productionBranch = await runCommand(
77011
+ ["git", "branch", "--show-current"],
77012
+ {
77013
+ silent: true,
77014
+ cwd,
77015
+ useSpinner: false,
77016
+ captureOutput: true
77017
+ }
77018
+ );
77019
+ return productionBranch.trim();
77020
+ } catch (err) {
77021
+ }
77022
+ return "main";
77023
+ }
77024
+
77026
77025
  // src/validators.ts
77027
77026
  var import_fs10 = require("fs");
77028
77027
  var import_path12 = require("path");
@@ -77217,6 +77216,10 @@ var createContext = async (args, prevArgs) => {
77217
77216
  const currentArgs = { ...args };
77218
77217
  let linesPrinted = 0;
77219
77218
  switch (from) {
77219
+ case "category":
77220
+ linesPrinted = 6;
77221
+ args.projectName = void 0;
77222
+ break;
77220
77223
  case "type":
77221
77224
  linesPrinted = 9;
77222
77225
  args.category = void 0;
@@ -77250,7 +77253,7 @@ var createContext = async (args, prevArgs) => {
77250
77253
  type: "text",
77251
77254
  question: `In which directory do you want to create your application?`,
77252
77255
  helpText: "also used as application name",
77253
- defaultValue: defaultName,
77256
+ defaultValue: prevArgs?.projectName ?? defaultName,
77254
77257
  label: "dir",
77255
77258
  validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName, args),
77256
77259
  format: (val) => `./${val}`
@@ -77277,7 +77280,8 @@ var createContext = async (args, prevArgs) => {
77277
77280
  description: "Start from an existing GitHub repo link"
77278
77281
  },
77279
77282
  // This is used only if the type is `pre-existing`
77280
- { label: "Others", value: "others", hidden: true }
77283
+ { label: "Others", value: "others", hidden: true },
77284
+ backOption
77281
77285
  ];
77282
77286
  const category = await processArgument(args, "category", {
77283
77287
  type: "select",
@@ -77286,6 +77290,9 @@ var createContext = async (args, prevArgs) => {
77286
77290
  options: categoryOptions,
77287
77291
  defaultValue: prevArgs?.category ?? C3_DEFAULTS.category
77288
77292
  });
77293
+ if (category === BACK_VALUE) {
77294
+ return goBack("category");
77295
+ }
77289
77296
  let template;
77290
77297
  if (category === "web-framework") {
77291
77298
  const frameworkMap = getFrameworkMap({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.29.3",
3
+ "version": "2.30.1",
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.20241018.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -67,9 +67,9 @@
67
67
  "xdg-app-paths": "^8.3.0",
68
68
  "yargs": "^17.7.2",
69
69
  "@cloudflare/cli": "1.1.1",
70
+ "@cloudflare/workers-tsconfig": "0.0.0",
70
71
  "@cloudflare/eslint-config-worker": "1.1.0",
71
- "wrangler": "3.80.5",
72
- "@cloudflare/workers-tsconfig": "0.0.0"
72
+ "wrangler": "3.82.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
+ }
@@ -2,7 +2,7 @@
2
2
  name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  compatibility_flags = ["nodejs_compat_v2"]
5
- main = "./dist/_worker.js"
5
+ main = "./dist/_worker.js/index.js"
6
6
  assets = { directory = "./dist", binding = "ASSETS" }
7
7
 
8
8
  # Workers Logs