create-cloudflare 0.0.0-8c7c3b56b → 0.0.0-8c873edd9

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-8c7c3b56b";
73728
+ var version = "0.0.0-8c873edd9";
73718
73729
 
73719
73730
  // src/metrics.ts
73720
73731
  var import_node_async_hooks = require("node:async_hooks");
@@ -73806,6 +73817,13 @@ var runCommand = async (command2, opts = {}) => {
73806
73817
  doneText: opts.doneText,
73807
73818
  promise() {
73808
73819
  const [executable, ...args] = command2;
73820
+ if (args[0] === "wrangler") {
73821
+ const metrics = readMetricsConfig();
73822
+ if (metrics.c3permission?.enabled === false) {
73823
+ opts.env ??= {};
73824
+ opts.env["WRANGLER_SEND_METRICS"] = "false";
73825
+ }
73826
+ }
73809
73827
  const abortController = new AbortController();
73810
73828
  const cmd = (0, import_cross_spawn.spawn)(executable, [...args], {
73811
73829
  // TODO: ideally inherit stderr, but npm install uses this for warnings
@@ -73994,7 +74012,7 @@ var detectPmMismatch = (ctx) => {
73994
74012
  case "pnpm":
73995
74013
  return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "pnpm-lock.yaml"));
73996
74014
  case "bun":
73997
- return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb"));
74015
+ return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb")) && !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lock"));
73998
74016
  }
73999
74017
  };
74000
74018
 
@@ -74461,189 +74479,6 @@ var usesEslint = (ctx) => {
74461
74479
  // templates-experimental/angular/c3.ts
74462
74480
  var import_node_path3 = require("node:path");
74463
74481
 
74464
- // ../wrangler/package.json
74465
- var version2 = "0.0.0-8c7c3b56b";
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
74482
  // src/frameworks/package.json
74648
74483
  var package_default = {
74649
74484
  name: "frameworks_clis_info",
@@ -74652,20 +74487,20 @@ var package_default = {
74652
74487
  "so that we can use dependabot to update these dependencies automatically."
74653
74488
  ],
74654
74489
  dependencies: {
74655
- "create-astro": "4.8.0",
74490
+ "create-astro": "4.10.0",
74656
74491
  "create-analog": "1.8.1",
74657
- "@angular/create": "18.2.8",
74658
- "create-docusaurus": "3.5.2",
74659
- "create-hono": "0.14.1",
74492
+ "@angular/create": "19.0.0",
74493
+ "create-docusaurus": "3.6.1",
74494
+ "create-hono": "0.14.2",
74660
74495
  "create-next-app": "14.2.5",
74661
- "create-qwik": "1.9.1",
74662
- "create-vite": "5.5.3",
74663
- "create-remix": "2.13.1",
74496
+ "create-qwik": "1.11.0",
74497
+ "create-vite": "5.5.5",
74498
+ "create-remix": "2.14.0",
74664
74499
  "create-solid": "0.5.13",
74665
- "create-svelte": "6.4.0",
74666
- "create-vue": "3.10.4",
74667
- gatsby: "5.13.7",
74668
- nuxi: "3.12.0"
74500
+ "create-vue": "3.12.1",
74501
+ gatsby: "5.14.0",
74502
+ nuxi: "3.15.0",
74503
+ sv: "0.6.1"
74669
74504
  }
74670
74505
  };
74671
74506
 
@@ -74693,24 +74528,16 @@ var runFrameworkGenerator = async (ctx, args) => {
74693
74528
  );
74694
74529
  logRaw("");
74695
74530
  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
74531
  };
74709
74532
 
74710
74533
  // templates-experimental/angular/c3.ts
74711
74534
  var { npm } = detectPackageManager();
74712
74535
  var generate = async (ctx) => {
74713
- await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
74536
+ await runFrameworkGenerator(ctx, [
74537
+ ctx.project.name,
74538
+ "--ssr",
74539
+ "--server-routing"
74540
+ ]);
74714
74541
  logRaw("");
74715
74542
  };
