create-cloudflare 0.0.0-d031e75a → 0.0.0-d04c69f81

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 (299) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +53093 -50411
  3. package/package.json +39 -29
  4. package/templates/analog/c3.ts +135 -0
  5. package/templates/analog/snippets/devBindingsModule.ts +7 -0
  6. package/templates/analog/templates/env.d.ts +13 -0
  7. package/templates/analog/templates/src/dev-bindings.ts +18 -0
  8. package/templates/analog/templates/worker-configuration.d.ts +4 -0
  9. package/templates/analog/templates/wrangler.jsonc +5 -0
  10. package/templates/angular/c3.ts +5 -96
  11. package/templates/angular/pages/c3.ts +135 -0
  12. package/templates/angular/pages/templates/src/server.ts +15 -0
  13. package/templates/angular/pages/templates/tools/copy-files.mjs +15 -0
  14. package/templates/angular/workers/c3.ts +130 -0
  15. package/templates/angular/workers/templates/src/server.ts +15 -0
  16. package/templates/angular/workers/templates/wrangler.jsonc +12 -0
  17. package/templates/astro/c3.ts +5 -46
  18. package/templates/astro/pages/c3.ts +99 -0
  19. package/templates/astro/pages/templates/js/wrangler.jsonc +8 -0
  20. package/templates/astro/pages/templates/ts/src/env.d.ts +5 -0
  21. package/templates/astro/pages/templates/ts/worker-configuration.d.ts +4 -0
  22. package/templates/astro/pages/templates/ts/wrangler.jsonc +8 -0
  23. package/templates/astro/workers/c3.ts +98 -0
  24. package/templates/astro/workers/templates/js/public/.assetsignore +2 -0
  25. package/templates/astro/workers/templates/js/wrangler.jsonc +15 -0
  26. package/templates/astro/workers/templates/ts/public/.assetsignore +2 -0
  27. package/templates/astro/workers/templates/ts/src/env.d.ts +5 -0
  28. package/templates/astro/workers/templates/ts/worker-configuration.d.ts +4 -0
  29. package/templates/astro/workers/templates/ts/wrangler.jsonc +15 -0
  30. package/templates/common/c3.ts +15 -7
  31. package/templates/common/js/.editorconfig +0 -1
  32. package/templates/common/js/package.json +1 -1
  33. package/templates/common/js/wrangler.jsonc +8 -0
  34. package/templates/common/ts/.editorconfig +0 -1
  35. package/templates/common/ts/package.json +4 -3
  36. package/templates/common/ts/src/ab-test.ts +2 -2
  37. package/templates/common/ts/src/index.ts +5 -2
  38. package/templates/common/ts/src/proxy.ts +2 -2
  39. package/templates/common/ts/src/redirect.ts +2 -2
  40. package/templates/common/ts/tsconfig.json +37 -95
  41. package/templates/common/ts/worker-configuration.d.ts +2 -14
  42. package/templates/common/ts/wrangler.jsonc +8 -0
  43. package/templates/docusaurus/c3.ts +5 -23
  44. package/templates/docusaurus/pages/c3.ts +31 -0
  45. package/templates/docusaurus/workers/c3.ts +33 -0
  46. package/templates/docusaurus/workers/templates/wrangler.jsonc +10 -0
  47. package/templates/gatsby/c3.ts +5 -42
  48. package/templates/gatsby/pages/c3.ts +51 -0
  49. package/templates/gatsby/workers/c3.ts +53 -0
  50. package/templates/gatsby/workers/templates/wrangler.jsonc +10 -0
  51. package/templates/hello-world/c3.ts +30 -8
  52. package/templates/hello-world/js/.editorconfig +0 -1
  53. package/templates/hello-world/js/package.json +5 -2
  54. package/templates/hello-world/js/test/index.spec.js +20 -0
  55. package/templates/hello-world/js/vitest.config.js +11 -0
  56. package/templates/hello-world/js/wrangler.jsonc +8 -0
  57. package/templates/hello-world/py/.python-version +1 -0
  58. package/templates/hello-world/py/README.md +23 -0
  59. package/templates/hello-world/py/package.json +13 -0
  60. package/templates/hello-world/py/pyproject.toml +9 -0
  61. package/templates/hello-world/py/src/entry.py +4 -0
  62. package/templates/hello-world/py/uv.lock +22 -0
  63. package/templates/hello-world/py/wrangler.jsonc +9 -0
  64. package/templates/hello-world/ts/.editorconfig +0 -1
  65. package/templates/hello-world/ts/package.json +7 -3
  66. package/templates/hello-world/ts/src/index.ts +5 -19
  67. package/templates/hello-world/ts/test/env.d.ts +3 -0
  68. package/templates/hello-world/ts/test/index.spec.ts +25 -0
  69. package/templates/hello-world/ts/test/tsconfig.json +8 -0
  70. package/templates/hello-world/ts/tsconfig.json +39 -96
  71. package/templates/hello-world/ts/vitest.config.mts +11 -0
  72. package/templates/hello-world/ts/worker-configuration.d.ts +8 -0
  73. package/templates/hello-world/ts/wrangler.jsonc +8 -0
  74. package/templates/hello-world-assets-only/c3.ts +16 -0
  75. package/templates/hello-world-assets-only/templates/package.json +13 -0
  76. package/templates/hello-world-assets-only/templates/public/index.html +11 -0
  77. package/templates/hello-world-assets-only/templates/wrangler.jsonc +10 -0
  78. package/templates/hello-world-durable-object/c3.ts +14 -8
  79. package/templates/hello-world-durable-object/js/.editorconfig +0 -1
  80. package/templates/hello-world-durable-object/js/package.json +1 -1
  81. package/templates/hello-world-durable-object/js/src/index.js +28 -23
  82. package/templates/hello-world-durable-object/js/wrangler.jsonc +24 -0
  83. package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
  84. package/templates/hello-world-durable-object/ts/package.json +4 -4
  85. package/templates/hello-world-durable-object/ts/src/index.ts +32 -44
  86. package/templates/hello-world-durable-object/ts/tsconfig.json +36 -95
  87. package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +7 -0
  88. package/templates/hello-world-durable-object/ts/wrangler.jsonc +24 -0
  89. package/templates/hello-world-durable-object-with-assets/c3.ts +23 -0
  90. package/templates/hello-world-durable-object-with-assets/js/.editorconfig +12 -0
  91. package/templates/hello-world-durable-object-with-assets/js/.prettierrc +6 -0
  92. package/templates/hello-world-durable-object-with-assets/js/package.json +13 -0
  93. package/templates/hello-world-durable-object-with-assets/js/public/index.html +19 -0
  94. package/templates/hello-world-durable-object-with-assets/js/src/index.js +70 -0
  95. package/templates/hello-world-durable-object-with-assets/js/wrangler.jsonc +28 -0
  96. package/templates/hello-world-durable-object-with-assets/ts/.editorconfig +12 -0
  97. package/templates/hello-world-durable-object-with-assets/ts/.prettierrc +6 -0
  98. package/templates/hello-world-durable-object-with-assets/ts/package.json +15 -0
  99. package/templates/hello-world-durable-object-with-assets/ts/public/index.html +19 -0
  100. package/templates/hello-world-durable-object-with-assets/ts/src/index.ts +67 -0
  101. package/templates/hello-world-durable-object-with-assets/ts/tsconfig.json +42 -0
  102. package/templates/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +8 -0
  103. package/templates/hello-world-durable-object-with-assets/ts/wrangler.jsonc +28 -0
  104. package/templates/hello-world-with-assets/c3.ts +25 -0
  105. package/templates/hello-world-with-assets/js/.editorconfig +12 -0
  106. package/templates/hello-world-with-assets/js/.prettierrc +6 -0
  107. package/templates/hello-world-with-assets/js/package.json +16 -0
  108. package/templates/hello-world-with-assets/js/public/index.html +31 -0
  109. package/templates/hello-world-with-assets/js/src/index.js +23 -0
  110. package/templates/hello-world-with-assets/js/test/index.spec.js +41 -0
  111. package/templates/hello-world-with-assets/js/vitest.config.js +11 -0
  112. package/templates/hello-world-with-assets/js/wrangler.jsonc +15 -0
  113. package/templates/hello-world-with-assets/py/package.json +13 -0
  114. package/templates/hello-world-with-assets/py/public/index.html +31 -0
  115. package/templates/hello-world-with-assets/py/src/entry.py +9 -0
  116. package/templates/hello-world-with-assets/py/wrangler.jsonc +15 -0
  117. package/templates/hello-world-with-assets/ts/.editorconfig +12 -0
  118. package/templates/hello-world-with-assets/ts/.prettierrc +6 -0
  119. package/templates/hello-world-with-assets/ts/package.json +18 -0
  120. package/templates/hello-world-with-assets/ts/public/index.html +31 -0
  121. package/templates/hello-world-with-assets/ts/src/index.ts +26 -0
  122. package/templates/hello-world-with-assets/ts/test/env.d.ts +3 -0
  123. package/templates/hello-world-with-assets/ts/test/index.spec.ts +41 -0
  124. package/templates/hello-world-with-assets/ts/test/tsconfig.json +8 -0
  125. package/templates/hello-world-with-assets/ts/tsconfig.json +44 -0
  126. package/templates/hello-world-with-assets/ts/vitest.config.mts +11 -0
  127. package/templates/hello-world-with-assets/ts/worker-configuration.d.ts +7 -0
  128. package/templates/hello-world-with-assets/ts/wrangler.jsonc +15 -0
  129. package/templates/hono/c3.ts +5 -21
  130. package/templates/hono/pages/c3.ts +44 -0
  131. package/templates/hono/pages/templates/src/index.tsx +12 -0
  132. package/templates/hono/pages/templates/worker-configuration.d.ts +4 -0
  133. package/templates/hono/pages/templates/wrangler.jsonc +8 -0
  134. package/templates/hono/workers/c3.ts +42 -0
  135. package/templates/hono/workers/templates/public/index.html +19 -0
  136. package/templates/hono/workers/templates/src/index.ts +9 -0
  137. package/templates/hono/workers/templates/worker-configuration.d.ts +4 -0
  138. package/templates/hono/workers/templates/wrangler.jsonc +9 -0
  139. package/templates/next/c3.ts +7 -209
  140. package/templates/next/pages/README.md +67 -0
  141. package/templates/next/pages/app/js/app/api/hello/route.js +21 -0
  142. package/templates/next/pages/app/js/app/not-found.js +58 -0
  143. package/templates/next/pages/app/ts/app/api/hello/route.ts +21 -0
  144. package/templates/next/pages/app/ts/app/not-found.tsx +58 -0
  145. package/templates/next/pages/c3.ts +225 -0
  146. package/templates/next/pages/env.d.ts +5 -0
  147. package/templates/next/pages/pages/js/pages/api/hello.js +23 -0
  148. package/templates/next/pages/pages/ts/pages/api/hello.ts +24 -0
  149. package/templates/next/pages/wrangler.jsonc +8 -0
  150. package/templates/next/workers/c3.ts +74 -0
  151. package/templates/next/workers/templates/.dev.vars +2 -0
  152. package/templates/next/workers/templates/cloudflare-env.d.ts +5 -0
  153. package/templates/next/workers/templates/open-next.config.ts +9 -0
  154. package/templates/next/workers/templates/wrangler.jsonc +12 -0
  155. package/templates/nuxt/c3.ts +5 -55
  156. package/templates/nuxt/pages/c3.ts +147 -0
  157. package/templates/nuxt/pages/templates/env.d.ts +14 -0
  158. package/templates/nuxt/pages/templates/worker-configuration.d.ts +4 -0
  159. package/templates/nuxt/pages/templates/wrangler.jsonc +5 -0
  160. package/templates/nuxt/workers/c3.ts +146 -0
  161. package/templates/nuxt/workers/templates/env.d.ts +14 -0
  162. package/templates/nuxt/workers/templates/worker-configuration.d.ts +4 -0
  163. package/templates/nuxt/workers/templates/wrangler.jsonc +12 -0
  164. package/templates/openapi/c3.ts +6 -2
  165. package/templates/openapi/ts/README.md +3 -3
  166. package/templates/openapi/ts/package.json +7 -4
  167. package/templates/openapi/ts/src/endpoints/taskCreate.ts +26 -16
  168. package/templates/openapi/ts/src/endpoints/taskDelete.ts +20 -19
  169. package/templates/openapi/ts/src/endpoints/taskFetch.ts +30 -23
  170. package/templates/openapi/ts/src/endpoints/taskList.ts +27 -24
  171. package/templates/openapi/ts/src/index.ts +14 -20
  172. package/templates/openapi/ts/src/types.ts +9 -8
  173. package/templates/openapi/ts/worker-configuration.d.ts +4 -0
  174. package/templates/openapi/ts/wrangler.jsonc +8 -0
  175. package/templates/pre-existing/c3.ts +45 -24
  176. package/templates/pre-existing/js/.editorconfig +0 -1
  177. package/templates/pre-existing/js/package.json +1 -1
  178. package/templates/queues/c3.ts +14 -7
  179. package/templates/queues/js/.editorconfig +0 -1
  180. package/templates/queues/js/package.json +1 -1
  181. package/templates/queues/js/wrangler.jsonc +21 -0
  182. package/templates/queues/ts/.editorconfig +0 -1
  183. package/templates/queues/ts/package.json +4 -3
  184. package/templates/queues/ts/src/index.ts +6 -8
  185. package/templates/queues/ts/tsconfig.json +36 -95
  186. package/templates/queues/ts/worker-configuration.d.ts +5 -0
  187. package/templates/queues/ts/wrangler.jsonc +21 -0
  188. package/templates/qwik/c3.ts +5 -32
  189. package/templates/qwik/pages/c3.ts +150 -0
  190. package/templates/qwik/pages/snippets/getPlatformProxy.ts +6 -0
  191. package/templates/qwik/pages/templates/worker-configuration.d.ts +4 -0
  192. package/templates/qwik/pages/templates/wrangler.jsonc +8 -0
  193. package/templates/qwik/workers/c3.ts +154 -0
  194. package/templates/qwik/workers/snippets/getPlatformProxy.ts +6 -0
  195. package/templates/qwik/workers/templates/public/.assetsignore +4 -0
  196. package/templates/qwik/workers/templates/worker-configuration.d.ts +4 -0
  197. package/templates/qwik/workers/templates/wrangler.jsonc +15 -0
  198. package/templates/react/c3.ts +5 -25
  199. package/templates/react/pages/c3.ts +63 -0
  200. package/templates/react/workers/c3.ts +183 -0
  201. package/templates/react/workers/js/src/App.css +45 -0
  202. package/templates/react/workers/js/src/App.jsx +58 -0
  203. package/templates/react/workers/js/src/assets/Cloudflare_Logo.svg +53 -0
  204. package/templates/react/workers/js/worker/index.js +13 -0
  205. package/templates/react/workers/js/wrangler.jsonc +9 -0
  206. package/templates/react/workers/ts/src/App.css +45 -0
  207. package/templates/react/workers/ts/src/App.tsx +58 -0
  208. package/templates/react/workers/ts/src/assets/Cloudflare_Logo.svg +51 -0
  209. package/templates/react/workers/ts/tsconfig.worker.json +8 -0
  210. package/templates/react/workers/ts/worker/index.ts +12 -0
  211. package/templates/react/workers/ts/worker-configuration.d.ts +5 -0
  212. package/templates/react/workers/ts/wrangler.jsonc +9 -0
  213. package/templates/react-router/c3.ts +53 -0
  214. package/templates/react-router/templates/worker-configuration.d.ts +8 -0
  215. package/templates/remix/c3.ts +6 -29
  216. package/templates/remix/pages/c3.ts +69 -0
  217. package/templates/remix/pages/templates/worker-configuration.d.ts +4 -0
  218. package/templates/remix/pages/templates/wrangler.jsonc +5 -0
  219. package/templates/remix/workers/c3.ts +52 -0
  220. package/templates/remix/workers/templates/public/.assetsignore +0 -0
  221. package/templates/remix/workers/templates/worker-configuration.d.ts +4 -0
  222. package/templates/remix/workers/templates/wrangler.toml +11 -0
  223. package/templates/scheduled/c3.ts +14 -7
  224. package/templates/scheduled/js/.editorconfig +0 -1
  225. package/templates/scheduled/js/package.json +3 -3
  226. package/templates/scheduled/js/src/index.js +9 -2
  227. package/templates/scheduled/js/wrangler.jsonc +13 -0
  228. package/templates/scheduled/ts/.editorconfig +0 -1
  229. package/templates/scheduled/ts/package.json +5 -4
  230. package/templates/scheduled/ts/src/index.ts +15 -25
  231. package/templates/scheduled/ts/tsconfig.json +36 -95
  232. package/templates/scheduled/ts/worker-configuration.d.ts +4 -0
  233. package/templates/scheduled/ts/wrangler.jsonc +13 -0
  234. package/templates/solid/c3.ts +57 -18
  235. package/templates/solid/templates/wrangler.jsonc +8 -0
  236. package/templates/svelte/c3.ts +6 -72
  237. package/templates/svelte/pages/c3.ts +160 -0
  238. package/templates/svelte/pages/templates/wrangler.jsonc +5 -0
  239. package/templates/svelte/workers/c3.ts +129 -0
  240. package/templates/svelte/workers/templates/static/.assetsignore +2 -0
  241. package/templates/svelte/workers/templates/wrangler.jsonc +12 -0
  242. package/templates/vue/c3.ts +5 -23
  243. package/templates/vue/pages/c3.ts +31 -0
  244. package/templates/vue/workers/c3.ts +98 -0
  245. package/templates/vue/workers/js/server/index.js +13 -0
  246. package/templates/vue/workers/js/src/App.vue +107 -0
  247. package/templates/vue/workers/js/src/components/HelloWorld.vue +47 -0
  248. package/templates/vue/workers/js/vite.config.js +21 -0
  249. package/templates/vue/workers/js/wrangler.jsonc +11 -0
  250. package/templates/vue/workers/ts/server/index.ts +12 -0
  251. package/templates/vue/workers/ts/src/App.vue +107 -0
  252. package/templates/vue/workers/ts/src/components/HelloWorld.vue +44 -0
  253. package/templates/vue/workers/ts/tsconfig.worker.json +8 -0
  254. package/templates/vue/workers/ts/vite.config.ts +21 -0
  255. package/templates/vue/workers/ts/worker-configuration.d.ts +6 -0
  256. package/templates/vue/workers/ts/wrangler.jsonc +11 -0
  257. package/templates-experimental/solid/c3.ts +94 -0
  258. package/templates-experimental/solid/templates/wrangler.jsonc +15 -0
  259. package/templates/angular/templates/server.ts +0 -34
  260. package/templates/angular/templates/tools/alter-polyfills.mjs +0 -27
  261. package/templates/angular/templates/tools/copy-files.mjs +0 -9
  262. package/templates/angular/templates/tools/paths.mjs +0 -9
  263. package/templates/chatgptPlugin/c3.ts +0 -10
  264. package/templates/chatgptPlugin/ts/.assets/example.png +0 -0
  265. package/templates/chatgptPlugin/ts/README.md +0 -25
  266. package/templates/chatgptPlugin/ts/__dot__gitignore +0 -171
  267. package/templates/chatgptPlugin/ts/package.json +0 -16
  268. package/templates/chatgptPlugin/ts/src/index.ts +0 -33
  269. package/templates/chatgptPlugin/ts/src/search.ts +0 -59
  270. package/templates/chatgptPlugin/ts/wrangler.toml +0 -3
  271. package/templates/common/js/__dot__gitignore +0 -172
  272. package/templates/common/js/wrangler.toml +0 -51
  273. package/templates/common/ts/__dot__gitignore +0 -172
  274. package/templates/common/ts/wrangler.toml +0 -51
  275. package/templates/hello-world/js/__dot__gitignore +0 -172
  276. package/templates/hello-world/js/wrangler.toml +0 -51
  277. package/templates/hello-world/ts/__dot__gitignore +0 -172
  278. package/templates/hello-world/ts/wrangler.toml +0 -51
  279. package/templates/hello-world-durable-object/js/__dot__gitignore +0 -172
  280. package/templates/hello-world-durable-object/js/wrangler.toml +0 -51
  281. package/templates/hello-world-durable-object/ts/__dot__gitignore +0 -172
  282. package/templates/hello-world-durable-object/ts/wrangler.toml +0 -51
  283. package/templates/next/templates.ts +0 -281
  284. package/templates/openapi/ts/__dot__gitignore +0 -171
  285. package/templates/openapi/ts/wrangler.toml +0 -3
  286. package/templates/pre-existing/js/__dot__gitignore +0 -172
  287. package/templates/pre-existing/js/wrangler.toml +0 -3
  288. package/templates/queues/js/__dot__gitignore +0 -172
  289. package/templates/queues/js/wrangler.toml +0 -19
  290. package/templates/queues/ts/__dot__gitignore +0 -172
  291. package/templates/queues/ts/wrangler.toml +0 -19
  292. package/templates/scheduled/js/__dot__gitignore +0 -172
  293. package/templates/scheduled/js/wrangler.toml +0 -9
  294. package/templates/scheduled/ts/__dot__gitignore +0 -172
  295. package/templates/scheduled/ts/wrangler.toml +0 -9
  296. package/templates/solid/js/vite.config.js +0 -7
  297. package/templates/solid/ts/vite.config.ts +0 -7
  298. package/templates/svelte/templates.ts +0 -13
  299. /package/templates/angular/{templates → pages/templates}/src/_routes.json +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-d031e75a",
