create-cloudflare 0.0.0-ffe8d10cb → 0.0.0-fff677e35

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 (184) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +7699 -9272
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +12 -7
  5. package/templates/analog/templates/worker-configuration.d.ts +1 -1
  6. package/templates/analog/templates/wrangler.jsonc +5 -0
  7. package/templates/angular/c3.ts +25 -13
  8. package/templates/angular/templates/src/server.ts +15 -0
  9. package/templates/angular/templates/tools/copy-files.mjs +8 -2
  10. package/templates/astro/c3.ts +17 -33
  11. package/templates/astro/templates/js/wrangler.jsonc +8 -0
  12. package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
  13. package/templates/astro/templates/ts/wrangler.jsonc +8 -0
  14. package/templates/common/js/package.json +1 -1
  15. package/templates/common/js/wrangler.jsonc +8 -0
  16. package/templates/common/ts/package.json +1 -1
  17. package/templates/common/ts/src/index.ts +1 -1
  18. package/templates/common/ts/tsconfig.json +37 -95
  19. package/templates/common/ts/worker-configuration.d.ts +1 -1
  20. package/templates/common/ts/wrangler.jsonc +8 -0
  21. package/templates/docusaurus/c3.ts +2 -1
  22. package/templates/hello-world/js/package.json +3 -3
  23. package/templates/hello-world/js/test/index.spec.js +1 -1
  24. package/templates/hello-world/js/vitest.config.js +1 -1
  25. package/templates/hello-world/js/wrangler.jsonc +8 -0
  26. package/templates/hello-world/py/package.json +1 -1
  27. package/templates/hello-world/py/wrangler.jsonc +9 -0
  28. package/templates/hello-world/ts/package.json +3 -3
  29. package/templates/hello-world/ts/src/index.ts +1 -1
  30. package/templates/hello-world/ts/test/tsconfig.json +1 -1
  31. package/templates/hello-world/ts/tsconfig.json +36 -95
  32. package/templates/hello-world/ts/vitest.config.mts +1 -1
  33. package/templates/hello-world/ts/worker-configuration.d.ts +1 -1
  34. package/templates/hello-world/ts/wrangler.jsonc +8 -0
  35. package/templates/hello-world-durable-object/js/package.json +1 -1
  36. package/templates/hello-world-durable-object/js/src/index.js +3 -3
  37. package/templates/hello-world-durable-object/js/wrangler.jsonc +24 -0
  38. package/templates/hello-world-durable-object/ts/package.json +1 -1
  39. package/templates/hello-world-durable-object/ts/src/index.ts +4 -4
  40. package/templates/hello-world-durable-object/ts/tsconfig.json +36 -95
  41. package/templates/hello-world-durable-object/ts/wrangler.jsonc +24 -0
  42. package/templates/hono/templates/worker-configuration.d.ts +1 -1
  43. package/templates/hono/templates/wrangler.jsonc +8 -0
  44. package/templates/next/README.md +3 -4
  45. package/templates/next/app/js/app/api/hello/route.js +4 -4
  46. package/templates/next/app/ts/app/api/hello/route.ts +4 -5
  47. package/templates/next/c3.ts +12 -30
  48. package/templates/next/wrangler.jsonc +8 -0
  49. package/templates/nuxt/c3.ts +1 -1
  50. package/templates/nuxt/templates/worker-configuration.d.ts +1 -1
  51. package/templates/nuxt/templates/wrangler.jsonc +8 -0
  52. package/templates/openapi/ts/package.json +1 -1
  53. package/templates/openapi/ts/worker-configuration.d.ts +1 -1
  54. package/templates/openapi/ts/wrangler.jsonc +8 -0
  55. package/templates/pre-existing/c3.ts +29 -10
  56. package/templates/pre-existing/js/package.json +1 -1
  57. package/templates/pre-existing/js/wrangler.jsonc +5 -0
  58. package/templates/queues/js/package.json +1 -1
  59. package/templates/queues/js/wrangler.jsonc +21 -0
  60. package/templates/queues/ts/package.json +1 -1
  61. package/templates/queues/ts/src/index.ts +1 -1
  62. package/templates/queues/ts/tsconfig.json +36 -95
  63. package/templates/queues/ts/worker-configuration.d.ts +1 -1
  64. package/templates/queues/ts/wrangler.jsonc +21 -0
  65. package/templates/qwik/templates/worker-configuration.d.ts +1 -1
  66. package/templates/qwik/templates/wrangler.jsonc +8 -0
  67. package/templates/remix/templates/worker-configuration.d.ts +1 -1
  68. package/templates/remix/templates/wrangler.jsonc +5 -0
  69. package/templates/scheduled/js/package.json +1 -1
  70. package/templates/scheduled/js/src/index.js +1 -1
  71. package/templates/scheduled/js/wrangler.jsonc +13 -0
  72. package/templates/scheduled/ts/package.json +1 -1
  73. package/templates/scheduled/ts/src/index.ts +4 -4
  74. package/templates/scheduled/ts/tsconfig.json +36 -95
  75. package/templates/scheduled/ts/worker-configuration.d.ts +1 -1
  76. package/templates/scheduled/ts/wrangler.jsonc +13 -0
  77. package/templates/solid/c3.ts +1 -1
  78. package/templates/solid/templates/wrangler.jsonc +8 -0
  79. package/templates/svelte/c3.ts +34 -7
  80. package/templates/svelte/templates/wrangler.jsonc +5 -0
  81. package/templates-experimental/angular/c3.ts +21 -7
  82. package/templates-experimental/angular/templates/src/server.ts +15 -0
  83. package/templates-experimental/angular/templates/wrangler.jsonc +12 -0
  84. package/templates-experimental/astro/c3.ts +17 -33
  85. package/templates-experimental/astro/templates/js/wrangler.jsonc +15 -0
  86. package/templates-experimental/astro/templates/ts/worker-configuration.d.ts +4 -0
  87. package/templates-experimental/astro/templates/ts/wrangler.jsonc +15 -0
  88. package/templates-experimental/docusaurus/templates/wrangler.jsonc +10 -0
  89. package/templates-experimental/gatsby/templates/wrangler.jsonc +10 -0
  90. package/templates-experimental/hello-world-assets-only/templates/wrangler.jsonc +10 -0
  91. package/templates-experimental/hello-world-durable-object-with-assets/js/package.json +1 -1
  92. package/templates-experimental/hello-world-durable-object-with-assets/js/src/index.js +3 -3
  93. package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.jsonc +28 -0
  94. package/templates-experimental/hello-world-durable-object-with-assets/ts/package.json +1 -1
  95. package/templates-experimental/hello-world-durable-object-with-assets/ts/src/index.ts +3 -3
  96. package/templates-experimental/hello-world-durable-object-with-assets/ts/tsconfig.json +36 -95
  97. package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.jsonc +28 -0
  98. package/templates-experimental/hello-world-with-assets/js/package.json +3 -3
  99. package/templates-experimental/hello-world-with-assets/js/test/index.spec.js +3 -3
  100. package/templates-experimental/hello-world-with-assets/js/vitest.config.js +1 -1
  101. package/templates-experimental/hello-world-with-assets/js/wrangler.jsonc +15 -0
  102. package/templates-experimental/hello-world-with-assets/py/package.json +1 -1
  103. package/templates-experimental/hello-world-with-assets/py/wrangler.jsonc +15 -0
  104. package/templates-experimental/hello-world-with-assets/ts/package.json +3 -3
  105. package/templates-experimental/hello-world-with-assets/ts/src/index.ts +1 -1
  106. package/templates-experimental/hello-world-with-assets/ts/test/index.spec.ts +5 -5
  107. package/templates-experimental/hello-world-with-assets/ts/tsconfig.json +36 -95
  108. package/templates-experimental/hello-world-with-assets/ts/vitest.config.mts +1 -1
  109. package/templates-experimental/hello-world-with-assets/ts/worker-configuration.d.ts +1 -1
  110. package/templates-experimental/hello-world-with-assets/ts/wrangler.jsonc +15 -0
  111. package/templates-experimental/hono/c3.ts +43 -0
  112. package/templates-experimental/hono/templates/public/index.html +19 -0
  113. package/templates-experimental/hono/templates/src/index.ts +9 -0
  114. package/templates-experimental/hono/templates/worker-configuration.d.ts +4 -0
  115. package/templates-experimental/hono/templates/wrangler.jsonc +9 -0
  116. package/templates-experimental/next/c3.ts +84 -0
  117. package/templates-experimental/next/templates/.dev.vars +2 -0
  118. package/templates-experimental/next/templates/__dot__gitignore +39 -0
  119. package/templates-experimental/next/templates/cloudflare-env.d.ts +5 -0
  120. package/templates-experimental/next/templates/open-next.config.ts +28 -0
  121. package/templates-experimental/next/templates/wrangler.jsonc +13 -0
  122. package/templates-experimental/nuxt/c3.ts +2 -2
  123. package/templates-experimental/nuxt/templates/worker-configuration.d.ts +1 -1
  124. package/templates-experimental/nuxt/templates/wrangler.jsonc +12 -0
  125. package/templates-experimental/qwik/templates/worker-configuration.d.ts +1 -1
  126. package/templates-experimental/qwik/templates/wrangler.jsonc +15 -0
  127. package/templates-experimental/remix/c3.ts +2 -27
  128. package/templates-experimental/remix/templates/public/.assetsignore +0 -4
  129. package/templates-experimental/remix/templates/wrangler.toml +7 -1
  130. package/templates-experimental/solid/c3.ts +8 -51
  131. package/templates-experimental/solid/templates/wrangler.jsonc +15 -0
  132. package/templates-experimental/svelte/c3.ts +4 -7
  133. package/templates-experimental/svelte/templates/wrangler.jsonc +12 -0
  134. package/templates-experimental/vue/c3.ts +33 -0
  135. package/templates-experimental/vue/templates/wrangler.jsonc +10 -0
  136. package/templates/analog/templates/wrangler.toml +0 -85
  137. package/templates/angular/templates/server.ts +0 -34
  138. package/templates/angular/templates/tools/alter-polyfills.mjs +0 -27
  139. package/templates/angular/templates/tools/paths.mjs +0 -9
  140. package/templates/astro/templates/wrangler.toml +0 -85
  141. package/templates/common/js/wrangler.toml +0 -107
  142. package/templates/common/ts/wrangler.toml +0 -107
  143. package/templates/hello-world/js/wrangler.toml +0 -108
  144. package/templates/hello-world/py/wrangler.toml +0 -108
  145. package/templates/hello-world/ts/wrangler.toml +0 -108
  146. package/templates/hello-world-durable-object/js/wrangler.toml +0 -107
  147. package/templates/hello-world-durable-object/ts/wrangler.toml +0 -107
  148. package/templates/hono/templates/wrangler.toml +0 -107
  149. package/templates/next/wrangler.toml +0 -86
  150. package/templates/nuxt/templates/wrangler.toml +0 -85
  151. package/templates/openapi/ts/wrangler.toml +0 -107
  152. package/templates/pre-existing/js/wrangler.toml +0 -4
  153. package/templates/queues/js/wrangler.toml +0 -112
  154. package/templates/queues/ts/wrangler.toml +0 -112
  155. package/templates/qwik/templates/wrangler.toml +0 -86
  156. package/templates/remix/templates/wrangler.toml +0 -85
  157. package/templates/scheduled/js/wrangler.toml +0 -113
  158. package/templates/scheduled/ts/wrangler.toml +0 -113
  159. package/templates/solid/templates/wrangler.toml +0 -84
  160. package/templates/svelte/js/wrangler.toml +0 -85
  161. package/templates/svelte/ts/wrangler.toml +0 -85
  162. package/templates-experimental/angular/templates/server.ts +0 -34
  163. package/templates-experimental/angular/templates/tools/alter-polyfills.mjs +0 -32
  164. package/templates-experimental/angular/templates/wrangler.toml +0 -5
  165. package/templates-experimental/astro/templates/wrangler.toml +0 -6
  166. package/templates-experimental/docusaurus/templates/wrangler.toml +0 -4
  167. package/templates-experimental/gatsby/templates/wrangler.toml +0 -4
  168. package/templates-experimental/hello-world-assets-only/templates/wrangler.toml +0 -4
  169. package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.toml +0 -19
  170. package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.toml +0 -19
  171. package/templates-experimental/hello-world-with-assets/js/wrangler.toml +0 -6
  172. package/templates-experimental/hello-world-with-assets/py/wrangler.toml +0 -6
  173. package/templates-experimental/hello-world-with-assets/ts/wrangler.toml +0 -6
  174. package/templates-experimental/nuxt/templates/cloudflare-preset/nitro.config.ts +0 -27
  175. package/templates-experimental/nuxt/templates/wrangler.toml +0 -5
  176. package/templates-experimental/qwik/templates/wrangler.toml +0 -6
  177. package/templates-experimental/solid/templates/wrangler.toml +0 -6
  178. package/templates-experimental/svelte/js/wrangler.toml +0 -5
  179. package/templates-experimental/svelte/ts/wrangler.toml +0 -5
  180. /package/templates/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  181. /package/templates-experimental/astro/templates/{public → js/public}/.assetsignore +0 -0
  182. /package/templates-experimental/{svelte/js/static → astro/templates/ts/public}/.assetsignore +0 -0
  183. /package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  184. /package/templates-experimental/svelte/{ts → templates}/static/.assetsignore +0 -0
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.ts",
4
+ "compatibility_date": "<TBD>",
5
+ "migrations": [
6
+ {
7
+ "new_classes": [
8
+ "MyDurableObject"
9
+ ],
10
+ "tag": "v1"
11
+ }
12
+ ],
13
+ "assets": {
14
+ "binding": "ASSETS",
15
+ "directory": "./public"
16
+ },
17
+ "durable_objects": {
18
+ "bindings": [
19
+ {
20
+ "class_name": "MyDurableObject",
21
+ "name": "MY_DURABLE_OBJECT"
22
+ }
23
+ ]
24
+ },
25
+ "observability": {
26
+ "enabled": true
27
+ }
28
+ }
@@ -9,8 +9,8 @@
9
9
  "test": "vitest"
