create-cloudflare 2.35.0 → 2.35.2

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 (24) hide show
  1. package/dist/cli.js +49 -68
  2. package/package.json +4 -4
  3. package/templates/astro/c3.ts +17 -33
  4. package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
  5. package/templates/astro/templates/ts/wrangler.toml +86 -0
  6. package/templates/next/c3.ts +1 -1
  7. package/templates/nuxt/c3.ts +1 -1
  8. package/templates/solid/c3.ts +1 -1
  9. package/templates-experimental/astro/c3.ts +17 -33
  10. package/templates-experimental/astro/templates/ts/public/.assetsignore +4 -0
  11. package/templates-experimental/astro/templates/ts/worker-configuration.d.ts +4 -0
  12. package/templates-experimental/astro/templates/ts/wrangler.toml +12 -0
  13. package/templates-experimental/next/c3.ts +7 -4
  14. package/templates-experimental/next/templates/.dev.vars +2 -0
  15. package/templates-experimental/next/templates/__dot__gitignore +2 -5
  16. package/templates-experimental/next/templates/open-next.config.ts +28 -0
  17. package/templates-experimental/next/templates/wrangler.toml +2 -2
  18. package/templates-experimental/nuxt/c3.ts +1 -1
  19. package/templates-experimental/solid/c3.ts +1 -1
  20. /package/templates/astro/templates/{wrangler.toml → js/wrangler.toml} +0 -0
  21. /package/templates/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  22. /package/templates-experimental/astro/templates/{public → js/public}/.assetsignore +0 -0
  23. /package/templates-experimental/astro/templates/{wrangler.toml → js/wrangler.toml} +0 -0
  24. /package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
package/dist/cli.js CHANGED
@@ -73725,7 +73725,7 @@ var Yargs = YargsFactory(esm_default);
73725
73725
  var yargs_default = Yargs;
73726
73726
 
73727
73727
  // package.json
73728
- var version = "2.35.0";
73728
+ var version = "2.35.2";
73729
73729
 
73730
73730
  // src/metrics.ts
73731
73731
  var import_node_async_hooks = require("node:async_hooks");
@@ -74489,18 +74489,18 @@ var package_default = {
74489
74489
  dependencies: {
74490
74490
  "create-astro": "4.11.0",
74491
74491
  "create-analog": "1.8.1",
74492
- "@angular/create": "19.0.4",
74493
- "create-docusaurus": "3.6.3",
74492
+ "@angular/create": "19.0.6",
74493
+ "create-docusaurus": "3.7.0",
74494
74494
  "create-hono": "0.14.3",
74495
- "create-next-app": "15.0.3",
74496
- "create-qwik": "1.11.0",
74497
- "create-vite": "6.0.1",
74498
- "create-remix": "2.15.1",
74495
+ "create-next-app": "15.1.3",
74496
+ "create-qwik": "1.12.0",
74497
+ "create-vite": "6.1.1",
74498
+ "create-remix": "2.15.2",
74499
74499
  "create-solid": "0.5.14",
74500
- "create-vue": "3.12.2",
74501
- gatsby: "5.14.0",
74502
- sv: "0.6.7",
74503
- nuxi: "3.16.0"
74500
+ "create-vue": "3.13.0",
74501
+ gatsby: "5.14.1",
74502
+ sv: "0.6.10",
74503
+ nuxi: "3.17.2"
74504
74504
  }
74505
74505
  };
74506
74506
 
@@ -74697,7 +74697,7 @@ var generate2 = async (ctx) => {
74697
74697
  await runFrameworkGenerator(ctx, [ctx.project.name, "--no-install"]);
74698
74698
  logRaw("");
74699
74699
  };
