create-sordo 0.4.0 → 1.0.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 (62) hide show
  1. package/CHANGELOG.md +5 -119
  2. package/README.md +3 -49
  3. package/bin/create-sordo.ts +1 -10
  4. package/package.json +7 -13
  5. package/src/index.ts +0 -667
  6. package/src/probes.ts +0 -28
  7. package/src/prompts.ts +0 -141
  8. package/src/readme.ts +0 -74
  9. package/src/ui.ts +0 -151
  10. package/src/versions.ts +0 -3
  11. package/templates/_backend/app/routes/api/todos.ts +0 -27
  12. package/templates/_claude/.claude/commands/sordo-init.md +0 -64
  13. package/templates/_claude/.claude/hooks/biome-check.sh +0 -17
  14. package/templates/_claude/.claude/rules/build-time-discovery.md +0 -17
  15. package/templates/_claude/.claude/rules/bun-native.md +0 -28
  16. package/templates/_claude/.claude/rules/filesystem-routing.md +0 -31
  17. package/templates/_claude/.claude/rules/islands.md +0 -46
  18. package/templates/_claude/.claude/rules/optional-ai.md +0 -16
  19. package/templates/_claude/.claude/rules/web-standards-boundary.md +0 -25
  20. package/templates/_claude/.claude/settings.json +0 -22
  21. package/templates/_claude/.claude/skills/sordo/SKILL.md +0 -120
  22. package/templates/_claude/.claude/skills/sordo-cli/SKILL.md +0 -112
  23. package/templates/_claude/CLAUDE.md +0 -28
  24. package/templates/_codex/.codex/README.md +0 -10
  25. package/templates/_codex/.codex/rules/build-time-discovery.md +0 -17
  26. package/templates/_codex/.codex/rules/bun-native.md +0 -28
  27. package/templates/_codex/.codex/rules/filesystem-routing.md +0 -31
  28. package/templates/_codex/.codex/rules/islands.md +0 -46
  29. package/templates/_codex/.codex/rules/optional-ai.md +0 -15
  30. package/templates/_codex/.codex/rules/sordo-cli.md +0 -108
  31. package/templates/_codex/.codex/rules/sordo-patterns.md +0 -121
  32. package/templates/_codex/.codex/rules/web-standards-boundary.md +0 -25
  33. package/templates/_codex/AGENTS.md +0 -27
  34. package/templates/_container/.dockerignore +0 -7
  35. package/templates/_container/Dockerfile +0 -27
  36. package/templates/_monorepo/packages/README.md +0 -18
  37. package/templates/_shared/sordo-patterns.md +0 -121
  38. package/templates/default/README-template.md +0 -172
  39. package/templates/default/app/islands/TodoApp.tsx +0 -83
  40. package/templates/default/app/routes/api/health.ts +0 -8
  41. package/templates/default/app/routes/index.tsx +0 -29
  42. package/templates/default/app/server.ts +0 -28
  43. package/templates/default/gitignore +0 -8
  44. package/templates/default/sordo.config.ts +0 -5
  45. package/templates/default/tsconfig.json +0 -14
  46. package/templates/ui-shadcn/components/button.tsx +0 -63
  47. package/templates/ui-shadcn/components/dialog.tsx +0 -158
  48. package/templates/ui-shadcn/demo/index.tsx +0 -58
  49. package/templates/ui-starter/_internal/cn.ts +0 -6
  50. package/templates/ui-starter/_internal/slot.ts +0 -50
  51. package/templates/ui-starter/_internal/variants.ts +0 -1
  52. package/templates/ui-starter/button.tsx +0 -60
  53. package/templates/ui-starter/card.tsx +0 -92
  54. package/templates/ui-starter/demo/TodoApp.tsx +0 -86
  55. package/templates/ui-starter/demo/index.tsx +0 -41
  56. package/templates/ui-starter/input.tsx +0 -20
  57. package/templates/ui-starter/label.tsx +0 -18
  58. package/templates/ui-starter/themes/neutral/tokens.css +0 -46
  59. package/templates/ui-starter/themes/slate/tokens.css +0 -46
  60. package/templates/ui-starter/themes/stone/tokens.css +0 -46
  61. package/templates/ui-starter/themes/zinc/tokens.css +0 -46
  62. package/templates/ui-starter/tokens.css +0 -46
