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.
- package/LICENSE +21 -0
- package/README.md +140 -2
- package/dist/addon.js +115 -0
- package/dist/bin.js +6 -0
- package/dist/cli.js +9 -0
- package/dist/commands/add.js +440 -0
- package/dist/commands/create.js +186 -0
- package/dist/diff.js +72 -0
- package/dist/exec.js +20 -0
- package/dist/generate.js +181 -0
- package/dist/manifest.js +14 -0
- package/dist/projectName.js +41 -0
- package/dist/prompts/flow.js +111 -0
- package/dist/prompts/navigable.js +97 -0
- package/dist/routeTree.js +7 -0
- package/dist/rules.js +24 -0
- package/dist/slots.js +96 -0
- package/dist/stack.js +68 -0
- package/dist/transforms/addAlchemyResource.js +71 -0
- package/dist/transforms/addArrayItem.js +31 -0
- package/dist/transforms/addAuthPlugin.js +77 -0
- package/dist/transforms/addDevVar.js +18 -0
- package/dist/transforms/addExport.js +46 -0
- package/dist/transforms/addImport.js +11 -0
- package/dist/transforms/addLayer.js +31 -0
- package/dist/transforms/addServerFnMiddleware.js +62 -0
- package/dist/transforms/addWorkflowSecret.js +43 -0
- package/dist/transforms/addWranglerBinding.js +61 -0
- package/dist/transforms/appendAgentsSection.js +26 -0
- package/dist/transforms/errors.js +7 -0
- package/dist/transforms/index.js +40 -0
- package/dist/transforms/setWranglerValue.js +40 -0
- package/dist/transforms/util.js +219 -0
- package/dist/tree.js +1 -0
- package/dist/versions.js +73 -0
- package/dist/write.js +26 -0
- package/package.json +63 -4
- package/templates/ai/effect-ai-byok/addon.json +619 -0
- package/templates/ai/effect-ai-byok/files/core/llm-crypto.test.ts +47 -0
- package/templates/ai/effect-ai-byok/files/core/llm-crypto.ts +76 -0
- package/templates/ai/effect-ai-byok/files/core/llm-store.ts +21 -0
- package/templates/ai/effect-ai-byok/files/core/llm.ts +32 -0
- package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/migration.sql +9 -0
- package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/snapshot.json +944 -0
- package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/migration.sql +10 -0
- package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/snapshot.json +1232 -0
- package/templates/ai/effect-ai-byok/files/routes/ai.tsx +193 -0
- package/templates/ai/effect-ai-byok/files/schema/d1.ts +16 -0
- package/templates/ai/effect-ai-byok/files/schema/pg.ts +14 -0
- package/templates/ai/effect-ai-byok/files/server/ai-settings.ts +129 -0
- package/templates/ai/effect-ai-byok/files/server/ai.ts +25 -0
- package/templates/ai/effect-ai-byok/files/server/llm-env.ts +48 -0
- package/templates/ai/effect-ai-byok/files/server/llm-orgs.ts +146 -0
- package/templates/ai/effect-ai-byok/files/server/llm-provider.ts +56 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-drizzle.ts +48 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-sql-d1.ts +41 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-sql-pg.ts +41 -0
- package/templates/ai/effect-ai-byok/files/sql/d1.sql +8 -0
- package/templates/ai/effect-ai-byok/files/sql/pg.sql +8 -0
- package/templates/auth/better-auth/addon.json +424 -0
- package/templates/auth/better-auth/files/core/Auth.ts +18 -0
- package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/migration.sql +51 -0
- package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/snapshot.json +522 -0
- package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/migration.sql +51 -0
- package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/snapshot.json +680 -0
- package/templates/auth/better-auth/files/lib/auth-client.ts +4 -0
- package/templates/auth/better-auth/files/routes/app.tsx +54 -0
- package/templates/auth/better-auth/files/schema/d1/auth-schema.ts +86 -0
- package/templates/auth/better-auth/files/schema/pg/auth-schema.ts +73 -0
- package/templates/auth/better-auth/files/server/auth-live.ts +47 -0
- package/templates/auth/better-auth/files/server/session.ts +14 -0
- package/templates/auth/better-auth/files/shared/components/auth-card.tsx +32 -0
- package/templates/auth/better-auth/files/shared/components/user-menu.tsx +44 -0
- package/templates/auth/better-auth/files/shared/drizzle/d1/drizzle.config.ts +7 -0
- package/templates/auth/better-auth/files/shared/drizzle/pg/drizzle.config.ts +10 -0
- package/templates/auth/better-auth/files/shared/lib/form.ts +5 -0
- package/templates/auth/better-auth/files/shared/lib/redirect.ts +6 -0
- package/templates/auth/better-auth/files/shared/routes/app/index.tsx +54 -0
- package/templates/auth/better-auth/files/shared/routes/sign-in.tsx +85 -0
- package/templates/auth/better-auth/files/shared/routes/sign-up.tsx +91 -0
- package/templates/auth/better-auth/files/shared/server/auth-route.ts +15 -0
- package/templates/auth/better-auth/files/shared/server/auth.ts +22 -0
- package/templates/auth/better-auth/files/shared/server/db/d1-drizzle.ts +25 -0
- package/templates/auth/better-auth/files/shared/server/db/d1-effect-sql.ts +17 -0
- package/templates/auth/better-auth/files/shared/server/db/pg-drizzle.ts +32 -0
- package/templates/auth/better-auth/files/shared/server/db/pg-effect-sql.ts +29 -0
- package/templates/auth/better-auth/files/shared/server/require-session.ts +20 -0
- package/templates/auth/better-auth/files/sql/d1/0002_auth.sql +13 -0
- package/templates/auth/better-auth/files/sql/pg/0002_auth.sql +13 -0
- package/templates/auth/better-auth-orgs/addon.json +463 -0
- package/templates/auth/better-auth-orgs/files/components/org-switcher.tsx +65 -0
- package/templates/auth/better-auth-orgs/files/core/Auth.ts +20 -0
- package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/migration.sql +88 -0
- package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/snapshot.json +862 -0
- package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/migration.sql +88 -0
- package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/snapshot.json +1127 -0
- package/templates/auth/better-auth-orgs/files/lib/auth-client.ts +5 -0
- package/templates/auth/better-auth-orgs/files/routes/accept-invite.$id.tsx +68 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings/index.tsx +27 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings/members.tsx +198 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings.tsx +30 -0
- package/templates/auth/better-auth-orgs/files/routes/app.tsx +58 -0
- package/templates/auth/better-auth-orgs/files/routes/onboarding.tsx +66 -0
- package/templates/auth/better-auth-orgs/files/schema/d1/auth-schema.ts +139 -0
- package/templates/auth/better-auth-orgs/files/schema/pg/auth-schema.ts +124 -0
- package/templates/auth/better-auth-orgs/files/server/auth-live.ts +52 -0
- package/templates/auth/better-auth-orgs/files/server/session.ts +44 -0
- package/templates/auth/better-auth-orgs/files/sql/d1/0002_auth.sql +27 -0
- package/templates/auth/better-auth-orgs/files/sql/pg/0002_auth.sql +27 -0
- package/templates/base/addon.json +212 -0
- package/templates/base/files/AGENTS.md +70 -0
- package/templates/base/files/CLAUDE.md +1 -0
- package/templates/base/files/README.md +28 -0
- package/templates/base/files/core/package.json +13 -0
- package/templates/base/files/core/src/index.ts +2 -0
- package/templates/base/files/core/test/core.test.ts +4 -0
- package/templates/base/files/core/tsconfig.json +6 -0
- package/templates/base/files/gitignore +11 -0
- package/templates/base/files/pnpm-workspace.yaml +11 -0
- package/templates/base/files/root/package.json +16 -0
- package/templates/base/files/root/tsconfig.base.json +19 -0
- package/templates/base/files/root/turbo.json +9 -0
- package/templates/base/files/root/vite.config.ts +61 -0
- package/templates/base/files/web/components.json +21 -0
- package/templates/base/files/web/package.json +17 -0
- package/templates/base/files/web/src/components/theme-provider.tsx +57 -0
- package/templates/base/files/web/src/components/theme-toggle.tsx +34 -0
- package/templates/base/files/web/src/components/ui/avatar.tsx +93 -0
- package/templates/base/files/web/src/components/ui/button.tsx +61 -0
- package/templates/base/files/web/src/components/ui/card.tsx +74 -0
- package/templates/base/files/web/src/components/ui/dialog.tsx +141 -0
- package/templates/base/files/web/src/components/ui/dropdown-menu.tsx +225 -0
- package/templates/base/files/web/src/components/ui/input.tsx +20 -0
- package/templates/base/files/web/src/components/ui/label.tsx +18 -0
- package/templates/base/files/web/src/components/ui/sonner.tsx +45 -0
- package/templates/base/files/web/src/components/widgets.tsx +4 -0
- package/templates/base/files/web/src/lib/utils.ts +6 -0
- package/templates/base/files/web/src/router.tsx +12 -0
- package/templates/base/files/web/src/routes/__root.tsx +42 -0
- package/templates/base/files/web/src/routes/app/index.tsx +27 -0
- package/templates/base/files/web/src/routes/app/settings.tsx +29 -0
- package/templates/base/files/web/src/routes/app.tsx +47 -0
- package/templates/base/files/web/src/routes/index.tsx +51 -0
- package/templates/base/files/web/src/server/greeting.ts +12 -0
- package/templates/base/files/web/src/server/layers.ts +10 -0
- package/templates/base/files/web/src/server/runtime.ts +5 -0
- package/templates/base/files/web/src/styles.css +81 -0
- package/templates/base/files/web/tsconfig.json +11 -0
- package/templates/base/files/web/vite.config.ts +9 -0
- package/templates/database/d1/addon.json +118 -0
- package/templates/database/d1/files/package.json +12 -0
- package/templates/database/d1/files/tsconfig.json +5 -0
- package/templates/database/postgres/addon.json +142 -0
- package/templates/database/postgres/files/docker-compose.yml +21 -0
- package/templates/database/postgres/files/package.json +12 -0
- package/templates/database/postgres/files/runtime.ts +12 -0
- package/templates/database/postgres/files/tsconfig.json +5 -0
- package/templates/extras/browser/addon.json +173 -0
- package/templates/extras/browser/files/BrowserContainer.ts +14 -0
- package/templates/extras/browser/files/app/Dockerfile +15 -0
- package/templates/extras/browser/files/app/dockerignore +1 -0
- package/templates/extras/browser/files/app/package-lock +605 -0
- package/templates/extras/browser/files/app/package.json +9 -0
- package/templates/extras/browser/files/app/src/server.ts +78 -0
- package/templates/extras/browser/files/app/src/url-policy.ts +115 -0
- package/templates/extras/browser/files/app/tsconfig.json +6 -0
- package/templates/extras/browser/files/browser.ts +34 -0
- package/templates/extras/browser/files/core-browser.ts +21 -0
- package/templates/extras/browser/files/run-browser.ts +25 -0
- package/templates/extras/email/addon.json +182 -0
- package/templates/extras/email/files/core-mailer.ts +28 -0
- package/templates/extras/email/files/invitation-email.ts +38 -0
- package/templates/extras/email/files/mailer.ts +58 -0
- package/templates/extras/realtime/addon.json +135 -0
- package/templates/extras/realtime/files/Room.ts +46 -0
- package/templates/extras/realtime/files/core-realtime.ts +19 -0
- package/templates/extras/realtime/files/realtime-demo.tsx +40 -0
- package/templates/extras/realtime/files/realtime-limits.test.ts +32 -0
- package/templates/extras/realtime/files/realtime-limits.ts +35 -0
- package/templates/extras/realtime/files/realtime-route.ts +39 -0
- package/templates/extras/realtime/files/realtime.ts +39 -0
- package/templates/extras/realtime/files/use-room.ts +67 -0
- package/templates/extras/storage/addon.json +132 -0
- package/templates/extras/storage/files/core-storage.ts +64 -0
- package/templates/extras/storage/files/storage-route.ts +50 -0
- package/templates/extras/storage/files/storage-security.test.ts +71 -0
- package/templates/extras/storage/files/storage-security.ts +92 -0
- package/templates/extras/storage/files/storage.ts +84 -0
- package/templates/extras/workflows/addon.json +95 -0
- package/templates/extras/workflows/files/Example.ts +42 -0
- package/templates/extras/workflows/files/core-jobs.ts +45 -0
- package/templates/extras/workflows/files/example-job.ts +36 -0
- package/templates/extras/workflows/files/jobs.ts +34 -0
- package/templates/infra/alchemy/addon.json +37 -0
- package/templates/infra/alchemy/files/README.md +27 -0
- package/templates/infra/alchemy/files/alchemy.run.ts +36 -0
- package/templates/infra/alchemy/files/github/deploy.yml +63 -0
- package/templates/infra/alchemy/files/tsconfig.json +5 -0
- package/templates/infra/alchemy/files/vite.config.ts +30 -0
- package/templates/orm/drizzle/addon.json +188 -0
- package/templates/orm/drizzle/files/d1/Database.ts +7 -0
- package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/migration.sql +10 -0
- package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/snapshot.json +60 -0
- package/templates/orm/drizzle/files/d1/drizzle.config.ts +7 -0
- package/templates/orm/drizzle/files/d1/layer.ts +13 -0
- package/templates/orm/drizzle/files/d1/migrate.ts +37 -0
- package/templates/orm/drizzle/files/d1/schema.ts +15 -0
- package/templates/orm/drizzle/files/pg/Database.ts +7 -0
- package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/migration.sql +10 -0
- package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/snapshot.json +75 -0
- package/templates/orm/drizzle/files/pg/drizzle.config.ts +10 -0
- package/templates/orm/drizzle/files/pg/layer.ts +16 -0
- package/templates/orm/drizzle/files/pg/migrate.ts +24 -0
- package/templates/orm/drizzle/files/pg/schema.ts +11 -0
- package/templates/orm/drizzle/files/shared/index.ts +2 -0
- package/templates/orm/drizzle/files/shared/notes.ts +15 -0
- package/templates/orm/drizzle/files/shared/page.tsx +50 -0
- package/templates/orm/effect-sql/addon.json +124 -0
- package/templates/orm/effect-sql/files/d1/layer.ts +13 -0
- package/templates/orm/effect-sql/files/d1/migrate.ts +20 -0
- package/templates/orm/effect-sql/files/d1/schema.ts +7 -0
- package/templates/orm/effect-sql/files/d1-sql/0001_init.sql +10 -0
- package/templates/orm/effect-sql/files/pg/layer.ts +16 -0
- package/templates/orm/effect-sql/files/pg/migrate.ts +66 -0
- package/templates/orm/effect-sql/files/pg/schema.ts +7 -0
- package/templates/orm/effect-sql/files/pg-sql/0001_init.sql +10 -0
- package/templates/orm/effect-sql/files/shared/Database.ts +7 -0
- package/templates/orm/effect-sql/files/shared/index.ts +2 -0
- package/templates/orm/effect-sql/files/shared/notes.ts +18 -0
- package/templates/orm/effect-sql/files/shared/page.tsx +50 -0
- package/templates/runtime/cloudflare/addon.json +52 -0
- package/templates/runtime/cloudflare/files/cloudflare.ts +10 -0
- package/templates/runtime/cloudflare/files/routes.ts +5 -0
- package/templates/runtime/cloudflare/files/server.ts +22 -0
- package/templates/runtime/cloudflare/files/tsconfig.json +12 -0
- package/templates/runtime/cloudflare/files/vite.config.ts +20 -0
- 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
|
-
|
|
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
|
-
|
|
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 });
|