10
10
  },
11
11
  "devDependencies": {
12
- "@cloudflare/vitest-pool-workers": "^0.5.2",
13
- "wrangler": "^3.60.3",
14
- "vitest": "2.0.5"
12
+ "@cloudflare/vitest-pool-workers": "^0.6.4",
13
+ "wrangler": "^3.101.0",
14
+ "vitest": "~2.1.9"
15
15
  }
16
16
  }
@@ -1,4 +1,4 @@
1
- import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
1
+ import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
2
2
  import { describe, it, expect } from 'vitest';
3
3
  import worker from '../src';
4
4
 
@@ -16,7 +16,7 @@ describe('Hello World user worker', () => {
16
16
 
17
17
  it('responds with "Hello, World!" (integration style)', async () => {
18
18
  const request = new Request('http://example.com/message');
19
- const response = await SELF.fetch(request, env, ctx);
19
+ const response = await SELF.fetch(request);
20
20
  expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
21
21
  });
22
22
  });
@@ -34,7 +34,7 @@ describe('Hello World user worker', () => {
34
34
 
35
35
  it('responds with a random UUID (integration style)', async () => {
36
36
  const request = new Request('http://example.com/random');
37
- const response = await SELF.fetch(request, env, ctx);
37
+ const response = await SELF.fetch(request);
38
38
  expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
39
39
  });
40
40
  });