74716
74543
  var configure = async (ctx) => {
@@ -74719,9 +74546,9 @@ var configure = async (ctx) => {
74719
74546
  await installCFWorker();
74720
74547
  };
74721
74548
  async function installCFWorker() {
74722
- await installPackages(["@cloudflare/workers-types", "wrangler"], {
74549
+ await installPackages(["xhr2"], {
74723
74550
  dev: true,
74724
- startText: "Installing adapter dependencies",
74551
+ startText: "Installing additional dependencies",
74725
74552
  doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`
74726
74553
  });
74727
74554
  }
@@ -74736,10 +74563,17 @@ async function updateAppCode() {
74736
74563
  );
74737
74564
  writeFile2((0, import_node_path3.resolve)(appConfigPath), newAppConfig);
74738
74565
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
74566
+ const appServerRoutesPath = "src/app/app.routes.server.ts";
74567
+ const appRoutes = readFile((0, import_node_path3.resolve)(appServerRoutesPath));
74568
+ const newAppRoutes = appRoutes.replace(
74569
+ "RenderMode.Prerender",
74570
+ "RenderMode.Server"
74571
+ );
74572
+ writeFile2((0, import_node_path3.resolve)(appServerRoutesPath), newAppRoutes);
74573
+ s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
74739
74574
  s.start(`Updating package.json`);
74740
74575
  const packageJsonPath = (0, import_node_path3.resolve)("package.json");
74741
74576
  const packageManifest = readJSON(packageJsonPath);
74742
- delete packageManifest["dependencies"]["@angular/ssr"];
74743
74577
  delete packageManifest["dependencies"]["express"];
74744
74578
  delete packageManifest["devDependencies"]["@types/express"];
74745
74579
  writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
@@ -74751,7 +74585,8 @@ function updateAngularJson(ctx) {
74751
74585
  const angularJson = readJSON((0, import_node_path3.resolve)("angular.json"));
74752
74586
  const architectSection = angularJson.projects[ctx.project.name].architect;
74753
74587
  architectSection.build.options.outputPath = "dist";
74754
- architectSection.build.options.assets.push("src/_routes.json");
74588
+ architectSection.build.options.outputMode = "server";
74589
+ architectSection.build.options.ssr.experimentalPlatform = "neutral";
74755
74590
  writeFile2((0, import_node_path3.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
74756
74591
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
74757
74592
  }
@@ -74767,13 +74602,13 @@ var config = {
74767
74602
  path: "templates-experimental/angular",
74768
74603
  devScript: "start",
74769
74604
  deployScript: "deploy",
74605
+ previewScript: "start",
74770
74606
  generate,
74771
74607
  configure,
74772
74608
  transformPackageJson: async () => ({
74773
74609
  scripts: {
74774
74610
  start: `${npm} run build && wrangler dev`,
74775
- build: `ng build && ${npm} run process`,
74776
- process: "node ./tools/alter-polyfills.mjs",
74611
+ build: `ng build`,
74777
74612
  deploy: `${npm} run build && wrangler deploy`
74778
74613
  }
74779
74614
  })
@@ -75253,7 +75088,7 @@ var updateNuxtConfig = () => {
75253
75088
  b2.objectExpression([
75254
75089
  b2.objectProperty(
75255
75090
  b2.identifier("preset"),
75256
- b2.stringLiteral("./cloudflare-preset")
75091
+ b2.stringLiteral("cloudflare_module")
75257
75092
  )
75258
75093
  ])
75259
75094
  );
@@ -75417,7 +75252,7 @@ var generate9 = async (ctx) => {
75417
75252
  await runFrameworkGenerator(ctx, [
75418
75253
  ctx.project.name,
75419
75254
  "--template",
75420
- "https://github.com/remix-run/remix/tree/main/templates/cloudflare"
75255
+ "https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers"
75421
75256
  ]);
75422
75257
  logRaw("");
75423
75258
  };
@@ -75427,19 +75262,6 @@ var configure6 = async () => {
75427
75262
  startText: "Updating the Wrangler version",
75428
75263
  doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`
75429
75264
  });
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
75265
  };
75444
75266
  var config10 = {
75445
75267
  configVersion: 1,
@@ -75455,7 +75277,6 @@ var config10 = {
75455
75277
  configure: configure6,
75456
75278
  transformPackageJson: async () => ({
75457
75279
  scripts: {
75458
- build: "remix vite:build && wrangler pages functions build --outdir build/worker",
75459
75280
  deploy: `${npm6} run build && wrangler deploy`,
75460
75281
  preview: `${npm6} run build && wrangler dev`,
75461
75282
  "cf-typegen": `wrangler types`
@@ -75483,6 +75304,7 @@ var configure7 = async (ctx) => {
75483
75304
  });
75484
75305
  usesTypescript(ctx);
75485
75306
  const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
75307
+ const compatDate = await getWorkerdCompatibilityDate();
75486
75308
  updateStatus(`Updating configuration in ${blue(filePath)}`);
75487
75309
  transformFile(filePath, {
75488
75310
  visitCallExpression: function(n2) {
@@ -75497,60 +75319,14 @@ var configure7 = async (ctx) => {
75497
75319
  b2.objectProperty(
75498
75320
  b2.identifier("server"),
75499
75321
  b2.objectExpression([
75500
- // preset: "cloudflare-pages"
75322
+ // preset: "cloudflare_module"
75501
75323
  b2.objectProperty(
75502
75324
  b2.identifier("preset"),
75503
- b2.stringLiteral("./cloudflare-pages")
75325
+ b2.stringLiteral("cloudflare_module")
75504
75326
  ),
75505
- // output: {
75506
- // dir: "{{ rootDir }}/dist",
75507
- // publicDir: "{{ output.dir }}/public",
75508
- // serverDir: "{{ output.dir }}/worker",
75509
- // },
75510
75327
  b2.objectProperty(
75511
- b2.identifier("output"),
75512
- b2.objectExpression([
75513
- b2.objectProperty(
75514
- b2.identifier("dir"),
75515
- b2.stringLiteral("{{ rootDir }}/dist")
75516
- ),
75517
- b2.objectProperty(
75518
- b2.identifier("publicDir"),
75519
- b2.stringLiteral("{{ output.dir }}/public")
75520
- ),
75521
- b2.objectProperty(
75522
- b2.identifier("serverDir"),
75523
- b2.stringLiteral("{{ output.dir }}/worker")
75524
- )
75525
- ])
75526
- ),
75527
- // rollupConfig: {
75528
- // external: ["node:async_hooks"],
75529
- // },
75530
- b2.objectProperty(
75531
- b2.identifier("rollupConfig"),
75532
- b2.objectExpression([
75533
- b2.objectProperty(
75534
- b2.identifier("external"),
75535
- b2.arrayExpression([b2.stringLiteral("node:async_hooks")])
75536
- )
75537
- ])
75538
- ),
75539
- // hooks: {
75540
- // // Prevent the Pages preset from writing the _routes.json etc.
75541
- // compiled() {},
75542
- // },
75543
- b2.objectProperty(
75544
- b2.identifier("hooks"),
75545
- b2.objectExpression([
75546
- b2.objectMethod(
75547
- "method",
75548
- b2.identifier("compiled"),
75549
- [],
75550
- b2.blockStatement([]),
75551
- false
75552
- )
75553
- ])
75328
+ b2.identifier("compatibilityDate"),
75329
+ b2.stringLiteral(compatDate)
75554
75330
  )
75555
75331
  ])
75556
75332
  )
@@ -75590,7 +75366,7 @@ var import_node_os3 = require("node:os");
75590
75366
  var recast6 = __toESM(require_main3());
75591
75367
  var { npm: npm8 } = detectPackageManager();
75592
75368
  var generate11 = async (ctx) => {
75593
- await runFrameworkGenerator(ctx, [ctx.project.name]);
75369
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
75594
75370
  logRaw("");
75595
75371
  };
75596
75372
  var configure8 = async (ctx) => {
@@ -75655,8 +75431,8 @@ var updateTypeDefinitions = (ctx) => {
75655
75431
  var config12 = {
75656
75432
  configVersion: 1,
75657
75433
  id: "svelte",
75658
- frameworkCli: "create-svelte",
75659
- displayName: "Svelte",
75434
+ frameworkCli: "sv",
75435
+ displayName: "SvelteKit",
75660
75436
  platform: "workers",
75661
75437
  copyFiles: {
75662
75438
  variants: {
@@ -75794,7 +75570,11 @@ var c3_default15 = config13;
75794
75570
  var import_node_path4 = require("node:path");
75795
75571
  var { npm: npm10 } = detectPackageManager();
75796
75572
  var generate13 = async (ctx) => {
75797
- await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
75573
+ await runFrameworkGenerator(ctx, [
75574
+ ctx.project.name,
75575
+ "--ssr",
75576
+ "--server-routing"
75577
+ ]);
75798
75578
  logRaw("");
75799
75579
  };
75800
75580
  var configure10 = async (ctx) => {
@@ -75803,14 +75583,11 @@ var configure10 = async (ctx) => {
75803
75583
  await installCFWorker2();
75804
75584
  };
75805
75585
  async function installCFWorker2() {
75806
- await installPackages(
75807
- ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
75808
- {
75809
- dev: true,
75810
- startText: "Installing adapter dependencies",
75811
- doneText: `${brandColor("installed")} ${dim(`via \`${npm10} install\``)}`
75812
- }
75813
- );
75586
+ await installPackages(["xhr2"], {
75587
+ dev: true,
75588
+ startText: "Installing additional dependencies",
75589
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm10} install\``)}`
75590
+ });
75814
75591
  }
75815
75592
  async function updateAppCode2() {
75816
75593
  const s = spinner();
@@ -75823,10 +75600,17 @@ async function updateAppCode2() {
75823
75600
  );
75824
75601
  writeFile2((0, import_node_path4.resolve)(appConfigPath), newAppConfig);
75825
75602
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
75603
+ const appServerRoutesPath = "src/app/app.routes.server.ts";
75604
+ const appRoutes = readFile((0, import_node_path4.resolve)(appServerRoutesPath));
75605
+ const newAppRoutes = appRoutes.replace(
75606
+ "RenderMode.Prerender",
75607
+ "RenderMode.Server"
75608
+ );
75609
+ writeFile2((0, import_node_path4.resolve)(appServerRoutesPath), newAppRoutes);
75610
+ s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
75826
75611
  s.start(`Updating package.json`);
75827
75612
  const packageJsonPath = (0, import_node_path4.resolve)("package.json");
75828
75613
  const packageManifest = readJSON(packageJsonPath);
75829
- delete packageManifest["dependencies"]["@angular/ssr"];
75830
75614
  delete packageManifest["dependencies"]["express"];
75831
75615
  delete packageManifest["devDependencies"]["@types/express"];
75832
75616
  writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
@@ -75838,6 +75622,8 @@ function updateAngularJson2(ctx) {
75838
75622
  const angularJson = readJSON((0, import_node_path4.resolve)("angular.json"));
75839
75623
  const architectSection = angularJson.projects[ctx.project.name].architect;
75840
75624
  architectSection.build.options.outputPath = "dist";
75625
+ architectSection.build.options.outputMode = "server";
75626
+ architectSection.build.options.ssr.experimentalPlatform = "neutral";
75841
75627
  architectSection.build.options.assets.push("src/_routes.json");
75842
75628
  writeFile2((0, import_node_path4.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
75843
75629
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
@@ -75853,13 +75639,14 @@ var config14 = {
75853
75639
  },
75854
75640
  devScript: "start",
75855
75641
  deployScript: "deploy",
75642
+ previewScript: "start",
75856
75643
  generate: generate13,
75857
75644
  configure: configure10,
75858
75645
  transformPackageJson: async () => ({
75859
75646
  scripts: {
75860
- start: `${npm10} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
75647
+ start: `${npm10} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}`,
75861
75648
  build: `ng build && ${npm10} run process`,
75862
- process: "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
75649
+ process: "node ./tools/copy-files.mjs",
75863
75650
  deploy: `${npm10} run build && wrangler pages deploy dist/cloudflare`
75864
75651
  }
75865
75652
  })
@@ -76514,7 +76301,6 @@ var isLoggedIn = async () => {
76514
76301
  // templates/pre-existing/c3.ts
76515
76302
  async function copyExistingWorkerFiles(ctx) {
76516
76303
  const { dlx } = detectPackageManager();
76517
- await chooseAccount(ctx);
76518
76304
  if (ctx.args.existingScript === void 0) {
76519
76305
  ctx.args.existingScript = await processArgument(
76520
76306
  ctx.args,
@@ -76568,11 +76354,23 @@ var c3_default27 = {
76568
76354
  copyFiles: {
76569
76355
  path: "./js"
76570
76356
  },
76571
- configure: async (ctx) => {
76572
- await copyExistingWorkerFiles(ctx);
76573
- ctx.args.deploy = false;
76574
- }
76357
+ configure: buildConfigure({
76358
+ login: wranglerLogin,
76359
+ chooseAccount,
76360
+ copyFiles: copyExistingWorkerFiles
76361
+ })
76575
76362
  };
76363
+ function buildConfigure(params) {
76364
+ return async function configure20(ctx) {
76365
+ const loginSuccess = await params.login(ctx);
76366
+ if (!loginSuccess) {
76367
+ throw new Error("Failed to login to Cloudflare");
76368
+ }
76369
+ await params.chooseAccount(ctx);
76370
+ await params.copyFiles(ctx);
76371
+ ctx.args.deploy = false;
76372
+ };
76373
+ }
76576
76374
 
76577
76375
  // templates/queues/c3.ts
76578
76376
  var c3_default28 = {
@@ -76903,7 +76701,7 @@ var import_node_os4 = require("node:os");
76903
76701
  var recast12 = __toESM(require_main3());
76904
76702
  var { npm: npm19 } = detectPackageManager();
76905
76703
  var generate24 = async (ctx) => {
76906
- await runFrameworkGenerator(ctx, [ctx.project.name]);
76704
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
76907
76705
  logRaw("");
76908
76706
  };
76909
76707
  var configure18 = async (ctx) => {
@@ -76968,8 +76766,8 @@ var updateTypeDefinitions2 = (ctx) => {
76968
76766
  var config24 = {
76969
76767
  configVersion: 1,
76970
76768
  id: "svelte",
76971
- frameworkCli: "create-svelte",
76972
- displayName: "Svelte",
76769
+ frameworkCli: "sv",
76770
+ displayName: "SvelteKit",
76973
76771
  platform: "pages",
76974
76772
  copyFiles: {
76975
76773
  variants: {
@@ -77023,6 +76821,189 @@ var config25 = {
77023
76821
  };
77024
76822
  var c3_default35 = config25;
77025
76823
 
76824
+ // ../wrangler/package.json
76825
+ var version2 = "0.0.0-8c873edd9";
76826
+
76827
+ // src/git.ts
76828
+ var offerGit = async (ctx) => {
76829
+ const gitInstalled = await isGitInstalled();
76830
+ if (!gitInstalled) {
76831
+ if (ctx.args.git) {
76832
+ updateStatus(
76833
+ "Couldn't find `git` installed on your machine. Continuing without git."
76834
+ );
76835
+ }
76836
+ ctx.args.git = false;
76837
+ return;
76838
+ }
76839
+ const insideGitRepo = await isInsideGitRepo(ctx.project.path);
76840
+ if (insideGitRepo) {
76841
+ ctx.args.git = true;
76842
+ return;
76843
+ }
76844
+ ctx.args.git = await processArgument(ctx.args, "git", {
76845
+ type: "confirm",
76846
+ question: "Do you want to use git for version control?",
76847
+ label: "git",
76848
+ defaultValue: C3_DEFAULTS.git
76849
+ });
76850
+ if (!ctx.args.git) {
76851
+ return;
76852
+ }
76853
+ const gitConfigured = await isGitConfigured();
76854
+ if (!gitConfigured) {
76855
+ updateStatus(
76856
+ "Must configure `user.name` and user.email` to use git. Continuing without git."
76857
+ );
76858
+ ctx.args.git = false;
76859
+ return;
76860
+ }
76861
+ await initializeGit(ctx.project.path);
76862
+ };
76863
+ var gitCommit = async (ctx) => {
76864
+ const commitMessage = await createCommitMessage(ctx);
76865
+ if (!ctx.args.git) {
76866
+ return;
76867
+ }
76868
+ if (ctx.gitRepoAlreadyExisted) {
76869
+ return;
76870
+ }
76871
+ const gitInstalled = await isGitInstalled();
76872
+ const gitInitialized = await isInsideGitRepo(ctx.project.path);
76873
+ if (!gitInstalled || !gitInitialized) {
76874
+ return;
76875
+ }
76876
+ const s = spinner();
76877
+ s.start("Committing new files");
76878
+ await runCommand(["git", "add", "."], {
76879
+ silent: true,
76880
+ cwd: ctx.project.path
76881
+ });
76882
+ await runCommand(["git", "commit", "-m", commitMessage], {
76883
+ silent: true,
76884
+ cwd: ctx.project.path
76885
+ });
76886
+ s.stop(`${brandColor("git")} ${dim(`commit`)}`);
76887
+ };
76888
+ var createCommitMessage = async (ctx) => {
76889
+ const framework = ctx.template.frameworkCli;
76890
+ const header = framework ? "Initialize web application via create-cloudflare CLI" : "Initial commit (by create-cloudflare CLI)";
76891
+ const packageManager = detectPackageManager();
76892
+ const gitVersion = await getGitVersion();
76893
+ const insideRepo = await isInsideGitRepo(ctx.project.path);
76894
+ const details = [
76895
+ { key: "C3", value: `create-cloudflare@${version}` },
76896
+ { key: "project name", value: ctx.project.name },
76897
+ ...framework ? [{ key: "framework", value: ctx.template.id }] : [],
76898
+ ...framework ? [{ key: "framework cli", value: getFrameworkCli(ctx) }] : [],
76899
+ {
76900
+ key: "package manager",
76901
+ value: `${packageManager.name}@${packageManager.version}`
76902
+ },
76903
+ {
76904
+ key: "wrangler",
76905
+ value: `wrangler@${version2}`
76906
+ },
76907
+ {
76908
+ key: "git",
76909
+ value: insideRepo ? gitVersion : "N/A"
76910
+ }
76911
+ ];
76912
+ const body = `Details:
76913
+ ${details.map(({ key, value }) => ` ${key} = ${value}`).join("\n")}
76914
+ `;
76915
+ const commitMessage = `${header}
76916
+
76917
+ ${body}
76918
+ `;
76919
+ ctx.commitMessage = commitMessage;
76920
+ return commitMessage;
76921
+ };
76922
+ async function getGitVersion() {
76923
+ try {
76924
+ const rawGitVersion = await runCommand(["git", "--version"], {
76925
+ useSpinner: false,
76926
+ silent: true
76927
+ });
76928
+ const gitVersion = rawGitVersion.replace(/^git\s+version\s+/, "");
76929
+ return gitVersion;
76930
+ } catch {
76931
+ return null;
76932
+ }
76933
+ }
76934
+ async function isGitInstalled() {
76935
+ return await getGitVersion() !== null;
76936
+ }
76937
+ async function isGitConfigured() {
76938
+ try {
76939
+ const userName = await runCommand(["git", "config", "user.name"], {
76940
+ useSpinner: false,
76941
+ silent: true
76942
+ });
76943
+ if (!userName) {
76944
+ return false;
76945
+ }
76946
+ const email = await runCommand(["git", "config", "user.email"], {
76947
+ useSpinner: false,
76948
+ silent: true
76949
+ });
76950
+ if (!email) {
76951
+ return false;
76952
+ }
76953
+ return true;
76954
+ } catch {
76955
+ return false;
76956
+ }
76957
+ }
76958
+ async function isInsideGitRepo(cwd) {
76959
+ try {
76960
+ const output = await runCommand(["git", "status"], {
76961
+ cwd,
76962
+ useSpinner: false,
76963
+ silent: true,
76964
+ captureOutput: true
76965
+ });
76966
+ return output.includes("not a git repository") === false;
76967
+ } catch (err) {
76968
+ return false;
76969
+ }
76970
+ }
76971
+ async function initializeGit(cwd) {
76972
+ const s = spinner();
76973
+ s.start("Initializing git repo");
76974
+ try {
76975
+ const defaultBranchName = await runCommand(
76976
+ ["git", "config", "--get", "init.defaultBranch"],
76977
+ { useSpinner: false, silent: true, cwd }
76978
+ );
76979
+ await runCommand(
76980
+ ["git", "init", "--initial-branch", defaultBranchName.trim() ?? "main"],
76981
+ // branch names can't contain spaces, so this is safe
76982
+ { useSpinner: false, silent: true, cwd }
76983
+ );
76984
+ } catch {
76985
+ await runCommand(["git", "init"], { useSpinner: false, silent: true, cwd });
76986
+ } finally {
76987
+ s.stop(`${brandColor("initialized")} ${dim(`git`)}`);
76988
+ }
76989
+ }
76990
+ async function getProductionBranch(cwd) {
76991
+ try {
76992
+ const productionBranch = await runCommand(
76993
+ ["git", "branch", "--show-current"],
76994
+ {
76995
+ silent: true,
76996
+ cwd,
76997
+ useSpinner: false,
76998
+ captureOutput: true
76999
+ }
77000
+ );
77001
+ return productionBranch.trim();
77002
+ } catch (err) {
77003
+ }
77004
+ return "main";
77005
+ }
77006
+
77026
77007
  // src/validators.ts
77027
77008
  var import_fs10 = require("fs");
77028
77009
  var import_path12 = require("path");
@@ -77912,11 +77893,13 @@ var processArgument = async (args, key, promptConfig) => {
77912
77893
  disableTelemetry: args[key] !== void 0,
77913
77894
  async promise() {
77914
77895
  const value = args[key];
77896
+ const error2 = promptConfig.validate?.(value) ?? null;
77915
77897
  const result = await inputPrompt({
77916
77898
  ...promptConfig,
77917
77899
  // Accept the default value if the arg is already set
77918
- acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
77900
+ acceptDefault: promptConfig.acceptDefault ?? (value !== void 0 && !error2),
77919
77901
  defaultValue: value ?? promptConfig.defaultValue,
77902
+ initialErrorMessage: error2,
77920
77903
  throwOnError: true
77921
77904
  });
77922
77905
  args[key] = result;
@@ -77928,6 +77911,9 @@ var processArgument = async (args, key, promptConfig) => {
77928
77911
  };
77929
77912
 
77930
77913
  // src/deploy.ts
77914
+ var import_promises4 = require("node:fs/promises");
77915
+ var import_node_os5 = require("node:os");
77916
+ var import_node_path5 = require("node:path");
77931
77917
  var import_toml2 = __toESM(require_toml());
77932
77918
 
77933
77919
  // src/helpers/poll.ts
@@ -79246,23 +79232,34 @@ var runDeploy = async (ctx) => {
79246
79232
  JSON.stringify(ctx.commitMessage)
79247
79233
  ] : []
79248
79234
  ];
79249
- const result = await runCommand(deployCmd, {
79250
- silent: true,
79235
+ const outputFile = (0, import_node_path5.join)(
79236
+ await (0, import_promises4.mkdtemp)((0, import_node_path5.join)((0, import_node_os5.tmpdir)(), "c3-wrangler-deploy-")),
79237
+ "output.json"
79238
+ );
79239
+ await runCommand(deployCmd, {
79251
79240
  cwd: ctx.project.path,
79252
79241
  env: {
79253
79242
  CLOUDFLARE_ACCOUNT_ID: ctx.account.id,
79254
- NODE_ENV: "production"
79243
+ NODE_ENV: "production",
79244
+ WRANGLER_OUTPUT_FILE_PATH: outputFile
79255
79245
  },
79256
79246
  startText: "Deploying your application",
79257
79247
  doneText: `${brandColor("deployed")} ${dim(
79258
79248
  `via \`${quoteShellArgs(baseDeployCmd)}\``
79259
79249
  )}`
79260
79250
  });
79261
- const deployedUrlRegex = /https:\/\/.+\.(pages|workers)\.dev/;
79262
- const deployedUrlMatch = result.match(deployedUrlRegex);
79263
- if (deployedUrlMatch) {
79264
- ctx.deployment.url = deployedUrlMatch[0];
79265
- } else {
79251
+ try {
79252
+ const contents = readFile(outputFile);
79253
+ const entries = contents.split("\n").filter(Boolean).map((entry) => JSON.parse(entry));
79254
+ const url = entries.find((entry) => entry.type === "deploy")?.targets?.[0] ?? entries.find((entry) => entry.type === "pages-deploy")?.url;
79255
+ const deployedUrlRegex = /https:\/\/.+\.(pages|workers)\.dev/;
79256
+ const deployedUrlMatch = url?.match(deployedUrlRegex);
79257
+ if (deployedUrlMatch) {
79258
+ ctx.deployment.url = deployedUrlMatch[0];
79259
+ } else {
79260
+ throw new Error("Failed to find deployment url.");
79261
+ }
79262
+ } catch {
79266
79263
  throw new Error("Failed to find deployment url.");
79267
79264
  }
79268
79265
  if (ctx.deployment.url?.endsWith(".pages.dev")) {
@@ -79347,6 +79344,7 @@ var printSummary = (ctx) => {
79347
79344
  ]);
79348
79345
  const documentationUrl = `https://developers.cloudflare.com/${ctx.template.platform}`;
79349
79346
  const discordUrl = `https://discord.cloudflare.com`;
79347
+ const reportIssueUrl = "https://github.com/cloudflare/workers-sdk/issues/new/choose";
79350
79348
  const lines = [
79351
79349
  `\u{1F389} ${bgGreen(" SUCCESS ")} Application ${ctx.deployment.url ? "deployed" : "created"} successfully!`,
79352
79350
  ``
@@ -79368,6 +79366,9 @@ var printSummary = (ctx) => {
79368
79366
  `\u{1F4D6} Explore Documentation`,
79369
79367
  `${blue.underline(hyperlink(documentationUrl))}`,
79370
79368
  ``,
79369
+ `\u{1F41B} Report an Issue`,
79370
+ `${blue.underline(hyperlink(reportIssueUrl))}`,
79371
+ ``,
79371
79372
  `\u{1F4AC} Join our Community`,
79372
79373
  `${blue.underline(hyperlink(discordUrl))}`
79373
79374
  );