create-cloudflare 2.71.1 → 2.72.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +596 -272
- package/package.json +6 -6
- package/templates/analog/c3.ts +1 -1
- package/templates/hello-world/js/package.json +3 -3
- package/templates/hello-world/js/vitest.config.mjs +10 -0
- package/templates/hello-world/ts/package.json +3 -3
- package/templates/hello-world/ts/test/tsconfig.json +1 -1
- package/templates/hello-world/ts/vitest.config.mts +8 -9
- package/templates/hello-world-with-assets/js/package.json +3 -3
- package/templates/hello-world-with-assets/js/vitest.config.mjs +10 -0
- package/templates/hello-world-with-assets/ts/package.json +3 -3
- package/templates/hello-world-with-assets/ts/test/tsconfig.json +1 -1
- package/templates/hello-world-with-assets/ts/vitest.config.mts +8 -9
- package/templates/next/c3.ts +125 -4
- package/templates/next/experimental_c3.ts +8 -4
- package/templates/hello-world/js/vitest.config.js +0 -11
- package/templates/hello-world/ts/test/env.d.ts +0 -3
- package/templates/hello-world-with-assets/js/vitest.config.js +0 -11
- package/templates/hello-world-with-assets/ts/test/env.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.72.1",
|
|
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.
|
|
34
|
+
"@cloudflare/workers-types": "^5.20260815.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.
|
|
74
|
+
"@cloudflare/cli-shared-helpers": "0.1.24",
|
|
75
75
|
"@cloudflare/codemod": "1.1.0",
|
|
76
76
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
77
|
-
"@cloudflare/vite-plugin": "1.52.0",
|
|
78
77
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
79
|
-
"@cloudflare/workers-utils": "0.33.
|
|
80
|
-
"wrangler": "4.
|
|
78
|
+
"@cloudflare/workers-utils": "0.33.1",
|
|
79
|
+
"wrangler": "4.124.0",
|
|
80
|
+
"@cloudflare/vite-plugin": "1.53.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=22.0.0"
|
package/templates/analog/c3.ts
CHANGED
|
@@ -25,7 +25,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
25
25
|
usesTypescript(ctx);
|
|
26
26
|
const filePath = `vite.config.${usesTypescript(ctx) ? "ts" : "js"}`;
|
|
27
27
|
|
|
28
|
-
const compatDate = getWorkerdCompatibilityDate(
|
|
28
|
+
const compatDate = getWorkerdCompatibilityDate();
|
|
29
29
|
|
|
30
30
|
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
31
31
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"cf-typegen": "wrangler types"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@cloudflare/vitest-pool-workers": "^0.
|
|
13
|
+
"@cloudflare/vitest-pool-workers": "^0.21.0",
|
|
14
14
|
"typescript": "^5.5.2",
|
|
15
|
-
"vitest": "~
|
|
16
|
-
"wrangler": "^
|
|
15
|
+
"vitest": "~4.1.0",
|
|
16
|
+
"wrangler": "^4"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
2
3
|
|
|
3
|
-
export default
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
},
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [
|
|
6
|
+
cloudflareTest({
|
|
7
|
+
wrangler: { configPath: "./wrangler.jsonc" },
|
|
8
|
+
}),
|
|
9
|
+
],
|
|
11
10
|
});
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"cf-typegen": "wrangler types"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@cloudflare/vitest-pool-workers": "^0.
|
|
13
|
+
"@cloudflare/vitest-pool-workers": "^0.21.0",
|
|
14
14
|
"typescript": "^5.5.2",
|
|
15
|
-
"vitest": "~
|
|
16
|
-
"wrangler": "^
|
|
15
|
+
"vitest": "~4.1.0",
|
|
16
|
+
"wrangler": "^4"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
2
3
|
|
|
3
|
-
export default
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
},
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [
|
|
6
|
+
cloudflareTest({
|
|
7
|
+
wrangler: { configPath: "./wrangler.jsonc" },
|
|
8
|
+
}),
|
|
9
|
+
],
|
|
11
10
|
});
|
package/templates/next/c3.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
123
|
+
|
|
20
124
|
export default {
|
|
21
125
|
configVersion: 1,
|
|
22
126
|
id: "next",
|
|
23
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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",
|