create-efforge 0.0.0-stage → 0.2.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 +88 -2
- package/dist/addon.js +115 -0
- package/dist/bin.js +13 -0
- package/dist/cli.js +28 -0
- package/dist/commands/add.js +640 -0
- package/dist/commands/create.js +319 -0
- package/dist/commands/list.js +80 -0
- package/dist/diff.js +72 -0
- package/dist/exec.js +33 -0
- package/dist/generate.js +181 -0
- package/dist/manifest.js +14 -0
- package/dist/projectName.js +41 -0
- package/dist/prompts/flow.js +122 -0
- package/dist/prompts/navigable.js +193 -0
- package/dist/routeTree.js +7 -0
- package/dist/rules.js +27 -0
- package/dist/slots.js +116 -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 +28 -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 +52 -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 +202 -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 +216 -0
- package/templates/base/files/AGENTS.md +82 -0
- package/templates/base/files/CLAUDE.md +1 -0
- package/templates/base/files/README.md +32 -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/lint/effect-tests.js +45 -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 +86 -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,89 @@
|
|
|
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 a Cloudflare app where every server capability is an <a href="https://effect.website">Effect</a> service.<br>
|
|
9
|
+
Pick a database, auth, AI and extras now; add more later with one command.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/create-efforge"><img src="https://img.shields.io/npm/v/create-efforge" alt="npm version"></a>
|
|
14
|
+
<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>
|
|
15
|
+
<a href="https://github.com/amagdy46/efforge/blob/main/LICENSE"><img src="https://img.shields.io/github/license/amagdy46/efforge" alt="MIT license"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm create efforge my-app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="https://raw.githubusercontent.com/amagdy46/efforge/main/.github/assets/demo.gif" width="760" alt="Terminal recording: npm create efforge my-app picks Cloudflare D1, Effect SQL, Better Auth with organizations and Storage, installs and commits in a few seconds, then efforge add email adds a Mailer service and lists the new env vars">
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
`pnpm create efforge my-app` and `bun create efforge my-app` work too. The generated project uses pnpm, and needs Node 24.11+ or 26+.
|
|
27
|
+
|
|
28
|
+
## Why efforge
|
|
29
|
+
|
|
30
|
+
You get a TypeScript monorepo: a [TanStack Start](https://tanstack.com/start) app on Cloudflare Workers, with the server side written in Effect.
|
|
31
|
+
|
|
32
|
+
- **Every capability is a service.** Database, auth, mail, storage and AI are Effect services with tagged errors in `packages/core`, implemented as layers and composed in one file, `apps/web/src/server/layers.ts`. Swap a layer to test or to change a provider.
|
|
33
|
+
- **Cloudflare bindings stay at the edge of your code.** Only `apps/web/src/server/cloudflare.ts` reads the Worker environment. Everything else gets bindings through layers, so it runs under `@effect/vitest`.
|
|
34
|
+
- **`efforge add` edits code, not docs.** Adding email later wires the layer, the exports, the binding and the secrets with AST transforms, and refuses to overwrite a file you've changed.
|
|
35
|
+
- **Ready for coding agents.** The generated `AGENTS.md` describes the layout and its rules, and `pnpm check` runs format, lint (with Effect diagnostics) and types.
|
|
36
|
+
|
|
37
|
+
CI generates 15 stacks on every change, installs them and runs typecheck, lint, tests and a build on each. There is no telemetry.
|
|
38
|
+
|
|
39
|
+
Use something else if you want Next.js, a runtime other than Cloudflare, or plain async code without Effect: [create-effect-app](https://github.com/Effect-TS/examples) for an Effect project without the web stack, or `npm create cloudflare` for TanStack Start on Workers without Effect.
|
|
40
|
+
|
|
41
|
+
## Pick your stack
|
|
42
|
+
|
|
43
|
+
The prompts walk through these (and let you go back). Each one is also a flag, so `npm create efforge my-app -- --yes --database=d1 --orm=effect-sql` asks nothing.
|
|
44
|
+
|
|
45
|
+
| Slot | Options | Default |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `database` | `postgres` (via Hyperdrive), `d1`, `none` | `postgres` |
|
|
48
|
+
| `orm` | `drizzle`, `effect-sql`, `none` | `drizzle` |
|
|
49
|
+
| `auth` | `better-auth-orgs`, `better-auth`, `none` | `better-auth-orgs` |
|
|
50
|
+
| `infra` | `none` (`wrangler.jsonc`), `alchemy` | `none` |
|
|
51
|
+
| `ai` | `none`, `effect-ai-byok` | `none` |
|
|
52
|
+
| `extras` | `workflows`, `realtime`, `browser`, `storage`, `email` | none |
|
|
53
|
+
|
|
54
|
+
`orm` is set exactly when `database` is, and `auth` needs a database. When it finishes, efforge prints the next steps for your stack (start Postgres, run migrations, `pnpm dev`) and a command that recreates the same stack.
|
|
55
|
+
|
|
56
|
+
## Add more later
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
npx create-efforge list # every add-on, ✓ for the ones you have
|
|
60
|
+
npx create-efforge add email # wire one in
|
|
61
|
+
npx create-efforge add ai/effect-ai-byok extras/storage --dry-run # see what would change
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`add` reads the stack from `efforge.jsonc`, checks the new choice is compatible, writes the add-on's files and edits the files that compose the app. It computes everything first and writes nothing if any step fails. Files you've edited since they were generated are left alone unless you pass `--overwrite`, and it shows you the diff. When it's done it lists the new env vars to fill in. Run it with a clean git tree and review the result with `git diff`.
|
|
65
|
+
|
|
66
|
+
## What you get
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
apps/web TanStack Start app: Worker entry, routes, shadcn/ui, Tailwind v4
|
|
70
|
+
packages/core service interfaces, tagged errors, schemas
|
|
71
|
+
packages/db schema, migrations, database layer (with a database)
|
|
72
|
+
infra/ alchemy.run.ts (infra=alchemy)
|
|
73
|
+
apps/browser Playwright container image (extras=browser)
|
|
74
|
+
efforge.jsonc your stack choices, read by efforge add
|
|
75
|
+
AGENTS.md layout and rules for coding agents
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The workspace pins exact versions in a pnpm `catalog:`, runs `dev`, `build`, `typecheck` and `test` through Turborepo, and lints and formats with [Vite+](https://viteplus.dev) (Oxlint, Oxfmt).
|
|
79
|
+
|
|
80
|
+
## Status
|
|
81
|
+
|
|
82
|
+
v0.1: Cloudflare is the only runtime, add-ons can be added but not removed, and the CLI's options may still change. Drizzle is pinned to a release candidate and Alchemy support uses a beta. With `--auth=none`, the AI demo endpoint isn't gated; add auth or remove it before deploying. Details and known gaps: [docs/limits.md](https://github.com/amagdy46/efforge/blob/main/docs/limits.md).
|
|
83
|
+
|
|
84
|
+
## Docs
|
|
85
|
+
|
|
86
|
+
- [CLI reference](https://github.com/amagdy46/efforge/blob/main/docs/cli.md): every flag, CI and scripting, `add` in detail
|
|
87
|
+
- [Contributing](https://github.com/amagdy46/efforge/blob/main/CONTRIBUTING.md) and the [changelog](https://github.com/amagdy46/efforge/blob/main/CHANGELOG.md)
|
|
88
|
+
|
|
89
|
+
Prompts by [Clack](https://github.com/bombshell-dev/clack). MIT licensed.
|
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,13 @@
|
|
|
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
|
+
// `efforge list | head` closes the pipe early: that's the reader being done, not an error.
|
|
7
|
+
for (const stream of [process.stdout, process.stderr])
|
|
8
|
+
stream.on("error", (e) => {
|
|
9
|
+
if (e.code === "EPIPE")
|
|
10
|
+
process.exit(0);
|
|
11
|
+
throw e;
|
|
12
|
+
});
|
|
13
|
+
main.pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, PromptIOLive)), NodeRuntime.runMain);
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from "effect/cli";
|
|
2
|
+
import { addCommand } from "./commands/add.js";
|
|
3
|
+
import { createCommand, createConfig, createHandler } from "./commands/create.js";
|
|
4
|
+
import { listCommand } from "./commands/list.js";
|
|
5
|
+
import { efforgeVersion } from "./versions.js";
|
|
6
|
+
/** Root behaves as `create`; `efforge create` is an explicit alias, `add` and `list` are separate. */
|
|
7
|
+
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, listCommand]), Command.withExamples([
|
|
8
|
+
{
|
|
9
|
+
command: "npm create efforge my-app",
|
|
10
|
+
description: "Answer a few questions, then create ./my-app",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
command: "npm create efforge my-app -- --yes --database=d1 --orm=effect-sql",
|
|
14
|
+
description: "No questions: flags, defaults for the rest",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
command: "npm create efforge . -- --yes",
|
|
18
|
+
description: "Create in the current (empty) directory",
|
|
19
|
+
},
|
|
20
|
+
{ command: "npx create-efforge list", description: "See every add-on" },
|
|
21
|
+
{
|
|
22
|
+
command: "npx create-efforge add email storage",
|
|
23
|
+
description: "Add add-ons to an existing project",
|
|
24
|
+
},
|
|
25
|
+
]));
|
|
26
|
+
export const main = Command.run(root, { version: efforgeVersion });
|
|
27
|
+
/** Same command, but with explicit arguments (used by tests). */
|
|
28
|
+
export const runWith = Command.runWith(root, { version: efforgeVersion });
|