create-cloudflare 2.46.2 → 2.47.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.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.46.2",
3
+ "version": "2.47.1",
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.20250507.0",
33
+ "@cloudflare/workers-types": "^4.20250508.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -73,9 +73,9 @@
73
73
  "@cloudflare/cli": "1.1.1",
74
74
  "@cloudflare/eslint-config-worker": "1.1.0",
75
75
  "@cloudflare/mock-npm-registry": "0.0.0",
76
- "@cloudflare/vite-plugin": "1.1.1",
76
+ "@cloudflare/vite-plugin": "1.2.1",
77
77
  "@cloudflare/workers-tsconfig": "0.0.0",
78
- "wrangler": "4.14.4"
78
+ "wrangler": "4.15.1"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=18.14.1"
@@ -3,8 +3,6 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { spinner } from "@cloudflare/cli/interactive";
4
4
  import { runFrameworkGenerator } from "frameworks/index";
5
5
  import { loadTemplateSnippets, transformFile } from "helpers/codemod";
6
- import { getLatestTypesEntrypoint } from "helpers/compatDate";
7
- import { readFile, writeFile } from "helpers/files";
8
6
  import { detectPackageManager } from "helpers/packageManagers";
9
7
  import { installPackages } from "helpers/packages";
10
8
  import * as recast from "recast";
@@ -40,28 +38,6 @@ const configure = async (ctx: C3Context) => {
40
38
  }
41
39
 
42
40
  updateViteConfig(ctx);
43
- updateEnvTypes(ctx);
44
- };
45
-
46
- const updateEnvTypes = (ctx: C3Context) => {
47
- const filepath = "env.d.ts";
48
-
49
- const s = spinner();
50
- s.start(`Updating ${filepath}`);
51
-
52
- let file = readFile(filepath);
53
-
54
- let typesEntrypoint = `@cloudflare/workers-types`;
55
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
56
- if (latestEntrypoint) {
57
- typesEntrypoint += `/${latestEntrypoint}`;
58
- }
59
-
60
- // Replace placeholder with actual types entrypoint
61
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
62
- writeFile("env.d.ts", file);
63
-
64
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
65
41
  };
66
42
 