3
+ "version": "0.0.0-d04c69f81",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -23,14 +23,14 @@
23
23
  "bin": "./dist/cli.js",
24
24
  "files": [
25
25
  "dist",
26
- "templates"
26
+ "templates",
27
+ "templates-experimental"
27
28
  ],
28
29
  "devDependencies": {
29
30
  "@babel/parser": "^7.21.3",
30
31
  "@babel/types": "^7.21.4",
31
32
  "@clack/prompts": "^0.6.3",
32
- "@cloudflare/eslint-config-worker": "*",
33
- "@cloudflare/workers-types": "^4.20230419.0",
33
+ "@cloudflare/workers-types": "^4.20250409.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -38,58 +38,68 @@
38
38
  "@types/degit": "^2.8.6",
39
39
  "@types/dns2": "^2.0.3",
40
40
  "@types/esprima": "^4.0.3",
41
- "@types/node": "^18.15.3",
41
+ "@types/node": "^18.19.75",
42
42
  "@types/semver": "^7.5.1",
43
- "@types/shell-quote": "^1.7.2",
44
43
  "@types/which-pm-runs": "^1.0.0",
45
44
  "@types/yargs": "^17.0.22",
46
- "@typescript-eslint/eslint-plugin": "^5.55.0",
47
- "@typescript-eslint/parser": "^5.55.0",
45
+ "@typescript-eslint/eslint-plugin": "^6.9.0",
46
+ "@typescript-eslint/parser": "^6.9.0",
48
47
  "chalk": "^5.2.0",
49
48
  "command-exists": "^1.2.9",
49
+ "comment-json": "^4.2.5",
50
50
  "cross-spawn": "^7.0.3",
51
51
  "deepmerge": "^4.3.1",
52
52
  "degit": "^2.8.4",
53
53
  "dns2": "^2.1.0",
54
- "esbuild": "^0.17.12",
54
+ "dotenv": "^16.0.0",
55
+ "esbuild": "0.24.2",
55
56
  "execa": "^7.1.1",
56
57
  "glob": "^10.3.3",
57
58
  "haikunator": "^2.1.2",
59
+ "indent-string": "^5.0.0",
58
60
  "magic-string": "^0.30.5",
59
61
  "open": "^8.4.0",
60
- "pnpm": "^8.10.0",
61
62
  "recast": "^0.22.0",
62
- "semver": "^7.5.1",
63
- "shell-quote": "^1.8.1",
64
- "typescript": "^5.0.2",
65
- "undici": "5.28.2",
63
+ "semver": "^7.7.1",
64
+ "typescript": "^5.7.2",
65
+ "undici": "^5.28.5",
66
+ "vite": "^5.4.14",
66
67
  "vite-tsconfig-paths": "^4.0.8",
68
+ "vitest": "~3.0.8",
67
69
  "which-pm-runs": "^1.1.0",
68
- "yargs": "^17.7.1",
69
- "yarn": "^1.22.19",
70
+ "wrap-ansi": "^9.0.0",
71
+ "xdg-app-paths": "^8.3.0",
72
+ "yargs": "^17.7.2",
70
73
  "@cloudflare/cli": "1.1.1",
74
+ "@cloudflare/mock-npm-registry": "0.0.0",
75
+ "@cloudflare/vite-plugin": "0.0.0-d04c69f81",
71
76
  "@cloudflare/workers-tsconfig": "0.0.0",
72
- "wrangler": "3.24.0"
77
+ "wrangler": "0.0.0-d04c69f81",
78
+ "@cloudflare/eslint-config-worker": "1.1.0"
73
79
  },