@@ -4,7 +4,7 @@ export default defineWorkersConfig({
4
4
  test: {
5
5
  poolOptions: {
6
6
  workers: {
7
- wrangler: { configPath: './wrangler.toml' },
7
+ wrangler: { configPath: './wrangler.jsonc' },
8
8
  },
9
9
  },
10
10
  },
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.js",
4
+ "compatibility_date": "<TBD>",
5
+ "compatibility_flags": [
6
+ "nodejs_compat"
7
+ ],
8
+ "assets": {
9
+ "binding": "ASSETS",
10
+ "directory": "./public"
11
+ },
12
+ "observability": {
13
+ "enabled": true
14
+ }
15
+ }
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.60.3"
11
+ "wrangler": "^3.101.0"
12
12
  }
13
13
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/entry.py",
4
+ "compatibility_date": "<TBD>",
5
+ "compatibility_flags": [
6
+ "python_workers"
7
+ ],
8
+ "assets": {
9
+ "binding": "ASSETS",
10
+ "directory": "./public"
11
+ },
12
+ "observability": {
13
+ "enabled": true
14
+ }
15
+ }
@@ -10,9 +10,9 @@
10
10
  "cf-typegen": "wrangler types"
11
11
  },
12
12
  "devDependencies": {
13
- "@cloudflare/vitest-pool-workers": "^0.5.2",
13
+ "@cloudflare/vitest-pool-workers": "^0.6.4",
14
14
  "typescript": "^5.5.2",
15
- "vitest": "2.0.5",
16
- "wrangler": "^3.60.3"
15
+ "vitest": "~2.1.9",
16
+ "wrangler": "^3.101.0"
17
17
  }
