create-cloudflare 2.46.2 → 2.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/cli.js +196 -162
  2. package/package.json +4 -4
  3. package/templates/analog/c3.ts +0 -24
  4. package/templates/analog/templates/env.d.ts +1 -1
  5. package/templates/angular/pages/c3.ts +3 -3
  6. package/templates/angular/pages/templates/wrangler.jsonc +5 -0
  7. package/templates/angular/workers/c3.ts +1 -0
  8. package/templates/astro/workers/templates/js/wrangler.jsonc +2 -1
  9. package/templates/astro/workers/templates/ts/wrangler.jsonc +2 -1
  10. package/templates/common/ts/tsconfig.json +0 -3
  11. package/templates/docusaurus/pages/c3.ts +1 -0
  12. package/templates/docusaurus/workers/c3.ts +1 -0
  13. package/templates/gatsby/pages/c3.ts +1 -0
  14. package/templates/gatsby/workers/c3.ts +1 -0
  15. package/templates/hello-world/ts/test/index.spec.ts +0 -1
  16. package/templates/hello-world/ts/test/tsconfig.json +1 -1
  17. package/templates/hello-world/ts/tsconfig.json +0 -2
  18. package/templates/hello-world-durable-object/ts/tsconfig.json +0 -2
  19. package/templates/hello-world-durable-object-with-assets/ts/tsconfig.json +0 -2
  20. package/templates/hello-world-with-assets/js/wrangler.jsonc +2 -1
  21. package/templates/hello-world-with-assets/ts/test/tsconfig.json +1 -1
  22. package/templates/hello-world-with-assets/ts/tsconfig.json +0 -2
  23. package/templates/hello-world-with-assets/ts/wrangler.jsonc +2 -1
  24. package/templates/hono/pages/c3.ts +4 -1
  25. package/templates/hono/workers/c3.ts +3 -1
  26. package/templates/next/pages/c3.ts +6 -10
  27. package/templates/next/workers/c3.ts +7 -5
  28. package/templates/nuxt/pages/c3.ts +2 -26
  29. package/templates/nuxt/pages/templates/env.d.ts +1 -1
  30. package/templates/nuxt/workers/c3.ts +2 -26
  31. package/templates/nuxt/workers/templates/env.d.ts +1 -1
  32. package/templates/openapi/ts/tsconfig.json +0 -1
  33. package/templates/queues/ts/tsconfig.json +0 -2
  34. package/templates/qwik/pages/c3.ts +1 -0
  35. package/templates/qwik/workers/c3.ts +1 -0
  36. package/templates/qwik/workers/templates/wrangler.jsonc +2 -1
  37. package/templates/react/pages/c3.ts +4 -2
  38. package/templates/react/pages/templates/wrangler.jsonc +5 -0
  39. package/templates/react/workers/ts/tsconfig.worker.json +1 -1
  40. package/templates/react-router/c3.ts +0 -12
  41. package/templates/remix/pages/c3.ts +1 -0
  42. package/templates/remix/pages/templates/worker-configuration.d.ts +1 -1
  43. package/templates/remix/workers/c3.ts +1 -0
  44. package/templates/scheduled/ts/tsconfig.json +0 -2
  45. package/templates/solid/c3.ts +1 -0
  46. package/templates/svelte/pages/c3.ts +3 -3
  47. package/templates/svelte/workers/c3.ts +3 -3
  48. package/templates/vue/pages/c3.ts +5 -3
  49. package/templates/vue/pages/templates/wrangler.jsonc +5 -0
  50. package/templates/vue/workers/ts/tsconfig.worker.json +1 -1
  51. package/templates-experimental/solid/c3.ts +1 -1
  52. package/templates/analog/templates/worker-configuration.d.ts +0 -4
  53. package/templates/astro/workers/templates/ts/worker-configuration.d.ts +0 -4
  54. package/templates/common/ts/worker-configuration.d.ts +0 -4
  55. package/templates/hello-world/ts/worker-configuration.d.ts +0 -8
  56. package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +0 -7
  57. package/templates/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +0 -8
  58. package/templates/hello-world-with-assets/ts/worker-configuration.d.ts +0 -7
  59. package/templates/hono/pages/templates/worker-configuration.d.ts +0 -4
  60. package/templates/hono/workers/templates/worker-configuration.d.ts +0 -4
  61. package/templates/next/pages/env.d.ts +0 -5
  62. package/templates/next/workers/templates/cloudflare-env.d.ts +0 -5
  63. package/templates/nuxt/pages/templates/worker-configuration.d.ts +0 -4
  64. package/templates/nuxt/workers/templates/worker-configuration.d.ts +0 -4
  65. package/templates/openapi/ts/worker-configuration.d.ts +0 -4
  66. package/templates/queues/ts/worker-configuration.d.ts +0 -5
  67. package/templates/react/workers/ts/worker-configuration.d.ts +0 -5
  68. package/templates/react-router/templates/worker-configuration.d.ts +0 -8
  69. package/templates/scheduled/ts/worker-configuration.d.ts +0 -4
  70. package/templates/vue/workers/ts/worker-configuration.d.ts +0 -6
