create-cloudflare 0.0.0-e3136f935 → 0.0.0-e3791f7d8

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 (131) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +33184 -32403
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +8 -6
  5. package/templates/angular/c3.ts +25 -13
  6. package/templates/angular/templates/src/server.ts +15 -0
  7. package/templates/angular/templates/tools/copy-files.mjs +8 -2
  8. package/templates/astro/c3.ts +17 -33
  9. package/templates/astro/templates/{wrangler.toml → js/wrangler.toml} +1 -0
  10. package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
  11. package/templates/{svelte → astro/templates}/ts/wrangler.toml +2 -1
  12. package/templates/common/js/wrangler.toml +6 -0
  13. package/templates/common/ts/tsconfig.json +37 -95
  14. package/templates/common/ts/wrangler.toml +6 -0
  15. package/templates/docusaurus/c3.ts +2 -1
  16. package/templates/hello-world/js/package.json +1 -1
  17. package/templates/hello-world/js/wrangler.toml +6 -0
  18. package/templates/hello-world/py/wrangler.toml +6 -0
  19. package/templates/hello-world/ts/package.json +1 -1
  20. package/templates/hello-world/ts/test/tsconfig.json +1 -1
  21. package/templates/hello-world/ts/tsconfig.json +36 -95
  22. package/templates/hello-world/ts/wrangler.toml +6 -0
  23. package/templates/hello-world-durable-object/js/wrangler.toml +6 -0
  24. package/templates/hello-world-durable-object/ts/src/index.ts +0 -21
  25. package/templates/hello-world-durable-object/ts/tsconfig.json +36 -95
  26. package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +3 -4
  27. package/templates/hello-world-durable-object/ts/wrangler.toml +6 -0
  28. package/templates/hono/templates/wrangler.toml +6 -0
  29. package/templates/next/README.md +1 -1
  30. package/templates/next/app/js/app/api/hello/route.js +4 -4
  31. package/templates/next/app/ts/app/api/hello/route.ts +4 -5
  32. package/templates/next/c3.ts +9 -10
  33. package/templates/nuxt/c3.ts +1 -1
  34. package/templates/nuxt/templates/wrangler.toml +1 -0
  35. package/templates/openapi/ts/wrangler.toml +6 -0
  36. package/templates/pre-existing/c3.ts +28 -9
  37. package/templates/queues/js/wrangler.toml +6 -0
  38. package/templates/queues/ts/tsconfig.json +36 -95
  39. package/templates/queues/ts/wrangler.toml +6 -0
  40. package/templates/qwik/c3.ts +3 -3
  41. package/templates/qwik/templates/wrangler.toml +1 -0
  42. package/templates/react/c3.ts +2 -2
  43. package/templates/scheduled/js/wrangler.toml +6 -0
  44. package/templates/scheduled/ts/tsconfig.json +36 -95
  45. package/templates/scheduled/ts/wrangler.toml +6 -0
  46. package/templates/svelte/c3.ts +34 -7
  47. package/templates-experimental/angular/c3.ts +24 -14
  48. package/templates-experimental/angular/templates/src/server.ts +15 -0
  49. package/templates-experimental/angular/templates/wrangler.toml +8 -2
  50. package/templates-experimental/astro/c3.ts +17 -33
  51. package/templates-experimental/astro/templates/js/wrangler.toml +12 -0
  52. package/templates-experimental/astro/templates/ts/worker-configuration.d.ts +4 -0
  53. package/templates-experimental/astro/templates/ts/wrangler.toml +12 -0
  54. package/templates-experimental/docusaurus/templates/wrangler.toml +7 -1
  55. package/templates-experimental/gatsby/templates/wrangler.toml +7 -1
  56. package/templates-experimental/hello-world-assets-only/c3.ts +15 -0
  57. package/templates-experimental/hello-world-assets-only/templates/package.json +13 -0
  58. package/templates-experimental/hello-world-assets-only/templates/public/index.html +11 -0
  59. package/templates-experimental/hello-world-assets-only/templates/wrangler.toml +10 -0
  60. package/templates-experimental/hello-world-durable-object-with-assets/c3.ts +23 -0
  61. package/templates-experimental/hello-world-durable-object-with-assets/js/.editorconfig +12 -0
  62. package/templates-experimental/hello-world-durable-object-with-assets/js/.prettierrc +6 -0
  63. package/templates-experimental/hello-world-durable-object-with-assets/js/__dot__gitignore +172 -0
  64. package/templates-experimental/hello-world-durable-object-with-assets/js/package.json +13 -0
  65. package/templates-experimental/hello-world-durable-object-with-assets/js/public/index.html +19 -0
  66. package/templates-experimental/hello-world-durable-object-with-assets/js/src/index.js +69 -0
  67. package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.toml +24 -0
  68. package/templates-experimental/hello-world-durable-object-with-assets/ts/.editorconfig +12 -0
  69. package/templates-experimental/hello-world-durable-object-with-assets/ts/.prettierrc +6 -0
  70. package/templates-experimental/hello-world-durable-object-with-assets/ts/__dot__gitignore +172 -0
  71. package/templates-experimental/hello-world-durable-object-with-assets/ts/package.json +15 -0
  72. package/templates-experimental/hello-world-durable-object-with-assets/ts/public/index.html +19 -0
  73. package/templates-experimental/hello-world-durable-object-with-assets/ts/src/index.ts +66 -0
  74. package/templates-experimental/hello-world-durable-object-with-assets/ts/tsconfig.json +42 -0
  75. package/templates-experimental/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +5 -0
  76. package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.toml +24 -0
  77. package/templates-experimental/hello-world-with-assets/c3.ts +2 -2
  78. package/templates-experimental/hello-world-with-assets/js/package.json +1 -1
  79. package/templates-experimental/hello-world-with-assets/js/public/index.html +13 -1
  80. package/templates-experimental/hello-world-with-assets/js/src/index.js +9 -1
  81. package/templates-experimental/hello-world-with-assets/js/test/index.spec.js +33 -12
  82. package/templates-experimental/hello-world-with-assets/js/wrangler.toml +7 -1
  83. package/templates-experimental/hello-world-with-assets/py/public/index.html +14 -2
  84. package/templates-experimental/hello-world-with-assets/py/src/entry.py +7 -2
  85. package/templates-experimental/hello-world-with-assets/py/wrangler.toml +7 -1
  86. package/templates-experimental/hello-world-with-assets/ts/package.json +1 -1
  87. package/templates-experimental/hello-world-with-assets/ts/public/index.html +13 -1
  88. package/templates-experimental/hello-world-with-assets/ts/src/index.ts +10 -2
  89. package/templates-experimental/hello-world-with-assets/ts/test/index.spec.ts +33 -17
  90. package/templates-experimental/hello-world-with-assets/ts/tsconfig.json +36 -95
  91. package/templates-experimental/hello-world-with-assets/ts/wrangler.toml +7 -1
  92. package/templates-experimental/hono/c3.ts +43 -0
  93. package/templates-experimental/hono/templates/public/index.html +19 -0
  94. package/templates-experimental/hono/templates/src/index.ts +9 -0
  95. package/templates-experimental/hono/templates/worker-configuration.d.ts +4 -0
  96. package/templates-experimental/hono/templates/wrangler.toml +5 -0
  97. package/templates-experimental/next/c3.ts +56 -0
  98. package/templates-experimental/next/templates/__dot__gitignore +42 -0
  99. package/templates-experimental/next/templates/env.d.ts +5 -0
  100. package/templates-experimental/next/templates/wrangler.toml +12 -0
  101. package/templates-experimental/nuxt/c3.ts +2 -2
  102. package/templates-experimental/nuxt/templates/wrangler.toml +8 -2
  103. package/templates-experimental/qwik/c3.ts +1 -1
  104. package/templates-experimental/qwik/templates/wrangler.toml +7 -1
  105. package/templates-experimental/remix/c3.ts +2 -27
  106. package/templates-experimental/remix/templates/public/.assetsignore +0 -4
  107. package/templates-experimental/remix/templates/wrangler.toml +8 -2
  108. package/templates-experimental/solid/c3.ts +7 -50
  109. package/templates-experimental/solid/templates/wrangler.toml +8 -2
  110. package/templates-experimental/svelte/c3.ts +4 -7
  111. package/templates-experimental/svelte/templates/wrangler.toml +11 -0
  112. package/templates-experimental/vue/c3.ts +33 -0
  113. package/templates-experimental/vue/templates/wrangler.toml +10 -0
  114. package/templates/angular/templates/server.ts +0 -34
  115. package/templates/angular/templates/tools/alter-polyfills.mjs +0 -27
  116. package/templates/angular/templates/tools/paths.mjs +0 -9
  117. package/templates-experimental/angular/templates/server.ts +0 -34
  118. package/templates-experimental/angular/templates/tools/alter-polyfills.mjs +0 -27
  119. package/templates-experimental/angular/templates/tools/copy-files.mjs +0 -9
  120. package/templates-experimental/angular/templates/tools/paths.mjs +0 -9
  121. package/templates-experimental/astro/templates/wrangler.toml +0 -6
  122. package/templates-experimental/nuxt/templates/cloudflare-preset/nitro.config.ts +0 -27
  123. package/templates-experimental/svelte/js/wrangler.toml +0 -5
  124. package/templates-experimental/svelte/ts/static/.assetsignore +0 -4
  125. package/templates-experimental/svelte/ts/wrangler.toml +0 -5
  126. /package/templates/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  127. /package/templates/svelte/{js → templates}/wrangler.toml +0 -0
  128. /package/templates-experimental/{angular/templates/src → astro/templates/js/public}/.assetsignore +0 -0
  129. /package/templates-experimental/astro/templates/{public → ts/public}/.assetsignore +0 -0
  130. /package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  131. /package/templates-experimental/svelte/{js → templates}/static/.assetsignore +0 -0