18
18
  }
@@ -5,7 +5,7 @@
5
5
  * - Open a browser tab at http://localhost:8787/ to see your worker in action
6
6
  * - Run `npm run deploy` to publish your worker
7
7
  *
8
- * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
8
+ * Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the
9
9
  * `Env` object can be regenerated with `npm run cf-typegen`.
10
10
  *
11
11
  * Learn more at https://developers.cloudflare.com/workers/
@@ -1,11 +1,11 @@
1
- import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
1
+ import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
2
2
  import { describe, it, expect } from 'vitest';
3
3
  import worker from '../src';
4
4
 
5
5
  describe('Hello World user worker', () => {
6
6
  describe('request for /message', () => {
7
7
  it('/ responds with "Hello, World!" (unit style)', async () => {
8
- const request = new Request('http://example.com/message');
8
+ const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/message');
9
9
  // Create an empty context to pass to `worker.fetch()`.
10
10
  const ctx = createExecutionContext();
11
11
  const response = await worker.fetch(request, env, ctx);
@@ -16,14 +16,14 @@ describe('Hello World user worker', () => {
16
16
 
17
17
  it('responds with "Hello, World!" (integration style)', async () => {
18
18
  const request = new Request('http://example.com/message');
19
- const response = await SELF.fetch(request, env, ctx);
19
+ const response = await SELF.fetch(request);
20
20
  expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
21
21
  });
22
22
  });
23
23
 
24
24
  describe('request for /random', () => {
25
25
  it('/ responds with a random UUID (unit style)', async () => {
26
- const request = new Request('http://example.com/random');
26
+ const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/random');
27
27
  // Create an empty context to pass to `worker.fetch()`.
28
28
  const ctx = createExecutionContext();
29
29
  const response = await worker.fetch(request, env, ctx);
@@ -34,7 +34,7 @@ describe('Hello World user worker', () => {
34
34
 
35
35
  it('responds with a random UUID (integration style)', async () => {
36
36
  const request = new Request('http://example.com/random');
37
- const response = await SELF.fetch(request, env, ctx);
37
+ const response = await SELF.fetch(request);
38
38
  expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
39
39
  });
40
40
  });
@@ -2,101 +2,42 @@
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
4
 
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
- "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
-
26
- /* Modules */
27
- "module": "es2022" /* Specify what module code is generated. */,
28
- // "rootDir": "./", /* Specify the root folder within your source files. */
29
- "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
30
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34
- "types": ["@cloudflare/workers-types"] /* Specify type package names to be included without being referenced in a source file. */,
35
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
- "resolveJsonModule": true /* Enable importing .json files */,
37
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
38
-
39
- /* JavaScript Support */
40
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
41
- "checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
42
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
43
-
44
- /* Emit */
45
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
47
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
50
- // "outDir": "./", /* Specify an output folder for all emitted files. */
51
- // "removeComments": true, /* Disable emitting comments. */
52
- "noEmit": true /* Disable emitting files from a compilation. */,
53
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
55
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61
- // "newLine": "crlf", /* Set the newline character for emitting files. */
62
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
63
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
64
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
66
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
68
-
69
- /* Interop Constraints */
70
- "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
71
- "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
72
- // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
73
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
75
-
76
- /* Type Checking */
77
- "strict": true /* Enable all strict type-checking options. */,
78
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
79
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
80
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
81
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
82
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
83
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
84
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
85
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
86
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
87
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
88
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
89
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
90
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
91
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
92
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
93
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
94
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
95
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
96
-
97
- /* Completeness */
98
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
5
+ /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
6
+ "target": "es2021",
7
+ /* Specify a set of bundled library declaration files that describe the target runtime environment. */
8
+ "lib": ["es2021"],
9
+ /* Specify what JSX code is generated. */
10
+ "jsx": "react-jsx",
11
+
12
+ /* Specify what module code is generated. */
13
+ "module": "es2022",
14
+ /* Specify how TypeScript looks up a file from a given module specifier. */
15
+ "moduleResolution": "Bundler",
16
+ /* Specify type package names to be included without being referenced in a source file. */
17
+ "types": ["@cloudflare/workers-types"],
18
+ /* Enable importing .json files */
19
+ "resolveJsonModule": true,
20
+
21
+ /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
22
+ "allowJs": true,
23
+ /* Enable error reporting in type-checked JavaScript files. */
24
+ "checkJs": false,
25
+
26
+ /* Disable emitting files from a compilation. */
27
+ "noEmit": true,
28
+
29
+ /* Ensure that each file can be safely transpiled without relying on other imports. */
30
+ "isolatedModules": true,
31
+ /* Allow 'import x from y' when a module doesn't have a default export. */
32
+ "allowSyntheticDefaultImports": true,
33
+ /* Ensure that casing is correct in imports. */
34
+ "forceConsistentCasingInFileNames": true,
35
+
36
+ /* Enable all strict type-checking options. */
37
+ "strict": true,
38
+
39
+ /* Skip type checking all .d.ts files. */
40
+ "skipLibCheck": true
100
41
  },
101
42
  "exclude": ["test"],
102
43
  "include": ["worker-configuration.d.ts", "src/**/*.ts"]
@@ -4,7 +4,7 @@ export default defineWorkersConfig({
4
4
  test: {
5
5
  poolOptions: {
6
6
  workers: {
7
- wrangler: { configPath: './wrangler.toml' },
7
+ wrangler: { configPath: './wrangler.jsonc' },
8
8
  },
9
9
  },
10
10
  },
@@ -1,4 +1,4 @@
1
1
  // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
2
+ // After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3
3
  interface Env {
4
4
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.ts",
4
+ "compatibility_date": "<TBD>",
5
+ "compatibility_flags": [
6
+ "nodejs_compat"
7
+ ],
8
+ "assets": {
9
+ "binding": "ASSETS",
10
+ "directory": "./public"
11
+ },
12
+ "observability": {
13
+ "enabled": true
14
+ }
15
+ }
@@ -0,0 +1,43 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { runFrameworkGenerator } from "frameworks/index";
3
+ import { detectPackageManager } from "helpers/packageManagers";
4
+ import type { TemplateConfig } from "../../src/templates";
5
+ import type { C3Context } from "types";
6
+
7
+ const generate = async (ctx: C3Context) => {
8
+ const { name: pm } = detectPackageManager();
9
+
10
+ await runFrameworkGenerator(ctx, [
11
+ ctx.project.name,
12
+ "--template",
13
+ "cloudflare-workers",
14
+ "--install",
15
+ "--pm",
16
+ pm,
17
+ ]);
18
+
19
+ logRaw(""); // newline
20
+ };
21
+
22
+ const config: TemplateConfig = {
23
+ configVersion: 1,
24
+ id: "hono",
25
+ frameworkCli: "create-hono",
26
+ displayName: "Hono",
27
+ copyFiles: {
28
+ path: "./templates",
29
+ },
30
+ platform: "workers",
31
+ path: "templates-experimental/hono",
32
+ generate,
33
+ transformPackageJson: async () => ({
34
+ scripts: {
35
+ dev: "wrangler dev",
36
+ deploy: "wrangler deploy --minify",
37
+ "cf-typegen": "wrangler types --env-interface CloudflareBindings",
38
+ },
39
+ }),
40
+ devScript: "dev",
41
+ deployScript: "deploy",
42
+ };
43
+ export default config;
@@ -0,0 +1,19 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Hello, World!</title>
7
+ </head>
8
+ <body>
9
+ <h1 id="heading"></h1>
10
+ <script>
11
+ fetch('/message')
12
+ .then((resp) => resp.text())
13
+ .then((text) => {
14
+ const h1 = document.getElementById('heading');
15
+ h1.textContent = text;
16
+ });
17
+ </script>
18
+ </body>
19
+ </html>
@@ -0,0 +1,9 @@
1
+ import { Hono } from "hono";
2
+
3
+ const app = new Hono<{ Bindings: CloudflareBindings }>();
4
+
5
+ app.get("/message", (c) => {
6
+ return c.text("Hello Hono!");
7
+ });
8
+
9
+ export default app;
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3
+ interface CloudflareBindings {
4
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.ts",
4
+ "compatibility_date": "<TBD>",
5
+ "assets": {
6
+ "binding": "ASSETS",
7
+ "directory": "./public"
8
+ }
9
+ }
@@ -0,0 +1,84 @@
1
+ import { brandColor, dim } from "@cloudflare/cli/colors";
2
+ import { spinner } from "@cloudflare/cli/interactive";
3
+ import { runFrameworkGenerator } from "frameworks/index";
4
+ import { readFile, writeFile } from "helpers/files";
5
+ import { installPackages } from "helpers/packages";
6
+ import type { TemplateConfig } from "../../src/templates";
7
+ import type { C3Context } from "types";
8
+
9
+ const generate = async (ctx: C3Context) => {
10
+ await runFrameworkGenerator(ctx, [
11
+ ctx.project.name,
12
+ "--ts",
13
+ "--tailwind",
14
+ "--eslint",
15
+ "--app",
16
+ "--import-alias",
17
+ "@/*",
18
+ "--src-dir",
19
+ ]);
20
+ };
21
+
22
+ const configure = async () => {
23
+ const packages = [
24
+ "@opennextjs/cloudflare@0.4.x",
25
+ "@cloudflare/workers-types",
26
+ ];
27
+ await installPackages(packages, {
28
+ dev: true,
29
+ startText: "Adding the Cloudflare adapter",
30
+ doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`,
31
+ });
32
+
33
+ updateNextConfig();
34
+ };
35
+
36
+ const updateNextConfig = () => {
37
+ const s = spinner();
38
+
39
+ const configFile = "next.config.mjs";
40
+ s.start(`Updating \`${configFile}\``);
41
+
42
+ const configContent = readFile(configFile);
43
+
44
+ const updatedConfigFile =
45
+ configContent +
46
+ `
47
+ // added by create cloudflare to enable calling \`getCloudflareContext()\` in \`next dev\`
48
+ import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';
49
+ initOpenNextCloudflareForDev();
50
+ `.replace(/\n\t*/g, "\n");
51
+
52
+ writeFile(configFile, updatedConfigFile);
53
+
54
+ s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
55
+ };
56
+
57
+ export default {
58
+ configVersion: 1,
59
+ id: "next",
60
+ frameworkCli: "create-next-app",
61
+ // TODO: here we need to specify a version of create-next-app which is different from the
62
+ // standard one used in the stable Next.js template, that's because our open-next adapter
63
+ // is not yet fully ready for Next.js 15, once it is we should remove the following
64
+ frameworkCliPinnedVersion: "^14.2.23",
65
+ platform: "workers",
66
+ displayName: "Next.js (using Node.js compat + Workers Assets)",
67
+ path: "templates-experimental/next",
68
+ copyFiles: {
69
+ path: "./templates",
70
+ },
71
+ generate,
72
+ configure,
73
+ transformPackageJson: async () => ({
74
+ scripts: {
75
+ deploy: `opennextjs-cloudflare && wrangler deploy`,
76
+ preview: `opennextjs-cloudflare && wrangler dev`,
77
+ "cf-typegen": `wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts`,
78
+ },
79
+ }),
80
+ devScript: "dev",
81
+ previewScript: "preview",
82
+ deployScript: "deploy",
83
+ compatibilityFlags: ["nodejs_compat"],
84
+ } as TemplateConfig;
@@ -0,0 +1,2 @@
1
+ # Load .env.development* files when running `wrangler dev`
2
+ NEXTJS_ENV=development
@@ -0,0 +1,39 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+ .yarn/install-state.gz
8
+
9
+ # testing
10
+ /coverage
11
+
12
+ # next.js
13
+ /.next/
14
+ /out/
15
+
16
+ # production
17
+ /build
18
+
19
+ # misc
20
+ .DS_Store
21
+ *.pem
22
+
23
+ # debug
24
+ npm-debug.log*
25
+ yarn-debug.log*
26
+ yarn-error.log*
27
+
28
+ # local env files
29
+ .env*.local
30
+
31
+ # vercel
32
+ .vercel
33
+
34
+ # typescript
35
+ *.tsbuildinfo
36
+ next-env.d.ts
37
+
38
+ # OpenNext
39
+ /.open-next
@@ -0,0 +1,5 @@
1
+ // Generated by Wrangler
2
+ // by running `wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts`
3
+
4
+ interface CloudflareEnv {
5
+ }
@@ -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;
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "<app-name>",
3
+ "main": ".open-next/worker.js",
4
+ "compatibility_date": "2024-09-26",
5
+ "compatibility_flags": [
6
+ "nodejs_compat"
7
+ ],
8
+ "minify": true,
9
+ "assets": {
10
+ "binding": "ASSETS",
11
+ "directory": ".open-next/assets"
12
+ }
13
+ }