74700
- var configure2 = async (ctx) => {
74700
+ var configure2 = async () => {
74701
74701
  await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
74702
74702
  silent: true,
74703
74703
  startText: "Installing adapter",
@@ -74706,7 +74706,6 @@ var configure2 = async (ctx) => {
74706
74706
  )}`
74707
74707
  });
74708
74708
  updateAstroConfig();
74709
- updateEnvDeclaration(ctx);
74710
74709
  };
74711
74710
  var updateAstroConfig = () => {
74712
74711
  const filePath = "astro.config.mjs";
@@ -74732,26 +74731,6 @@ var updateAstroConfig = () => {
74732
74731
  }
74733
74732
  });
74734
74733
  };
74735
- var updateEnvDeclaration = (ctx) => {
74736
- if (!usesTypescript(ctx)) {
74737
- return;
74738
- }
74739
- const filePath = "src/env.d.ts";
74740
- updateStatus(`Adding type declarations in ${blue(filePath)}`);
74741
- transformFile(filePath, {
74742
- visitProgram: function(n2) {
74743
- const snippets = loadTemplateSnippets(ctx);
74744
- const patch = snippets.runtimeDeclarationTs;
74745
- const b2 = recast2.types.builders;
74746
- const comments = n2.get("comments").value;
74747
- n2.node.comments = comments.map(
74748
- (c2) => b2.commentLine(c2.value)
74749
- );
74750
- n2.get("body").push(...patch);
74751
- return false;
74752
- }
74753
- });
74754
- };
74755
74734
  var config2 = {
74756
74735
  configVersion: 1,
74757
74736
  id: "astro",
@@ -74759,7 +74738,17 @@ var config2 = {
74759
74738
  platform: "workers",
74760
74739
  displayName: "Astro",
74761
74740
  copyFiles: {
74762
- path: "./templates"
74741
+ async selectVariant(ctx) {
74742
+ return usesTypescript(ctx) ? "ts" : "js";
74743
+ },
74744
+ variants: {
74745
+ js: {
74746
+ path: "./templates/js"
74747
+ },
74748
+ ts: {
74749
+ path: "./templates/ts"
74750
+ }
74751
+ }
74763
74752
  },
74764
74753
  devScript: "dev",
74765
74754
  deployScript: "deploy",
@@ -74956,7 +74945,10 @@ var generate6 = async (ctx) => {
74956
74945
  ]);
74957
74946
  };
74958
74947
  var configure3 = async () => {
74959
- const packages = ["@opennextjs/cloudflare", "@cloudflare/workers-types"];
74948
+ const packages = [
74949
+ "@opennextjs/cloudflare@0.3.x",
74950
+ "@cloudflare/workers-types"
74951
+ ];
74960
74952
  await installPackages(packages, {
74961
74953
  dev: true,
74962
74954
  startText: "Adding the Cloudflare adapter",
@@ -74972,7 +74964,7 @@ var c3_default9 = {
74972
74964
  // is not yet fully ready for Next.js 15, once it is we should remove the following
74973
74965
  frameworkCliPinnedVersion: "14.2.5",
74974
74966
  platform: "workers",
74975
- displayName: "Next (using Node.js compat + Workers Assets)",
74967
+ displayName: "Next.js (using Node.js compat + Workers Assets)",
74976
74968
  path: "templates-experimental/next",
74977
74969
  copyFiles: {
74978
74970
  path: "./templates"
@@ -74981,8 +74973,8 @@ var c3_default9 = {
74981
74973
  configure: configure3,
74982
74974
  transformPackageJson: async () => ({
74983
74975
  scripts: {
74984
- deploy: `cloudflare && wrangler deploy`,
74985
- preview: `cloudflare && wrangler dev`,
74976
+ deploy: `opennextjs-cloudflare && wrangler deploy`,
74977
+ preview: `opennextjs-cloudflare && wrangler dev`,
74986
74978
  "cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`
74987
74979
  }
74988
74980
  }),
@@ -75002,7 +74994,7 @@ async function getWorkerdCompatibilityDate() {
75002
74994
  const latestWorkerdVersion = await getLatestPackageVersion("workerd");
75003
74995
  const match = latestWorkerdVersion.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/);