@@ -1,25 +0,0 @@
1
- # Web-standards boundary rule
2
-
3
- The framework stays close to web standards at handler boundaries. Do
4
- not paper over them with a custom request abstraction.
5
-
6
- - **Handler signature:** `(req: Request, ctx: SordoContext) => Response | Promise<Response>`.
7
- `req` is a standard web `Request`; the handler returns a standard web
8
- `Response`. Streaming responses use `ReadableStream`.
9
- - **`SordoContext` is the only framework-added affordance.** It
10
- exposes `params`, `cookies`, `env`, `vars`, `url`, and the
11
- short-circuit helpers `ctx.json(data, init?)`, `ctx.html(body, init?)`,
12
- `ctx.redirect(to, status?)`. Keep it thin — don't expect a
13
- Next-style `request.cookies.set(...)` API.
14
- - **No Hono / Express / Fastify types.** If you find yourself reaching
15
- for `MiddlewareHandler` from Hono, write the standard
16
- `Middleware = (req, ctx, next) => Promise<Response>` instead.
17
- - **React SSR uses `renderToReadableStream`** (the streaming web API).
18
- Do not use `renderToString` or `renderToPipeableStream`.
19
- - **Client hydration uses `hydrateRoot`** (React 19). Do not use
20
- `ReactDOM.render`.
21
-
22
- If a deployment target needs platform-specific wiring (Vercel edge
23
- context, Cloudflare bindings, etc.), the framework's adapters under
24
- `sordo/adapters` translate to/from these web-standard handlers — that
25
- belongs in the adapter, not in your routes.
@@ -1,27 +0,0 @@
1
- # {{name}}
2
-
3
- Built with Sordo — a Bun-native full-stack meta-framework.
4
-
5
- > Codex reads this file. The conventions below are split into focused
6
- > files under `.codex/rules/`; treat the links here as authoritative —
7
- > open each one when its topic is in scope for the task at hand.
8
-
9
- ## Conventions
10
-
11
- - [Bun-native](.codex/rules/bun-native.md) — reach for Bun primitives, not Node-era replacements.
12
- - [Web-standards boundary](.codex/rules/web-standards-boundary.md) — handlers use standard Request / Response; `SordoContext` stays thin.
13
- - [Filesystem routing](.codex/rules/filesystem-routing.md) — how `app/routes/` becomes URLs.
14
- - [Islands](.codex/rules/islands.md) — when and how to use `app/islands/*.tsx`.
15
- - [Build-time discovery](.codex/rules/build-time-discovery.md) — discovery happens at build time, not at request time.
16
- - [Optional AI dependency](.codex/rules/optional-ai.md) — keep `@anthropic-ai/sdk` import-disjoint from non-AI code paths.
17
- - [Sordo CLI](.codex/rules/sordo-cli.md) — `sordo dev / build / start / deploy / secret`.
18
- - [Sordo patterns](.codex/rules/sordo-patterns.md) — add UI components and scaffold feature patterns (auth, CRM, task board, pivot, dashboard).
19
-
20
- ## Live inventory
21
-
22
- The section between the markers below is regenerated by `sordo dev`
23
- and `sordo build` from the actual contents of `app/`. Everything
24
- outside the markers is preserved across regenerations.
25
-
26
- <!-- sordo:manifest-start -->
27
- <!-- sordo:manifest-end -->
@@ -1,7 +0,0 @@
1
- node_modules
2
- .sordo
3
- .git
4
- *.log
5
- Dockerfile
6
- .dockerignore
7
- README.md
@@ -1,27 +0,0 @@
1
- # syntax=docker/dockerfile:1
2
- # Multi-stage build for a Sordo app on the `bun` adapter.
3
- # Build: docker build -t {{name}} .
4
- # Run: docker run -p 3000:3000 {{name}}
5
-
6
- FROM oven/bun:1.3 AS base
7
- WORKDIR /app
8
-
9
- # --- deps: install once, cached on package.json changes ---
10
- FROM base AS deps
11
- COPY package.json bun.lock* ./
12
- RUN bun install
13
-
14
- # --- build: produce the production server bundle in .sordo/ ---
15
- FROM base AS build
16
- COPY --from=deps /app/node_modules ./node_modules
17
- COPY . .
18
- RUN bunx sordo build --target bun
19
-
20
- # --- release: minimal runtime image ---
21
- FROM base AS release
22
- ENV NODE_ENV=production
23
- COPY --from=deps /app/node_modules ./node_modules
24
- COPY --from=build /app/.sordo ./.sordo
25
- COPY package.json ./
26
- EXPOSE 3000
27
- CMD ["bun", ".sordo/server/server-entry.js"]
@@ -1,18 +0,0 @@
1
- # packages/
2
-
3
- Shared code for this Bun workspace. Create a package per shared concern
4
- (e.g. `packages/ui`, `packages/db`) with its own `package.json`, then depend
5
- on it from an app under `apps/*` using the workspace protocol:
6
-
7
- ```jsonc
8
- // apps/<app>/package.json
9
- {
10
- "dependencies": {
11
- "@{{name}}/ui": "workspace:*"
12
- }
13
- }
14
- ```
15
-
16
- Bun resolves `workspace:*` to the local package and runs scripts
17
- topologically with `bun --filter`. This monorepo is intentionally
18
- Bun-workspaces-only — no Turborepo / Nx.
@@ -1,121 +0,0 @@
1
- <!--
2
- Canonical source for the /sordo pattern catalog (cli spec 19).
3
- Both the Claude skill (.claude/skills/sordo/SKILL.md) and the Codex rule
4
- (.codex/rules/sordo-patterns.md) are generated from this body by
5
- scripts/gen-sordo-skill.ts. Edit THIS file, then run
6
- `bun run generate:sordo-skill`. Do not edit the generated files by hand.
7
- -->
8
-
9
- ## When to use
10
-
11
- Use this when the user wants to **add a UI component** or **scaffold a
12
- feature pattern** (auth + RBAC, a CRM, a task board, a pivot table, a
13
- dashboard). It covers scaffolding only — for running, building, deploying, or
14
- managing secrets, use the `sordo-cli` skill instead.
15
-
16
- Two capabilities:
17
-
18
- 1. **Add a UI component** — a thin wrapper over the deterministic catalog.
19
- 2. **Scaffold a feature pattern** — instruction-driven: you generate the files,
20
- adapting names/fields/copy to the user's domain.
21
-
22
- ## Add a component
23
-
24
- Components are upstream shadcn/ui, stamped verbatim — never hand-author
25
- component source; the shadcn registry is the source of truth.
26
-
27
- 1. If `app/components/ui/_internal/` does not exist, the UI setup isn't
28
- initialized — run `sordo ui init --shadcn` first (it wires the `@/*` alias
29
- and `app/lib/utils.ts`).
30
- 2. Run `sordo add @shadcn/<name>` (preview first with
31
- `sordo add --view @shadcn/<name>` if the user wants to see the source).
32
- 3. Import the stamped component from `app/components/ui/<name>.tsx` and use it.
33
- Pages that render shadcn components must `export const hydrate = true`
34
- (whole-tree hydration).
35
-
36
- `sordo add` edits `package.json` (it never runs an install) and stamps source
37
- into `app/components/ui/`. After adding, remind the user to run `bun install` if
38
- new peer deps were added.
39
-
40
- ## Scaffold a pattern
41
-
42
- Pick a pattern below, `sordo add @shadcn/<name>` its components first, then
43
- generate the listed files — adapting entity names, fields, columns, and copy to
44
- the user's stated domain (e.g. "a CRM for veterinary clinics").
45
-
46
- | Pattern | Goal | `@shadcn/<name>` components | Generated files (under `app/`) |
47
- |---|---|---|---|
48
- | **auth-rbac** | Login / logout + role-gated route | `input`, `label`, `button`, `card` | `routes/login.tsx` (native POST form), `routes/api/login.ts`, `routes/api/logout.ts`, `routes/admin.tsx` (gated by middleware), `app/middleware.ts` (gates `/admin`), `lib/auth.ts` (cookie session over mock users), `lib/rbac.ts` (role guard), `lib/mock-users.ts` |
49
- | **crm** | Contacts list + detail / edit | `table`, `dialog`, `form`, `input`, `button`, `badge` | `routes/contacts/index.tsx` (table), `routes/contacts/[id].tsx` (detail), `islands/ContactForm.tsx`, `lib/mock-contacts.ts` |
50
- | **task** | Task board / list | `card`, `checkbox`, `badge`, `dialog`, `button` | `routes/tasks.tsx`, `islands/TaskBoard.tsx` (columns + toggle), `lib/mock-tasks.ts` |
51
- | **pivot** | Group-by / pivot over rows | `table`, `select`, `card` | `routes/pivot.tsx`, `islands/PivotTable.tsx` (pick row/col/measure), `lib/mock-rows.ts` |
52
- | **dashboard** | Metrics overview | `card`, `chart`, `separator`, `sidebar` | `routes/dashboard.tsx` (cards + chart + sidebar shell), `lib/mock-metrics.ts` |
53
-
54
- Per-pattern recipes:
55
-
56
- - **auth-rbac** — sessions are a signed cookie over the mock user list. Because
57
- pages can't read cookies or redirect (see Conventions), the gate lives in
58
- `app/middleware.ts`: it checks the session + role and redirects unauthenticated
59
- `/admin` hits to `/login`. The login page is a native `<form method="post"
60
- action="/api/login">` (no `form` component) posting to `routes/api/login.ts`,
61
- which sets the cookie and redirects; `routes/api/logout.ts` clears it. Make the
62
- mock-only nature loud: a banner on the login page and a TODO at the top of the
63
- auth module. Real auth needs persistence (a future DB spec).
64
- - **crm** — the list uses `table` over `mock-contacts`; create / edit
65
- happens in a `dialog` driven by a `form` island. The detail route reads the
66
- same mock store by id.
67
- - **task** — the board is an island holding `useState` columns; toggling a
68
- `checkbox` moves a task between done / not-done. No persistence — state resets
69
- on reload (call this out).
70
- - **pivot** — an island lets the user pick a row dimension, a column dimension,
71
- and a numeric measure from `select`s, then renders the aggregated `table`.
72
- Aggregation runs client-side over the mock rows.
73
- - **dashboard** — a static SSR shell (`sidebar` is `subtree`, `chart` hydrates)
74
- with metric `card`s fed by `mock-metrics`; the chart is the one interactive
75
- island.
76
-
77
- Always `sordo add @shadcn/<name>` the listed components (running
78
- `sordo ui init --shadcn` first if needed) before generating files that import
79
- them. Only reference components that exist in the upstream shadcn registry.
80
-
81
- ## Depth contract: UI + mock data
82
-
83
- Every pattern is scaffolded at **"UI + mock data"** depth:
84
-
85
- - **In scope:** SSR routes / pages, islands where interactivity is needed,
86
- stamped UI components, and a typed in-memory seed in
87
- `app/lib/mock-<entity>.ts` that the pages read from.
88
- - **Out of scope:** `bun:sqlite`, migrations, a real persistence or auth
89
- backend, network calls. The pattern *shows the shape*; the developer swaps the
90
- mock data for a real source later.
91
- - Every generated `mock-*` module starts with `// TODO: replace mock data with a
92
- real source`, and the route / page carries a short note marking the mock
93
- boundary.
94
-
95
- Do not generate a database layer, migrations, or a real auth/network backend
96
- from this skill — that is deferred to a future spec.
97
-
98
- ## Conventions
99
-
100
- - Pages live under `app/routes/*.tsx` (default-export a React component); API
101
- handlers under `app/routes/api/*.ts` (named `GET`/`POST`/… returning a
102
- `Response`, e.g. via `ctx.json()`). Dynamic segments use `[id]`. A `.ts` route
103
- **must** be under `app/routes/api/` — anywhere else is a build error.
104
- - **Pages get only `ctx.params`** — they can't read cookies, set headers, or
105
- redirect. Push that work to an API route or to `app/middleware.ts` (the single
106
- global `Middleware (req, ctx, next)`, the only place to gate a page). Mutation
107
- forms use a native `<form method="post" action="/api/…">` posting to a `.ts`
108
- handler.
109
- - Islands (interactive client components) live under `app/islands/` and are
110
- wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
111
- `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
112
- - **Styling is automatic.** `sordo.config.ts` sets `css: "app/styles/app.css"`;
113
- `dev`/`build` compile it and link the sheet on every page, so new routes need
114
- no extra setup.
115
- - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
116
- - Never re-author component source — stamp from the catalog and import.
117
-
118
- ## See also
119
-
120
- - The `sordo-cli` skill — running, building, deploying the app.
121
- - cli specs 11–15 (UI: `ui init`, `add`, `view`, `update`, registries).
@@ -1,172 +0,0 @@
1
- # {{name}}
2
-
3
- Built with [Sordo](https://github.com/bihaviour/sordo) — a
4
- Bun-native full-stack meta-framework.
5
-
6
- <!-- if:type=fullstack -->
7
- ## What you got
8
-
9
- A full-stack Sordo app:
10
-
11
- - `app/routes/index.tsx` — server-rendered page that mounts an island.
12
- - `app/islands/TodoApp.tsx` — `useState`-based todo list, hydrated in the browser.
13
- - `app/routes/api/health.ts` — a JSON API route (`GET /api/health` → `{ ok: true }`).
14
- - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
15
- <!-- /if -->
16
- <!-- if:type=frontend -->
17
- ## What you got
18
-
19
- A frontend Sordo app:
20
-
21
- - `app/routes/index.tsx` — server-rendered page that mounts an island.
22
- - `app/islands/TodoApp.tsx` — `useState`-based todo list, hydrated in the browser.
23
- - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
24
- <!-- /if -->
25
- <!-- if:type=backend -->
26
- ## What you got
27
-
28
- A backend Sordo app — API routes, no React UI:
29
-
30
- - `app/routes/api/health.ts` — `GET /api/health` → `{ ok: true }`.
31
- - `app/routes/api/todos.ts` — a sample in-memory `GET` / `POST` resource.
32
- - `app/server.ts` — dev entry that wires the router into `Bun.serve`.
33
- <!-- /if -->
34
-
35
- ## Run it
36
-
37
- ```sh
38
- bun install # if you used --no-install
39
- <!-- if:monorepo=yes -->bun --filter {{app_name}} dev # → http://localhost:3000<!-- /if -->
40
- <!-- if:monorepo=no -->bunx sordo dev # → http://localhost:3000<!-- /if -->
41
- ```
42
-
43
- <!-- if:ui=yes -->
44
- ## UI starter
45
-
46
- Styled components are stamped into `app/components/ui/` (`button`, `card`,
47
- `input`, `label`) with shared helpers in `app/components/ui/_internal/` and
48
- design tokens in `app/styles/tokens.css`.
49
-
50
- Add more components with `sordo add @shadcn/<component>` (e.g.
51
- `sordo add @shadcn/dialog`), preview first with `sordo add --view @shadcn/<component>`, or ask your coding agent — see
52
- the agent section below.
53
-
54
- ### Styling
55
-
56
- Tailwind is wired through sordo's `css` build entry:
57
-
58
- - `app/styles/app.css` is pre-wired (`@import "tailwindcss"` + the token mapping)
59
- and `sordo.config.ts` points `css` at it.
60
- - `sordo dev` and `sordo build` compile it with `bun-plugin-tailwind` into a
61
- content-hashed sheet that every page links automatically — no per-page setup.
62
- <!-- /if -->
63
-
64
- ## Project layout
65
-
66
- <!-- if:monorepo=yes -->
67
- ```
68
- apps/
69
- {{app_name}}/
70
- app/
71
- routes/ # filesystem-routed pages and API handlers
72
- islands/ # interactive client components
73
- server.ts # dev entry — wires the router into Bun.serve
74
- sordo.config.ts
75
- package.json
76
- packages/ # shared workspace packages
77
- package.json # Bun workspace root
78
- ```
79
-
80
- This is a Bun workspace. Run app scripts with `bun --filter <app> <script>`
81
- (e.g. `bun --filter {{app_name}} build`) or from inside `apps/{{app_name}}/`.
82
- Add more apps under `apps/` and shared code under `packages/`.
83
- <!-- /if -->
84
- <!-- if:monorepo=no -->
85
- ```
86
- app/
87
- routes/ # filesystem-routed pages and API handlers
88
- islands/ # interactive client components
89
- server.ts # dev entry — wires the router into Bun.serve
90
- sordo.config.ts
91
- package.json
92
- tsconfig.json
93
- ```
94
- <!-- /if -->
95
-
96
- ## Build for production
97
-
98
- ```sh
99
- <!-- if:monorepo=yes -->bun --filter {{app_name}} run build<!-- /if -->
100
- <!-- if:monorepo=no -->bun run build<!-- /if -->
101
- ```
102
-
103
- Build artifacts land in `.sordo/`. Run the server bundle with
104
- `bun .sordo/server/server-entry.js`.
105
-
106
- <!-- if:target=container -->
107
- ## Deploy — container
108
-
109
- A `Dockerfile` (+ `.dockerignore`) is included for the `bun` runtime:
110
-
111
- ```sh
112
- docker build -t {{name}} .
113
- docker run -p 3000:3000 {{name}}
114
- ```
115
- <!-- /if -->
116
- <!-- if:deploy=cloudflare -->
117
- ## Deploy
118
-
119
- This project is configured for **Cloudflare** deployment. See the
120
- `@sordo/deploy-cloudflare` plugin docs for the next steps.
121
- <!-- /if -->
122
- <!-- if:deploy=vercel -->
123
- ## Deploy
124
-
125
- This project is configured for **Vercel** deployment. See the
126
- `@sordo/deploy-vercel` plugin docs for the next steps.
127
- <!-- /if -->
128
- <!-- if:deploy=deno -->
129
- ## Deploy
130
-
131
- This project is configured for **Deno Deploy**. See the
132
- `@sordo/deploy-deno` plugin docs for the next steps.
133
- <!-- /if -->
134
- <!-- if:deploy=netlify -->
135
- ## Deploy
136
-
137
- This project is configured for **Netlify Edge**. See the
138
- `@sordo/deploy-netlify` plugin docs for the next steps.
139
- <!-- /if -->
140
-
141
- <!-- if:agent=claude -->
142
- ## Claude Code is set up
143
-
144
- `CLAUDE.md` describes the framework conventions. The `/sordo` skill
145
- (`.claude/skills/sordo/`) adds components and scaffolds feature patterns
146
- (auth, CRM, task board, dashboard, …). For a guided first scaffold, open a new
147
- terminal and run:
148
-
149
- ```sh
150
- claude --permission-mode plan "/sordo-init"
151
- ```
152
- <!-- /if -->
153
- <!-- if:agent=codex -->
154
- ## Codex is set up
155
-
156
- `AGENTS.md` describes the framework conventions and links
157
- `.codex/rules/sordo-patterns.md`, which tells Codex how to add components and
158
- scaffold feature patterns. Open Codex and ask it to scaffold a pattern.
159
- <!-- /if -->
160
- <!-- if:agent=none -->
161
- ## No agent
162
-
163
- Add UI components with `sordo add @shadcn/<component>`. Feature patterns
164
- (auth, CRM, dashboard, …) are agent-driven — scaffold a project with
165
- `--agent claude` or `--agent codex` to get the `/sordo` skill.
166
- <!-- /if -->
167
-
168
- ## Learn more
169
-
170
- - Sordo docs: https://bun-patties.com
171
- - Bun: https://bun.sh
172
- - React 19: https://react.dev
@@ -1,83 +0,0 @@
1
- "use client";
2
-
3
- import { useState } from "react";
4
-
5
- interface Todo {
6
- id: number;
7
- text: string;
8
- done: boolean;
9
- }
10
-
11
- export default function TodoApp() {
12
- const [todos, setTodos] = useState<Todo[]>([
13
- { id: 1, text: "edit app/routes/index.tsx", done: false },
14
- { id: 2, text: "edit app/islands/TodoApp.tsx", done: false },
15
- { id: 3, text: "delete this demo when you're ready", done: false },
16
- ]);
17
- const [draft, setDraft] = useState("");
18
-
19
- function add(): void {
20
- const text = draft.trim();
21
- if (!text) return;
22
- setTodos([...todos, { id: Date.now(), text, done: false }]);
23
- setDraft("");
24
- }
25
-
26
- function toggle(id: number): void {
27
- setTodos(todos.map((t) => (t.id === id ? { ...t, done: !t.done } : t)));
28
- }
29
-
30
- function remove(id: number): void {
31
- setTodos(todos.filter((t) => t.id !== id));
32
- }
33
-
34
- return (
35
- <section aria-label="Todo demo">
36
- <form
37
- onSubmit={(e) => {
38
- e.preventDefault();
39
- add();
40
- }}
41
- >
42
- <input
43
- type="text"
44
- value={draft}
45
- onChange={(e) => setDraft(e.target.value)}
46
- placeholder="What needs doing?"
47
- aria-label="New todo"
48
- />
49
- <button type="submit">Add</button>
50
- </form>
51
- <ul>
52
- {todos.map((t) => (
53
- <li key={t.id}>
54
- <label>
55
- <input
56
- type="checkbox"
57
- checked={t.done}
58
- onChange={() => toggle(t.id)}
59
- />
60
- <span
61
- style={{ textDecoration: t.done ? "line-through" : "none" }}
62
- >
63
- {t.text}
64
- </span>
65
- </label>
66
- <button
67
- type="button"
68
- onClick={() => remove(t.id)}
69
- aria-label="Remove"
70
- >
71
- ×
72
- </button>
73
- </li>
74
- ))}
75
- </ul>
76
- <p>
77
- <small>
78
- {todos.filter((t) => !t.done).length} of {todos.length} remaining
79
- </small>
80
- </p>
81
- </section>
82
- );
83
- }
@@ -1,8 +0,0 @@
1
- import type { SordoContext } from "sordo/middleware";
2
-
3
- // API routes live under app/routes/api/ and export named HTTP methods
4
- // (GET/POST/…) that return a standard Response. `ctx.json()` is the thin
5
- // SordoContext helper for JSON replies.
6
- export function GET(_req: Request, ctx: SordoContext): Response {
7
- return ctx.json({ ok: true });
8
- }
@@ -1,29 +0,0 @@
1
- import { Island } from "sordo/render";
2
- import TodoApp from "../islands/TodoApp.tsx";
3
-
4
- export const meta = {
5
- title: "Welcome to Sordo",
6
- description: "A Bun-native full-stack meta-framework.",
7
- };
8
-
9
- export default function Index() {
10
- return (
11
- <main>
12
- <h1>Welcome to Sordo</h1>
13
- <p>
14
- This page is server-rendered. The list below is a client island —{" "}
15
- <code>app/islands/TodoApp.tsx</code> — hydrated in the browser.
16
- </p>
17
- <Island name="TodoApp">
18
- <TodoApp />
19
- </Island>
20
- <hr />
21
- <p>
22
- <small>
23
- When you're ready, replace this page — or run <code>/sordo-init</code>{" "}
24
- to scaffold your first real feature.
25
- </small>
26
- </p>
27
- </main>
28
- );
29
- }
@@ -1,28 +0,0 @@
1
- import { type DevServer, setupDevClient } from "sordo/dev";
2
- import { createRenderer } from "sordo/render";
3
- import { createRouter } from "sordo/router";
4
- import { startServer } from "sordo/server";
5
-
6
- interface StartOpts {
7
- devServer: DevServer;
8
- port: number;
9
- host: string;
10
- appDir: string;
11
- }
12
-
13
- export default async function start(opts: StartOpts): Promise<void> {
14
- // Bundle islands and serve their chunks under `/_sordo/client/*`.
15
- // `manifest` tells the renderer which <script> to inject so islands hydrate.
16
- const devClient = await setupDevClient({ appDir: opts.appDir });
17
- const renderer = createRenderer({ manifest: devClient.manifest, dev: true });
18
- const router = await createRouter({ appDir: opts.appDir, renderer });
19
-
20
- startServer({
21
- port: opts.port,
22
- hostname: opts.host,
23
- dev: true,
24
- devServer: opts.devServer,
25
- routes: { ...devClient.routes, ...router.routes },
26
- fallback: router.fallback,
27
- });
28
- }
@@ -1,8 +0,0 @@
1
- node_modules
2
- .sordo
3
- sordo-gen
4
- dist
5
- .env
6
- .env.local
7
- *.log
8
- .DS_Store
@@ -1,5 +0,0 @@
1
- import { defineConfig } from "sordo/config";
2
-
3
- export default defineConfig({
4
- target: "bun",
5
- });
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "jsx": "react-jsx",
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "noEmit": true,
10
- "allowImportingTsExtensions": true,
11
- "types": ["bun-types", "react", "react-dom"]
12
- },
13
- "include": ["app", "sordo.config.ts"]
14
- }
@@ -1,63 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
- import { cn } from "cn"
4
- import { Slot } from "radix-ui"
5
-
6
- const buttonVariants = cva(
7
- "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
- {
9
- variants: {
10
- variant: {
11
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
12
- destructive:
13
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
14
- outline:
15
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
16
- secondary:
17
- "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
- ghost:
19
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
20
- link: "text-primary underline-offset-4 hover:underline",
21
- },
22
- size: {
23
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
24
- xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
25
- sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
26
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
- icon: "size-9",
28
- "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
29
- "icon-sm": "size-8",
30
- "icon-lg": "size-10",
31
- },
32
- },
33
- defaultVariants: {
34
- variant: "default",
35
- size: "default",
36
- },
37
- }
38
- )
39
-
40
- function Button({
41
- className,
42
- variant = "default",
43
- size = "default",
44
- asChild = false,
45
- ...props
46
- }: React.ComponentProps<"button"> &
47
- VariantProps<typeof buttonVariants> & {
48
- asChild?: boolean
49
- }) {
50
- const Comp = asChild ? Slot.Root : "button"
51
-
52
- return (
53
- <Comp
54
- data-slot="button"
55
- data-variant={variant}
56
- data-size={size}
57
- className={cn(buttonVariants({ variant, size, className }))}
58
- {...props}
59
- />
60
- )
61
- }
62
-
63
- export { Button, buttonVariants }