67
43
  const updateViteConfig = (ctx: C3Context) => {
@@ -1,4 +1,4 @@
1
- /// <reference types="WORKERS_TYPES_ENTRYPOINT" />
1
+ /// <reference types="./worker-configuration.d.ts" />
2
2
 
3
3
  declare module "h3" {
4
4
  interface H3EventContext {
@@ -3,7 +3,6 @@ import { logRaw } from "@cloudflare/cli";
3
3
  import { brandColor, dim } from "@cloudflare/cli/colors";
4
4
  import { spinner } from "@cloudflare/cli/interactive";
5
5
  import { runFrameworkGenerator } from "frameworks/index";
6
- import { compatDateFlag } from "helpers/compatDate";
7
6
  import { readFile, readJSON, writeFile } from "helpers/files";
8
7
  import { detectPackageManager } from "helpers/packageManagers";
9
8
  import { installPackages } from "helpers/packages";
@@ -107,10 +106,11 @@ const config: TemplateConfig = {
107
106
  configure,
108
107
  transformPackageJson: async () => ({
109
108
  scripts: {
110
- start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}`,
109
+ start: `${npm} run build && wrangler pages dev`,
111
110
  build: `ng build && ${npm} run process`,
112
111
  process: "node ./tools/copy-files.mjs",
113
- deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
112
+ deploy: `${npm} run build && wrangler pages deploy`,
113
+ "cf-typegen": `wrangler types`,
114
114
  },
115
115
  }),
116
116
  };
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "pages_build_output_dir": "./dist/cloudflare"
5
+ }
@@ -106,6 +106,7 @@ const config: TemplateConfig = {
106
106
  start: `${npm} run build && wrangler dev`,
107
107
  build: `ng build`,
108
108
  deploy: `${npm} run build && wrangler deploy`,
109
+ "cf-typegen": `wrangler types`,
109
110
  },
110
111
  }),
111
112
  };
@@ -3,7 +3,8 @@
3
3
  "main": "./dist/_worker.js/index.js",
4
4
  "compatibility_date": "<TBD>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat"
6
+ "nodejs_compat",
7
+ "global_fetch_strictly_public"
7
8
  ],
8
9
  "assets": {
9
10
  "binding": "ASSETS",
@@ -3,7 +3,8 @@
3
3
  "main": "./dist/_worker.js/index.js",
4
4
  "compatibility_date": "<TBD>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat"
6
+ "nodejs_compat",
7
+ "global_fetch_strictly_public"
7
8
  ],
8
9
  "assets": {
9
10
  "binding": "ASSETS",
@@ -16,9 +16,6 @@
16
16
  /* Enable importing .json files */
17
17
  "resolveJsonModule": true,
18
18
 
19
- /* Specify type package names to be included without being referenced in a source file. */
20
- "types": ["@cloudflare/workers-types"],
21
-
22
19
  /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
23
20
  "allowJs": true,
24
21
  /* Enable error reporting in type-checked JavaScript files. */
@@ -27,5 +27,6 @@ const config: TemplateConfig = {
27
27
  devScript: "preview",
28
28
  deployScript: "deploy",
29
29
  previewScript: "preview",
30
+ workersTypes: "none",
30
31
  };
31
32
  export default config;
@@ -29,5 +29,6 @@ const config: TemplateConfig = {
29
29
  devScript: "start",
30
30
  deployScript: "deploy",
31
31
  previewScript: "preview",
32
+ workersTypes: "none",
32
33
  };
33
34
  export default config;
@@ -47,5 +47,6 @@ const config: TemplateConfig = {
47
47
  devScript: "develop",
48
48
  deployScript: "deploy",
49
49
  previewScript: "preview",
50
+ workersTypes: "none",
50
51
  };
51
52
  export default config;
@@ -49,5 +49,6 @@ const config: TemplateConfig = {
49
49
  devScript: "develop",
50
50
  deployScript: "deploy",
51
51
  previewScript: "preview",
52
+ workersTypes: "none",
52
53
  };
53
54
  export default config;
@@ -1,4 +1,3 @@
1
- // test/index.spec.ts
2
1
  import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
3
2
  import { describe, it, expect } from 'vitest';
4
3
  import worker from '../src/index';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
- "types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"]
4
+ "types": ["@cloudflare/vitest-pool-workers"]
5
5
  },
6
6
  "include": ["./**/*.ts", "../worker-configuration.d.ts"],
7
7
  "exclude": []
@@ -13,8 +13,6 @@
13
13
  "module": "es2022",
14
14
  /* Specify how TypeScript looks up a file from a given module specifier. */
15
15
  "moduleResolution": "Bundler",
16
- /* Specify type package names to be included without being referenced in a source file. */
17
- "types": ["@cloudflare/workers-types"],
18
16
  /* Enable importing .json files */
19
17
  "resolveJsonModule": true,
20
18
 
@@ -13,8 +13,6 @@
13
13
  "module": "es2022",
14
14
  /* Specify how TypeScript looks up a file from a given module specifier. */
15
15
  "moduleResolution": "node",
16
- /* Specify type package names to be included without being referenced in a source file. */
17
- "types": ["@cloudflare/workers-types"],
18
16
  /* Enable importing .json files */
19
17
  "resolveJsonModule": true,
20
18
 
@@ -13,8 +13,6 @@
13
13
  "module": "es2022",
14
14
  /* Specify how TypeScript looks up a file from a given module specifier. */
15
15
  "moduleResolution": "node",
16
- /* Specify type package names to be included without being referenced in a source file. */
17
- "types": ["@cloudflare/workers-types"],
18
16
  /* Enable importing .json files */
19
17
  "resolveJsonModule": true,
20
18
 
@@ -3,7 +3,8 @@
3
3
  "main": "src/index.js",
4
4
  "compatibility_date": "<TBD>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat"
6
+ "nodejs_compat",
7
+ "global_fetch_strictly_public"
7
8
  ],
8
9
  "assets": {
9
10
  "binding": "ASSETS",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
- "types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"]
4
+ "types": ["@cloudflare/vitest-pool-workers"]
5
5
  },
6
6
  "include": ["./**/*.ts", "../worker-configuration.d.ts"],
7
7
  "exclude": []
@@ -13,8 +13,6 @@
13
13
  "module": "es2022",
14
14
  /* Specify how TypeScript looks up a file from a given module specifier. */
15
15
  "moduleResolution": "Bundler",
16
- /* Specify type package names to be included without being referenced in a source file. */
17
- "types": ["@cloudflare/workers-types"],
18
16
  /* Enable importing .json files */
19
17
  "resolveJsonModule": true,
20
18
 
@@ -3,7 +3,8 @@
3
3
  "main": "src/index.ts",
4
4
  "compatibility_date": "<TBD>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat"
6
+ "nodejs_compat",
7
+ "global_fetch_strictly_public"
7
8
  ],
8
9
  "assets": {
9
10
  "binding": "ASSETS",
@@ -19,6 +19,8 @@ const generate = async (ctx: C3Context) => {
19
19
  logRaw(""); // newline
20
20
  };
21
21
 
22
+ const envInterfaceName = "CloudflareBindings";
23
+
22
24
  const config: TemplateConfig = {
23
25
  configVersion: 1,
24
26
  id: "hono",
@@ -33,12 +35,13 @@ const config: TemplateConfig = {
33
35
  generate,
34
36
  transformPackageJson: async () => ({
35
37
  scripts: {
36
- "cf-typegen": "wrangler types --env-interface CloudflareBindings",
38
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
37
39
  preview: "vite build && wrangler pages dev",
38
40
  },
39
41
  }),
40
42
  devScript: "dev",
41
43
  deployScript: "deploy",
42
44
  previewScript: "preview",
45
+ envInterfaceName,
43
46
  };
44
47
  export default config;
@@ -19,6 +19,7 @@ const generate = async (ctx: C3Context) => {
19
19
  logRaw(""); // newline
20
20
  };
21
21
 
22
+ const envInterfaceName = "CloudflareBindings";
22
23
  const config: TemplateConfig = {
23
24
  configVersion: 1,
24
25
  id: "hono",
@@ -32,11 +33,12 @@ const config: TemplateConfig = {
32
33
  generate,
33
34
  transformPackageJson: async () => ({
34
35
  scripts: {
35
- "cf-typegen": "wrangler types --env-interface CloudflareBindings",
36
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
36
37
  },
37
38
  }),
38
39
  devScript: "dev",
39
40
  deployScript: "deploy",
40
41
  previewScript: "dev",
42
+ envInterfaceName,
41
43
  };
42
44
  export default config;
@@ -75,14 +75,6 @@ const configure = async (ctx: C3Context) => {
75
75
 
76
76
  const usesTs = usesTypescript(ctx);
77
77
 
78
- if (usesTs) {
79
- copyFile(
80
- join(getTemplatePath(ctx), "env.d.ts"),
81
- join(projectPath, "env.d.ts"),
82
- );
83
- updateStatus("Created an env.d.ts file");
84
- }
85
-
86
78
  const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
87
79
 
88
80
  if (installEslintPlugin) {
@@ -145,7 +137,6 @@ export const writeEslintrc = async (ctx: C3Context): Promise<void> => {
145
137
  const addDevDependencies = async (installEslintPlugin: boolean) => {
146
138
  const packages = [
147
139
  "@cloudflare/next-on-pages@1",
148
- "@cloudflare/workers-types",
149
140
  "vercel",
150
141
  ...(installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []),
151
142
  ];
@@ -156,6 +147,9 @@ const addDevDependencies = async (installEslintPlugin: boolean) => {
156
147
  });
157
148
  };
158
149
 
150
+ const envInterfaceName = "CloudflareEnv";
151
+ const typesPath = "./env.d.ts";
152
+
159
153
  export default {
160
154
  configVersion: 1,
161
155
  id: "next",
@@ -213,7 +207,7 @@ export default {
213
207
  preview: `${pagesBuildRunCommand} && wrangler pages dev`,
214
208
  deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
215
209
  ...(usesTypescript(ctx) && {
216
- "cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`,
210
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${typesPath}`,
217
211
  }),
218
212
  },
219
213
  };
@@ -222,4 +216,6 @@ export default {
222
216
  previewScript: "preview",
223
217
  deployScript: "deploy",
224
218
  compatibilityFlags: ["nodejs_compat"],
219
+ typesPath,
220
+ envInterfaceName,
225
221
  } as TemplateConfig;
@@ -11,7 +11,7 @@ const generate = async (ctx: C3Context) => {
11
11
  };
12
12
 
13
13
  const configure = async (ctx: C3Context) => {
14
- await installPackages(["@opennextjs/cloudflare@~1.0.0-beta.0 || ^1.0.0"], {
14
+ await installPackages(["@opennextjs/cloudflare@^1.0.2"], {
15
15
  startText: "Adding the Cloudflare adapter",
16
16
  doneText: `${brandColor(`installed`)} @opennextjs/cloudflare)}`,
17
17
  });
@@ -42,13 +42,14 @@ const updateNextConfig = (usesTs: boolean) => {
42
42
  s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
43
43
  };
44
44
 
45
+ const envInterfaceName = "CloudflareBindings";
46
+ const typesPath = "./cloudflare-env.d.ts";
45
47
  export default {
46
48
  configVersion: 1,
47
49
  id: "next",
48
50
  frameworkCli: "create-next-app",
49
- frameworkCliPinnedVersion: "~15.3.0",
50
51
  platform: "workers",
51
- displayName: "Next.js (using Node.js compat + Workers Assets)",
52
+ displayName: "Next.js",
52
53
  path: "templates/next/workers",
53
54
  copyFiles: {
54
55
  path: "./templates",
@@ -59,11 +60,12 @@ export default {
59
60
  scripts: {
60
61
  deploy: `opennextjs-cloudflare build && opennextjs-cloudflare deploy`,
61
62
  preview: `opennextjs-cloudflare build && opennextjs-cloudflare preview`,
62
- "cf-typegen": `wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts`,
63
+ "cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${typesPath}`,
63
64
  },
64
65
  }),
65
66
  devScript: "dev",
66
67
  previewScript: "preview",
67
68
  deployScript: "deploy",
68
- compatibilityFlags: ["nodejs_compat"],
69
+ typesPath,
70
+ envInterfaceName,
69
71
  } as TemplateConfig;
