create-efforge 0.0.0-stage → 0.1.0

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 (237) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +140 -2
  3. package/dist/addon.js +115 -0
  4. package/dist/bin.js +6 -0
  5. package/dist/cli.js +9 -0
  6. package/dist/commands/add.js +440 -0
  7. package/dist/commands/create.js +186 -0
  8. package/dist/diff.js +72 -0
  9. package/dist/exec.js +20 -0
  10. package/dist/generate.js +181 -0
  11. package/dist/manifest.js +14 -0
  12. package/dist/projectName.js +41 -0
  13. package/dist/prompts/flow.js +111 -0
  14. package/dist/prompts/navigable.js +97 -0
  15. package/dist/routeTree.js +7 -0
  16. package/dist/rules.js +24 -0
  17. package/dist/slots.js +96 -0
  18. package/dist/stack.js +68 -0
  19. package/dist/transforms/addAlchemyResource.js +71 -0
  20. package/dist/transforms/addArrayItem.js +31 -0
  21. package/dist/transforms/addAuthPlugin.js +77 -0
  22. package/dist/transforms/addDevVar.js +18 -0
  23. package/dist/transforms/addExport.js +46 -0
  24. package/dist/transforms/addImport.js +11 -0
  25. package/dist/transforms/addLayer.js +31 -0
  26. package/dist/transforms/addServerFnMiddleware.js +62 -0
  27. package/dist/transforms/addWorkflowSecret.js +43 -0
  28. package/dist/transforms/addWranglerBinding.js +61 -0
  29. package/dist/transforms/appendAgentsSection.js +26 -0
  30. package/dist/transforms/errors.js +7 -0
  31. package/dist/transforms/index.js +40 -0
  32. package/dist/transforms/setWranglerValue.js +40 -0
  33. package/dist/transforms/util.js +219 -0
  34. package/dist/tree.js +1 -0
  35. package/dist/versions.js +73 -0
  36. package/dist/write.js +26 -0
  37. package/package.json +63 -4
  38. package/templates/ai/effect-ai-byok/addon.json +619 -0
  39. package/templates/ai/effect-ai-byok/files/core/llm-crypto.test.ts +47 -0
  40. package/templates/ai/effect-ai-byok/files/core/llm-crypto.ts +76 -0
  41. package/templates/ai/effect-ai-byok/files/core/llm-store.ts +21 -0
  42. package/templates/ai/effect-ai-byok/files/core/llm.ts +32 -0
  43. package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/migration.sql +9 -0
  44. package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/snapshot.json +944 -0
  45. package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/migration.sql +10 -0
  46. package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/snapshot.json +1232 -0
  47. package/templates/ai/effect-ai-byok/files/routes/ai.tsx +193 -0
  48. package/templates/ai/effect-ai-byok/files/schema/d1.ts +16 -0
  49. package/templates/ai/effect-ai-byok/files/schema/pg.ts +14 -0
  50. package/templates/ai/effect-ai-byok/files/server/ai-settings.ts +129 -0
  51. package/templates/ai/effect-ai-byok/files/server/ai.ts +25 -0
  52. package/templates/ai/effect-ai-byok/files/server/llm-env.ts +48 -0
  53. package/templates/ai/effect-ai-byok/files/server/llm-orgs.ts +146 -0
  54. package/templates/ai/effect-ai-byok/files/server/llm-provider.ts +56 -0
  55. package/templates/ai/effect-ai-byok/files/server/llm-store-drizzle.ts +48 -0
  56. package/templates/ai/effect-ai-byok/files/server/llm-store-sql-d1.ts +41 -0
  57. package/templates/ai/effect-ai-byok/files/server/llm-store-sql-pg.ts +41 -0
  58. package/templates/ai/effect-ai-byok/files/sql/d1.sql +8 -0
  59. package/templates/ai/effect-ai-byok/files/sql/pg.sql +8 -0
  60. package/templates/auth/better-auth/addon.json +424 -0
  61. package/templates/auth/better-auth/files/core/Auth.ts +18 -0
  62. package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/migration.sql +51 -0
  63. package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/snapshot.json +522 -0
  64. package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/migration.sql +51 -0
  65. package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/snapshot.json +680 -0
  66. package/templates/auth/better-auth/files/lib/auth-client.ts +4 -0
  67. package/templates/auth/better-auth/files/routes/app.tsx +54 -0
  68. package/templates/auth/better-auth/files/schema/d1/auth-schema.ts +86 -0
  69. package/templates/auth/better-auth/files/schema/pg/auth-schema.ts +73 -0
  70. package/templates/auth/better-auth/files/server/auth-live.ts +47 -0
  71. package/templates/auth/better-auth/files/server/session.ts +14 -0
  72. package/templates/auth/better-auth/files/shared/components/auth-card.tsx +32 -0
  73. package/templates/auth/better-auth/files/shared/components/user-menu.tsx +44 -0
  74. package/templates/auth/better-auth/files/shared/drizzle/d1/drizzle.config.ts +7 -0
  75. package/templates/auth/better-auth/files/shared/drizzle/pg/drizzle.config.ts +10 -0
  76. package/templates/auth/better-auth/files/shared/lib/form.ts +5 -0
  77. package/templates/auth/better-auth/files/shared/lib/redirect.ts +6 -0
  78. package/templates/auth/better-auth/files/shared/routes/app/index.tsx +54 -0
  79. package/templates/auth/better-auth/files/shared/routes/sign-in.tsx +85 -0
  80. package/templates/auth/better-auth/files/shared/routes/sign-up.tsx +91 -0
  81. package/templates/auth/better-auth/files/shared/server/auth-route.ts +15 -0
  82. package/templates/auth/better-auth/files/shared/server/auth.ts +22 -0
  83. package/templates/auth/better-auth/files/shared/server/db/d1-drizzle.ts +25 -0
  84. package/templates/auth/better-auth/files/shared/server/db/d1-effect-sql.ts +17 -0
  85. package/templates/auth/better-auth/files/shared/server/db/pg-drizzle.ts +32 -0
  86. package/templates/auth/better-auth/files/shared/server/db/pg-effect-sql.ts +29 -0
  87. package/templates/auth/better-auth/files/shared/server/require-session.ts +20 -0
  88. package/templates/auth/better-auth/files/sql/d1/0002_auth.sql +13 -0
  89. package/templates/auth/better-auth/files/sql/pg/0002_auth.sql +13 -0
  90. package/templates/auth/better-auth-orgs/addon.json +463 -0
  91. package/templates/auth/better-auth-orgs/files/components/org-switcher.tsx +65 -0
  92. package/templates/auth/better-auth-orgs/files/core/Auth.ts +20 -0
  93. package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/migration.sql +88 -0
  94. package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/snapshot.json +862 -0
  95. package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/migration.sql +88 -0
  96. package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/snapshot.json +1127 -0
  97. package/templates/auth/better-auth-orgs/files/lib/auth-client.ts +5 -0
  98. package/templates/auth/better-auth-orgs/files/routes/accept-invite.$id.tsx +68 -0
  99. package/templates/auth/better-auth-orgs/files/routes/app/settings/index.tsx +27 -0
  100. package/templates/auth/better-auth-orgs/files/routes/app/settings/members.tsx +198 -0
  101. package/templates/auth/better-auth-orgs/files/routes/app/settings.tsx +30 -0
  102. package/templates/auth/better-auth-orgs/files/routes/app.tsx +58 -0
  103. package/templates/auth/better-auth-orgs/files/routes/onboarding.tsx +66 -0
  104. package/templates/auth/better-auth-orgs/files/schema/d1/auth-schema.ts +139 -0
  105. package/templates/auth/better-auth-orgs/files/schema/pg/auth-schema.ts +124 -0
  106. package/templates/auth/better-auth-orgs/files/server/auth-live.ts +52 -0
  107. package/templates/auth/better-auth-orgs/files/server/session.ts +44 -0
  108. package/templates/auth/better-auth-orgs/files/sql/d1/0002_auth.sql +27 -0
  109. package/templates/auth/better-auth-orgs/files/sql/pg/0002_auth.sql +27 -0
  110. package/templates/base/addon.json +212 -0
  111. package/templates/base/files/AGENTS.md +70 -0
  112. package/templates/base/files/CLAUDE.md +1 -0
  113. package/templates/base/files/README.md +28 -0
  114. package/templates/base/files/core/package.json +13 -0
  115. package/templates/base/files/core/src/index.ts +2 -0
  116. package/templates/base/files/core/test/core.test.ts +4 -0
  117. package/templates/base/files/core/tsconfig.json +6 -0
  118. package/templates/base/files/gitignore +11 -0
  119. package/templates/base/files/pnpm-workspace.yaml +11 -0
  120. package/templates/base/files/root/package.json +16 -0
  121. package/templates/base/files/root/tsconfig.base.json +19 -0
  122. package/templates/base/files/root/turbo.json +9 -0
  123. package/templates/base/files/root/vite.config.ts +61 -0
  124. package/templates/base/files/web/components.json +21 -0
  125. package/templates/base/files/web/package.json +17 -0
  126. package/templates/base/files/web/src/components/theme-provider.tsx +57 -0
  127. package/templates/base/files/web/src/components/theme-toggle.tsx +34 -0
  128. package/templates/base/files/web/src/components/ui/avatar.tsx +93 -0
  129. package/templates/base/files/web/src/components/ui/button.tsx +61 -0
  130. package/templates/base/files/web/src/components/ui/card.tsx +74 -0
  131. package/templates/base/files/web/src/components/ui/dialog.tsx +141 -0
  132. package/templates/base/files/web/src/components/ui/dropdown-menu.tsx +225 -0
  133. package/templates/base/files/web/src/components/ui/input.tsx +20 -0
  134. package/templates/base/files/web/src/components/ui/label.tsx +18 -0
  135. package/templates/base/files/web/src/components/ui/sonner.tsx +45 -0
  136. package/templates/base/files/web/src/components/widgets.tsx +4 -0
  137. package/templates/base/files/web/src/lib/utils.ts +6 -0
  138. package/templates/base/files/web/src/router.tsx +12 -0
  139. package/templates/base/files/web/src/routes/__root.tsx +42 -0
  140. package/templates/base/files/web/src/routes/app/index.tsx +27 -0
  141. package/templates/base/files/web/src/routes/app/settings.tsx +29 -0
  142. package/templates/base/files/web/src/routes/app.tsx +47 -0
  143. package/templates/base/files/web/src/routes/index.tsx +51 -0
  144. package/templates/base/files/web/src/server/greeting.ts +12 -0
  145. package/templates/base/files/web/src/server/layers.ts +10 -0
  146. package/templates/base/files/web/src/server/runtime.ts +5 -0
  147. package/templates/base/files/web/src/styles.css +81 -0
  148. package/templates/base/files/web/tsconfig.json +11 -0
  149. package/templates/base/files/web/vite.config.ts +9 -0
  150. package/templates/database/d1/addon.json +118 -0
  151. package/templates/database/d1/files/package.json +12 -0
  152. package/templates/database/d1/files/tsconfig.json +5 -0
  153. package/templates/database/postgres/addon.json +142 -0
  154. package/templates/database/postgres/files/docker-compose.yml +21 -0
  155. package/templates/database/postgres/files/package.json +12 -0
  156. package/templates/database/postgres/files/runtime.ts +12 -0
  157. package/templates/database/postgres/files/tsconfig.json +5 -0
  158. package/templates/extras/browser/addon.json +173 -0
  159. package/templates/extras/browser/files/BrowserContainer.ts +14 -0
  160. package/templates/extras/browser/files/app/Dockerfile +15 -0
  161. package/templates/extras/browser/files/app/dockerignore +1 -0
  162. package/templates/extras/browser/files/app/package-lock +605 -0
  163. package/templates/extras/browser/files/app/package.json +9 -0
  164. package/templates/extras/browser/files/app/src/server.ts +78 -0
  165. package/templates/extras/browser/files/app/src/url-policy.ts +115 -0
  166. package/templates/extras/browser/files/app/tsconfig.json +6 -0
  167. package/templates/extras/browser/files/browser.ts +34 -0
  168. package/templates/extras/browser/files/core-browser.ts +21 -0
  169. package/templates/extras/browser/files/run-browser.ts +25 -0
  170. package/templates/extras/email/addon.json +182 -0
  171. package/templates/extras/email/files/core-mailer.ts +28 -0
  172. package/templates/extras/email/files/invitation-email.ts +38 -0
  173. package/templates/extras/email/files/mailer.ts +58 -0
  174. package/templates/extras/realtime/addon.json +135 -0
  175. package/templates/extras/realtime/files/Room.ts +46 -0
  176. package/templates/extras/realtime/files/core-realtime.ts +19 -0
  177. package/templates/extras/realtime/files/realtime-demo.tsx +40 -0
  178. package/templates/extras/realtime/files/realtime-limits.test.ts +32 -0
  179. package/templates/extras/realtime/files/realtime-limits.ts +35 -0
  180. package/templates/extras/realtime/files/realtime-route.ts +39 -0
  181. package/templates/extras/realtime/files/realtime.ts +39 -0
  182. package/templates/extras/realtime/files/use-room.ts +67 -0
  183. package/templates/extras/storage/addon.json +132 -0
  184. package/templates/extras/storage/files/core-storage.ts +64 -0
  185. package/templates/extras/storage/files/storage-route.ts +50 -0
  186. package/templates/extras/storage/files/storage-security.test.ts +71 -0
  187. package/templates/extras/storage/files/storage-security.ts +92 -0
  188. package/templates/extras/storage/files/storage.ts +84 -0
  189. package/templates/extras/workflows/addon.json +95 -0
  190. package/templates/extras/workflows/files/Example.ts +42 -0
  191. package/templates/extras/workflows/files/core-jobs.ts +45 -0
  192. package/templates/extras/workflows/files/example-job.ts +36 -0
  193. package/templates/extras/workflows/files/jobs.ts +34 -0
  194. package/templates/infra/alchemy/addon.json +37 -0
  195. package/templates/infra/alchemy/files/README.md +27 -0
  196. package/templates/infra/alchemy/files/alchemy.run.ts +36 -0
  197. package/templates/infra/alchemy/files/github/deploy.yml +63 -0
  198. package/templates/infra/alchemy/files/tsconfig.json +5 -0
  199. package/templates/infra/alchemy/files/vite.config.ts +30 -0
  200. package/templates/orm/drizzle/addon.json +188 -0
  201. package/templates/orm/drizzle/files/d1/Database.ts +7 -0
  202. package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/migration.sql +10 -0
  203. package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/snapshot.json +60 -0
  204. package/templates/orm/drizzle/files/d1/drizzle.config.ts +7 -0
  205. package/templates/orm/drizzle/files/d1/layer.ts +13 -0
  206. package/templates/orm/drizzle/files/d1/migrate.ts +37 -0
  207. package/templates/orm/drizzle/files/d1/schema.ts +15 -0
  208. package/templates/orm/drizzle/files/pg/Database.ts +7 -0
  209. package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/migration.sql +10 -0
  210. package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/snapshot.json +75 -0
  211. package/templates/orm/drizzle/files/pg/drizzle.config.ts +10 -0
  212. package/templates/orm/drizzle/files/pg/layer.ts +16 -0
  213. package/templates/orm/drizzle/files/pg/migrate.ts +24 -0
  214. package/templates/orm/drizzle/files/pg/schema.ts +11 -0
  215. package/templates/orm/drizzle/files/shared/index.ts +2 -0
  216. package/templates/orm/drizzle/files/shared/notes.ts +15 -0
  217. package/templates/orm/drizzle/files/shared/page.tsx +50 -0
  218. package/templates/orm/effect-sql/addon.json +124 -0
  219. package/templates/orm/effect-sql/files/d1/layer.ts +13 -0
  220. package/templates/orm/effect-sql/files/d1/migrate.ts +20 -0
  221. package/templates/orm/effect-sql/files/d1/schema.ts +7 -0
  222. package/templates/orm/effect-sql/files/d1-sql/0001_init.sql +10 -0
  223. package/templates/orm/effect-sql/files/pg/layer.ts +16 -0
  224. package/templates/orm/effect-sql/files/pg/migrate.ts +66 -0
  225. package/templates/orm/effect-sql/files/pg/schema.ts +7 -0
  226. package/templates/orm/effect-sql/files/pg-sql/0001_init.sql +10 -0
  227. package/templates/orm/effect-sql/files/shared/Database.ts +7 -0
  228. package/templates/orm/effect-sql/files/shared/index.ts +2 -0
  229. package/templates/orm/effect-sql/files/shared/notes.ts +18 -0
  230. package/templates/orm/effect-sql/files/shared/page.tsx +50 -0
  231. package/templates/runtime/cloudflare/addon.json +52 -0
  232. package/templates/runtime/cloudflare/files/cloudflare.ts +10 -0
  233. package/templates/runtime/cloudflare/files/routes.ts +5 -0
  234. package/templates/runtime/cloudflare/files/server.ts +22 -0
  235. package/templates/runtime/cloudflare/files/tsconfig.json +12 -0
  236. package/templates/runtime/cloudflare/files/vite.config.ts +20 -0
  237. package/templates/runtime/cloudflare/files/wrangler.jsonc +8 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abdulrahman Magdy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,141 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/amagdy46/efforge/main/.github/assets/logo.svg" width="96" height="96" alt="efforge logo: three stacked layers, the top one glowing orange">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">efforge</h1>