74
80
  "engines": {
75
81
  "node": ">=18.14.1"
76
82
  },
77
83
  "workers-sdk": {
78
- "prerelease": true
84
+ "prerelease": true,
85
+ "type": "cli"
86
+ },
87
+ "volta": {
88
+ "extends": "../../package.json"
79
89
  },
80
90
  "scripts": {
81
91
  "build": "node -r esbuild-register scripts/build.ts",
82
- "check:lint": "eslint .",
92
+ "dev:codemod": "node -r esbuild-register scripts/codemodDev.ts",
93
+ "check:lint": "eslint . --max-warnings=0",
83
94
  "check:type": "tsc",
84
- "lint": "eslint",
85
- "test:e2e:cleanup": "node -r esbuild-register scripts/e2eCleanup.ts",
86
- "test:e2e:npm": "pnpm run build && cross-env TEST_PM=npm vitest run --config ./vitest-e2e.config.ts",
87
- "test:e2e:pnpm": "pnpm run build && cross-env TEST_PM=pnpm vitest run --config ./vitest-e2e.config.ts",
88
- "test:e2e:bun": "pnpm run build && cross-env TEST_PM=bun vitest run --config ./vitest-e2e.config.ts",
89
- "test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.ts",
90
- "test:unit": "vitest run --config ./vitest.config.ts",
91
- "test:unit:watch": "vitest --config ./vitest.config.ts",
92
- "watch": "node -r esbuild-register scripts/build.ts --watch",
93
- "test:ci": "vitest run --config ./vitest.config.ts"
95
+ "test:e2e": "vitest run --config ./vitest-e2e.config.mts",
96
+ "test:e2e:npm": "pnpm run build && cross-env TEST_PM=npm vitest run --config ./vitest-e2e.config.mts",
97
+ "test:e2e:pnpm": "pnpm run build && cross-env TEST_PM=pnpm vitest run --config ./vitest-e2e.config.mts",
98
+ "test:e2e:bun": "pnpm run build && cross-env TEST_PM=bun vitest run --config ./vitest-e2e.config.mts",
99
+ "test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.mts",
100
+ "test:unit": "vitest run --config ./vitest.config.mts",
101
+ "test:unit:watch": "vitest --config ./vitest.config.mts",
102
+ "dev": "node -r esbuild-register scripts/build.ts --watch",
103
+ "test:ci": "vitest run --config ./vitest.config.mts"
94
104
  }
