create-cloudflare 0.0.0-ecef68635 → 0.0.0-ed3bc2f3b

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 (180) hide show
  1. package/dist/cli.js +7669 -9338
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +13 -8
  4. package/templates/analog/templates/worker-configuration.d.ts +1 -1
  5. package/templates/analog/templates/wrangler.jsonc +5 -0
  6. package/templates/angular/c3.ts +25 -13
  7. package/templates/angular/templates/src/server.ts +15 -0
  8. package/templates/angular/templates/tools/copy-files.mjs +8 -2
  9. package/templates/astro/c3.ts +17 -33
  10. package/templates/astro/templates/js/wrangler.jsonc +8 -0
  11. package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
  12. package/templates/astro/templates/ts/wrangler.jsonc +8 -0
  13. package/templates/common/js/package.json +1 -1
  14. package/templates/common/js/wrangler.jsonc +8 -0
  15. package/templates/common/ts/package.json +1 -1
  16. package/templates/common/ts/src/index.ts +1 -1
  17. package/templates/common/ts/tsconfig.json +37 -95
  18. package/templates/common/ts/worker-configuration.d.ts +1 -1
  19. package/templates/common/ts/wrangler.jsonc +8 -0
  20. package/templates/hello-world/js/package.json +3 -3
  21. package/templates/hello-world/js/test/index.spec.js +1 -1
  22. package/templates/hello-world/js/vitest.config.js +1 -1
  23. package/templates/hello-world/js/wrangler.jsonc +8 -0
  24. package/templates/hello-world/py/package.json +1 -1
  25. package/templates/hello-world/py/wrangler.jsonc +9 -0
  26. package/templates/hello-world/ts/package.json +3 -3
  27. package/templates/hello-world/ts/src/index.ts +1 -1
  28. package/templates/hello-world/ts/test/tsconfig.json +1 -1
  29. package/templates/hello-world/ts/tsconfig.json +36 -95
  30. package/templates/hello-world/ts/vitest.config.mts +1 -1
  31. package/templates/hello-world/ts/worker-configuration.d.ts +1 -1
  32. package/templates/hello-world/ts/wrangler.jsonc +8 -0
  33. package/templates/hello-world-durable-object/js/package.json +1 -1
  34. package/templates/hello-world-durable-object/js/src/index.js +3 -3
  35. package/templates/hello-world-durable-object/js/wrangler.jsonc +24 -0
  36. package/templates/hello-world-durable-object/ts/package.json +1 -1
  37. package/templates/hello-world-durable-object/ts/src/index.ts +4 -4
  38. package/templates/hello-world-durable-object/ts/tsconfig.json +36 -95
  39. package/templates/hello-world-durable-object/ts/wrangler.jsonc +24 -0
  40. package/templates/hono/templates/worker-configuration.d.ts +1 -1
  41. package/templates/hono/templates/wrangler.jsonc +8 -0
  42. package/templates/next/README.md +3 -4
  43. package/templates/next/app/js/app/api/hello/route.js +4 -4
  44. package/templates/next/app/ts/app/api/hello/route.ts +4 -5
  45. package/templates/next/c3.ts +12 -30
  46. package/templates/next/wrangler.jsonc +8 -0
  47. package/templates/nuxt/c3.ts +1 -1
  48. package/templates/nuxt/templates/worker-configuration.d.ts +1 -1
  49. package/templates/nuxt/templates/wrangler.jsonc +8 -0
  50. package/templates/openapi/ts/package.json +1 -1
  51. package/templates/openapi/ts/worker-configuration.d.ts +1 -1
  52. package/templates/openapi/ts/wrangler.jsonc +8 -0
  53. package/templates/pre-existing/c3.ts +29 -10
  54. package/templates/pre-existing/js/package.json +1 -1
  55. package/templates/pre-existing/js/wrangler.jsonc +5 -0
  56. package/templates/queues/js/package.json +1 -1
  57. package/templates/queues/js/wrangler.jsonc +21 -0
  58. package/templates/queues/ts/package.json +1 -1
  59. package/templates/queues/ts/src/index.ts +1 -1
  60. package/templates/queues/ts/tsconfig.json +36 -95
  61. package/templates/queues/ts/worker-configuration.d.ts +1 -1
  62. package/templates/queues/ts/wrangler.jsonc +21 -0
  63. package/templates/qwik/templates/worker-configuration.d.ts +1 -1
  64. package/templates/qwik/templates/wrangler.jsonc +8 -0
  65. package/templates/remix/templates/worker-configuration.d.ts +1 -1
  66. package/templates/remix/templates/wrangler.jsonc +5 -0
  67. package/templates/scheduled/js/package.json +1 -1
  68. package/templates/scheduled/js/src/index.js +1 -1
  69. package/templates/scheduled/js/wrangler.jsonc +13 -0
  70. package/templates/scheduled/ts/package.json +1 -1
  71. package/templates/scheduled/ts/src/index.ts +4 -4
  72. package/templates/scheduled/ts/tsconfig.json +36 -95
  73. package/templates/scheduled/ts/worker-configuration.d.ts +1 -1
  74. package/templates/scheduled/ts/wrangler.jsonc +13 -0
  75. package/templates/solid/c3.ts +1 -1
  76. package/templates/solid/templates/wrangler.jsonc +8 -0
  77. package/templates/svelte/c3.ts +34 -7
  78. package/templates/svelte/templates/wrangler.jsonc +5 -0
  79. package/templates-experimental/angular/c3.ts +21 -7
  80. package/templates-experimental/angular/templates/src/server.ts +15 -0
  81. package/templates-experimental/angular/templates/wrangler.jsonc +12 -0
  82. package/templates-experimental/astro/c3.ts +17 -33
  83. package/templates-experimental/astro/templates/js/wrangler.jsonc +15 -0
  84. package/templates-experimental/astro/templates/ts/worker-configuration.d.ts +4 -0
  85. package/templates-experimental/astro/templates/ts/wrangler.jsonc +15 -0
  86. package/templates-experimental/docusaurus/templates/wrangler.jsonc +10 -0
  87. package/templates-experimental/gatsby/templates/wrangler.jsonc +10 -0
  88. package/templates-experimental/hello-world-assets-only/templates/wrangler.jsonc +10 -0
  89. package/templates-experimental/hello-world-durable-object-with-assets/js/package.json +1 -1
  90. package/templates-experimental/hello-world-durable-object-with-assets/js/src/index.js +3 -3
  91. package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.jsonc +28 -0
  92. package/templates-experimental/hello-world-durable-object-with-assets/ts/package.json +1 -1
  93. package/templates-experimental/hello-world-durable-object-with-assets/ts/src/index.ts +3 -3
  94. package/templates-experimental/hello-world-durable-object-with-assets/ts/tsconfig.json +36 -95
  95. package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.jsonc +28 -0
  96. package/templates-experimental/hello-world-with-assets/js/package.json +3 -3
  97. package/templates-experimental/hello-world-with-assets/js/vitest.config.js +1 -1
  98. package/templates-experimental/hello-world-with-assets/js/wrangler.jsonc +15 -0
  99. package/templates-experimental/hello-world-with-assets/py/package.json +1 -1
  100. package/templates-experimental/hello-world-with-assets/py/wrangler.jsonc +15 -0
  101. package/templates-experimental/hello-world-with-assets/ts/package.json +3 -3
  102. package/templates-experimental/hello-world-with-assets/ts/src/index.ts +1 -1
  103. package/templates-experimental/hello-world-with-assets/ts/tsconfig.json +36 -95
  104. package/templates-experimental/hello-world-with-assets/ts/vitest.config.mts +1 -1
  105. package/templates-experimental/hello-world-with-assets/ts/worker-configuration.d.ts +1 -1
  106. package/templates-experimental/hello-world-with-assets/ts/wrangler.jsonc +15 -0
  107. package/templates-experimental/hono/templates/worker-configuration.d.ts +1 -1
  108. package/templates-experimental/hono/templates/wrangler.jsonc +9 -0
  109. package/templates-experimental/next/c3.ts +37 -5
  110. package/templates-experimental/next/templates/.dev.vars +2 -0
  111. package/templates-experimental/next/templates/__dot__gitignore +2 -5
  112. package/templates-experimental/next/templates/cloudflare-env.d.ts +5 -0
  113. package/templates-experimental/next/templates/open-next.config.ts +28 -0
  114. package/templates-experimental/next/templates/wrangler.jsonc +13 -0
  115. package/templates-experimental/nuxt/c3.ts +2 -2
  116. package/templates-experimental/nuxt/templates/worker-configuration.d.ts +1 -1
  117. package/templates-experimental/nuxt/templates/wrangler.jsonc +12 -0
  118. package/templates-experimental/qwik/templates/worker-configuration.d.ts +1 -1
  119. package/templates-experimental/qwik/templates/wrangler.jsonc +15 -0
  120. package/templates-experimental/remix/c3.ts +1 -26
  121. package/templates-experimental/remix/templates/public/.assetsignore +0 -4
  122. package/templates-experimental/remix/templates/wrangler.toml +1 -1
  123. package/templates-experimental/solid/c3.ts +8 -51
  124. package/templates-experimental/solid/templates/wrangler.jsonc +15 -0
  125. package/templates-experimental/svelte/c3.ts +4 -7
  126. package/templates-experimental/svelte/templates/wrangler.jsonc +12 -0
  127. package/templates-experimental/vue/c3.ts +33 -0
  128. package/templates-experimental/vue/templates/wrangler.jsonc +10 -0
  129. package/templates/analog/templates/wrangler.toml +0 -85
  130. package/templates/angular/templates/server.ts +0 -34
  131. package/templates/angular/templates/tools/alter-polyfills.mjs +0 -27
  132. package/templates/angular/templates/tools/paths.mjs +0 -9
  133. package/templates/astro/templates/wrangler.toml +0 -85
  134. package/templates/common/js/wrangler.toml +0 -113
  135. package/templates/common/ts/wrangler.toml +0 -113
  136. package/templates/hello-world/js/wrangler.toml +0 -114
  137. package/templates/hello-world/py/wrangler.toml +0 -114
  138. package/templates/hello-world/ts/wrangler.toml +0 -114
  139. package/templates/hello-world-durable-object/js/wrangler.toml +0 -113
  140. package/templates/hello-world-durable-object/ts/wrangler.toml +0 -113
  141. package/templates/hono/templates/wrangler.toml +0 -113
  142. package/templates/next/wrangler.toml +0 -86
  143. package/templates/nuxt/templates/wrangler.toml +0 -86
  144. package/templates/openapi/ts/wrangler.toml +0 -113
  145. package/templates/pre-existing/js/wrangler.toml +0 -4
  146. package/templates/queues/js/wrangler.toml +0 -118
  147. package/templates/queues/ts/wrangler.toml +0 -118
  148. package/templates/qwik/templates/wrangler.toml +0 -86
  149. package/templates/remix/templates/wrangler.toml +0 -85
  150. package/templates/scheduled/js/wrangler.toml +0 -119
  151. package/templates/scheduled/ts/wrangler.toml +0 -119
  152. package/templates/solid/templates/wrangler.toml +0 -84
  153. package/templates/svelte/js/wrangler.toml +0 -85
  154. package/templates/svelte/ts/wrangler.toml +0 -85
  155. package/templates-experimental/angular/templates/server.ts +0 -34
  156. package/templates-experimental/angular/templates/tools/alter-polyfills.mjs +0 -32
  157. package/templates-experimental/angular/templates/wrangler.toml +0 -11
  158. package/templates-experimental/astro/templates/wrangler.toml +0 -12
  159. package/templates-experimental/docusaurus/templates/wrangler.toml +0 -10
  160. package/templates-experimental/gatsby/templates/wrangler.toml +0 -10
  161. package/templates-experimental/hello-world-assets-only/templates/wrangler.toml +0 -10
  162. package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.toml +0 -24
  163. package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.toml +0 -24
  164. package/templates-experimental/hello-world-with-assets/js/wrangler.toml +0 -12
  165. package/templates-experimental/hello-world-with-assets/py/wrangler.toml +0 -12
  166. package/templates-experimental/hello-world-with-assets/ts/wrangler.toml +0 -12
  167. package/templates-experimental/hono/templates/wrangler.toml +0 -5
  168. package/templates-experimental/next/templates/env.d.ts +0 -5
  169. package/templates-experimental/next/templates/wrangler.toml +0 -12
  170. package/templates-experimental/nuxt/templates/cloudflare-preset/nitro.config.ts +0 -27
  171. package/templates-experimental/nuxt/templates/wrangler.toml +0 -11
  172. package/templates-experimental/qwik/templates/wrangler.toml +0 -12
  173. package/templates-experimental/solid/templates/wrangler.toml +0 -12
  174. package/templates-experimental/svelte/js/wrangler.toml +0 -11
  175. package/templates-experimental/svelte/ts/wrangler.toml +0 -11
  176. /package/templates/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  177. /package/templates-experimental/astro/templates/{public → js/public}/.assetsignore +0 -0
  178. /package/templates-experimental/{svelte/js/static → astro/templates/ts/public}/.assetsignore +0 -0
  179. /package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
  180. /package/templates-experimental/svelte/{ts → templates}/static/.assetsignore +0 -0