@@ -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"]
@@ -3,4 +3,10 @@ name = "<TBD>"
3
3
  main = "src/index.ts"
4
4
  compatibility_date = "<TBD>"
5
5
  compatibility_flags = ["nodejs_compat"]
6
- experimental_assets = { directory = "./public", binding = "ASSETS" }
6
+ assets = { directory = "./public", 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
@@ -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.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface CloudflareBindings {
4
+ }
@@ -0,0 +1,5 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ main = "src/index.ts"
4
+ compatibility_date = "<TBD>"
5
+ assets = { directory = "./public", binding = "ASSETS" }
@@ -0,0 +1,56 @@
1
+ import { brandColor, dim } from "@cloudflare/cli/colors";
2
+ import { runFrameworkGenerator } from "frameworks/index";
3
+ import { installPackages } from "helpers/packages";
4
+ import type { TemplateConfig } from "../../src/templates";
5
+ import type { C3Context } from "types";
6
+
7
+ const generate = async (ctx: C3Context) => {
8
+ await runFrameworkGenerator(ctx, [
9
+ ctx.project.name,
10
+ "--ts",
11
+ "--tailwind",
12
+ "--eslint",
13
+ "--app",
14
+ "--import-alias",
15
+ "@/*",
16
+ "--src-dir",
17
+ ]);
18
+ };
19
+
20
+ const configure = async () => {
21
+ const packages = ["@opennextjs/cloudflare", "@cloudflare/workers-types"];
22
+ await installPackages(packages, {
23
+ dev: true,
24
+ startText: "Adding the Cloudflare adapter",
25
+ doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`,
26
+ });
27
+ };
28
+
29
+ export default {
30
+ configVersion: 1,
31
+ id: "next",
32
+ frameworkCli: "create-next-app",
33
+ // TODO: here we need to specify a version of create-next-app which is different from the
34
+ // standard one used in the stable Next.js template, that's because our open-next adapter
35
+ // is not yet fully ready for Next.js 15, once it is we should remove the following
36
+ frameworkCliPinnedVersion: "14.2.5",
37
+ platform: "workers",
38
+ displayName: "Next (using Node.js compat + Workers Assets)",
39
+ path: "templates-experimental/next",
40
+ copyFiles: {
41
+ path: "./templates",
42
+ },
43
+ generate,
44
+ configure,
45
+ transformPackageJson: async () => ({
46
+ scripts: {
47
+ deploy: `cloudflare && wrangler deploy`,
48
+ preview: `cloudflare && wrangler dev`,
49
+ "cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`,
50
+ },
51
+ }),
52
+ devScript: "dev",
53
+ previewScript: "preview",
54
+ deployScript: "deploy",
55
+ compatibilityFlags: ["nodejs_compat"],
56
+ } as TemplateConfig;
@@ -0,0 +1,42 @@
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
+
39
+ # Cloudflare related
40
+ /.save.next
41
+ /.worker-next
42
+ /.wrangler
@@ -0,0 +1,5 @@
1
+ // Generated by Wrangler
2
+ // by running `wrangler types --env-interface CloudflareEnv env.d.ts`
3
+
4
+ interface CloudflareEnv {
5
+ }
@@ -0,0 +1,12 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<app-name>"
3
+ main = ".worker-next/index.mjs"
4
+
5
+ compatibility_date = "2024-09-26"
6
+ compatibility_flags = ["nodejs_compat"]
7
+
8
+ # Minification helps to keep the Worker bundle size down and improve start up time.
9
+ minify = true
10
+
11
+ # Use the new Workers + Assets to host the static frontend files
12
+ assets = { directory = ".worker-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
  };