@@ -3,8 +3,7 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { spinner } from "@cloudflare/cli/interactive";
4
4
  import { runFrameworkGenerator } from "frameworks/index";
5
5
  import { mergeObjectProperties, transformFile } from "helpers/codemod";
6
- import { getLatestTypesEntrypoint } from "helpers/compatDate";
7
- import { readFile, writeFile } from "helpers/files";
6
+ import { writeFile } from "helpers/files";
8
7
  import { detectPackageManager } from "helpers/packageManagers";
9
8
  import { installPackages } from "helpers/packages";
10
9
  import * as recast from "recast";
@@ -30,7 +29,7 @@ const generate = async (ctx: C3Context) => {
30
29
  logRaw(""); // newline
31
30
  };
32
31
 
33
- const configure = async (ctx: C3Context) => {
32
+ const configure = async () => {
34
33
  const packages = ["nitro-cloudflare-dev"];
35
34
 
36
35
  // When using pnpm, explicitly add h3 package so the H3Event type declaration can be updated.
@@ -45,29 +44,6 @@ const configure = async (ctx: C3Context) => {
45
44
  doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
46
45
  });
47
46
  updateNuxtConfig();
48
-
49
- updateEnvTypes(ctx);
50
- };
51
-
52
- const updateEnvTypes = (ctx: C3Context) => {
53
- const filepath = "env.d.ts";
54
-
55
- const s = spinner();
56
- s.start(`Updating ${filepath}`);
57
-
58
- let file = readFile(filepath);
59
-
60
- let typesEntrypoint = `@cloudflare/workers-types`;
61
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
62
- if (latestEntrypoint) {
63
- typesEntrypoint += `/${latestEntrypoint}`;
64
- }
65
-
66
- // Replace placeholder with actual types entrypoint
67
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
68
- writeFile("env.d.ts", file);
69
-
70
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
71
47
  };
