create-cloudflare 2.71.0 → 2.72.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.71.0",
3
+ "version": "2.72.0",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -31,7 +31,7 @@
31
31
  "@babel/parser": "^7.21.3",
32
32
  "@babel/types": "^7.21.4",
33
33
  "@clack/prompts": "^1.2.0",
34
- "@cloudflare/workers-types": "^5.20260804.1",
34
+ "@cloudflare/workers-types": "^5.20260811.1",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
37
37
  "@types/deepmerge": "^2.2.0",
@@ -71,13 +71,13 @@
71
71
  "which-pm-runs": "^1.1.0",
72
72
  "wrap-ansi": "^9.0.0",
73
73
  "yargs": "^17.7.2",
74
- "@cloudflare/cli-shared-helpers": "0.1.22",
75
- "@cloudflare/codemod": "1.1.0",
74
+ "@cloudflare/cli-shared-helpers": "0.1.23",
76
75
  "@cloudflare/mock-npm-registry": "0.0.0",
77
- "@cloudflare/vite-plugin": "1.51.3",
76
+ "@cloudflare/codemod": "1.1.0",
77
+ "@cloudflare/vite-plugin": "1.52.1",
78
78
  "@cloudflare/workers-tsconfig": "0.0.0",
79
- "@cloudflare/workers-utils": "0.32.0",
80
- "wrangler": "4.121.0"
79
+ "@cloudflare/workers-utils": "0.33.0",
80
+ "wrangler": "4.123.0"
81
81
  },
82
82
  "engines": {
83
83
  "node": ">=22.0.0"
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "name": "<WORKER_NAME>",
3
3
  "compatibility_date": "<COMPATIBILITY_DATE>",
4
- "compatibility_flags": [
5
- "nodejs_compat"
6
- ],
7
4
  "pages_build_output_dir": "./dist"
8
5
  }
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "name": "<WORKER_NAME>",
3
3
  "compatibility_date": "<COMPATIBILITY_DATE>",
4
- "compatibility_flags": [
5
- "nodejs_compat"
6
- ],
7
4
  "pages_build_output_dir": "./dist"
8
5
  }
@@ -11,6 +11,6 @@
11
11
  "devDependencies": {
12
12
  "@cloudflare/vitest-pool-workers": "^0.12.4",
13
13
  "vitest": "~3.2.0",
14
- "wrangler": "^3.101.0"
14
+ "wrangler": "^4"
15
15
  }
16
16
  }
@@ -13,6 +13,6 @@
13
13
  "@cloudflare/vitest-pool-workers": "^0.12.4",
14
14
  "typescript": "^5.5.2",
15
15
  "vitest": "~3.2.0",
16
- "wrangler": "^3.101.0"
16
+ "wrangler": "^4"
17
17
  }
18
18
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@cloudflare/vitest-pool-workers": "^0.12.4",
13
- "wrangler": "^3.101.0",
13
+ "wrangler": "^4",
14
14
  "vitest": "~3.2.0"
15
15
  }
16
16
  }
@@ -3,7 +3,6 @@
3
3
  "main": "src/index.js",
4
4
  "compatibility_date": "<COMPATIBILITY_DATE>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat",
7
6
  "global_fetch_strictly_public"
8
7
  ],
9
8
  "assets": {
@@ -13,6 +13,6 @@
13
13
  "@cloudflare/vitest-pool-workers": "^0.12.4",
14
14
  "typescript": "^5.5.2",
15
15
  "vitest": "~3.2.0",
16
- "wrangler": "^3.101.0"
16
+ "wrangler": "^4"
17
17
  }
18
18
  }
@@ -1,8 +1,96 @@
1
+ import assert from "node:assert";
2
+ import { logRaw } from "@cloudflare/cli-shared-helpers";
3
+ import { inputPrompt } from "@cloudflare/cli-shared-helpers/interactive";
4
+ import { runFrameworkGenerator } from "frameworks/index";
5
+ import { detectPackageManager } from "helpers/packageManagers";
1
6
  import { downloadRemoteTemplate, updatePackageName } from "../../src/templates";
2
7
  import type { TemplateConfig } from "../../src/templates";
3
8
  import type { C3Context } from "types";
4
9
 