75004
74996
  if (match) {
75005
- const [, year, month, date] = match ?? [];
74997
+ const [, year, month, date] = match;
75006
74998
  const compatDate = `${year}-${month}-${date}`;
75007
74999
  s.stop(`${brandColor("compatibility date")} ${dim(compatDate)}`);
75008
75000
  return compatDate;
@@ -75052,7 +75044,7 @@ var generate7 = async (ctx) => {
75052
75044
  npm4,
75053
75045
  gitFlag
75054
75046
  ]);
75055
- writeFile2("./.node-version", "17");
75047
+ writeFile2("./.node-version", "18");
75056
75048
  logRaw("");
75057
75049
  };
75058
75050
  var configure4 = async (ctx) => {
@@ -75344,7 +75336,7 @@ var config11 = {
75344
75336
  configVersion: 1,
75345
75337
  id: "solid",
75346
75338
  frameworkCli: "create-solid",
75347
- displayName: "Solid",
75339
+ displayName: "SolidStart",
75348
75340
  platform: "workers",
75349
75341
  copyFiles: {
75350
75342
  path: "./templates"
@@ -75689,7 +75681,7 @@ var generate15 = async (ctx) => {
75689
75681
  await runFrameworkGenerator(ctx, [ctx.project.name, "--no-install"]);
75690
75682
  logRaw("");
75691
75683
  };
75692
- var configure11 = async (ctx) => {
75684
+ var configure11 = async () => {
75693
75685
  await runCommand([npx3, "astro", "add", "cloudflare", "-y"], {
75694
75686
  silent: true,
75695
75687
  startText: "Installing adapter",
@@ -75698,7 +75690,6 @@ var configure11 = async (ctx) => {
75698
75690
  )}`
75699
75691
  });
75700
75692
  updateAstroConfig2();
75701
- updateEnvDeclaration2(ctx);
75702
75693
  };
75703
75694
  var updateAstroConfig2 = () => {
75704
75695
  const filePath = "astro.config.mjs";
@@ -75724,26 +75715,6 @@ var updateAstroConfig2 = () => {
75724
75715
  }
75725
75716
  });
75726
75717
  };
75727
- var updateEnvDeclaration2 = (ctx) => {
75728
- if (!usesTypescript(ctx)) {
75729
- return;
75730
- }
75731
- const filePath = "src/env.d.ts";
75732
- updateStatus(`Adding type declarations in ${blue(filePath)}`);
75733
- transformFile(filePath, {
75734
- visitProgram: function(n2) {
75735
- const snippets = loadTemplateSnippets(ctx);
75736
- const patch = snippets.runtimeDeclarationTs;
75737
- const b2 = recast8.types.builders;
75738
- const comments = n2.get("comments").value;
75739
- n2.node.comments = comments.map(
75740
- (c2) => b2.commentLine(c2.value)
75741
- );
75742
- n2.get("body").push(...patch);
75743
- return false;
75744
- }
75745
- });
75746
- };
75747
75718
  var config16 = {
75748
75719
  configVersion: 1,
75749
75720
  id: "astro",
@@ -75751,7 +75722,17 @@ var config16 = {
75751
75722
  platform: "pages",
75752
75723
  displayName: "Astro",
75753
75724
  copyFiles: {
75754
- path: "./templates"
75725
+ async selectVariant(ctx) {
75726
+ return usesTypescript(ctx) ? "ts" : "js";
75727
+ },
75728
+ variants: {
75729
+ js: {
75730
+ path: "./templates/js"
75731
+ },
75732
+ ts: {
75733
+ path: "./templates/ts"
75734
+ }
75735
+ }
75755
75736
  },
75756
75737
  devScript: "dev",
75757
75738
  deployScript: "deploy",
@@ -76059,7 +76040,7 @@ var c3_default25 = {
76059
76040
  id: "next",
76060
76041
  frameworkCli: "create-next-app",
76061
76042
  platform: "pages",
76062
- displayName: "Next",
76043
+ displayName: "Next.js",
76063
76044
  generate: generate19,
76064
76045
  configure: configure13,
76065
76046
  copyFiles: {
@@ -76128,7 +76109,7 @@ var generate20 = async (ctx) => {
76128
76109
  npm15,
76129
76110
  gitFlag
76130
76111
  ]);
76131
- writeFile2("./.node-version", "17");
76112
+ writeFile2("./.node-version", "18");
76132
76113
  logRaw("");
76133
76114
  };
76134
76115
  var configure14 = async (ctx) => {
@@ -76705,7 +76686,7 @@ var config24 = {
76705
76686
  configVersion: 1,
76706
76687
  id: "solid",
76707
76688
  frameworkCli: "create-solid",
76708
- displayName: "Solid",
76689
+ displayName: "SolidStart",
76709
76690
  platform: "pages",
76710
76691
  copyFiles: {
76711
76692
  path: "./templates"
@@ -76872,7 +76853,7 @@ var config26 = {
76872
76853
  var c3_default36 = config26;
76873
76854
 
76874
76855
  // ../wrangler/package.json
76875
- var version2 = "3.96.0";
76856
+ var version2 = "3.100.0";
76876
76857
 
76877
76858
  // src/git.ts
76878
76859
  var offerGit = async (ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.35.0",
3
+ "version": "2.35.2",
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.20241205.0",
33
+ "@cloudflare/workers-types": "^4.20241230.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",
71
70
  "@cloudflare/eslint-config-worker": "1.1.0",
72
- "wrangler": "3.96.0"
71
+ "@cloudflare/workers-tsconfig": "0.0.0",
72
+ "wrangler": "3.100.0"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=18.14.1"
@@ -1,7 +1,7 @@
1
1
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
2
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { runFrameworkGenerator } from "frameworks/index";
4
- import { loadTemplateSnippets, transformFile } from "helpers/codemod";
4
+ import { transformFile } from "helpers/codemod";
5
5
  import { runCommand } from "helpers/command";
6
6
  import { usesTypescript } from "helpers/files";
7
7
  import { detectPackageManager } from "helpers/packageManagers";
@@ -17,7 +17,7 @@ const generate = async (ctx: C3Context) => {
17
17
  logRaw(""); // newline
18
18
  };
19
19
 
20
- const configure = async (ctx: C3Context) => {
20
+ const configure = async () => {
21
21
  await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
22
22
  silent: true,
23
23
  startText: "Installing adapter",
@@ -27,7 +27,6 @@ const configure = async (ctx: C3Context) => {
27
27
  });
28
28
 
29
29
  updateAstroConfig();
30
- updateEnvDeclaration(ctx);
31
30
  };
32
31
 
33
32
  const updateAstroConfig = () => {
@@ -59,35 +58,6 @@ const updateAstroConfig = () => {
59
58
  });
60
59
  };
61
60
 
62
- const updateEnvDeclaration = (ctx: C3Context) => {
63
- if (!usesTypescript(ctx)) {
64
- return;
65
- }
66
-
67
- const filePath = "src/env.d.ts";
68
-
69
- updateStatus(`Adding type declarations in ${blue(filePath)}`);
70
-
71
- transformFile(filePath, {
72
- visitProgram: function (n) {
73
- const snippets = loadTemplateSnippets(ctx);
74
- const patch = snippets.runtimeDeclarationTs;
75
- const b = recast.types.builders;
76
-
77
- // Preserve comments with the new body
78
- const comments = n.get("comments").value;
79
- n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
80
- b.commentLine(c.value),
81
- );
82
-
83
- // Add the patch
84
- n.get("body").push(...patch);
85
-
86
- return false;
87
- },
88
- });
89
- };
90
-
91
61
  const config: TemplateConfig = {
92
62
  configVersion: 1,
93
63
  id: "astro",
@@ -95,7 +65,21 @@ const config: TemplateConfig = {
95
65
  platform: "pages",
96
66
  displayName: "Astro",
97
67
  copyFiles: {
98
- path: "./templates",
68
+ async selectVariant(ctx) {
69
+ // Note: this `selectVariant` function should not be needed
70
+ // this is just a quick workaround until
71
+ // https://github.com/cloudflare/workers-sdk/issues/7495
72
+ // is resolved
73
+ return usesTypescript(ctx) ? "ts" : "js";
74
+ },
75
+ variants: {
76
+ js: {
77
+ path: "./templates/js",
78
+ },
79
+ ts: {
80
+ path: "./templates/ts",
81
+ },
82
+ },
99
83
  },
100
84
  devScript: "dev",
101
85
  deployScript: "deploy",
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ }
@@ -0,0 +1,86 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+ compatibility_flags = ["nodejs_compat"]
5
+ pages_build_output_dir = "./dist"
6
+
7
+ # Automatically place your workloads in an optimal location to minimize latency.
8
+ # If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
9
+ # rather than the end user may result in better performance.
10
+ # Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
11
+ # [placement]
12
+ # mode = "smart"
13
+
14
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
15
+ # Docs:
16
+ # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
17
+ # Note: Use secrets to store sensitive data.
18
+ # - https://developers.cloudflare.com/pages/functions/bindings/#secrets
19
+ # [vars]
20
+ # MY_VARIABLE = "production_value"
21
+
22
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
23
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
24
+ # [ai]
25
+ # binding = "AI"
26
+
27
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
28
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
29
+ # [[d1_databases]]
30
+ # binding = "MY_DB"
31
+ # database_name = "my-database"
32
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
33
+
34
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
35
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
36
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
37
+ # [[durable_objects.bindings]]
38
+ # name = "MY_DURABLE_OBJECT"
39
+ # class_name = "MyDurableObject"
40
+ # script_name = 'my-durable-object'
41
+
42
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
43
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
44
+ # [[kv_namespaces]]
45
+ # binding = "MY_KV_NAMESPACE"
46
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
47
+
48
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
49
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
50
+ # [[queues.producers]]
51
+ # binding = "MY_QUEUE"
52
+ # queue = "my-queue"
53
+
54
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
55
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
56
+ # [[r2_buckets]]
57
+ # binding = "MY_BUCKET"
58
+ # bucket_name = "my-bucket"
59
+
60
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
61
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
62
+ # [[services]]
63
+ # binding = "MY_SERVICE"
64
+ # service = "my-service"
65
+
66
+ # To use different bindings for preview and production environments, follow the examples below.
67
+ # When using environment-specific overrides for bindings, ALL bindings must be specified on a per-environment basis.
68
+ # Docs: https://developers.cloudflare.com/pages/functions/wrangler-configuration#environment-specific-overrides
69
+
70
+ ######## PREVIEW environment config ########
71
+
72
+ # [env.preview.vars]
73
+ # API_KEY = "xyz789"
74
+
75
+ # [[env.preview.kv_namespaces]]
76
+ # binding = "MY_KV_NAMESPACE"
77
+ # id = "<PREVIEW_NAMESPACE_ID>"
78
+
79
+ ######## PRODUCTION environment config ########
80
+
81
+ # [env.production.vars]
82
+ # API_KEY = "abc123"
83
+
84
+ # [[env.production.kv_namespaces]]
85
+ # binding = "MY_KV_NAMESPACE"
86
+ # id = "<PRODUCTION_NAMESPACE_ID>"
@@ -176,7 +176,7 @@ export default {
176
176
  id: "next",
177
177
  frameworkCli: "create-next-app",
178
178
  platform: "pages",
179
- displayName: "Next",
179
+ displayName: "Next.js",
180
180
  generate,
181
181
  configure,
182
182
  copyFiles: {
@@ -24,7 +24,7 @@ const generate = async (ctx: C3Context) => {
24
24
  gitFlag,
25
25
  ]);
26
26
 
27
- writeFile("./.node-version", "17");
27
+ writeFile("./.node-version", "18");
28
28
 
29
29
  logRaw(""); // newline
30
30
  };
@@ -66,7 +66,7 @@ const config: TemplateConfig = {
66
66
  configVersion: 1,
67
67
  id: "solid",
68
68
  frameworkCli: "create-solid",
69
- displayName: "Solid",
69
+ displayName: "SolidStart",
70
70
  platform: "pages",
71
71
  copyFiles: {
72
72
  path: "./templates",
@@ -1,7 +1,7 @@
1
1
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
2
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { runFrameworkGenerator } from "frameworks/index";
4
- import { loadTemplateSnippets, transformFile } from "helpers/codemod";
4
+ import { transformFile } from "helpers/codemod";
5
5
  import { runCommand } from "helpers/command";
6
6
  import { usesTypescript } from "helpers/files";
7
7
  import { detectPackageManager } from "helpers/packageManagers";
@@ -17,7 +17,7 @@ const generate = async (ctx: C3Context) => {
17
17
  logRaw(""); // newline
18
18
  };
19
19
 
20
- const configure = async (ctx: C3Context) => {
20
+ const configure = async () => {
21
21
  await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
22
22
  silent: true,
23
23
  startText: "Installing adapter",
@@ -27,7 +27,6 @@ const configure = async (ctx: C3Context) => {
27
27
  });
28
28
 
29
29
  updateAstroConfig();
30
- updateEnvDeclaration(ctx);
31
30
  };
32
31
 
33
32
  const updateAstroConfig = () => {
@@ -59,35 +58,6 @@ const updateAstroConfig = () => {
59
58
  });
60
59
  };
61
60
 
62
- const updateEnvDeclaration = (ctx: C3Context) => {
63
- if (!usesTypescript(ctx)) {
64
- return;
65
- }
66
-
67
- const filePath = "src/env.d.ts";
68
-
69
- updateStatus(`Adding type declarations in ${blue(filePath)}`);
70
-
71
- transformFile(filePath, {
72
- visitProgram: function (n) {
73
- const snippets = loadTemplateSnippets(ctx);
74
- const patch = snippets.runtimeDeclarationTs;
75
- const b = recast.types.builders;
76
-
77
- // Preserve comments with the new body
78
- const comments = n.get("comments").value;
79
- n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
80
- b.commentLine(c.value),
81
- );
82
-
83
- // Add the patch
84
- n.get("body").push(...patch);
85
-
86
- return false;
87
- },
88
- });
89
- };
90
-
91
61
  const config: TemplateConfig = {
92
62
  configVersion: 1,
93
63
  id: "astro",
@@ -95,7 +65,21 @@ const config: TemplateConfig = {
95
65
  platform: "workers",
96
66
  displayName: "Astro",
97
67
  copyFiles: {
98
- path: "./templates",
68
+ async selectVariant(ctx) {
69
+ // Note: this `selectVariant` function should not be needed
70
+ // this is just a quick workaround until
71
+ // https://github.com/cloudflare/workers-sdk/issues/7495
72
+ // is resolved
73
+ return usesTypescript(ctx) ? "ts" : "js";
74
+ },
75
+ variants: {
76
+ js: {
77
+ path: "./templates/js",
78
+ },
79
+ ts: {
80
+ path: "./templates/ts",
81
+ },
82
+ },
99
83
  },
100
84
  devScript: "dev",
101
85
  deployScript: "deploy",
@@ -0,0 +1,4 @@
1
+ _worker.js
2
+ _routes.json
3
+ _headers
4
+ _redirects
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ }
@@ -0,0 +1,12 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+ compatibility_flags = ["nodejs_compat"]
5
+ main = "./dist/_worker.js/index.js"
6
+ assets = { directory = "./dist", binding = "ASSETS" }
7
+
8
+ # Workers Logs
9
+ # Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
10
+ # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
11
+ [observability]
12
+ enabled = true
@@ -18,7 +18,10 @@ const generate = async (ctx: C3Context) => {
18
18
  };
19
19
 
20
20
  const configure = async () => {
21
- const packages = ["@opennextjs/cloudflare", "@cloudflare/workers-types"];
21
+ const packages = [
22
+ "@opennextjs/cloudflare@0.3.x",
23
+ "@cloudflare/workers-types",
24
+ ];
22
25
  await installPackages(packages, {
23
26
  dev: true,
24
27
  startText: "Adding the Cloudflare adapter",
@@ -35,7 +38,7 @@ export default {
35
38
  // is not yet fully ready for Next.js 15, once it is we should remove the following
36
39
  frameworkCliPinnedVersion: "14.2.5",
37
40
  platform: "workers",
38
- displayName: "Next (using Node.js compat + Workers Assets)",
41
+ displayName: "Next.js (using Node.js compat + Workers Assets)",
39
42
  path: "templates-experimental/next",
40
43
  copyFiles: {
41
44
  path: "./templates",
@@ -44,8 +47,8 @@ export default {
44
47
  configure,
45
48
  transformPackageJson: async () => ({
46
49
  scripts: {
47
- deploy: `cloudflare && wrangler deploy`,
48
- preview: `cloudflare && wrangler dev`,
50
+ deploy: `opennextjs-cloudflare && wrangler deploy`,
51
+ preview: `opennextjs-cloudflare && wrangler dev`,
49
52
  "cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`,
50
53
  },
51
54
  }),
@@ -0,0 +1,2 @@
1
+ # Load .env.development* files when running `wrangler dev`
2
+ NEXTJS_ENV=development
@@ -35,8 +35,5 @@ yarn-error.log*
35
35
  *.tsbuildinfo
36
36
  next-env.d.ts
37
37
 
38
-
39
- # Cloudflare related
40
- /.save.next
41
- /.worker-next
42
- /.wrangler
38
+ # OpenNext
39
+ /.open-next
@@ -0,0 +1,28 @@
1
+ import cache from "@opennextjs/cloudflare/kvCache";
2
+
3
+ const config = {
4
+ default: {
5
+ override: {
6
+ wrapper: "cloudflare-node",
7
+ converter: "edge",
8
+ incrementalCache: async () => cache,
9
+ tagCache: "dummy",
10
+ queue: "dummy",
11
+ },
12
+ },
13
+
14
+ middleware: {
15
+ external: true,
16
+ override: {
17
+ wrapper: "cloudflare-edge",
18
+ converter: "edge",
19
+ proxyExternalRequest: "fetch",
20
+ },
21
+ },
22
+
23
+ dangerous: {
24
+ enableCacheInterception: false,
25
+ },
26
+ };
27
+
28
+ export default config;
@@ -1,6 +1,6 @@
1
1
  #:schema node_modules/wrangler/config-schema.json
2
2
  name = "<app-name>"
3
- main = ".worker-next/index.mjs"
3
+ main = ".open-next/worker.js"
4
4
 
5
5
  compatibility_date = "2024-09-26"
6
6
  compatibility_flags = ["nodejs_compat"]
@@ -9,4 +9,4 @@ compatibility_flags = ["nodejs_compat"]
9
9
  minify = true
10
10
 
11
11
  # Use the new Workers + Assets to host the static frontend files
12
- assets = { directory = ".worker-next/assets", binding = "ASSETS" }
12
+ assets = { directory = ".open-next/assets", binding = "ASSETS" }
@@ -24,7 +24,7 @@ const generate = async (ctx: C3Context) => {
24
24
  gitFlag,
25
25
  ]);
26
26
 
27
- writeFile("./.node-version", "17");
27
+ writeFile("./.node-version", "18");
28
28
 
29
29
  logRaw(""); // newline
30
30
  };
@@ -72,7 +72,7 @@ const config: TemplateConfig = {
72
72
  configVersion: 1,
73
73
  id: "solid",
74
74
  frameworkCli: "create-solid",
75
- displayName: "Solid",
75
+ displayName: "SolidStart",
76
76
  platform: "workers",
77
77
  copyFiles: {
78
78
  path: "./templates",