@brust/create-app 2.0.0-alpha.3 → 2.0.0-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brust/create-app",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "Scaffold a brust v2 app — bun create @brust/app <name>",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/args.ts CHANGED
@@ -5,7 +5,7 @@ import { isAbsolute, resolve } from 'node:path'
5
5
  const NAME_RE = /^[a-z0-9][a-z0-9_-]*$/
6
6
  const MAX_NAME_LEN = 50
7
7
 
8
- export const USAGE = 'usage: bun create @brust/app <name> [--template blank|pokedex] [--dir <path>] [--yes] [--brust-dep <spec>]'
8
+ export const USAGE = 'usage: bun create @brust/app <name> [--template blank|pokedex] [--tailwind] [--dir <path>] [--yes] [--brust-dep <spec>]'
9
9
 
10
10
  export interface ParsedArgs {
11
11
  projectName: string
@@ -13,6 +13,8 @@ export interface ParsedArgs {
13
13
  template?: string
14
14
  yes: boolean
15
15
  brustDep?: string
16
+ /** `--tailwind` (L21): accepted and ignored since L28: the blank template uses Tailwind CSS v4 by default. */
17
+ tailwind: boolean
16
18
  help: boolean
17
19
  }
18
20
 
@@ -22,6 +24,7 @@ export function parseArgs(args: string[]): ParsedArgs {
22
24
  let template: string | undefined
23
25
  let brustDep: string | undefined
24
26
  let yes = false
27
+ let tailwind = false
25
28
  let help = false
26
29
  const need = (flag: string, v: string | undefined): string => {
27
30
  if (!v) throw new Error(`create-app: ${flag} requires a value`)
@@ -39,12 +42,13 @@ export function parseArgs(args: string[]): ParsedArgs {
39
42
  else if (a === '--brust-dep') brustDep = need('--brust-dep', args[++i])
40
43
  else if (a.startsWith('--brust-dep=')) brustDep = need('--brust-dep', a.slice('--brust-dep='.length))
41
44
  else if (a === '--yes' || a === '-y') yes = true
45
+ else if (a === '--tailwind') tailwind = true
42
46
  else if (a.startsWith('-')) throw new Error(`create-app: unknown flag "${a}"`)
43
47
  else if (name === undefined) name = a
44
48
  else throw new Error(`create-app: unexpected positional argument "${a}"`)
45
49
  }
46
50
 
47
- if (help) return { projectName: name ?? '', targetDir: '', template, yes, brustDep, help }
51
+ if (help) return { projectName: name ?? '', targetDir: '', template, yes, brustDep, tailwind, help }
48
52
  if (!name) throw new Error(`create-app: missing project name. ${USAGE}`)
49
53
  if (name.length > MAX_NAME_LEN) throw new Error(`create-app: project name too long (max ${MAX_NAME_LEN} chars)`)
50
54
  if (!NAME_RE.test(name)) {
@@ -52,5 +56,5 @@ export function parseArgs(args: string[]): ParsedArgs {
52
56
  }
53
57
  const cwd = process.cwd()
54
58
  const targetDir = dir ? (isAbsolute(dir) ? dir : resolve(cwd, dir)) : resolve(cwd, name)
55
- return { projectName: name, targetDir, template, yes, brustDep, help }
59
+ return { projectName: name, targetDir, template, yes, brustDep, tailwind, help }
56
60
  }
package/src/cli.ts CHANGED
@@ -4,6 +4,7 @@ import { readdir, rm } from 'node:fs/promises'
4
4
  import { copyTemplate } from './copy.ts'
5
5
  import { parseArgs, USAGE } from './args.ts'
6
6
  import { applyOverrides, monorepoRoot, resolveBrustDep } from './dep.ts'
7
+ import { TAILWIND_DEFAULT_NOTE } from './tailwind.ts'
7
8
  import { selectTemplate } from './templates.ts'
8
9
 
9
10
  const fail = (msg: string): never => {
@@ -26,6 +27,8 @@ export async function main(argv: string[]): Promise<void> {
26
27
 
27
28
  let tmpl: ReturnType<typeof selectTemplate>
28
29
  try { tmpl = selectTemplate({ explicit: parsed.template, yes: parsed.yes, isTTY: Boolean(process.stdin.isTTY) }) } catch (e) { return fail(msg(e)) }
30
+ // L28 R29.1: Tailwind is the blank template's default; the flag stays accepted so older instructions still work.
31
+ if (parsed.tailwind) console.log(TAILWIND_DEFAULT_NOTE)
29
32
  const dep = resolveBrustDep({ explicit: parsed.brustDep, targetDir })
30
33
 
31
34
  try {
@@ -0,0 +1,9 @@
1
+ // Tailwind CSS v4 in the blank template (gaps round L21, made the default by L28 R29.1): the template ships `app.css`
2
+ // (`@import "tailwindcss"` + `@theme` tokens), the layout imports it (brust builds it and links it in <head>, L19), and
3
+ // the two pinned dev dependencies below are in its package.json (R21.1: the app's own). `--tailwind` no longer changes
4
+ // anything; it prints TAILWIND_DEFAULT_NOTE.
5
+
6
+ /** The exact versions brust's own tests build with (the blank template's package.json pins the same). */
7
+ export const TAILWIND_DEV_DEPS = { 'bun-plugin-tailwind': '0.1.2', tailwindcss: '4.3.3' }
8
+
9
+ export const TAILWIND_DEFAULT_NOTE = 'create-app: Tailwind CSS v4 is the default; the --tailwind flag does nothing'
@@ -6,7 +6,7 @@ A [brust](https://github.com/AssetsArt/brust) app: React components compiled ahe
6
6
 
7
7
  ```bash
8
8
  bun install
9
- bun run dev # brust build routes.tsx && brust start -> http://127.0.0.1:1337
9
+ bun run dev # brust dev routes.tsx (hot reload) -> http://127.0.0.1:1337
10
10
  ```
11
11
 
12
12
  Scripts: `dev` (build then start), `build`, `start`, `typecheck`, `dev:cf` (build for Cloudflare Workers and run `wrangler dev`), `deploy:cf` (build and `wrangler deploy`).
@@ -1,3 +1,4 @@
1
1
  node_modules/
2
2
  dist/
3
+ .brust/
3
4
  .wrangler/
@@ -0,0 +1,32 @@
1
+ @import "tailwindcss";
2
+
3
+ /* Tailwind CSS v4, CSS-first: no tailwind.config. The tokens below are the brust docs palette; each one becomes a
4
+ utility (bg-paper, text-ink, border-rule, ...). A *.module.css that uses @apply starts with
5
+ @reference "../app.css"; (see brust docs/css.md). */
6
+ @theme {
7
+ --color-paper: oklch(94% 0.035 78);
8
+ --color-sheet: oklch(97% 0.02 82);
9
+ --color-ink: oklch(18% 0.035 82);
10
+ --color-ink-2: oklch(36% 0.045 80);
11
+ --color-rule: oklch(76% 0.05 77);
12
+ --color-amber: oklch(68% 0.145 74);
13
+ --color-amber-ink: oklch(46% 0.12 62);
14
+ --font-sans: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
15
+ }
16
+
17
+ /* Dark mode follows the system: the same tokens, darker values, so every utility switches with them. */
18
+ @media (prefers-color-scheme: dark) {
19
+ :root {
20
+ --color-paper: oklch(20% 0.028 185);
21
+ --color-sheet: oklch(24% 0.032 182);
22
+ --color-ink: oklch(91% 0.02 82);
23
+ --color-ink-2: oklch(77% 0.03 82);
24
+ --color-rule: oklch(36% 0.032 180);
25
+ --color-amber: oklch(74% 0.12 78);
26
+ --color-amber-ink: oklch(81% 0.11 80);
27
+ }
28
+ }
29
+
30
+ :root {
31
+ color-scheme: light dark;
32
+ }
@@ -4,7 +4,11 @@ import { useState } from 'react'
4
4
  export default function Counter() {
5
5
  const [count, setCount] = useState(0)
6
6
  return (
7
- <button type="button" onClick={() => setCount(count + 1)}>
7
+ <button
8
+ type="button"
9
+ className="cursor-pointer rounded-[0.6rem] border border-amber-ink bg-amber px-[1.1rem] py-2 font-semibold text-[oklch(18%_0.035_82)] hover:brightness-106 focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-amber-ink"
10
+ onClick={() => setCount(count + 1)}
11
+ >
8
12
  count is {count}
9
13
  </button>
10
14
  )
@@ -1,5 +1,7 @@
1
- // The document root: a plain <html> with <Outlet/> for the page. Static files are served from /public.
1
+ // The document root: a plain <html> with <Outlet/> for the page. app.css (Tailwind CSS v4) is imported here; brust
2
+ // builds it into one hashed file and links it in <head>. Static files are served from /public.
2
3
  import { Outlet } from '@brust/core/routes'
4
+ import '../app.css'
3
5
 
4
6
  export default function Layout() {
5
7
  return (
@@ -9,10 +11,9 @@ export default function Layout() {
9
11
  <meta name="viewport" content="width=device-width, initial-scale=1" />
10
12
  <title>brust app</title>
11
13
  <link rel="icon" href="/public/favicon.svg" />
12
- <link rel="stylesheet" href="/public/app.css" />
13
14
  </head>
14
- <body>
15
- <main>
15
+ <body className="bg-paper font-sans text-ink leading-[1.55]">
16
+ <main className="mx-auto box-border max-w-2xl px-4 py-16">
16
17
  <Outlet />
17
18
  </main>
18
19
  </body>
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "brust build routes.tsx && brust start",
7
+ "dev": "brust dev routes.tsx",
8
8
  "build": "brust build routes.tsx",
9
9
  "start": "brust start",
10
10
  "typecheck": "bun check",
@@ -21,6 +21,8 @@
21
21
  "devDependencies": {
22
22
  "@types/bun": "^1.4.0",
23
23
  "@types/react": "^19.2.0",
24
+ "bun-plugin-tailwind": "0.1.2",
25
+ "tailwindcss": "4.3.3",
24
26
  "typescript": "^7.0.2",
25
27
  "wrangler": "^4.149.0"
26
28
  }
@@ -1,11 +1,35 @@
1
1
  import Counter from '../components/Counter'
2
2
 
3
+ const link = 'font-semibold text-amber-ink underline underline-offset-[0.2em] hover:decoration-2 focus-visible:rounded focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-amber-ink'
4
+
3
5
  export default function HomePage() {
4
6
  return (
5
- <section>
6
- <h1>Hello from brust</h1>
7
- <p>Edit pages/HomePage.tsx, then run bun run dev again.</p>
8
- <Counter />
9
- </section>
7
+ <>
8
+ <header className="flex items-center gap-[0.9rem]">
9
+ <svg className="flex-none" viewBox="0 0 32 32" width="44" height="44" aria-hidden="true">
10
+ <rect width="32" height="32" rx="8" fill="#062323" />
11
+ <path d="M7 19a9 9 0 0 1 18 0z" fill="#f2a516" />
12
+ <rect x="5" y="20.5" width="22" height="2.2" rx="1.1" fill="#f2a516" />
13
+ <rect x="10" y="24.6" width="12" height="2" rx="1" fill="#f2a516" opacity=".55" />
14
+ </svg>
15
+ <h1 className="m-0 text-4xl leading-[1.1] font-bold tracking-[-0.01em]">brust app</h1>
16
+ </header>
17
+ <p className="mt-4 mb-8 text-lg text-ink-2">Edit pages/HomePage.tsx and save. The page reloads.</p>
18
+ <section className="rounded-2xl border border-rule bg-sheet p-6">
19
+ <Counter />
20
+ <p className="mt-4 mb-0 text-[0.9375rem] text-ink-2">useState only, so this button is native: a signal in the browser, no React shipped.</p>
21
+ </section>
22
+ <nav className="mt-8 flex flex-wrap gap-x-6 gap-y-2" aria-label="Learn more">
23
+ <a className={link} href="https://brust.dev">
24
+ Docs
25
+ </a>
26
+ <a className={link} href="https://brust.dev/docs/routing">
27
+ Routes
28
+ </a>
29
+ <a className={link} href="https://brust.dev/docs/actions">
30
+ Actions
31
+ </a>
32
+ </nav>
33
+ </>
10
34
  )
11
35
  }
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="15" fill="#ef4444"/><rect x="1" y="14" width="30" height="4" fill="#111"/><circle cx="16" cy="16" r="5" fill="#fff" stroke="#111" stroke-width="2"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#062323"/><path d="M7 19a9 9 0 0 1 18 0z" fill="#f2a516"/><rect x="5" y="20.5" width="22" height="2.2" rx="1.1" fill="#f2a516"/><rect x="10" y="24.6" width="12" height="2" rx="1" fill="#f2a516" opacity=".55"/></svg>
@@ -7,7 +7,7 @@ React islands, and a persistent team built with Elysia actions + SQLite and one
7
7
 
8
8
  ```bash
9
9
  bun install
10
- bun run dev # brust build routes.tsx && brust start -> http://127.0.0.1:1337
10
+ bun run dev # brust dev routes.tsx (hot reload) -> http://127.0.0.1:1337
11
11
  ```
12
12
 
13
13
  Scripts: `dev` (build then start), `build`, `start`, `typecheck`, `snapshot` (needs network; rewrites `data/pokedex.json`).
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "brust build routes.tsx && brust start",
7
+ "dev": "brust dev routes.tsx",
8
8
  "build": "brust build routes.tsx",
9
9
  "dev:cf": "wrangler d1 migrations apply TEAM_DB --local --persist-to .wrangler/state && brust dev routes.tsx --target cloudflare",
10
10
  "deploy:cf": "brust build routes.tsx --target cloudflare && wrangler deploy -c dist/cf/wrangler.jsonc",
@@ -1,14 +0,0 @@
1
- :root { color-scheme: light dark; font-family: system-ui, sans-serif; }
2
- body { margin: 0; }
3
- main { max-width: 40rem; margin: 4rem auto; padding: 0 1.5rem; line-height: 1.5; }
4
- h1 { font-size: 2rem; margin: 0 0 0.5rem; }
5
- button {
6
- cursor: pointer;
7
- font: inherit;
8
- padding: 0.5rem 1rem;
9
- border: 1px solid currentColor;
10
- border-radius: 0.5rem;
11
- background: transparent;
12
- color: inherit;
13
- }
14
- button:hover { opacity: 0.8; }