5
- const generate = async (ctx: C3Context) => {
10
+ const { npm } = detectPackageManager();
11
+
12
+ type NextVariantValue = "vinext" | "opennext";
13
+
14
+ const VINEXT_TYPES_PATH = "./worker-configuration.d.ts";
15
+ const OPENNEXT_TYPES_PATH = "./cloudflare-env.d.ts";
16
+
17
+ type NextVariant = {
18
+ value: NextVariantValue;
19
+ label: string;
20
+ };
21
+
22
+ const NEXT_VARIANTS: NextVariant[] = [
23
+ {
24
+ value: "vinext",
25
+ label: "vinext (recommended)",
26
+ },
27
+ {
28
+ value: "opennext",
29
+ label: "OpenNext adapter",
30
+ },
31
+ ];
32
+
33
+ async function getNextVariant(ctx: C3Context): Promise<NextVariant> {
34
+ if (ctx.args.variant) {
35
+ const selected = NEXT_VARIANTS.find(
36
+ (variant) => variant.value === ctx.args.variant
37
+ );
38
+ if (!selected) {
39
+ throw new Error(
40
+ `Unknown Next.js variant "${
41
+ ctx.args.variant
42
+ }". Valid variants are: ${NEXT_VARIANTS.map((v) => v.value).join(", ")}`
43
+ );
44
+ }
45
+ return selected;
46
+ }
47
+
48
+ const value = await inputPrompt({
49
+ type: "select",
50
+ question: "Which Next.js adapter do you want to use?",
51
+ label: "variant",
52
+ options: NEXT_VARIANTS,
53
+ defaultValue: NEXT_VARIANTS[0].value,
54
+ // Honour -y / --accept-defaults by taking the recommended vinext path.
55
+ acceptDefault: Boolean(ctx.args.acceptDefaults),
56
+ });
57
+
58
+ const selected = NEXT_VARIANTS.find((variant) => variant.value === value);
59
+ assert(selected, "Expected a Next.js variant to be selected");
60
+ return selected;
61
+ }
62
+
63
+ async function generateVinext(ctx: C3Context) {
64
+ // Delegate to create-vinext-app, which scaffolds a Next.js App Router project
65
+ // already configured for vinext + Cloudflare Workers.
66
+ const pmFlag =
67
+ npm === "pnpm"
68
+ ? "--use-pnpm"
69
+ : npm === "yarn"
70
+ ? "--use-yarn"
71
+ : npm === "bun"
72
+ ? "--use-bun"
73
+ : "--use-npm";
74
+
75
+ await runFrameworkGenerator(ctx, [
76
+ ctx.project.name,
77
+ "--platform",
78
+ "cloudflare",
79
+ // Avoid a placeholder KV namespace id that would block `wrangler deploy`
80
+ // until the user manually provisions one. Caching can be added later
81
+ // via vinext's Cloudflare cache adapters.
82
+ "--data-cache",
83
+ "none",
84
+ "--yes",
85
+ "--skip-install",
86
+ "--disable-git",
87
+ pmFlag,
88
+ ]);
89
+
90
+ logRaw("");
91
+ }
92
+
93
+ async function generateOpenNext(ctx: C3Context) {
6
94
  // Easy way to switch branch for local testing
7
95
  const branch = "main";
8
96
 
@@ -13,20 +101,53 @@ const generate = async (ctx: C3Context) => {
13
101
  });
14
102
 
15
103
  await updatePackageName(ctx);
104
+ }
105
+
106
+ const generate = async (ctx: C3Context) => {
107
+ const variant = await getNextVariant(ctx);
108
+ // Stash on args so transformPackageJson can branch without re-prompting.
109
+ ctx.args.variant = variant.value;
110
+ ctx.template.typesPath =
111
+ variant.value === "opennext" ? OPENNEXT_TYPES_PATH : VINEXT_TYPES_PATH;
112
+
113
+ if (variant.value === "opennext") {
114
+ ctx.template.frameworkCliUsed = false;
115
+ await generateOpenNext(ctx);
116
+ return;
117
+ }
118
+
119
+ await generateVinext(ctx);
16
120
  };
17
121
 
18
122
  const envInterfaceName = "CloudflareEnv";
19
- const typesPath = "./cloudflare-env.d.ts";
123
+
20
124
  export default {
21
125
  configVersion: 1,
22
126
  id: "next",
23
- frameworkCli: "create-next-app",
127
+ // Used by runFrameworkGenerator for the vinext path. OpenNext downloads a
128
+ // remote template and does not invoke this CLI.
129
+ frameworkCli: "create-vinext-app",
24
130
  platform: "workers",
25
131
  displayName: "Next.js",
26
132
  generate,
133
+ transformPackageJson: async (_pkgJson, ctx) => {
134
+ // OpenNext's remote template already has deploy/preview/cf-typegen.
135
+ if (ctx.args.variant === "opennext") {
136
+ return {};
137
+ }
138
+
139
+ return {
140
+ scripts: {
141
+ // Align with OpenNext so the shared previewScript: "preview" works
142
+ // for both variants (vinext only ships dev/build/start/deploy).
143
+ preview: `${npm} run build && ${npm} run start${npm === "npm" ? " --" : ""}`,
144
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${VINEXT_TYPES_PATH}`,
145
+ },
146
+ };
147
+ },
27
148
  devScript: "dev",
28
149
  previewScript: "preview",
29
150
  deployScript: "deploy",
30
- typesPath,
151
+ typesPath: VINEXT_TYPES_PATH,
31
152
  envInterfaceName,
32
153
  } as TemplateConfig;
@@ -3,14 +3,18 @@ import type { TemplateConfig } from "../../src/templates";
3
3
  import type { C3Context } from "types";
4
4
 
5
5
  const generate = async (ctx: C3Context) => {
6
- await runFrameworkGenerator(ctx, [
7
- ctx.project.name,
8
- "--skip-install",
9
- ]);
6
+ if (ctx.args.variant) {
7
+ throw new Error(
8
+ "Next.js adapter variants are not supported with --experimental."
9
+ );
10
+ }
11
+
12
+ await runFrameworkGenerator(ctx, [ctx.project.name, "--skip-install"]);
10
13
  };
11
14
 
12
15
  const envInterfaceName = "CloudflareEnv";
13
16
  const typesPath = "./cloudflare-env.d.ts";
17
+
14
18
  export default {
15
19
  configVersion: 1,
16
20
  id: "next",
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "name": "<WORKER_NAME>",
3
3
  "compatibility_date": "<COMPATIBILITY_DATE>",
4
- "compatibility_flags": [
5
- "nodejs_compat"
6
- ],
7
4
  "pages_build_output_dir": "./dist"
8
5
  }
@@ -3,7 +3,6 @@
3
3
  "main": "./dist/_worker.js",
4
4
  "compatibility_date": "<COMPATIBILITY_DATE>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat",
7
6
  "global_fetch_strictly_public"
8
7
  ],
9
8
  "assets": {
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "name": "<WORKER_NAME>",
3
3
  "compatibility_date": "<COMPATIBILITY_DATE>",
4
- "compatibility_flags": [
5
- "nodejs_compat"
6
- ],
7
4
  "observability": {
8
5
  "enabled": true
9
6
  }