@@ -82,7 +82,7 @@ const updateNuxtConfig = () => {
82
82
  b.objectExpression([
83
83
  b.objectProperty(
84
84
  b.identifier("preset"),
85
- b.stringLiteral("./cloudflare-preset"),
85
+ b.stringLiteral("cloudflare_module"),
86
86
  ),
87
87
  ]),
88
88
  );
@@ -1,5 +1,11 @@
1
1
  #:schema node_modules/wrangler/config-schema.json
2
2
  name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
- main = "./dist/worker/index.js"
5
- experimental_assets = { directory = "./dist/public", binding = "ASSETS" }
4
+ main = "./.output/server/index.mjs"
5
+ assets = { directory = "./.output/public/", binding = "ASSETS" }
6
+
7
+ # Workers Logs
8
+ # Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
9
+ # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
10
+ [observability]
11
+ enabled = true
@@ -13,7 +13,7 @@ import type { C3Context } from "types";
13
13
  const { npm, npx } = detectPackageManager();
14
14
 
15
15
  const generate = async (ctx: C3Context) => {
16
- await runFrameworkGenerator(ctx, ["basic", ctx.project.name]);
16
+ await runFrameworkGenerator(ctx, ["playground", ctx.project.name]);
17
17
  };
18
18
 
19
19
  const configure = async (ctx: C3Context) => {
@@ -3,4 +3,10 @@ name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  compatibility_flags = ["nodejs_compat"]
5
5
  main = "./dist/_worker.js"
6
- experimental_assets = { directory = "./dist", binding = "ASSET" }
6
+ assets = { directory = "./dist", binding = "ASSET" }
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
@@ -1,8 +1,6 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
2
  import { brandColor, dim } from "@cloudflare/cli/colors";
3
- import { spinner } from "@cloudflare/cli/interactive";
4
3
  import { runFrameworkGenerator } from "frameworks/index";
5
- import { transformFile } from "helpers/codemod";
6
4
  import { detectPackageManager } from "helpers/packageManagers";
7
5
  import { installPackages } from "helpers/packages";
8
6
  import type { TemplateConfig } from "../../src/templates";
@@ -14,7 +12,7 @@ const generate = async (ctx: C3Context) => {
14
12
  await runFrameworkGenerator(ctx, [
15
13
  ctx.project.name,
16
14
  "--template",
17
- "https://github.com/remix-run/remix/tree/main/templates/cloudflare",
15
+ "https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers",
18
16
  ]);
19
17
 
20
18
  logRaw(""); // newline
@@ -24,29 +22,8 @@ const configure = async () => {
24
22
  await installPackages(["wrangler@latest"], {
25
23
  dev: true,
26
24
  startText: "Updating the Wrangler version",
27
- doneText: `${brandColor(`updateed`)} ${dim("wrangler@latest")}`,
25
+ doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`,
28
26
  });
29
-
30
- const typeDefsPath = "load-context.ts";
31
-
32
- const s = spinner();
33
- s.start(`Updating \`${typeDefsPath}\``);
34
-
35
- // Remove the empty Env declaration from the template to allow the type from
36
- // worker-configuration.d.ts to take over
37
- transformFile(typeDefsPath, {
38
- visitTSInterfaceDeclaration(n) {
39
- if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
40
- return this.traverse(n);
41
- }
42
-
43
- // Removes the node
44
- n.replace();
45
- return false;
46
- },
47
- });
48
-
49
- s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
50
27
  };
51
28
 
52
29
  const config: TemplateConfig = {
@@ -63,8 +40,6 @@ const config: TemplateConfig = {
63
40
  configure,
64
41
  transformPackageJson: async () => ({
65
42
  scripts: {
66
- build:
67
- "remix vite:build && wrangler pages functions build --outdir build/worker",
68
43
  deploy: `${npm} run build && wrangler deploy`,
69
44
  preview: `${npm} run build && wrangler dev`,
70
45
  "cf-typegen": `wrangler types`,
@@ -1,4 +0,0 @@
1
- _worker.js
2
- _routes.json
3
- _headers
4
- _redirects
@@ -1,5 +1,11 @@
1
1
  #:schema node_modules/wrangler/config-schema.json
2
2
  name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
- main = "./build/worker/index.js"
5
- experimental_assets = { directory = "./build/client" }
4
+ main = "./server.ts"
5
+ assets = { directory = "./build/client" }
6
+
7
+ # Workers Logs
8
+ # Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
9
+ # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
10
+ [observability]
11
+ enabled = true
@@ -2,6 +2,7 @@ import { logRaw, updateStatus } from "@cloudflare/cli";
2
2
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { runFrameworkGenerator } from "frameworks/index";
4
4
  import { mergeObjectProperties, transformFile } from "helpers/codemod";
5
+ import { getWorkerdCompatibilityDate } from "helpers/compatDate";
5
6
  import { usesTypescript } from "helpers/files";
6
7
  import { detectPackageManager } from "helpers/packageManagers";
7
8
  import { installPackages } from "helpers/packages";
@@ -30,6 +31,8 @@ const configure = async (ctx: C3Context) => {
30
31
  usesTypescript(ctx);
31
32
  const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
32
33
 
34
+ const compatDate = await getWorkerdCompatibilityDate();
35
+
33
36
  updateStatus(`Updating configuration in ${blue(filePath)}`);
34
37
 
35
38
  transformFile(filePath, {
@@ -46,60 +49,14 @@ const configure = async (ctx: C3Context) => {
46
49
  b.objectProperty(
47
50
  b.identifier("server"),
48
51
  b.objectExpression([
49
- // preset: "cloudflare-pages"
52
+ // preset: "cloudflare_module"
50
53
  b.objectProperty(
51
54
  b.identifier("preset"),
52
- b.stringLiteral("./cloudflare-pages"),
53
- ),
54
- // output: {
55
- // dir: "{{ rootDir }}/dist",
56
- // publicDir: "{{ output.dir }}/public",
57
- // serverDir: "{{ output.dir }}/worker",
58
- // },
59
- b.objectProperty(
60
- b.identifier("output"),
61
- b.objectExpression([
62
- b.objectProperty(
63
- b.identifier("dir"),
64
- b.stringLiteral("{{ rootDir }}/dist"),
65
- ),
66
- b.objectProperty(
67
- b.identifier("publicDir"),
68
- b.stringLiteral("{{ output.dir }}/public"),
69
- ),
70
- b.objectProperty(
71
- b.identifier("serverDir"),
72
- b.stringLiteral("{{ output.dir }}/worker"),
73
- ),
74
- ]),
75
- ),
76
- // rollupConfig: {
77
- // external: ["node:async_hooks"],
78
- // },
79
- b.objectProperty(
80
- b.identifier("rollupConfig"),
81
- b.objectExpression([
82
- b.objectProperty(
83
- b.identifier("external"),
84
- b.arrayExpression([b.stringLiteral("node:async_hooks")]),
85
- ),
86
- ]),
55
+ b.stringLiteral("cloudflare_module"),
87
56
  ),
88
- // hooks: {
89
- // // Prevent the Pages preset from writing the _routes.json etc.
90
- // compiled() {},
91
- // },
92
57
  b.objectProperty(
93
- b.identifier("hooks"),
94
- b.objectExpression([
95
- b.objectMethod(
96
- "method",
97
- b.identifier("compiled"),
98
- [],
99
- b.blockStatement([]),
100
- false,
101
- ),
102
- ]),
58
+ b.identifier("compatibilityDate"),
59
+ b.stringLiteral(compatDate),
103
60
  ),
104
61
  ]),
105
62
  ),
@@ -2,5 +2,11 @@
2
2
  name = "<TBD>"
3
3
  compatibility_date = "<TBD>"
4
4
  compatibility_flags = ["nodejs_compat"]
5
- main = "./dist/worker/index.js"
6
- experimental_assets = { directory = "./dist/public", binding = "ASSETS" }
5
+ main = "./.output/server/index.mjs"
6
+ assets = { directory = "./.output/public", 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
@@ -13,7 +13,7 @@ import type { C3Context, PackageJson } from "types";
13
13
  const { npm } = detectPackageManager();
14
14
 
15
15
  const generate = async (ctx: C3Context) => {
16
- await runFrameworkGenerator(ctx, [ctx.project.name]);
16
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
17
17
 
18
18
  logRaw("");
19
19
  };
@@ -97,14 +97,11 @@ const updateTypeDefinitions = (ctx: C3Context) => {
97
97
  const config: TemplateConfig = {
98
98
  configVersion: 1,
99
99
  id: "svelte",
100
- frameworkCli: "create-svelte",
101
- displayName: "Svelte",
100
+ frameworkCli: "sv",
101
+ displayName: "SvelteKit",
102
102
  platform: "workers",
103
103
  copyFiles: {
104
- variants: {
105
- js: { path: "./js" },
106
- ts: { path: "./ts" },
107
- },
104
+ path: "./templates",
108
105
  },
109
106
  path: "templates-experimental/svelte",
110
107
  generate,
@@ -0,0 +1,11 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+ main = ".svelte-kit/cloudflare/_worker.js"
5
+ assets = { directory = ".svelte-kit/cloudflare", binding = "ASSETS" }
6
+
7
+ # Workers Logs
8
+ # Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
9
+ # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
10
+ [observability]
11
+ enabled = true