create-sordo 0.3.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # create-sordo
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 5a49288: Fix the gaps found verifying the Cloudflare recipe. The UI starter now installs `tailwindcss`, and `--deploy cloudflare` on edge adds `@sordo/deploy-cloudflare` plus a `plugins` entry to `sordo.config.ts`. Edge builds in the default inline mode now serve `public/` files at `/_sordo/assets/<name>`. Build failures report the bundler's logs instead of a bare "Bundle failed", and a css build that cannot resolve a package names it. The generated edge `fetch` is typed so it passes a strict tsconfig. The README augments `SordoBindings` through `sordo/middleware` and no longer claims the scaffold's `build` script generates CSS.
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 10e162a: UI starters use sordo's `css` build entry: the generated `sordo.config.ts` sets `css: "app/styles/app.css"` and `bun-plugin-tailwind` replaces `@tailwindcss/cli`. The `css` / `css:watch` scripts, `app.generated.css`, `css.d.ts`, the `/api/styles` route and `_head.tsx` (plus the `head` re-exports) are gone.
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sordo",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Scaffolder for new Sordo projects.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.ts CHANGED
@@ -145,6 +145,9 @@ export async function run(argv: string[]): Promise<number> {
145
145
  // Gating (spec 18 §Behavior): backend has no UI surface; only full-stack
146
146
  // projects can be a monorepo or use the container target.
147
147
  if (args.type === "backend") args.ui = false;
148
+ // Deploy plugins only apply to the edge target; the README and package.json
149
+ // would otherwise describe a plugin that isn't installed.
150
+ if (args.target !== "edge") args.deploy = "none";
148
151
  if (args.type !== "fullstack") {
149
152
  args.monorepo = false;
150
153
  if (args.target === "container") {
@@ -416,27 +419,12 @@ async function applyProjectType(
416
419
  }
417
420
  }
418
421
 
419
- function pkgScripts(ui: boolean): Record<string, string> {
420
- if (!ui) {
421
- return {
422
- dev: "sordo dev",
423
- build: "sordo build",
424
- start: "sordo start",
425
- typecheck: "tsc --noEmit",
426
- };
427
- }
428
- // UI projects compile Tailwind themselves (Sordo bundles no CSS). `css`
429
- // emits the sheet the styles route serves; `dev`/`build` run it first so the
430
- // app is styled on boot. `css:watch` rebuilds on className changes in dev.
431
- const css =
432
- "tailwindcss -i app/styles/app.css -o app/styles/app.generated.css";
422
+ function pkgScripts(): Record<string, string> {
433
423
  return {
434
- dev: "bun run css && sordo dev",
435
- build: "bun run css && sordo build",
424
+ dev: "sordo dev",
425
+ build: "sordo build",
436
426
  start: "sordo start",
437
427
  typecheck: "tsc --noEmit",
438
- css,
439
- "css:watch": `${css} --watch`,
440
428
  };
441
429
  }
442
430
 
@@ -458,6 +446,9 @@ async function writeAppPackageJson(
458
446
  "bun-types": "^1.3.0",
459
447
  typescript: "^5.5.0",
460
448
  };
449
+ if (wantsCloudflarePlugin(args)) {
450
+ devDependencies["@sordo/deploy-cloudflare"] = `^${SORDO_VERSION}`;
451
+ }
461
452
  if (args.ui) {
462
453
  Object.assign(
463
454
  dependencies,
@@ -470,7 +461,7 @@ async function writeAppPackageJson(
470
461
  version: "0.1.0",
471
462
  private: true,
472
463
  type: "module",
473
- scripts: pkgScripts(args.ui),
464
+ scripts: pkgScripts(),
474
465
  dependencies: sorted(dependencies),
475
466
  devDependencies: sorted(devDependencies),
476
467
  engines: { bun: ">=1.3.0" },
@@ -544,6 +535,10 @@ function configTarget(target: Target): "bun" | "edge" {
544
535
  return target === "edge" ? "edge" : "bun";
545
536
  }
546
537
 
538
+ function wantsCloudflarePlugin(args: Args): boolean {
539
+ return args.target === "edge" && args.deploy === "cloudflare";
540
+ }
541
+
547
542
  async function patchSordoConfig(dir: string, args: Args): Promise<void> {
548
543
  const path = `${dir}/sordo.config.ts`;
549
544
  if (!(await Bun.file(path).exists())) return;
@@ -560,6 +555,33 @@ async function patchSordoConfig(dir: string, args: Args): Promise<void> {
560
555
  (m) => `${m.replace(/,?\n$/, ",\n")}\tagentsMd: { path: "AGENTS.md" },\n`,
561
556
  );
562
557
  }
558
+ // UI starters ship app/styles/app.css; sordo compiles it via `css`.
559
+ if (args.ui && !/\bcss:/.test(nextText)) {
560
+ nextText = nextText.replace(
561
+ /target:\s*"(bun|edge)",?\n/,
562
+ (m) => `${m.replace(/,?\n$/, ",\n")}\tcss: "app/styles/app.css",\n`,
563
+ );
564
+ }
565
+ if (wantsCloudflarePlugin(args) && !/\bplugins:/.test(nextText)) {
566
+ const importRe = /^(import \{ defineConfig \} from "sordo\/config";\n)/;
567
+ const targetRe = /target:\s*"(bun|edge)",?\n/;
568
+ // Patch both or neither: a plugins entry without its import won't load.
569
+ if (!importRe.test(nextText) || !targetRe.test(nextText)) {
570
+ throw new Error(
571
+ "create-sordo: sordo.config.ts template no longer matches the Cloudflare plugin patch",
572
+ );
573
+ }
574
+ nextText = nextText
575
+ .replace(
576
+ importRe,
577
+ `$1import { cloudflare } from "@sordo/deploy-cloudflare";\n`,
578
+ )
579
+ .replace(
580
+ targetRe,
581
+ (m) =>
582
+ `${m.replace(/,?\n$/, ",\n")}\tplugins: [cloudflare({ name: ${JSON.stringify(args.name)} })],\n`,
583
+ );
584
+ }
563
585
  if (nextText !== current) await Bun.write(path, nextText);
564
586
  }
565
587
 
package/src/ui.ts CHANGED
@@ -22,10 +22,11 @@ export const UI_DEPS: Record<string, string> = {
22
22
  "tailwind-merge": "^2.5.0",
23
23
  };
24
24
 
25
- // Dev-only: the Tailwind v4 CLI that compiles app.css → app.generated.css (the
26
- // `css` script `dev`/`build` run for you — see pkgScripts in src/index.ts).
25
+ // Dev-only: the Bun plugin sordo's `css` build entry loads to compile the
26
+ // Tailwind v4 stylesheet (`css: "app/styles/app.css"` in sordo.config.ts).
27
27
  export const UI_DEV_DEPS: Record<string, string> = {
28
- "@tailwindcss/cli": "^4.0.0",
28
+ "bun-plugin-tailwind": "^0.1.2",
29
+ tailwindcss: "^4.0.0",
29
30
  };
30
31
 
31
32
  const STARTER_COMPONENTS = ["button", "card", "input", "label"] as const;
@@ -99,15 +100,15 @@ async function addAppAlias(appRoot: string): Promise<void> {
99
100
  await Bun.write(path, `${JSON.stringify(config, null, "\t")}\n`);
100
101
  }
101
102
 
102
- // Tokens, Tailwind entry, and the stylesheet route both starters share.
103
+ // Tokens and the Tailwind entry both starters share; sordo.config.ts points its
104
+ // `css` option at app.css.
103
105
  async function writeStyling(
104
106
  appRoot: string,
105
107
  theme: Theme,
106
108
  uiStarterDir: string,
107
109
  ): Promise<void> {
108
- const componentsDir = `${appRoot}/app/components`;
109
110
  const stylesDir = `${appRoot}/app/styles`;
110
- await Bun.$`mkdir -p ${componentsDir} ${stylesDir}`.quiet();
111
+ await Bun.$`mkdir -p ${stylesDir}`.quiet();
111
112
 
112
113
  const themeTokens = resolve(uiStarterDir, "themes", theme, "tokens.css");
113
114
  const tokens = existsSync(themeTokens)
@@ -117,26 +118,10 @@ async function writeStyling(
117
118
  // app.css is written (not vendored) because a committed `@theme` stylesheet
118
119
  // would trip this repo's Biome CSS parser, which has Tailwind directives off.
119
120
  await Bun.write(`${stylesDir}/app.css`, APP_CSS);
120
- // Placeholder so the styles route's `type: "text"` import always resolves,
121
- // even before the first `bun run css`. `dev`/`build` recompile it; it's
122
- // gitignored so the real output never gets committed.
123
- await Bun.write(`${stylesDir}/app.generated.css`, GENERATED_CSS_PLACEHOLDER);
124
- // Type for the `type: "text"` CSS import so `tsc --noEmit` stays clean.
125
- await Bun.write(`${stylesDir}/css.d.ts`, CSS_DTS);
126
-
127
- // CSS wiring: Sordo ships no stylesheet link, so the starter serves the
128
- // compiled Tailwind output from an API route and links it via a shared
129
- // `head()`. Pages opt in by re-exporting `head` (the demo + every
130
- // /sordo-init page does).
131
- await Bun.write(`${componentsDir}/_head.tsx`, HEAD_TSX);
132
- const apiDir = `${appRoot}/app/routes/api`;
133
- await Bun.$`mkdir -p ${apiDir}`.quiet();
134
- await Bun.write(`${apiDir}/styles.ts`, STYLES_ROUTE);
135
121
  }
136
122
 
137
123
  // Pre-wired Tailwind v4 + tokens stylesheet (the wiring `sordo ui init`
138
- // prints). Sordo does not bundle Tailwind — compile this with the Tailwind
139
- // CLI; see the generated README "Styling" section.
124
+ // prints). `sordo build` / `sordo dev` compile it via the `css` config option.
140
125
  const APP_CSS = `@import "tailwindcss";
141
126
  @import "./tokens.css";
142
127
 
@@ -165,43 +150,3 @@ const APP_CSS = `@import "tailwindcss";
165
150
  --radius-sm: calc(var(--radius) - 4px);
166
151
  }
167
152
  `;
168
-
169
- // Written before the first compile so the styles route always imports cleanly.
170
- const GENERATED_CSS_PLACEHOLDER = `/* Generated by \`bun run css\` from app/styles/app.css — do not edit.
171
- Empty until the first compile; \`bun run dev\` / \`bun run build\` regenerate it. */
172
- `;
173
-
174
- // Lets \`import css from "./app.generated.css" with { type: "text" }\` typecheck.
175
- const CSS_DTS = `declare module "*.css" {
176
- const css: string;
177
- export default css;
178
- }
179
- `;
180
-
181
- // Shared <head> contributions. Pages re-export this as `head` so every route
182
- // links the compiled stylesheet that app/routes/api/styles.ts serves.
183
- const HEAD_TSX = `import type * as React from "react";
184
-
185
- // Sordo links no stylesheet on its own, so the UI starter routes one in here:
186
- // pages re-export this as \`head\` (\`export { head } from "../components/_head.tsx"\`)
187
- // and the renderer emits whatever it returns into <head>. The "_" prefix keeps
188
- // this file out of the route table.
189
- export function head(): React.ReactNode {
190
- return <link rel="stylesheet" href="/api/styles" />;
191
- }
192
- `;
193
-
194
- // API route that hands out the compiled Tailwind sheet. The \`type: "text"\`
195
- // import embeds the CSS into the bundle, so this works in dev and in the
196
- // compiled production binary alike.
197
- const STYLES_ROUTE = `import css from "../../styles/app.generated.css" with { type: "text" };
198
-
199
- // GET /api/styles — the compiled Tailwind stylesheet. Sordo ships no CSS
200
- // pipeline; the \`css\` script (run by \`dev\`/\`build\`) compiles app/styles/app.css
201
- // into app.generated.css, and app/components/_head.tsx links this route.
202
- export function GET(): Response {
203
- return new Response(css, {
204
- headers: { "content-type": "text/css; charset=utf-8" },
205
- });
206
- }
207
- `;
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/sync-versions.ts — do not edit. Versions of the
2
2
  // workspace packages this create-sordo release ships alongside.
3
- export const SORDO_VERSION = "0.3.0";
3
+ export const SORDO_VERSION = "0.5.0";
@@ -108,10 +108,9 @@ from this skill — that is deferred to a future spec.
108
108
  - Islands (interactive client components) live under `app/islands/` and are
109
109
  wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
110
110
  `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
111
- - **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
112
- page route must re-export it (`export { head } from "../components/_head.tsx";`)
113
- or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
114
- classNames; `dev`/`build` compile it for you.
111
+ - **Styling is automatic.** `sordo.config.ts` sets `css: "app/styles/app.css"`;
112
+ `dev`/`build` compile it and link the sheet on every page, so new routes need
113
+ no extra setup.
115
114
  - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
116
115
  - Never re-author component source — stamp from the catalog and import.
117
116
 
@@ -109,10 +109,9 @@ from this skill — that is deferred to a future spec.
109
109
  - Islands (interactive client components) live under `app/islands/` and are
110
110
  wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
111
111
  `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
112
- - **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
113
- page route must re-export it (`export { head } from "../components/_head.tsx";`)
114
- or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
115
- classNames; `dev`/`build` compile it for you.
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.
116
115
  - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
117
116
  - Never re-author component source — stamp from the catalog and import.
118
117
 
@@ -109,10 +109,9 @@ from this skill — that is deferred to a future spec.
109
109
  - Islands (interactive client components) live under `app/islands/` and are
110
110
  wrapped at the use site in `<Island name="…">…</Island>` from `sordo/render`.
111
111
  `chart` and `form` are islands (they pull `recharts` / `react-hook-form`).
112
- - **Styling is opt-in per page.** If `app/components/_head.tsx` exists, every new
113
- page route must re-export it (`export { head } from "../components/_head.tsx";`)
114
- or it renders unstyled. Run `bun run css` (or `bun run css:watch`) after adding
115
- classNames; `dev`/`build` compile it for you.
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.
116
115
  - Mock data lives in `app/lib/mock-<entity>.ts`, typed, with the TODO marker.
117
116
  - Never re-author component source — stamp from the catalog and import.
118
117
 
@@ -53,21 +53,12 @@ the agent section below.
53
53
 
54
54
  ### Styling
55
55
 
56
- Sordo bundles no CSS, so the starter wires Tailwind for you:
56
+ Tailwind is wired through sordo's `css` build entry:
57
57
 
58
- - `app/styles/app.css` is pre-wired (`@import "tailwindcss"` + the token mapping).
59
- - `bun run css` compiles it to `app/styles/app.generated.css` (gitignored).
60
- `bun run dev` and `bun run build` run this first, so the app is styled on boot.
61
- - `app/routes/api/styles.ts` serves the compiled sheet and `app/components/_head.tsx`
62
- links it. Each page re-exports that `head` —
63
- `export { head } from "../components/_head.tsx";` — so add the line to new pages.
64
-
65
- While iterating on classNames, run the watcher in a second terminal so the sheet
66
- rebuilds as you save:
67
-
68
- ```sh
69
- bun run css:watch
70
- ```
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.
71
62
  <!-- /if -->
72
63
 
73
64
  ## Project layout
@@ -125,8 +116,10 @@ docker run -p 3000:3000 {{name}}
125
116
  <!-- if:deploy=cloudflare -->
126
117
  ## Deploy
127
118
 
128
- This project is configured for **Cloudflare** deployment. See the
129
- `@sordo/deploy-cloudflare` plugin docs for the next steps.
119
+ This project is configured for **Cloudflare** deployment: the
120
+ `@sordo/deploy-cloudflare` plugin is installed and listed in `sordo.config.ts`
121
+ (edge target only). Run `bunx wrangler login`, then `bunx sordo deploy`. See
122
+ the plugin docs for options.
130
123
  <!-- /if -->
131
124
  <!-- if:deploy=vercel -->
132
125
  ## Deploy
@@ -2,7 +2,6 @@ node_modules
2
2
  .sordo
3
3
  sordo-gen
4
4
  dist
5
- app/styles/app.generated.css
6
5
  .env
7
6
  .env.local
8
7
  *.log
@@ -11,10 +11,6 @@ import {
11
11
  DialogTrigger,
12
12
  } from "@/components/ui/dialog";
13
13
 
14
- // Links the compiled Tailwind sheet (served by app/routes/api/styles.ts). Every
15
- // page route re-exports this so it renders styled — keep it on new pages too.
16
- export { head } from "../components/_head.tsx";
17
-
18
14
  // Whole-tree hydration: this page's entire React tree hydrates in the browser,
19
15
  // so upstream shadcn/ui components work as written — function props, shared
20
16
  // context, no island wrappers. Pages without this export ship zero JS.
@@ -8,10 +8,6 @@ import {
8
8
  } from "../components/ui/card.tsx";
9
9
  import TodoApp from "../islands/TodoApp.tsx";
10
10
 
11
- // Links the compiled Tailwind sheet (served by app/routes/api/styles.ts). Every
12
- // page route re-exports this so it renders styled — keep it on new pages too.
13
- export { head } from "../components/_head.tsx";
14
-
15
11
  export const meta = {
16
12
  title: "Welcome to Sordo",
17
13
  description: "A Bun-native full-stack meta-framework.",