@@ -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,13 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.ts",
4
+ "compatibility_date": "<TBD>",
5
+ "observability": {
6
+ "enabled": true
7
+ },
8
+ "triggers": {
9
+ "crons": [
10
+ "* * * * *"
11
+ ]
12
+ }
13
+ }
@@ -66,7 +66,7 @@ const config: TemplateConfig = {
66
66
  configVersion: 1,
67
67
  id: "solid",
68
68
  frameworkCli: "create-solid",
69
- displayName: "Solid",
69
+ displayName: "SolidStart",
70
70
  platform: "pages",
71
71
  copyFiles: {
72
72
  path: "./templates",
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "compatibility_flags": [
5
+ "nodejs_compat"
6
+ ],
7
+ "pages_build_output_dir": "./dist"
8
+ }
@@ -1,3 +1,4 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { platform } from "node:os";
2
3
  import { logRaw, updateStatus } from "@cloudflare/cli";
3
4
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
@@ -13,7 +14,7 @@ import type { C3Context, PackageJson } from "types";
13
14
  const { npm } = detectPackageManager();
14
15
 
15
16
  const generate = async (ctx: C3Context) => {
16
- await runFrameworkGenerator(ctx, [ctx.project.name]);
17
+ await runFrameworkGenerator(ctx, ["create", ctx.project.name]);
17
18
 
18
19
  logRaw("");
19
20
  };
@@ -28,6 +29,7 @@ const configure = async (ctx: C3Context) => {
28
29
  });