72
48
 
73
49
  const updateNuxtConfig = () => {
@@ -1,4 +1,4 @@
1
- /// <reference types="WORKERS_TYPES_ENTRYPOINT" />
1
+ /// <reference types="./worker-configuration.d.ts" />
2
2
 
3
3
  declare module "h3" {
4
4
  interface H3EventContext {
@@ -3,8 +3,7 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { spinner } from "@cloudflare/cli/interactive";
4
4
  import { runFrameworkGenerator } from "frameworks/index";
5
5
  import { mergeObjectProperties, transformFile } from "helpers/codemod";
6
- import { getLatestTypesEntrypoint } from "helpers/compatDate";
7
- import { readFile, writeFile } from "helpers/files";
6
+ import { writeFile } from "helpers/files";
8
7
  import { detectPackageManager } from "helpers/packageManagers";
9
8
  import { installPackages } from "helpers/packages";
10
9
  import * as recast from "recast";
@@ -30,7 +29,7 @@ const generate = async (ctx: C3Context) => {
30
29
  logRaw(""); // newline
31
30
  };
32
31
 
33
- const configure = async (ctx: C3Context) => {
32
+ const configure = async () => {
34
33
  const packages = ["nitro-cloudflare-dev", "nitropack"];
35
34
 
36
35
  // When using pnpm, explicitly add h3 package so the H3Event type declaration can be updated.
@@ -45,29 +44,6 @@ const configure = async (ctx: C3Context) => {
45
44
  doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
46
45
  });
47
46
  updateNuxtConfig();
48
-
49
- updateEnvTypes(ctx);
50
- };
51
-
52
- const updateEnvTypes = (ctx: C3Context) => {
53
- const filepath = "env.d.ts";
54
-
55
- const s = spinner();
56
- s.start(`Updating ${filepath}`);
57
-
58
- let file = readFile(filepath);
59
-
60
- let typesEntrypoint = `@cloudflare/workers-types`;
61
- const latestEntrypoint = getLatestTypesEntrypoint(ctx);
62
- if (latestEntrypoint) {
63
- typesEntrypoint += `/${latestEntrypoint}`;
64
- }
65
-
66
- // Replace placeholder with actual types entrypoint
67
- file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
68
- writeFile("env.d.ts", file);
69
-
70
- s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
71
47
  };
72
48
 
73
49
  const updateNuxtConfig = () => {
@@ -1,4 +1,4 @@
1
- /// <reference types="WORKERS_TYPES_ENTRYPOINT" />
1
+ /// <reference types="./worker-configuration.d.ts" />
2
2
 
3
3
  declare module "h3" {
4
4
  interface H3EventContext {
@@ -22,7 +22,6 @@
22
22
  "types": [
23
23
  "@types/node",
24
24
  "@types/service-worker-mock",
25
- "@cloudflare/workers-types"
26
25
  ]
27
26
  },
28
27
  "exclude": ["node_modules", "dist", "tests"],
@@ -13,8 +13,6 @@
13
13
  "module": "es2022",
14
14
  /* Specify how TypeScript looks up a file from a given module specifier. */
15
15
  "moduleResolution": "node",
16
- /* Specify type package names to be included without being referenced in a source file. */
17
- "types": ["@cloudflare/workers-types"],
18
16
  /* Enable importing .json files */
19
17
  "resolveJsonModule": true,
20
18
 
@@ -146,5 +146,6 @@ const config: TemplateConfig = {
146
146
  devScript: "dev",
147
147
  deployScript: "deploy",
148
148
  previewScript: "preview",
149
+ workersTypes: "installed",
149
150
  };
150
151
  export default config;
@@ -148,5 +148,6 @@ const config: TemplateConfig = {
148
148
  devScript: "dev",
149
149
  deployScript: "deploy",
150
150
  previewScript: "preview",
151
+ workersTypes: "installed",
151
152
  };
152
153
  export default config;
@@ -3,7 +3,8 @@
3
3
  "main": "./dist/_worker.js",
4
4
  "compatibility_date": "<TBD>",
5
5
  "compatibility_flags": [
6
- "nodejs_compat"
6
+ "nodejs_compat",
7
+ "global_fetch_strictly_public"
7
8
  ],
8
9
  "assets": {
9
10
  "binding": "ASSET",
@@ -49,11 +49,13 @@ const config: TemplateConfig = {
49
49
  platform: "pages",
50
50
  hidden: true,
51
51
  path: "templates/react/pages",
52
+ copyFiles: { path: "./templates" },
52
53
  generate,
53
54
  transformPackageJson: async () => ({
54
55
  scripts: {
55
- deploy: `${npm} run build && wrangler pages deploy ./dist`,
56
- preview: `${npm} run build && wrangler pages dev ./dist`,
56
+ deploy: `${npm} run build && wrangler pages deploy`,
57
+ preview: `${npm} run build && wrangler pages dev`,
58
+ "cf-typegen": `wrangler types`,
57
59
  },
58
60
  }),
59
61
  devScript: "dev",
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "pages_build_output_dir": "./dist"
5
+ }
@@ -2,7 +2,7 @@
2
2
  "extends": "./tsconfig.node.json",
3
3
  "compilerOptions": {
4
4
  "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
5
- "types": ["@cloudflare/workers-types/2023-07-01", "vite/client"]
5
+ "types": ["./worker-configuration.d.ts", "vite/client"],
6
6
  },
7
7
  "include": ["./worker-configuration.d.ts", "./worker"]
8
8
  }
@@ -19,24 +19,12 @@ const generate = async (ctx: C3Context) => {
19
19
  logRaw(""); // newline
20
20
  };
21
21
 
22
- // TODO: Uncomment this once @react-router/dev updates its peer dependency to Wrangler v4
23
- // const configure = async () => {
24
- // await installPackages(["wrangler@latest"], {
25
- // dev: true,
26
- // startText: "Updating the Wrangler version",
27
- // doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`,
28
- // });
29
- // };
30
-
31
22
  const config: TemplateConfig = {
32
23
  configVersion: 1,
33
24
  id: "react-router",
34
25
  platform: "workers",
35
26
  frameworkCli: "create-react-router",
36
27
  displayName: "React Router (formerly Remix)",
37
- copyFiles: {
38
- path: "./templates",
39
- },
40
28
  generate,
41
29
  // configure,
42
30
  transformPackageJson: async () => ({
@@ -65,5 +65,6 @@ const config: TemplateConfig = {
65
65
  devScript: "dev",
66
66
  deployScript: "deploy",
67
67
  previewScript: "preview",
68
+ workersTypes: "installed",
68
69
  };
69
70
  export default config;
@@ -1,4 +1,4 @@
1
1
  // Generated by Wrangler
2
- // After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
3
  interface Env {
4
4
  }
@@ -48,5 +48,6 @@ const config: TemplateConfig = {
48
48
  devScript: "dev",
49
49
  deployScript: "deploy",
50
50
  previewScript: "preview",
51
+ workersTypes: "installed",
51
52
  };
52
53
  export default config;