95
105
  }
@@ -0,0 +1,135 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { spinner } from "@cloudflare/cli/interactive";
4
+ import { runFrameworkGenerator } from "frameworks/index";
5
+ import { loadTemplateSnippets, transformFile } from "helpers/codemod";
6
+ import { getLatestTypesEntrypoint } from "helpers/compatDate";
7
+ import { readFile, writeFile } from "helpers/files";
8
+ import { detectPackageManager } from "helpers/packageManagers";
9
+ import { installPackages } from "helpers/packages";
10
+ import * as recast from "recast";
11
+ import type { TemplateConfig } from "../../src/templates";
12
+ import type { C3Context } from "types";
13
+
14
+ const { npm, name: pm } = detectPackageManager();
15
+
16
+ const generate = async (ctx: C3Context) => {
17
+ await runFrameworkGenerator(ctx, [
18
+ ctx.project.name,
19
+ "--template",
20
+ "angular-v17",
21
+ ]);
22
+
23
+ logRaw(""); // newline
24
+ };
25
+
26
+ const configure = async (ctx: C3Context) => {
27
+ // Fix hoisting issues with pnpm, yarn and bun
28
+ if (pm === "pnpm" || pm === "yarn" || pm === "bun") {
29
+ const packages = [];
30
+ packages.push("nitropack");
31
+ packages.push("h3");
32
+ packages.push("@ngtools/webpack");
33
+ packages.push("@angular-devkit/build-angular");
34
+
35
+ await installPackages(packages, {
36
+ dev: true,
37
+ startText: `Installing ${packages.join(", ")}`,
38
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
39
+ });
40
+ }
41
+
42
+ updateViteConfig(ctx);
43
+ updateEnvTypes(ctx);
44
+ };
45
+
46
+ const updateEnvTypes = (ctx: C3Context) => {
47
+ const filepath = "env.d.ts";
48
+
49
+ const s = spinner();
50
+ s.start(`Updating ${filepath}`);
51
+
52
+ let file = readFile(filepath);
53
+
54
+ let typesEntrypoint = `@cloudflare/workers-types`;
55
+ const latestEntrypoint = getLatestTypesEntrypoint(ctx);
56
+ if (latestEntrypoint) {
57
+ typesEntrypoint += `/${latestEntrypoint}`;
58
+ }
59
+
60
+ // Replace placeholder with actual types entrypoint
61
+ file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
62
+ writeFile("env.d.ts", file);
63
+
64
+ s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
65
+ };
66
+
67
+ const updateViteConfig = (ctx: C3Context) => {
68
+ const b = recast.types.builders;
69
+ const s = spinner();
70
+
71
+ const configFile = "vite.config.ts";
72
+ s.start(`Updating \`${configFile}\``);
73
+
74
+ const snippets = loadTemplateSnippets(ctx);
75
+
76
+ transformFile(configFile, {
77
+ visitProgram(n) {
78
+ const lastImportIndex = n.node.body.findLastIndex(
79
+ (t) => t.type === "ImportDeclaration",
80
+ );
81
+ const lastImport = n.get("body", lastImportIndex);
82
+ lastImport.insertAfter(...snippets.devBindingsModuleTs);
83
+
84
+ return this.traverse(n);
85
+ },
86
+ visitCallExpression(n) {
87
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
88
+ if (callee.name === "analog") {
89
+ const pluginArguments = b.objectProperty(
90
+ b.identifier("nitro"),
91
+ b.objectExpression([
92
+ b.objectProperty(
93
+ b.identifier("preset"),
94
+ b.stringLiteral("cloudflare-pages"),
95
+ ),
96
+ b.objectProperty(
97
+ b.identifier("modules"),
98
+ b.arrayExpression([b.identifier("devBindingsModule")]),
99
+ ),
100
+ ]),
101
+ );
102
+
103
+ n.node.arguments = [b.objectExpression([pluginArguments])];
104
+ }
105
+
106
+ return this.traverse(n);
107
+ },
108
+ });
109
+
110
+ s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
111
+ };
112
+
113
+ const config: TemplateConfig = {
114
+ configVersion: 1,
115
+ id: "analog",
116
+ frameworkCli: "create-analog",
117
+ platform: "pages",
118
+ displayName: "Analog",
119
+ copyFiles: {
120
+ path: "./templates",
121
+ },
122
+ generate,
123
+ configure,
124
+ transformPackageJson: async () => ({
125
+ scripts: {
126
+ preview: `${npm} run build && wrangler pages dev`,
127
+ deploy: `${npm} run build && wrangler pages deploy`,
128
+ "cf-typegen": `wrangler types`,
129
+ },
130
+ }),
131
+ devScript: "dev",
132
+ deployScript: "deploy",
133
+ previewScript: "preview",
134
+ };
135
+ export default config;
@@ -0,0 +1,7 @@
1
+ import { Nitro } from 'nitropack';
2
+
3
+ const devBindingsModule = async (nitro: Nitro) => {
4
+ if (nitro.options.dev) {
5
+ nitro.options.plugins.push('./src/dev-bindings.ts');
6
+ }
7
+ };
@@ -0,0 +1,13 @@
1
+ /// <reference types="WORKERS_TYPES_ENTRYPOINT" />
2
+
3
+ declare module "h3" {
4
+ interface H3EventContext {
5
+ cf: CfProperties;
6
+ cloudflare: {
7
+ env: Env;
8
+ context: ExecutionContext;
9
+ };
10
+ }
11
+ }
12
+
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import { NitroApp } from 'nitropack';
2
+ import { defineNitroPlugin } from 'nitropack/dist/runtime/plugin';
3
+
4
+ export default defineNitroPlugin((nitroApp: NitroApp) => {
5
+ nitroApp.hooks.hook('request', async (event) => {
6
+ const _pkg = 'wrangler'; // Bypass bundling!
7
+ const { getPlatformProxy } = (await import(
8
+ _pkg
9
+ )) as typeof import('wrangler');
10
+ const platform = await getPlatformProxy();
11
+
12
+ event.context.cf = platform['cf'];
13
+ event.context.cloudflare = {
14
+ env: platform['env'] as unknown as Env,
15
+ context: platform['ctx'],
16
+ };
17
+ });
18
+ });
@@ -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,5 @@
1
+ {
2
+ "name": "<TBD>",
3
+ "compatibility_date": "<TBD>",
4
+ "pages_build_output_dir": "./dist/analog/public"
5
+ }
@@ -1,100 +1,9 @@
1
- import { cp } from "node:fs/promises";
2
- import { resolve } from "node:path";
3
- import { logRaw } from "@cloudflare/cli";
4
- import { brandColor, dim } from "@cloudflare/cli/colors";
5
- import { spinner } from "@cloudflare/cli/interactive";
6
- import { installPackages, runFrameworkGenerator } from "helpers/command";
7
- import { compatDateFlag, readFile, readJSON, writeFile } from "helpers/files";
8
- import { detectPackageManager } from "helpers/packages";
9
- import type { TemplateConfig } from "../../src/templates";
10
- import type { C3Context } from "types";
1
+ import pages from "./pages/c3";
2
+ import workers from "./workers/c3";
3
+ import type { MultiPlatformTemplateConfig } from "../../src/templates";
11
4
 