6
+
7
+ <p align="center">
8
+ Start an <a href="https://effect.website">Effect</a> app with database, auth, and Cloudflare services already wired together.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/create-efforge"><img src="https://img.shields.io/npm/v/create-efforge" alt="npm version"></a>
13
+ <a href="https://github.com/amagdy46/efforge/actions/workflows/ci.yml"><img src="https://github.com/amagdy46/efforge/actions/workflows/ci.yml/badge.svg" alt="CI status"></a>
14
+ <a href="https://github.com/amagdy46/efforge/blob/main/LICENSE"><img src="https://img.shields.io/github/license/amagdy46/efforge" alt="MIT license"></a>
15
+ </p>
16
+
17
+ `npm create efforge` generates a TypeScript monorepo: a [TanStack Start](https://tanstack.com/start) app on Cloudflare Workers, where each capability is an Effect service and layer. You choose the database, ORM, auth, infrastructure tool, AI and extras when you create the project, and `efforge add` adds more later.
18
+
19
+ Status: v0.1, early. The default ORM (Drizzle) is pinned to a release candidate, and the optional Alchemy support uses a beta. Needs Node 24.11+ or 26+ (Vite+ does not support Node 25) and pnpm. MIT licensed.
20
+
21
+ ```console
22
+ $ npm create efforge my-app -- --yes --database=d1 --orm=effect-sql --auth=better-auth --extras=storage
23
+ ┌ create-efforge Effect apps on Cloudflare, already wired
24
+ ◇ Your stack ─────────────────────────────────────────────────────────╮
25
+ │ name my-app │
26
+ │ runtime cloudflare │
27
+ │ database d1 │
28
+ │ orm effect-sql │
29
+ │ auth better-auth │
30
+ │ infra none │
31
+ │ ai none │
32
+ │ extras storage │
33
+ ├──────────────────────────────────────────────────────────────────────╯
34
+ ◇ ✓ Writing files
35
+ ◇ ✓ Initializing git
36
+ ◇ ✓ Installing dependencies (pnpm install)
37
+ ◇ ✓ Generating the route tree (tsr generate)
38
+ ◇ ✓ Formatting (vp fmt)
39
+ ◇ ✓ Creating the initial commit
40
+ └ Done.
41
+ ```
42
+
43
+ (Output abridged: blank lines and the re-run command are left out.)
44
+
45
+ ## Why efforge
46
+
47
+ Other scaffolders cover parts of this stack. [create-effect-app](https://github.com/Effect-TS/examples) gives you a basic, CLI or monorepo Effect project. `npm create cloudflare` gives you a TanStack Start app on Workers.
48
+
49
+ efforge is narrower: it is for writing the whole server side in Effect, on Cloudflare.
50
+
51
+ - Each capability (database, auth, mail, storage, AI) is an Effect service with tagged errors in `packages/core`, implemented as a layer and composed in one file, `apps/web/src/server/layers.ts`.
52
+ - Application code gets Cloudflare bindings through Effect layers; only `apps/web/src/server/cloudflare.ts` reads the Worker environment. Code that uses bindings can be tested with `@effect/vitest`.
53
+ - `efforge add` wires a new add-on into the layers, exports, bindings and secrets with AST transforms, instead of asking you to paste code.
54
+ - The generated `AGENTS.md` gives coding agents the same layout and rules, and `pnpm check` runs format, lint (with Effect diagnostics) and types.
55
+
56
+ Use something else if you want Next.js, a runtime other than Cloudflare, or plain async code without Effect.
57
+
58
+ ## Quick start
59
+
60
+ ```sh
61
+ npm create efforge my-app # asks for each choice
62
+ cd my-app
63
+ ```
64
+
65
+ Then, with the default `infra=none`, set up the database you picked:
66
+
67
+ ```sh
68
+ # Postgres (the default): start the bundled database, then migrate
69
+ docker compose up -d --wait
70
+ pnpm db:migrate
71
+
72
+ # D1: apply migrations to the local D1 database
73
+ pnpm db:migrate
74
+
75
+ pnpm dev # http://localhost:5173
76
+ ```
77
+
78
+ `.dev.vars` is generated with development-only secrets. Replace them, and set them as Worker secrets, before deploying. With `infra=alchemy`, follow the generated `infra/README.md` instead.
79
+
80
+ ## Common commands
81
+
82
+ ```sh
83
+ # accept the defaults: Postgres, Drizzle, Better Auth with organizations
84
+ npm create efforge my-app -- --yes
85
+
86
+ # list the files a stack would write, without writing them
87
+ npm create efforge my-app -- --yes --database=d1 --orm=effect-sql --dry-run
88
+
89
+ # add an add-on to an existing project (run inside it)
90
+ npx create-efforge add email
91
+
92
+ # preview two add-ons without changing the project
93
+ npx create-efforge add ai/effect-ai-byok extras/storage --dry-run
94
+ ```
95
+
96
+ `efforge.jsonc` in the generated project records the stack and a `command` that recreates it. All flags, `add` behaviour and troubleshooting: [docs/cli.md](https://github.com/amagdy46/efforge/blob/main/docs/cli.md).
97
+
98
+ ## Stack options
99
+
100
+ | Slot | Options | Default |
101
+ |---|---|---|
102
+ | `runtime` | `cloudflare` | `cloudflare` |
103
+ | `database` | `postgres` (via Hyperdrive), `d1`, `none` | `postgres` |
104
+ | `orm` | `drizzle`, `effect-sql`, `none` | `drizzle` |
105
+ | `auth` | `better-auth-orgs`, `better-auth`, `none` | `better-auth-orgs` |
106
+ | `infra` | `none`, `alchemy` | `none` |
107
+ | `ai` | `none`, `effect-ai-byok` | `none` |
108
+ | `extras` (multi) | `workflows`, `realtime`, `browser`, `storage`, `email` | none |
109
+
110
+ Options are filtered by earlier choices. `orm` is set exactly when `database` is, and `auth` needs a database. With `infra=none`, bindings live in `wrangler.jsonc`; with `infra=alchemy`, they live in `infra/alchemy.run.ts`.
111
+
112
+ ## What you get
113
+
114
+ ```
115
+ apps/web TanStack Start app (Worker entry, routes, shadcn/ui, Tailwind v4)
116
+ packages/core service interfaces (Context.Service), tagged errors, schemas
117
+ packages/db schema, migrations, DB layer (when database != none)
118
+ infra/ alchemy.run.ts (infra=alchemy)
119
+ apps/browser Playwright container image (extras=browser)
120
+ efforge.jsonc the stack choices; `efforge add` reads it
121
+ AGENTS.md CLAUDE.md rules for AI agents and humans
122
+ ```
123
+
124
+ The workspace uses a pnpm `catalog:` of exact version pins, Turborepo for `dev`, `build`, `typecheck` and `test`, and [Vite+](https://viteplus.dev) (Oxlint and Oxfmt) for `pnpm check`.
125
+
126
+ ## Status and limits
127
+
128
+ v0.1 is the first release, and the CLI's options may still change.
129
+
130
+ - Cloudflare is the only runtime.
131
+ - You can add add-ons but not remove them, and a single-choice slot only moves from `none` to a value. To switch from Postgres to D1, create a new project.
132
+ - `infra=alchemy` uses Alchemy 2.0 beta (`2.0.0-beta.83`). Drizzle is pinned to `1.0.0-rc.5-5935859` ([why](https://github.com/amagdy46/efforge/blob/main/docs/decisions/0002-drizzle-rc-pin.md)).
133
+ - With `infra=alchemy`, local secrets are read from `.env`, not `.dev.vars`, and `pnpm db:migrate` on D1 still expects a `wrangler.jsonc`. Both are known v0.1 gaps.
134
+ - CI generates, installs and runs the full gate (typecheck, check, test, build) for a matrix of 15 stacks, not every combination.
135
+ - With `--auth=none`, the `effect-ai-byok` demo server function is not gated, so anyone who can reach the app can spend the configured API key. Add auth or remove the demo before deploying.
136
+
137
+ ## Contributing
138
+
139
+ Building and testing efforge itself: [CONTRIBUTING.md](https://github.com/amagdy46/efforge/blob/main/CONTRIBUTING.md). Releases: [CHANGELOG.md](https://github.com/amagdy46/efforge/blob/main/CHANGELOG.md).
140
+
141
+ MIT licensed. See [LICENSE](https://github.com/amagdy46/efforge/blob/main/LICENSE).
package/dist/addon.js ADDED
@@ -0,0 +1,115 @@
1
+ import { Effect, FileSystem, Path, Schema } from "effect";
2
+ import { slots } from "./slots.js";
3
+ import { SlotId } from "./stack.js";
4
+ const Strings = Schema.Array(Schema.String);
5
+ /** Per-slot allow-lists; a file or transform applies only when every listed slot matches. */
6
+ export const When = Schema.Struct(Object.fromEntries(SlotId.literals.map((s) => [s, Schema.optionalKey(Strings)])));
7
+ /** `"base"` or `"<slot>/<option>"`. */
8
+ export const AddonId = Schema.String.check(Schema.isPattern(/^(?:base|[a-z]+\/[a-z0-9-]+)$/));
9
+ export const AddonFile = Schema.Struct({
10
+ /** relative to the add-on directory */
11
+ path: Schema.String,
12
+ /** relative to the project root */
13
+ target: Schema.String,
14
+ when: Schema.optionalKey(When),
15
+ });
16
+ /** workspace package dir (e.g. `apps/web`) -> package names; versions come from `versions.ts`. */
17
+ const PackagesByDir = Schema.Record(Schema.String, Strings);
18
+ export const AddonManifest = Schema.Struct({
19
+ id: AddonId,
20
+ title: Schema.String,
21
+ description: Schema.String,
22
+ docs: Schema.optionalKey(Schema.String),
23
+ files: Schema.Array(AddonFile),
24
+ dependencies: PackagesByDir,
25
+ devDependencies: PackagesByDir,
26
+ /** workspace package dir (`.` for the root) -> script name -> command; an add-on's script replaces one of the same name */
27
+ scripts: Schema.optionalKey(Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String))),
28
+ envVars: Schema.Array(Schema.Struct({
29
+ name: Schema.String,
30
+ example: Schema.String,
31
+ description: Schema.String,
32
+ when: Schema.optionalKey(When),
33
+ })),
34
+ requires: Strings,
35
+ conflicts: Strings,
36
+ transforms: Schema.Array(Schema.Struct({
37
+ name: Schema.String,
38
+ args: Schema.Record(Schema.String, Schema.String),
39
+ when: Schema.optionalKey(When),
40
+ })),
41
+ });
42
+ export class AddonLoadError extends Schema.TaggedError()("AddonLoadError", {
43
+ addon: Schema.String,
44
+ reason: Schema.Literals([
45
+ "io",
46
+ "invalid",
47
+ "id-mismatch",
48
+ "missing-file",
49
+ "unknown-reference",
50
+ "no-base",
51
+ ]),
52
+ message: Schema.String,
53
+ }) {
54
+ }
55
+ /** Loads `<templatesDir>/base` and `<templatesDir>/<slot>/<option>` add-ons and cross-checks them. */
56
+ export const loadAddons = (templatesDir) => Effect.gen(function* () {
57
+ const fs = yield* FileSystem.FileSystem;
58
+ const path = yield* Path.Path;
59
+ const fail = (addon, reason, message) => new AddonLoadError({ addon, reason, message });
60
+ const io = (addon, eff) => eff.pipe(Effect.mapError((e) => fail(addon, "io", e.message)));
61
+ const dirs = [];
62
+ for (const entry of yield* io(templatesDir, fs.readDirectory(templatesDir))) {
63
+ const dir = path.join(templatesDir, entry);
64
+ if (!(yield* io(dir, fs.stat(dir))).type.startsWith("Directory"))
65
+ continue;
66
+ if (yield* io(dir, fs.exists(path.join(dir, "addon.json")))) {
67
+ dirs.push({ id: entry, dir });
68
+ continue;
69
+ }
70
+ for (const option of yield* io(dir, fs.readDirectory(dir))) {
71
+ const optionDir = path.join(dir, option);
72
+ if (yield* io(optionDir, fs.exists(path.join(optionDir, "addon.json"))))
73
+ dirs.push({ id: `${entry}/${option}`, dir: optionDir });
74
+ }
75
+ }
76
+ const addons = new Map();
77
+ for (const { id, dir } of dirs.toSorted((a, b) => a.id.localeCompare(b.id))) {
78
+ const file = path.join(dir, "addon.json");
79
+ const text = yield* io(id, fs.readFileString(file));
80
+ const json = yield* Effect.try({
81
+ try: () => JSON.parse(text),
82
+ catch: (e) => fail(id, "invalid", `${file}: ${String(e)}`),
83
+ });
84
+ const manifest = yield* Schema.decodeUnknownEffect(AddonManifest)(json).pipe(Effect.mapError((e) => fail(id, "invalid", `${file}: ${e.message}`)));
85
+ if (manifest.id !== id)
86
+ return yield* fail(id, "id-mismatch", `${file}: id "${manifest.id}" must be "${id}"`);
87
+ addons.set(id, { manifest, dir });
88
+ }
89
+ if (!addons.has("base"))
90
+ return yield* fail("base", "no-base", `${templatesDir}/base/addon.json not found`);
91
+ for (const { manifest, dir } of addons.values()) {
92
+ for (const ref of [...manifest.requires, ...manifest.conflicts])
93
+ if (!addons.has(ref))
94
+ return yield* fail(manifest.id, "unknown-reference", `references unknown add-on "${ref}"`);
95
+ for (const f of manifest.files)
96
+ if (!(yield* io(manifest.id, fs.exists(path.join(dir, f.path)))))
97
+ return yield* fail(manifest.id, "missing-file", `file "${f.path}" does not exist in ${dir}`);
98
+ }
99
+ return addons;
100
+ });
101
+ /** `base`, then one id per slot whose value isn't `none`, then the extras, all in slot order (later overlays win). */
102
+ export const addonIdsFor = (config) => {
103
+ const ids = ["base"];
104
+ for (const slot of slots) {
105
+ if (slot.id === "extras") {
106
+ // canonical slot-option order, so overlay order doesn't depend on the order extras were given
107
+ const order = slot.options.map((o) => o.id);
108
+ const chosen = [...new Set(config.extras)].toSorted((a, b) => order.indexOf(a) - order.indexOf(b));
109
+ ids.push(...chosen.map((e) => `extras/${e}`));
110
+ }
111
+ else if (config[slot.id] !== "none")
112
+ ids.push(`${slot.id}/${config[slot.id]}`);
113
+ }
114
+ return ids;
115
+ };
package/dist/bin.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { NodeRuntime, NodeServices } from "@effect/platform-node";
3
+ import { Effect, Layer } from "effect";
4
+ import { main } from "./cli.js";
5
+ import { PromptIOLive } from "./prompts/navigable.js";
6
+ main.pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, PromptIOLive)), NodeRuntime.runMain);
package/dist/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ import { Command } from "effect/cli";
2
+ import { addCommand } from "./commands/add.js";
3
+ import { createCommand, createConfig, createHandler } from "./commands/create.js";
4
+ import { efforgeVersion } from "./versions.js";
5
+ /** Root behaves as `create`; `efforge create` is an explicit alias, `efforge add` is separate. */
6
+ export const root = Command.make("create-efforge", createConfig, createHandler).pipe(Command.withDescription("Scaffold an Effect + TanStack Start app on Cloudflare with database, auth and services already wired together"), Command.withSubcommands([createCommand, addCommand]));
7
+ export const main = Command.run(root, { version: efforgeVersion });
8
+ /** Same command, but with explicit arguments (used by tests). */
9
+ export const runWith = Command.runWith(root, { version: efforgeVersion });