29
30
 
30
31
  updateSvelteConfig();
32
+ updatePlaywrightConfig(usesTypescript(ctx));
31
33
  updateTypeDefinitions(ctx);
32
34
  };
33
35
 
@@ -49,6 +51,34 @@ const updateSvelteConfig = () => {
49
51
  });
50
52
  };
51
53
 
54
+ const updatePlaywrightConfig = (shouldUseTypescript: boolean) => {
55
+ const filePath = `playwright.config.${shouldUseTypescript ? "ts" : "js"}`;
56
+ if (!existsSync(filePath)) {
57
+ return;
58
+ }
59
+
60
+ updateStatus(`Changing webServer port in ${blue(filePath)}`);
61
+
62
+ transformFile(filePath, {
63
+ visitObjectExpression: function (n) {
64
+ const portProp = n.node.properties.find((prop) => {
65
+ if (!("key" in prop) || !("name" in prop.key)) {
66
+ return false;
67
+ }
68
+
69
+ return prop.key.name === "port";
70
+ });
71
+
72
+ if (!portProp || !("value" in portProp) || !("value" in portProp.value)) {
73
+ return this.traverse(n);
74
+ }
75
+
76
+ portProp.value.value = 8788;
77
+ return false;
78
+ },
79
+ });
80
+ };
81
+
52
82
  const updateTypeDefinitions = (ctx: C3Context) => {
53
83
  if (!usesTypescript(ctx)) {
54
84
  return;
@@ -97,14 +127,11 @@ const updateTypeDefinitions = (ctx: C3Context) => {
97
127
  const config: TemplateConfig = {
98
128
  configVersion: 1,
99
129
  id: "svelte",
100
- frameworkCli: "create-svelte",
101
- displayName: "Svelte",
130
+ frameworkCli: "sv",
131
+ displayName: "SvelteKit",
102
132
  platform: "pages",
103
133
  copyFiles: {
104
- variants: {
105
- js: { path: "./js" },
106
- ts: { path: "./ts" },
107
- },
134
+ path: "./templates",
108
135
  },
109
136
  generate,
110
137
  configure,
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "pages_build_output_dir": ".svelte-kit/cloudflare"
5
+ }
@@ -12,7 +12,11 @@ import type { C3Context } from "types";
12
12
  const { npm } = detectPackageManager();
13
13
 
14
14
  const generate = async (ctx: C3Context) => {
15
- await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
15
+ await runFrameworkGenerator(ctx, [
16
+ ctx.project.name,
17
+ "--ssr",
18
+ "--server-routing" /** Dev Preview API */,
19
+ ]);
16
20
  logRaw("");
17
21
  };
18
22
 
@@ -23,9 +27,9 @@ const configure = async (ctx: C3Context) => {
23
27
  };
24
28
 
25
29
  async function installCFWorker() {
26
- await installPackages(["@cloudflare/workers-types", "wrangler"], {
30
+ await installPackages(["xhr2"], {
27
31
  dev: true,
28
- startText: "Installing adapter dependencies",
32
+ startText: "Installing additional dependencies",
29
33
  doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
30
34
  });
31
35
  }
@@ -46,12 +50,21 @@ async function updateAppCode() {
46
50
  writeFile(resolve(appConfigPath), newAppConfig);
47
51
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
48
52
 
53
+ // Update an app server routes file to:
54
+ const appServerRoutesPath = "src/app/app.routes.server.ts";
55
+ const appRoutes = readFile(resolve(appServerRoutesPath));
56
+ const newAppRoutes = appRoutes.replace(
57
+ "RenderMode.Prerender",
58
+ "RenderMode.Server",
59
+ );
60
+ writeFile(resolve(appServerRoutesPath), newAppRoutes);
61
+ s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
62
+
49
63
  // Remove unwanted dependencies
50
64
  s.start(`Updating package.json`);
51
65
  const packageJsonPath = resolve("package.json");
52
66
  const packageManifest = readJSON(packageJsonPath);
53
67
 
54
- delete packageManifest["dependencies"]["@angular/ssr"];
55
68
  delete packageManifest["dependencies"]["express"];
56
69
  delete packageManifest["devDependencies"]["@types/express"];
57
70
 
@@ -66,7 +79,8 @@ function updateAngularJson(ctx: C3Context) {
66
79
  // Update builder
67
80
  const architectSection = angularJson.projects[ctx.project.name].architect;
68
81
  architectSection.build.options.outputPath = "dist";
69
- architectSection.build.options.assets.push("src/_routes.json");
82
+ architectSection.build.options.outputMode = "server";
83
+ architectSection.build.options.ssr.experimentalPlatform = "neutral";
70
84
 
71
85
  writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
72
86
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
@@ -84,13 +98,13 @@ const config: TemplateConfig = {
84
98
  path: "templates-experimental/angular",
85
99
  devScript: "start",
86
100
  deployScript: "deploy",
101
+ previewScript: "start",
87
102
  generate,
88
103
  configure,
89
104
  transformPackageJson: async () => ({
90
105
  scripts: {
91
106
  start: `${npm} run build && wrangler dev`,
92
- build: `ng build && ${npm} run process`,
93
- process: "node ./tools/alter-polyfills.mjs",
107
+ build: `ng build`,
94
108
  deploy: `${npm} run build && wrangler deploy`,
95
109
  },
96
110
  }),
@@ -0,0 +1,15 @@
1
+ import { AngularAppEngine, createRequestHandler } from '@angular/ssr';
2
+
3
+ const angularApp = new AngularAppEngine();
4
+
5
+ /**
6
+ * This is a request handler used by the Angular CLI (dev-server and during build).
7
+ */
8
+ export const reqHandler = createRequestHandler(async (req) => {
9
+ const res = await angularApp.handle(req);
10
+
11
+ return res ?? new Response('Page not found.', { status: 404 });
12
+ });
13
+
14
+
15
+ export default { fetch: reqHandler };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "./dist/server/server.mjs",
4
+ "compatibility_date": "<TBD>",
5
+ "assets": {
6
+ "binding": "ASSETS",
7
+ "directory": "./dist/browser"
8
+ },
9
+ "observability": {
10
+ "enabled": true
11
+ }
12
+ }
@@ -1,7 +1,7 @@
1
1
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
2
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { runFrameworkGenerator } from "frameworks/index";
4
- import { loadTemplateSnippets, transformFile } from "helpers/codemod";
4
+ import { transformFile } from "helpers/codemod";
5
5
  import { runCommand } from "helpers/command";
6
6
  import { usesTypescript } from "helpers/files";
7
7
  import { detectPackageManager } from "helpers/packageManagers";
@@ -17,7 +17,7 @@ const generate = async (ctx: C3Context) => {
17
17
  logRaw(""); // newline
18
18
  };
19
19
 
20
- const configure = async (ctx: C3Context) => {
20
+ const configure = async () => {
21
21
  await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
22
22
  silent: true,
23
23
  startText: "Installing adapter",
@@ -27,7 +27,6 @@ const configure = async (ctx: C3Context) => {
27
27
  });
28
28
 
29
29
  updateAstroConfig();
30
- updateEnvDeclaration(ctx);
31
30
  };
32
31
 
33
32
  const updateAstroConfig = () => {
@@ -59,35 +58,6 @@ const updateAstroConfig = () => {
59
58
  });
60
59
  };
61
60
 
62
- const updateEnvDeclaration = (ctx: C3Context) => {
63
- if (!usesTypescript(ctx)) {
64
- return;
65
- }
66
-
67
- const filePath = "src/env.d.ts";
68
-
69
- updateStatus(`Adding type declarations in ${blue(filePath)}`);
70
-
71
- transformFile(filePath, {
72
- visitProgram: function (n) {
73
- const snippets = loadTemplateSnippets(ctx);
74
- const patch = snippets.runtimeDeclarationTs;
75
- const b = recast.types.builders;
76
-
77
- // Preserve comments with the new body
78
- const comments = n.get("comments").value;
79
- n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
80
- b.commentLine(c.value),
81
- );
82
-
83
- // Add the patch
84
- n.get("body").push(...patch);
85
-
86
- return false;
87
- },
88
- });
89
- };
90
-
91
61
  const config: TemplateConfig = {
92
62
  configVersion: 1,
93
63
  id: "astro",
@@ -95,7 +65,21 @@ const config: TemplateConfig = {
95
65
  platform: "workers",
96
66
  displayName: "Astro",
97
67
  copyFiles: {
98
- path: "./templates",
68
+ async selectVariant(ctx) {
69
+ // Note: this `selectVariant` function should not be needed
70
+ // this is just a quick workaround until
71
+ // https://github.com/cloudflare/workers-sdk/issues/7495
72
+ // is resolved
73
+ return usesTypescript(ctx) ? "ts" : "js";
74
+ },
75
+ variants: {
76
+ js: {
77
+ path: "./templates/js",
78
+ },
79
+ ts: {
80
+ path: "./templates/ts",
81
+ },
82
+ },
99
83
  },
100
84
  devScript: "dev",
101
85
  deployScript: "deploy",
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "./dist/_worker.js/index.js",
4
+ "compatibility_date": "<TBD>",
5
+ "compatibility_flags": [
6
+ "nodejs_compat"
7
+ ],
8
+ "assets": {
9
+ "binding": "ASSETS",
10
+ "directory": "./dist"
11
+ },
12
+ "observability": {
13
+ "enabled": true
14
+ }
15
+ }
@@ -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 Env {
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "./dist/_worker.js/index.js",
4
+ "compatibility_date": "<TBD>",
5
+ "compatibility_flags": [
6
+ "nodejs_compat"
7
+ ],
8
+ "assets": {
9
+ "binding": "ASSETS",
10
+ "directory": "./dist"
11
+ },
12
+ "observability": {
13
+ "enabled": true
14
+ }
15
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "assets": {
5
+ "directory": "./build"
6
+ },
7
+ "observability": {
8
+ "enabled": true
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "assets": {
5
+ "directory": "./public"
6
+ },
7
+ "observability": {
8
+ "enabled": true
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "assets": {
5
+ "directory": "./public"
6
+ },
7
+ "observability": {
8
+ "enabled": true
9
+ }
10
+ }
@@ -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
  }
@@ -11,7 +11,7 @@ import { DurableObject } from "cloudflare:workers";
11
11
  */
12
12
 
13
13
  /**
14
- * Env provides a mechanism to reference bindings declared in wrangler.toml within JavaScript
14
+ * Env provides a mechanism to reference bindings declared in wrangler.jsonc within JavaScript
15
15
  *
16
16
  * @typedef {Object} Env
17
17
  * @property {DurableObjectNamespace} MY_DURABLE_OBJECT - The Durable Object namespace binding
@@ -24,7 +24,7 @@ export class MyDurableObject extends DurableObject {
24
24
  * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
25
25
  *
26
26
  * @param {DurableObjectState} ctx - The interface for interacting with Durable Object state
27
- * @param {Env} env - The interface to reference bindings declared in wrangler.toml
27
+ * @param {Env} env - The interface to reference bindings declared in wrangler.jsonc
28
28
  */
29
29
  constructor(ctx, env) {
30
30
  super(ctx, env);
@@ -47,7 +47,7 @@ export default {
47
47
  * This is the standard fetch handler for a Cloudflare Worker
48
48
  *
49
49
  * @param {Request} request - The request submitted to the Worker from the client
50
- * @param {Env} env - The interface to reference bindings declared in wrangler.toml
50
+ * @param {Env} env - The interface to reference bindings declared in wrangler.jsonc
51
51
  * @param {ExecutionContext} ctx - The execution context of the Worker
52
52
  * @returns {Promise<Response>} The response to be sent back to the client
53
53
  */
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "main": "src/index.js",
4
+ "compatibility_date": "<TBD>",
5
+ "assets": {
6
+ "binding": "ASSETS",
7
+ "directory": "./public"
8
+ },
9
+ "durable_objects": {
10
+ "bindings": [
11
+ {
12
+ "class_name": "MyDurableObject",
13
+ "name": "MY_DURABLE_OBJECT"
14
+ }
15
+ ]
16
+ },
17
+ "migrations": [
18
+ {
19
+ "new_classes": [
20
+ "MyDurableObject"
21
+ ],
22
+ "tag": "v1"
23
+ }
24
+ ],
25
+ "observability": {
26
+ "enabled": true
27
+ }
28
+ }
@@ -10,6 +10,6 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "typescript": "^5.5.2",
13
- "wrangler": "^3.60.3"
13
+ "wrangler": "^3.101.0"
14
14
  }
15
15
  }
@@ -7,7 +7,7 @@ import { DurableObject } from "cloudflare:workers";
7
7
  * - Open a browser tab at http://localhost:8787/ to see your Durable Object in action
8
8
  * - Run `npm run deploy` to publish your application
9
9
  *
10
- * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
10
+ * Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the
11
11
  * `Env` object can be regenerated with `npm run cf-typegen`.
12
12
  *
13
13
  * Learn more at https://developers.cloudflare.com/durable-objects
@@ -21,7 +21,7 @@ export class MyDurableObject extends DurableObject {
21
21
  * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
22
22
  *
23
23
  * @param ctx - The interface for interacting with Durable Object state
24
- * @param env - The interface to reference bindings declared in wrangler.toml
24
+ * @param env - The interface to reference bindings declared in wrangler.jsonc
25
25
  */
26
26
  constructor(ctx: DurableObjectState, env: Env) {
27
27
  super(ctx, env);
@@ -44,7 +44,7 @@ export default {
44
44
  * This is the standard fetch handler for a Cloudflare Worker
45
45
  *
46
46
  * @param request - The request submitted to the Worker from the client
47
- * @param env - The interface to reference bindings declared in wrangler.toml
47
+ * @param env - The interface to reference bindings declared in wrangler.jsonc
48
48
  * @param ctx - The execution context of the Worker
49
49
  * @returns The response to be sent back to the client
50
50
  */
@@ -2,100 +2,41 @@
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": "node" /* 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": "node",
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
  }