12
- const { npm } = detectPackageManager();
13
-
14
- const generate = async (ctx: C3Context) => {
15
- await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
16
- logRaw("");
17
- };
18
-
19
- const configure = async (ctx: C3Context) => {
20
- updateAngularJson(ctx);
21
- await updateAppCode();
22
- await installCFWorker(ctx);
23
- };
24
-
25
- async function installCFWorker(ctx: C3Context) {
26
- await installPackages(
27
- ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
28
- {
29
- dev: true,
30
- startText: "Installing adapter dependencies",
31
- doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
32
- }
33
- );
34
- }
35
- async function updateAppCode() {
36
- const s = spinner();
37
- s.start(`Updating application code`);
38
-
39
- // Update an app config file to:
40
- // - add the `provideHttpClient(withFetch())` call to enable `fetch` usage in `HttpClient`
41
- const appConfigPath = "src/app/app.config.ts";
42
- const appConfig = readFile(resolve(appConfigPath));
43
- const newAppConfig =
44
- "import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
45
- appConfig.replace(
46
- "providers: [",
47
- "providers: [provideHttpClient(withFetch()), "
48
- );
49
- writeFile(resolve(appConfigPath), newAppConfig);
50
- s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
51
-
52
- // Remove unwanted dependencies
53
- s.start(`Updating package.json`);
54
- const packageJsonPath = resolve("package.json");
55
- const packageManifest = readJSON(packageJsonPath);
56
-
57
- delete packageManifest["dependencies"]["@angular/ssr"];
58
- delete packageManifest["dependencies"]["express"];
59
-
60
- writeFile(packageJsonPath, JSON.stringify(packageManifest, null, 2));
61
- s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
62
- }
63
-
64
- function updateAngularJson(ctx: C3Context) {
65
- const s = spinner();
66
- s.start(`Updating angular.json config`);
67
- const angularJson = readJSON(resolve("angular.json"));
68
- // Update builder
69
- const architectSection = angularJson.projects[ctx.project.name].architect;
70
- architectSection.build.options.outputPath = "dist";
71
- architectSection.build.options.assets.push("src/_routes.json");
72
-
73
- writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
74
- s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
75
- }
76
-
77
- const config: TemplateConfig = {
78
- configVersion: 1,
79
- id: "angular",
5
+ const config: MultiPlatformTemplateConfig = {
80
6
  displayName: "Angular",
81
- platform: "pages",
82
- copyFiles: {
83
- path: "./templates",
84
- },
85
- generate,
86
- configure,
87
- transformPackageJson: async () => ({
88
- scripts: {
89
- start: `${npm} run pages:build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
90
- process:
91
- "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
92
- "pages:build": `ng build && ${npm} run process`,
93
- deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`,
94
- },
95
- }),
96
- deployCommand: ["deploy"],
97
- devCommand: ["start"],
98
- testFlags: ["--style", "sass"],
7
+ platformVariants: { pages, workers },
99
8
  };
100
9
  export default config;
@@ -0,0 +1,135 @@
1
+ import { resolve } from "node:path";
2
+ import { logRaw } from "@cloudflare/cli";
3
+ import { brandColor, dim } from "@cloudflare/cli/colors";
4
+ import { spinner } from "@cloudflare/cli/interactive";
5
+ import { runFrameworkGenerator } from "frameworks/index";
6
+ import { compatDateFlag } from "helpers/compatDate";
7
+ import { readFile, readJSON, writeFile } from "helpers/files";
8
+ import { detectPackageManager } from "helpers/packageManagers";
9
+ import { installPackages } from "helpers/packages";
10
+ import type { TemplateConfig } from "../../../src/templates";
11
+ import type { C3Context, PackageJson } from "types";
12
+
13
+ const { npm } = detectPackageManager();
14
+
15
+ const generate = async (ctx: C3Context) => {
16
+ await runFrameworkGenerator(ctx, [
17
+ ctx.project.name,
18
+ "--ssr",
19
+ "--server-routing" /** Dev Preview API */,
20
+ ]);
21
+ logRaw("");
22
+ };
23
+
24
+ const configure = async (ctx: C3Context) => {
25
+ updateAngularJson(ctx);
26
+ await updateAppCode();
27
+ await installCFWorker();
28
+ };
29
+
30
+ async function installCFWorker() {
31
+ await installPackages(["xhr2"], {
32
+ dev: true,
33
+ startText: "Installing additional dependencies",
34
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
35
+ });
36
+ }
37
+ async function updateAppCode() {
38
+ const s = spinner();
39
+ s.start(`Updating application code`);
40
+
41
+ // Update an app config file to:
42
+ // - add the `provideHttpClient(withFetch())` call to enable `fetch` usage in `HttpClient`
43
+ const appConfigPath = "src/app/app.config.ts";
44
+ const appConfig = readFile(resolve(appConfigPath));
45
+ const newAppConfig =
46
+ "import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
47
+ appConfig.replace(
48
+ "providers: [",
49
+ "providers: [provideHttpClient(withFetch()), ",
50
+ );
51
+ writeFile(resolve(appConfigPath), newAppConfig);
52
+ s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
53
+
54
+ // Update an app server routes file to:
55
+ const appServerRoutesPath = "src/app/app.routes.server.ts";
56
+ const appRoutes = readFile(resolve(appServerRoutesPath));
57
+ const newAppRoutes = appRoutes.replace(
58
+ "RenderMode.Prerender",
59
+ "RenderMode.Server",
60
+ );
61
+ writeFile(resolve(appServerRoutesPath), newAppRoutes);
62
+ s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
63
+
64
+ // Remove unwanted dependencies
65
+ s.start(`Updating package.json`);
66
+ const packageJsonPath = resolve("package.json");
67
+ const packageManifest = readJSON(packageJsonPath) as PackageJson;
68
+
69
+ delete packageManifest["dependencies"]?.["express"];
70
+ delete packageManifest["devDependencies"]?.["@types/express"];
71
+
72
+ writeFile(packageJsonPath, JSON.stringify(packageManifest, null, 2));
73
+ s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
74
+ }
75
+
76
+ function updateAngularJson(ctx: C3Context) {
77
+ const s = spinner();
78
+ s.start(`Updating angular.json config`);
79
+ const angularJson = readJSON("angular.json") as AngularJson;
80
+
81
+ // Update builder
82
+ const architectSection = angularJson.projects[ctx.project.name].architect;
83
+ architectSection.build.options.outputPath = "dist";
84
+ architectSection.build.options.outputMode = "server";
85
+ architectSection.build.options.ssr.experimentalPlatform = "neutral";
86
+ architectSection.build.options.assets.push("src/_routes.json");
87
+
88
+ writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
89
+ s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
90
+ }
91
+
92
+ const config: TemplateConfig = {
93
+ configVersion: 1,
94
+ id: "angular",
95
+ frameworkCli: "@angular/create",
96
+ displayName: "Angular",
97
+ platform: "pages",
98
+ hidden: true,
99
+ copyFiles: {
100
+ path: "./templates",
101
+ },
102
+ path: "templates/angular/pages",
103
+ devScript: "start",
104
+ deployScript: "deploy",
105
+ previewScript: "start",
106
+ generate,
107
+ configure,
108
+ transformPackageJson: async () => ({
109
+ scripts: {
110
+ start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}`,
111
+ build: `ng build && ${npm} run process`,
112
+ process: "node ./tools/copy-files.mjs",
113
+ deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
114
+ },
115
+ }),
116
+ };
117
+ export default config;
118
+
119
+ type AngularJson = {
120
+ projects: Record<
121
+ string,
122
+ {
123
+ architect: {
124
+ build: {
125
+ options: {
126
+ outputPath: string;
127
+ outputMode: string;
128
+ ssr: Record<string, unknown>;
129
+ assets: string[];
130
+ };
131
+ };
132
+ };
133
+ }
134
+ >;
135
+ };
@@ -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,15 @@
1
+ // Copy the files over so that they can be uploaded by the pages publish command.
2
+ import fs from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = resolve(fileURLToPath(import.meta.url), "../../");
7
+ const client = resolve(root, "dist/browser");
8
+ const ssr = resolve(root, "dist/server");
9
+ const cloudflare = resolve(root, "dist/cloudflare");
10
+ const worker = resolve(cloudflare, "_worker.js");
11
+
12
+ fs.cpSync(client, cloudflare, { recursive: true });
13
+ fs.cpSync(ssr, worker, { recursive: true });
14
+
15
+ fs.renameSync(join(worker, "server.mjs"), join(worker, "index.js"));