package/dist/cli.js CHANGED
@@ -3111,8 +3111,8 @@ var require_path_key = __commonJS({
3111
3111
  "use strict";
3112
3112
  var pathKey = (options = {}) => {
3113
3113
  const environment = options.env || process.env;
3114
- const platform3 = options.platform || process.platform;
3115
- if (platform3 !== "win32") {
3114
+ const platform = options.platform || process.platform;
3115
+ if (platform !== "win32") {
3116
3116
  return "PATH";
3117
3117
  }
3118
3118
  return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
@@ -26411,7 +26411,7 @@ var require_index_688c5d50 = __commonJS({
26411
26411
  }
26412
26412
  var origCwd = process.cwd;
26413
26413
  var cwd = null;
26414
- var platform3 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
26414
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
26415
26415
  process.cwd = function() {
26416
26416
  if (!cwd)
26417
26417
  cwd = origCwd.call(process);
@@ -26466,7 +26466,7 @@ var require_index_688c5d50 = __commonJS({
26466
26466
  fs4.lchownSync = function() {
26467
26467
  };
26468
26468
  }
26469
- if (platform3 === "win32") {
26469
+ if (platform === "win32") {
26470
26470
  fs4.rename = /* @__PURE__ */ function(fs$rename) {
26471
26471
  return function(from, to, cb) {
26472
26472
  var start = Date.now();
@@ -31639,7 +31639,7 @@ var require_open = __commonJS({
31639
31639
  var isDocker = require_is_docker();
31640
31640
  var defineLazyProperty = require_define_lazy_prop();
31641
31641
  var localXdgOpenPath = path6.join(__dirname, "xdg-open");
31642
- var { platform: platform3, arch } = process;
31642
+ var { platform, arch } = process;
31643
31643
  var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
31644
31644
  const defaultMountPoint = "/mnt/";
31645
31645
  let mountPoint;
@@ -31706,7 +31706,7 @@ var require_open = __commonJS({
31706
31706
  let command2;
31707
31707
  const cliArguments = [];
31708
31708
  const childProcessOptions = {};
31709
- if (platform3 === "darwin") {
31709
+ if (platform === "darwin") {
31710
31710
  command2 = "open";
31711
31711
  if (options.wait) {
31712
31712
  cliArguments.push("--wait-apps");
@@ -31720,7 +31720,7 @@ var require_open = __commonJS({
31720
31720
  if (app) {
31721
31721
  cliArguments.push("-a", app);
31722
31722
  }
31723
- } else if (platform3 === "win32" || isWsl && !isDocker()) {
31723
+ } else if (platform === "win32" || isWsl && !isDocker()) {
31724
31724
  const mountPoint = await getWslDrivesMountPoint();
31725
31725
  command2 = isWsl ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
31726
31726
  cliArguments.push(
@@ -31761,7 +31761,7 @@ var require_open = __commonJS({
31761
31761
  exeLocalXdgOpen = true;
31762
31762
  } catch {
31763
31763
  }
31764
- const useSystemXdgOpen = process.versions.electron || platform3 === "android" || isBundled || !exeLocalXdgOpen;
31764
+ const useSystemXdgOpen = process.versions.electron || platform === "android" || isBundled || !exeLocalXdgOpen;
31765
31765
  command2 = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
31766
31766
  }
31767
31767
  if (appArguments.length > 0) {
@@ -31775,7 +31775,7 @@ var require_open = __commonJS({
31775
31775
  if (options.target) {
31776
31776
  cliArguments.push(options.target);
31777
31777
  }
31778
- if (platform3 === "darwin" && appArguments.length > 0) {
31778
+ if (platform === "darwin" && appArguments.length > 0) {
31779
31779
  cliArguments.push("--args", ...appArguments);
31780
31780
  }
31781
31781
  const subprocess = childProcess.spawn(command2, cliArguments, childProcessOptions);
@@ -31829,12 +31829,12 @@ var require_open = __commonJS({
31829
31829
  }
31830
31830
  return archBinary;
31831
31831
  }
31832
- function detectPlatformBinary({ [platform3]: platformBinary }, { wsl }) {
31832
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
31833
31833
  if (wsl && isWsl) {
31834
31834
  return detectArchBinary(wsl);
31835
31835
  }
31836
31836
  if (!platformBinary) {
31837
- throw new Error(`${platform3} is not supported`);
31837
+ throw new Error(`${platform} is not supported`);
31838
31838
  }
31839
31839
  return detectArchBinary(platformBinary);
31840
31840
  }
@@ -74560,7 +74560,7 @@ var Yargs = YargsFactory(esm_default);
74560
74560
  var yargs_default = Yargs;
74561
74561
 
74562
74562
  // package.json
74563
- var version = "2.46.2";
74563
+ var version = "2.47.0";
74564
74564
 
74565
74565
  // src/metrics.ts
74566
74566
  var import_node_async_hooks = require("node:async_hooks");
@@ -74892,8 +74892,8 @@ function promiseWithResolvers() {
74892
74892
  return { resolve: resolve12, reject, promise };
74893
74893
  }
74894
74894
  function getPlatform() {
74895
- const platform3 = process.platform;
74896
- switch (platform3) {
74895
+ const platform = process.platform;
74896
+ switch (platform) {
74897
74897
  case "win32":
74898
74898
  return "Windows";
74899
74899
  case "darwin":
@@ -74901,7 +74901,7 @@ function getPlatform() {
74901
74901
  case "linux":
74902
74902
  return "Linux";
74903
74903
  default:
74904
- return `Others: ${platform3}`;
74904
+ return `Others: ${platform}`;
74905
74905
  }
74906
74906
  }
74907
74907
  function createReporter() {
@@ -74912,7 +74912,7 @@ function createReporter() {
74912
74912
  const isEnabled = isTelemetryEnabled();
74913
74913
  const deviceId = getDeviceId(config48);
74914
74914
  const packageManager = detectPackageManager();
74915
- const platform3 = getPlatform();
74915
+ const platform = getPlatform();
74916
74916
  const amplitude_session_id = Date.now();
74917
74917
  const enableLog = process.env.CREATE_CLOUDFLARE_TELEMETRY_DEBUG === "1";
74918
74918
  let amplitude_event_id = 0;
@@ -74928,7 +74928,7 @@ function createReporter() {
74928
74928
  properties: {
74929
74929
  amplitude_session_id,
74930
74930
  amplitude_event_id: amplitude_event_id++,
74931
- platform: platform3,
74931
+ platform,
74932
74932
  c3Version: version,
74933
74933
  isFirstUsage,
74934
74934
  packageManager: packageManager.name,
@@ -75337,14 +75337,14 @@ var package_default = {
75337
75337
  dependencies: {
75338
75338
  "create-astro": "4.11.4",
75339
75339
  "create-analog": "1.8.1",
75340
- "@angular/create": "19.2.10",
75340
+ "@angular/create": "19.2.11",
75341
75341
  "create-docusaurus": "3.7.0",
75342
75342
  "create-hono": "0.18.0",
75343
- "create-next-app": "15.3.1",
75343
+ "create-next-app": "15.3.2",
75344
75344
  "create-qwik": "1.13.0",
75345
- "create-vite": "6.4.1",
75346
- "create-remix": "2.16.5",
75347
- "create-react-router": "7.5.3",
75345
+ "create-vite": "6.5.0",
75346
+ "create-remix": "2.16.6",
75347
+ "create-react-router": "7.6.0",
75348
75348
  "create-solid": "0.6.2",
75349
75349
  "create-vue": "3.16.4",
75350
75350
  gatsby: "5.14.3",
@@ -75483,10 +75483,6 @@ async function getWorkerdCompatibilityDate() {
75483
75483
  );
75484
75484
  return fallbackDate;
75485
75485
  }
75486
- var compatDateFlag = async () => {
75487
- const workerdCompatDate = await getWorkerdCompatibilityDate();
75488
- return `--compatibility-date=${workerdCompatDate}`;
75489
- };
75490
75486
  function getLatestTypesEntrypoint(ctx) {
75491
75487
  const workersTypesPath = (0, import_path9.resolve)(
75492
75488
  ctx.project.path,
@@ -75569,10 +75565,10 @@ var config = {
75569
75565
  transformPackageJson: async () => ({
75570
75566
  scripts: {
75571
75567
  preview: `${npm} run build && npx wrangler dev`,
75572
- deploy: `${npm} run build && wrangler deploy`
75568
+ deploy: `${npm} run build && wrangler deploy`,
75569
+ "cf-typegen": `wrangler types`
75573
75570
  }
75574
75571
  }),
75575
- compatibilityFlags: ["nodejs_compat"],
75576
75572
  devScript: "dev",
75577
75573
  deployScript: "deploy",
75578
75574
  previewScript: "preview"
@@ -75604,21 +75600,6 @@ var configure2 = async (ctx) => {
75604
75600
  });
75605
75601
  }
75606
75602
  updateViteConfig(ctx);
75607
- updateEnvTypes(ctx);
75608
- };
75609
- var updateEnvTypes = (ctx) => {
75610
- const filepath = "env.d.ts";
75611
- const s = spinner();
75612
- s.start(`Updating ${filepath}`);
75613
- let file = readFile(filepath);
75614
- let typesEntrypoint = `@cloudflare/workers-types`;
75615
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
75616
- if (latestEntrypoint) {
75617
- typesEntrypoint += `/${latestEntrypoint}`;
75618
- }
75619
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
75620
- writeFile2("env.d.ts", file);
75621
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
75622
75603
  };
75623
75604
  var updateViteConfig = (ctx) => {
75624
75605
  const b3 = recast3.types.builders;
@@ -75762,10 +75743,11 @@ var config3 = {
75762
75743
  configure: configure3,
75763
75744
  transformPackageJson: async () => ({
75764
75745
  scripts: {
75765
- start: `${npm3} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}`,
75746
+ start: `${npm3} run build && wrangler pages dev`,
75766
75747
  build: `ng build && ${npm3} run process`,
75767
75748
  process: "node ./tools/copy-files.mjs",
75768
- deploy: `${npm3} run build && wrangler pages deploy dist/cloudflare`
75749
+ deploy: `${npm3} run build && wrangler pages deploy`,
75750
+ "cf-typegen": `wrangler types`
75769
75751
  }
75770
75752
  })
75771
75753
  };
@@ -75851,7 +75833,8 @@ var config4 = {
75851
75833
  scripts: {
75852
75834
  start: `${npm4} run build && wrangler dev`,
75853
75835
  build: `ng build`,
75854
- deploy: `${npm4} run build && wrangler deploy`
75836
+ deploy: `${npm4} run build && wrangler deploy`,
75837
+ "cf-typegen": `wrangler types`
75855
75838
  }
75856
75839
  })
75857
75840
  };
@@ -76067,7 +76050,8 @@ var config10 = {
76067
76050
  }),
76068
76051
  devScript: "preview",
76069
76052
  deployScript: "deploy",
76070
- previewScript: "preview"
76053
+ previewScript: "preview",
76054
+ workersTypes: "none"
76071
76055
  };
76072
76056
  var c3_default10 = config10;
76073
76057
 
@@ -76095,7 +76079,8 @@ var config11 = {
76095
76079
  }),
76096
76080
  devScript: "start",
76097
76081
  deployScript: "deploy",
76098
- previewScript: "preview"
76082
+ previewScript: "preview",
76083
+ workersTypes: "none"
76099
76084
  };
76100
76085
  var c3_default11 = config11;
76101
76086
 
@@ -76144,7 +76129,8 @@ var config13 = {
76144
76129
  }),
76145
76130
  devScript: "develop",
76146
76131
  deployScript: "deploy",
76147
- previewScript: "preview"
76132
+ previewScript: "preview",
76133
+ workersTypes: "none"
76148
76134
  };
76149
76135
  var c3_default13 = config13;
76150
76136
 
@@ -76188,7 +76174,8 @@ var config14 = {
76188
76174
  }),
76189
76175
  devScript: "develop",
76190
76176
  deployScript: "deploy",
76191
- previewScript: "preview"
76177
+ previewScript: "preview",
76178
+ workersTypes: "none"
76192
76179
  };
76193
76180
  var c3_default14 = config14;
76194
76181
 
@@ -76333,6 +76320,7 @@ var generate11 = async (ctx) => {
76333
76320
  ]);
76334
76321
  logRaw("");
76335
76322
  };
76323
+ var envInterfaceName = "CloudflareBindings";
76336
76324
  var config20 = {
76337
76325
  configVersion: 1,
76338
76326
  id: "hono",
@@ -76347,13 +76335,14 @@ var config20 = {
76347
76335
  generate: generate11,
76348
76336
  transformPackageJson: async () => ({
76349
76337
  scripts: {
76350
- "cf-typegen": "wrangler types --env-interface CloudflareBindings",
76338
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
76351
76339
  preview: "vite build && wrangler pages dev"
76352
76340
  }
76353
76341
  }),
76354
76342
  devScript: "dev",
76355
76343
  deployScript: "deploy",
76356
- previewScript: "preview"
76344
+ previewScript: "preview",
76345
+ envInterfaceName
76357
76346
  };
76358
76347
  var c3_default21 = config20;
76359
76348
 
@@ -76370,6 +76359,7 @@ var generate12 = async (ctx) => {
76370
76359
  ]);
76371
76360
  logRaw("");
76372
76361
  };
76362
+ var envInterfaceName2 = "CloudflareBindings";
76373
76363
  var config21 = {
76374
76364
  configVersion: 1,
76375
76365
  id: "hono",
@@ -76383,12 +76373,13 @@ var config21 = {
76383
76373
  generate: generate12,
76384
76374
  transformPackageJson: async () => ({
76385
76375
  scripts: {
76386
- "cf-typegen": "wrangler types --env-interface CloudflareBindings"
76376
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName2}`
76387
76377
  }
76388
76378
  }),
76389
76379
  devScript: "dev",
76390
76380
  deployScript: "deploy",
76391
- previewScript: "dev"
76381
+ previewScript: "dev",
76382
+ envInterfaceName: envInterfaceName2
76392
76383
  };
76393
76384
  var c3_default22 = config21;
76394
76385
 
@@ -76441,13 +76432,6 @@ var configure7 = async (ctx) => {
76441
76432
  throw new Error("Could not find the `/api` or `/app` directory");
76442
76433
  }
76443
76434
  const usesTs = usesTypescript(ctx);
76444
- if (usesTs) {
76445
- copyFile(
76446
- (0, import_path10.join)(getTemplatePath(ctx), "env.d.ts"),
76447
- (0, import_path10.join)(projectPath, "env.d.ts")
76448
- );
76449
- updateStatus("Created an env.d.ts file");
76450
- }
76451
76435
  const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
76452
76436
  if (installEslintPlugin) {
76453
76437
  await writeEslintrc(ctx);
@@ -76492,7 +76476,6 @@ var writeEslintrc = async (ctx) => {
76492
76476
  var addDevDependencies = async (installEslintPlugin) => {
76493
76477
  const packages = [
76494
76478
  "@cloudflare/next-on-pages@1",
76495
- "@cloudflare/workers-types",
76496
76479
  "vercel",
76497
76480
  ...installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []
76498
76481
  ];
@@ -76502,6 +76485,8 @@ var addDevDependencies = async (installEslintPlugin) => {
76502
76485
  doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
76503
76486
  });
76504
76487
  };
76488
+ var envInterfaceName3 = "CloudflareEnv";
76489
+ var typesPath = "./env.d.ts";
76505
76490
  var c3_default24 = {
76506
76491
  configVersion: 1,
76507
76492
  id: "next",
@@ -76555,7 +76540,7 @@ var c3_default24 = {
76555
76540
  preview: `${pagesBuildRunCommand} && wrangler pages dev`,
76556
76541
  deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
76557
76542
  ...usesTypescript(ctx) && {
76558
- "cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`
76543
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName3} ${typesPath}`
76559
76544
  }
76560
76545
  }
76561
76546
  };
@@ -76563,7 +76548,9 @@ var c3_default24 = {
76563
76548
  devScript: "dev",
76564
76549
  previewScript: "preview",
76565
76550
  deployScript: "deploy",
76566
- compatibilityFlags: ["nodejs_compat"]
76551
+ compatibilityFlags: ["nodejs_compat"],
76552
+ typesPath,
76553
+ envInterfaceName: envInterfaceName3
76567
76554
  };
76568
76555
 
76569
76556
  // templates/next/workers/c3.ts
@@ -76571,7 +76558,7 @@ var generate14 = async (ctx) => {
76571
76558
  await runFrameworkGenerator(ctx, [ctx.project.name]);
76572
76559
  };
76573
76560
  var configure8 = async (ctx) => {
76574
- await installPackages(["@opennextjs/cloudflare@~1.0.0-beta.0 || ^1.0.0"], {
76561
+ await installPackages(["@opennextjs/cloudflare@^1.0.2"], {
76575
76562
  startText: "Adding the Cloudflare adapter",
76576
76563
  doneText: `${brandColor(`installed`)} @opennextjs/cloudflare)}`
76577
76564
  });
@@ -76591,13 +76578,14 @@ var updateNextConfig2 = (usesTs) => {
76591
76578
  writeFile2(configFile, updatedConfigFile);
76592
76579
  s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
76593
76580
  };
76581
+ var envInterfaceName4 = "CloudflareBindings";
76582
+ var typesPath2 = "./cloudflare-env.d.ts";
76594
76583
  var c3_default25 = {
76595
76584
  configVersion: 1,
76596
76585
  id: "next",
76597
76586
  frameworkCli: "create-next-app",
76598
- frameworkCliPinnedVersion: "~15.3.0",
76599
76587
  platform: "workers",
76600
- displayName: "Next.js (using Node.js compat + Workers Assets)",
76588
+ displayName: "Next.js",
76601
76589
  path: "templates/next/workers",
76602
76590
  copyFiles: {
76603
76591
  path: "./templates"
@@ -76608,13 +76596,14 @@ var c3_default25 = {
76608
76596
  scripts: {
76609
76597
  deploy: `opennextjs-cloudflare build && opennextjs-cloudflare deploy`,
76610
76598
  preview: `opennextjs-cloudflare build && opennextjs-cloudflare preview`,
76611
- "cf-typegen": `wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts`
76599
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName4} ${typesPath2}`
76612
76600
  }
76613
76601
  }),
76614
76602
  devScript: "dev",
76615
76603
  previewScript: "preview",
76616
76604
  deployScript: "deploy",
76617
- compatibilityFlags: ["nodejs_compat"]
76605
+ typesPath: typesPath2,
76606
+ envInterfaceName: envInterfaceName4
76618
76607
  };
76619
76608
 
76620
76609
  // templates/next/c3.ts
@@ -76640,7 +76629,7 @@ var generate15 = async (ctx) => {
76640
76629
  writeFile2("./.node-version", "18");
76641
76630
  logRaw("");
76642
76631
  };
76643
- var configure9 = async (ctx) => {
76632
+ var configure9 = async () => {
76644
76633
  const packages = ["nitro-cloudflare-dev"];
76645
76634
  if (pm2 === "pnpm") {
76646
76635
  packages.push("h3");
@@ -76651,21 +76640,6 @@ var configure9 = async (ctx) => {
76651
76640
  doneText: `${brandColor("installed")} ${dim(`via \`${npm10} install\``)}`
76652
76641
  });
76653
76642
  updateNuxtConfig();
76654
- updateEnvTypes2(ctx);
76655
- };
76656
- var updateEnvTypes2 = (ctx) => {
76657
- const filepath = "env.d.ts";
76658
- const s = spinner();
76659
- s.start(`Updating ${filepath}`);
76660
- let file = readFile(filepath);
76661
- let typesEntrypoint = `@cloudflare/workers-types`;
76662
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
76663
- if (latestEntrypoint) {
76664
- typesEntrypoint += `/${latestEntrypoint}`;
76665
- }
76666
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
76667
- writeFile2("env.d.ts", file);
76668
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
76669
76643
  };
76670
76644
  var updateNuxtConfig = () => {
76671
76645
  const s = spinner();
@@ -76751,7 +76725,7 @@ var generate16 = async (ctx) => {
76751
76725
  writeFile2("./.node-version", "18");
76752
76726
  logRaw("");
76753
76727
  };
76754
- var configure10 = async (ctx) => {
76728
+ var configure10 = async () => {
76755
76729
  const packages = ["nitro-cloudflare-dev", "nitropack"];
76756
76730
  if (pm3 === "pnpm") {
76757
76731
  packages.push("h3");
@@ -76762,21 +76736,6 @@ var configure10 = async (ctx) => {
76762
76736
  doneText: `${brandColor("installed")} ${dim(`via \`${npm11} install\``)}`
76763
76737
  });
76764
76738
  updateNuxtConfig2();
76765
- updateEnvTypes3(ctx);
76766
- };
76767
- var updateEnvTypes3 = (ctx) => {
76768
- const filepath = "env.d.ts";
76769
- const s = spinner();
76770
- s.start(`Updating ${filepath}`);
76771
- let file = readFile(filepath);
76772
- let typesEntrypoint = `@cloudflare/workers-types`;
76773
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
76774
- if (latestEntrypoint) {
76775
- typesEntrypoint += `/${latestEntrypoint}`;
76776
- }
76777
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
76778
- writeFile2("env.d.ts", file);
76779
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
76780
76739
  };
76781
76740
  var updateNuxtConfig2 = () => {
76782
76741
  const s = spinner();
@@ -77177,7 +77136,8 @@ var config30 = {
77177
77136
  }),
77178
77137
  devScript: "dev",
77179
77138
  deployScript: "deploy",
77180
- previewScript: "preview"
77139
+ previewScript: "preview",
77140
+ workersTypes: "installed"
77181
77141
  };
77182
77142
  var c3_default33 = config30;
77183
77143
 
@@ -77286,7 +77246,8 @@ var config31 = {
77286
77246
  }),
77287
77247
  devScript: "dev",
77288
77248
  deployScript: "deploy",
77289
- previewScript: "preview"
77249
+ previewScript: "preview",
77250
+ workersTypes: "installed"
77290
77251
  };
77291
77252
  var c3_default34 = config31;
77292
77253
 
@@ -77316,9 +77277,6 @@ var config33 = {
77316
77277
  platform: "workers",
77317
77278
  frameworkCli: "create-react-router",
77318
77279
  displayName: "React Router (formerly Remix)",
77319
- copyFiles: {
77320
- path: "./templates"
77321
- },
77322
77280
  generate: generate19,
77323
77281
  // configure,
77324
77282
  transformPackageJson: async () => ({
@@ -77374,11 +77332,13 @@ var config34 = {
77374
77332
  platform: "pages",
77375
77333
  hidden: true,
77376
77334
  path: "templates/react/pages",
77335
+ copyFiles: { path: "./templates" },
77377
77336
  generate: generate20,
77378
77337
  transformPackageJson: async () => ({
77379
77338
  scripts: {
77380
- deploy: `${npm15} run build && wrangler pages deploy ./dist`,
77381
- preview: `${npm15} run build && wrangler pages dev ./dist`
77339
+ deploy: `${npm15} run build && wrangler pages deploy`,
77340
+ preview: `${npm15} run build && wrangler pages dev`,
77341
+ "cf-typegen": `wrangler types`
77382
77342
  }
77383
77343
  }),
77384
77344
  devScript: "dev",
@@ -77579,7 +77539,8 @@ var config37 = {
77579
77539
  }),
77580
77540
  devScript: "dev",
77581
77541
  deployScript: "deploy",
77582
- previewScript: "preview"
77542
+ previewScript: "preview",
77543
+ workersTypes: "installed"
77583
77544
  };
77584
77545
  var c3_default40 = config37;
77585
77546
 
@@ -77621,7 +77582,8 @@ var config38 = {
77621
77582
  }),
77622
77583
  devScript: "dev",
77623
77584
  deployScript: "deploy",
77624
- previewScript: "preview"
77585
+ previewScript: "preview",
77586
+ workersTypes: "installed"
77625
77587
  };
77626
77588
  var c3_default41 = config38;
77627
77589
 
@@ -77712,7 +77674,8 @@ var config41 = {
77712
77674
  transformPackageJson: async () => ({
77713
77675
  scripts: {
77714
77676
  preview: `${npm19} run build && npx wrangler pages dev`,
77715
- deploy: `${npm19} run build && wrangler pages deploy`
77677
+ deploy: `${npm19} run build && wrangler pages deploy`,
77678
+ "cf-typegen": `wrangler types`
77716
77679
  }
77717
77680
  }),
77718
77681
  compatibilityFlags: ["nodejs_compat"],
@@ -77724,7 +77687,6 @@ var c3_default44 = config41;
77724
77687
 
77725
77688
  // templates/svelte/pages/c3.ts
77726
77689
  var import_node_fs3 = require("node:fs");
77727
- var import_node_os3 = require("node:os");
77728
77690
  var recast12 = __toESM(require_main3());
77729
77691
  var { npm: npm20 } = detectPackageManager();
77730
77692
  var generate25 = async (ctx) => {
@@ -77813,6 +77775,7 @@ var updateTypeDefinitions = (ctx) => {
77813
77775
  }
77814
77776
  });
77815
77777
  };
77778
+ var typesPath3 = "src/worker-configuration.d.ts";
77816
77779
  var config42 = {
77817
77780
  configVersion: 1,
77818
77781
  id: "svelte",
@@ -77832,22 +77795,21 @@ var config42 = {
77832
77795
  deploy: `${npm20} run build && wrangler pages deploy`
77833
77796
  };
77834
77797
  if (usesTypescript(ctx)) {
77835
- const mv = (0, import_node_os3.platform)() === "win32" ? "move" : "mv";
77836
77798
  scripts = {
77837
77799
  ...scripts,
77838
- "cf-typegen": `wrangler types && ${mv} worker-configuration.d.ts src/`
77800
+ "cf-typegen": `wrangler types ${typesPath3}`
77839
77801
  };
77840
77802
  }
77841
77803
  return { scripts };
77842
77804
  },
77843
77805
  devScript: "dev",
77844
77806
  deployScript: "deploy",
77845
- previewScript: "preview"
77807
+ previewScript: "preview",
77808
+ typesPath: typesPath3
77846
77809
  };
77847
77810
  var c3_default45 = config42;
77848
77811
 
77849
77812
  // templates/svelte/workers/c3.ts
77850
- var import_node_os4 = require("node:os");
77851
77813
  var recast13 = __toESM(require_main3());
77852
77814
  var { npm: npm21 } = detectPackageManager();
77853
77815
  var generate26 = async (ctx) => {
@@ -77913,6 +77875,7 @@ var updateTypeDefinitions2 = (ctx) => {
77913
77875
  }
77914
77876
  });
77915
77877
  };
77878
+ var typesPath4 = "./src/worker-configuration.d.ts";
77916
77879
  var config43 = {
77917
77880
  configVersion: 1,
77918
77881
  id: "svelte",
@@ -77931,17 +77894,17 @@ var config43 = {
77931
77894
  deploy: `${npm21} run build && wrangler deploy`
77932
77895
  };
77933
77896
  if (usesTypescript(ctx)) {
77934
- const mv = (0, import_node_os4.platform)() === "win32" ? "move" : "mv";
77935
77897
  scripts = {
77936
77898
  ...scripts,
77937
- "cf-typegen": `wrangler types && ${mv} worker-configuration.d.ts src/`
77899
+ "cf-typegen": `wrangler types ${typesPath4}`
77938
77900
  };
77939
77901
  }
77940
77902
  return { scripts };
77941
77903
  },
77942
77904
  devScript: "dev",
77943
77905
  deployScript: "deploy",
77944
- previewScript: "preview"
77906
+ previewScript: "preview",
77907
+ typesPath: typesPath4
77945
77908
  };
77946
77909
  var c3_default46 = config43;
77947
77910
 
@@ -77964,12 +77927,14 @@ var config45 = {
77964
77927
  displayName: "Vue",
77965
77928
  platform: "pages",
77966
77929
  hidden: true,
77967
- path: "templates/pages/vue",
77930
+ path: "templates/vue/pages",
77931
+ copyFiles: { path: "./templates" },
77968
77932
  generate: generate27,
77969
77933
  transformPackageJson: async () => ({
77970
77934
  scripts: {
77971
- deploy: `${npm22} run build && wrangler pages deploy ./dist`,
77972
- preview: `${npm22} run build && wrangler pages dev ./dist`
77935
+ deploy: `${npm22} run build && wrangler pages deploy`,
77936
+ preview: `${npm22} run build && wrangler pages dev`,
77937
+ "cf-typegen": `wrangler types`
77973
77938
  }
77974
77939
  }),
77975
77940
  devScript: "dev",
@@ -78064,7 +78029,7 @@ var c3_default50 = config47;
78064
78029
  var import_node_assert = __toESM(require("node:assert"));
78065
78030
 
78066
78031
  // ../wrangler/package.json
78067
- var version2 = "4.14.4";
78032
+ var version2 = "4.15.0";
78068
78033
 
78069
78034
  // src/git.ts
78070
78035
  var offerGit = async (ctx) => {
@@ -78569,7 +78534,7 @@ var createContext = async (args, prevArgs) => {
78569
78534
  if (availableVariants.length === 1) {
78570
78535
  args.platform ??= availableVariants[0][0];
78571
78536
  }
78572
- const platform3 = await processArgument(args, "platform", {
78537
+ const platform = await processArgument(args, "platform", {
78573
78538
  type: "select",
78574
78539
  label: "platform",
78575
78540
  question: "Select your deployment platform",
@@ -78593,10 +78558,10 @@ var createContext = async (args, prevArgs) => {
78593
78558
  defaultValue: "workers"
78594
78559
  });
78595
78560
  linesPrinted += 3;
78596
- if (platform3 === BACK_VALUE) {
78561
+ if (platform === BACK_VALUE) {
78597
78562
  return goBack("platform");
78598
78563
  }
78599
- frameworkConfig = frameworkConfig.platformVariants[platform3];
78564
+ frameworkConfig = frameworkConfig.platformVariants[platform];
78600
78565
  }
78601
78566
  template = {
78602
78567
  deployScript: "pages:deploy",
@@ -78633,6 +78598,12 @@ var createContext = async (args, prevArgs) => {
78633
78598
  throw new Error(`Unknown application type provided: ${type}.`);
78634
78599
  }
78635
78600
  }
78601
+ template = {
78602
+ workersTypes: "generated",
78603
+ typesPath: "worker-configuration.d.ts",
78604
+ envInterfaceName: "Env",
78605
+ ...template
78606
+ };
78636
78607
  const path6 = (0, import_path13.resolve)(projectName);
78637
78608
  const languageVariants = template.copyFiles && !isVariantInfo(template.copyFiles) && !template.copyFiles.selectVariant ? Object.keys(template.copyFiles.variants) : [];
78638
78609
  if (languageVariants.length > 0) {
@@ -79221,7 +79192,7 @@ var processArgument = async (args, key, promptConfig) => {
79221
79192
 
79222
79193
  // src/deploy.ts
79223
79194
  var import_promises5 = require("node:fs/promises");
79224
- var import_node_os5 = require("node:os");
79195
+ var import_node_os3 = require("node:os");
79225
79196
  var import_node_path6 = require("node:path");
79226
79197
  var import_toml3 = __toESM(require_toml());
79227
79198
 
@@ -80888,7 +80859,7 @@ var runDeploy = async (ctx) => {
80888
80859
  ] : []
80889
80860
  ];
80890
80861
  const outputFile = (0, import_node_path6.join)(
80891
- await (0, import_promises5.mkdtemp)((0, import_node_path6.join)((0, import_node_os5.tmpdir)(), "c3-wrangler-deploy-")),
80862
+ await (0, import_promises5.mkdtemp)((0, import_node_path6.join)((0, import_node_os3.tmpdir)(), "c3-wrangler-deploy-")),
80892
80863
  "output.json"
80893
80864
  );
80894
80865
  await runCommand(deployCmd, {
@@ -81468,48 +81439,107 @@ var createProject = async (ctx) => {
81468
81439
  // src/workers.ts
81469
81440
  var import_fs13 = require("fs");
81470
81441
  var import_path16 = require("path");
81471
- async function installWorkersTypes(ctx) {
81442
+ var import_toml4 = __toESM(require_toml());
81443
+ async function addTypes(ctx) {
81444
+ if (!usesTypescript(ctx) || ctx.template.workersTypes === "none") {
81445
+ return;
81446
+ }
81472
81447
  const { npm: npm25 } = detectPackageManager();
81473
- if (!usesTypescript(ctx)) {
81448
+ if (ctx.template.workersTypes === "installed") {
81449
+ await installWorkersTypes(npm25);
81450
+ } else if (ctx.template.workersTypes === "generated") {
81451
+ await generateWorkersTypes(ctx, npm25);
81452
+ }
81453
+ const usesNodeCompat = await maybeInstallNodeTypes(ctx, npm25);
81454
+ await updateTsConfig(ctx, { usesNodeCompat });
81455
+ }
81456
+ async function generateWorkersTypes(ctx, npm25) {
81457
+ const packageJsonPath = (0, import_path16.join)(ctx.project.path, "package.json");
81458
+ if (!(0, import_fs13.existsSync)(packageJsonPath)) {
81474
81459
  return;
81475
81460
  }
81476
- await installPackages(["@cloudflare/workers-types"], {
81477
- dev: true,
81478
- startText: "Installing @cloudflare/workers-types",
81479
- doneText: `${brandColor("installed")} ${dim(`via ${npm25}`)}`
81461
+ const packageManifest = readJSON(packageJsonPath);
81462
+ if (!packageManifest.scripts?.["cf-typegen"]) {
81463
+ return;
81464
+ }
81465
+ const typesCmd = [npm25, "run", "cf-typegen"];
81466
+ await runCommand(typesCmd, {
81467
+ cwd: ctx.project.path,
81468
+ silent: true,
81469
+ startText: "Generating types for your application",
81470
+ doneText: `${brandColor("generated")} ${dim(`to \`${ctx.template.typesPath}\` via \`${typesCmd.join(" ")}\``)}`
81480
81471
  });
81481
- await addWorkersTypesToTsConfig(ctx);
81472
+ if (packageManifest["devDependencies"]?.["@cloudflare/workers-types"]) {
81473
+ delete packageManifest["devDependencies"]?.["@cloudflare/workers-types"];
81474
+ writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
81475
+ }
81482
81476
  }
81483
- async function addWorkersTypesToTsConfig(ctx) {
81477
+ var maybeInstallNodeTypes = async (ctx, npm25) => {
81478
+ let parsedConfig = {};
81479
+ if (wranglerJsonExists(ctx)) {
81480
+ const wranglerJsonStr = readWranglerJson(ctx);
81481
+ parsedConfig = parse4(wranglerJsonStr, void 0, {
81482
+ allowTrailingComma: true
81483
+ });
81484
+ } else if (wranglerTomlExists(ctx)) {
81485
+ const wranglerTomlStr = readWranglerToml(ctx);
81486
+ parsedConfig = import_toml4.default.parse(wranglerTomlStr);
81487
+ }
81488
+ const compatibilityFlags = Array.isArray(parsedConfig["compatibility_flags"]) ? parsedConfig["compatibility_flags"] : [];
81489
+ if (compatibilityFlags.includes("nodejs_compat") || compatibilityFlags.includes("nodejs_compat_v2")) {
81490
+ await installPackages(["@types/node"], {
81491
+ dev: true,
81492
+ startText: "Installing @types/node",
81493
+ doneText: `${brandColor("installed")} ${dim(`via ${npm25}`)}`
81494
+ });
81495
+ return true;
81496
+ }
81497
+ return false;
81498
+ };
81499
+ async function updateTsConfig(ctx, { usesNodeCompat }) {
81484
81500
  const tsconfigPath = (0, import_path16.join)(ctx.project.path, "tsconfig.json");
81485
81501
  if (!(0, import_fs13.existsSync)(tsconfigPath)) {
81486
81502
  return;
81487
81503
  }
81488
- const s = spinner();
81489
- s.start("Adding latest types to `tsconfig.json`");
81490
81504
  const tsconfig = readFile(tsconfigPath);
81491
- const entrypointVersion = getLatestTypesEntrypoint(ctx);
81492
- if (entrypointVersion === null) {
81493
- s.stop(
81494
- `${brandColor(
81495
- "skipped"
81496
- )} couldn't find latest compatible version of @cloudflare/workers-types`
81497
- );
81498
- return;
81499
- }
81500
- const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
81501
81505
  try {
81502
81506
  const config48 = parse4(tsconfig);
81503
81507
  const currentTypes = config48.compilerOptions?.types ?? [];
81504
- const explicitEntrypoint = currentTypes.some(
81505
- (t2) => t2.match(/@cloudflare\/workers-types\/\d{4}-\d{2}-\d{2}/)
81506
- );
81507
- const newTypes = explicitEntrypoint ? [...currentTypes] : [
81508
- ...currentTypes.filter(
81509
- (t2) => t2 !== "@cloudflare/workers-types"
81510
- ),
81511
- typesEntrypoint
81512
- ];
81508
+ let newTypes = [...currentTypes];
81509
+ if (ctx.template.workersTypes === "installed") {
81510
+ const entrypointVersion = getLatestTypesEntrypoint(ctx);
81511
+ if (entrypointVersion === null) {
81512
+ return;
81513
+ }
81514
+ const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
81515
+ const explicitEntrypoint = currentTypes.some(
81516
+ (t2) => t2.match(/@cloudflare\/workers-types\/\d{4}-\d{2}-\d{2}/)
81517
+ );
81518
+ if (!explicitEntrypoint) {
81519
+ newTypes = newTypes.filter(
81520
+ (t2) => t2 !== "@cloudflare/workers-types"
81521
+ );
81522
+ newTypes.push(typesEntrypoint);
81523
+ }
81524
+ } else if (ctx.template.workersTypes === "generated") {
81525
+ newTypes.push(ctx.template.typesPath ?? "./worker-configuration.d.ts");
81526
+ const typegen = readFile(
81527
+ ctx.template.typesPath ?? "./worker-configuration.d.ts"
81528
+ ).split("\n");
81529
+ if (typegen.some(
81530
+ (line) => line.includes("// Runtime types generated with workerd")
81531
+ )) {
81532
+ newTypes = newTypes.filter(
81533
+ (t2) => !t2.startsWith("@cloudflare/workers-types")
81534
+ );
81535
+ }
81536
+ }
81537
+ if (usesNodeCompat) {
81538
+ newTypes.push("node");
81539
+ }
81540
+ if (newTypes.sort() === currentTypes.sort()) {
81541
+ return;
81542
+ }
81513
81543
  const useSpaces = !tsconfig.match(/\t/g);
81514
81544
  const edits = modify(
81515
81545
  tsconfig,
@@ -81522,11 +81552,15 @@ async function addWorkersTypesToTsConfig(ctx) {
81522
81552
  const updated = applyEdits(tsconfig, edits);
81523
81553
  writeFile2(tsconfigPath, updated);
81524
81554
  } catch (error2) {
81525
- warn(
81526
- "Failed to update `tsconfig.json` with latest `@cloudflare/workers-types` entrypoint."
81527
- );
81555
+ warn("Failed to update `tsconfig.json`.");
81528
81556
  }
81529
- s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
81557
+ }
81558
+ async function installWorkersTypes(npm25) {
81559
+ await installPackages(["@cloudflare/workers-types"], {
81560
+ dev: true,
81561
+ startText: "Installing @cloudflare/workers-types",
81562
+ doneText: `${brandColor("installed")} ${dim(`via ${npm25}`)}`
81563
+ });
81530
81564
  }
81531
81565
 
81532
81566
  // src/cli.ts
@@ -81606,7 +81640,6 @@ var create = async (ctx) => {
81606
81640
  var configure20 = async (ctx) => {
81607
81641
  startSection("Configuring your application for Cloudflare", "Step 2 of 3");
81608
81642
  await installWrangler();
81609
- await installWorkersTypes(ctx);
81610
81643
  await updateWranglerConfig(ctx);
81611
81644
  const { template } = ctx;
81612
81645
  if (template.configure) {
@@ -81614,6 +81647,7 @@ var configure20 = async (ctx) => {
81614
81647
  }
81615
81648
  addWranglerToGitIgnore(ctx);
81616
81649
  await updatePackageScripts(ctx);
81650
+ await addTypes(ctx);
81617
81651
  await offerGit(ctx);
81618
81652
  await gitCommit(ctx);
81619
81653
  endSection(`Application configured`);