diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..37b0034 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + # Prisma needs a connection string to generate the client; no database is + # contacted during lint, typecheck, test or build. + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/superlist?schema=public + BETTER_AUTH_SECRET: ci-only-secret-not-used-at-build-time + BETTER_AUTH_URL: http://localhost:4100 + CORS_ORIGIN: http://localhost:7153 + VITE_API_URL: http://localhost:4100 + +jobs: + verify: + name: Verify + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.4.0 + + # The Prisma CLI runs on Node. + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Generate Prisma client + run: bun run db:generate + + - name: Lint and format check + run: bun run lint:ci + + - name: Typecheck + run: bun run typecheck + + - name: Test + run: bun run test + + - name: Build + run: bun run build diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index f47e836..0000000 --- a/.prettierignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -dist -coverage -.turbo -bun.lock -bun.lockb -apps/web/src/routeTree.gen.ts -apps/api/src/generated diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index c03d068..0000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "semi": false, - "singleQuote": true, - "trailingComma": "all", - "printWidth": 100, - "tabWidth": 2 -} diff --git a/AGENTS.md b/AGENTS.md index d72c7cd..632e2d4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,12 +25,17 @@ No CI, no database migrations and no product features yet. - Verification commands, run from the repo root: - `bun run build` - `bun run lint` → `bun run typecheck` → `bun run test` (in that order) -- **Lint with Biome** (`biome.json` at the repo root, one config for every workspace): `bun run lint` - (per-package via turbo), `bun run lint:fix` (apply safe fixes), `bun run lint:ci` (whole repo, for CI). -- **Format with Prettier** (`bun run format`). Biome's formatter and assist are deliberately disabled in - `biome.json` so the two tools never fight each other. -- `apps/web/src/components/ui/**` is excluded from Biome's recommended preset through an `overrides` entry: - those files are vendored shadcn/ui source and get regenerated by the CLI. +- **Biome is the only JS/TS tooling: linting, formatting and import sorting.** One `biome.json` at the repo + root applies to every workspace. + - `bun run lint` → `biome check .` per package through turbo, so it also fails on formatting drift. + - `bun run lint:fix` → `biome check --write .` applies lint fixes, formatting and `organizeImports` across + the whole repo. + - `bun run lint:ci` → `biome ci .` is the whole-repo check used by CI. + - `bun run format` / `bun run format:check` are formatting-only. +- Markdown (`README.md`, `AGENTS.md`) is not covered: Biome does not format prose. +- `apps/web/src/components/ui/**` is excluded from Biome's recommended lint preset through an `overrides` entry: + those files are vendored shadcn/ui source regenerated by the CLI. They are still formatted. +- CI (`.github/workflows/ci.yml`) runs `db:generate` → `lint:ci` → `typecheck` → `test` → `build`. - Generated files are gitignored and must never be edited by hand: `apps/web/src/routeTree.gen.ts`, `apps/api/src/generated/`. @@ -126,7 +131,7 @@ apps/web/src/ - `cn` comes from the `cn` package; `src/lib/utils.ts` re-exports it for local imports. - Prefer small feature components over one large route file. - Biome does not flag the `Route` export of route files, so route files stay clean; only the vendored - `components/ui` files are exempted from the recommended preset. + `components/ui` files are exempted from the recommended lint preset. diff --git a/README.md b/README.md index 34d6dfa..b97f51d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ cp apps/web/.env.example apps/web/.env Run everything in parallel: ```bash -bun run dev # turbo run dev → api on :3000, web on :5173 +bun run dev # turbo run dev → api on :4100, web on :7153 ``` Or a single workspace: `bun run dev --filter=@superlist/web`. @@ -41,21 +41,24 @@ Or a single workspace: `bun run dev --filter=@superlist/web`. ```bash bun run build # turbo run build -bun run lint # biome check (per package) +bun run lint # biome check per package (lint + format + import order) bun run typecheck # tsc bun run test # bun test (api) / vitest (web, shared) ``` +CI (`.github/workflows/ci.yml`) runs `db:generate` → `lint:ci` → `typecheck` → `test` → `build` on every push +to `main` and every pull request. + ## Useful scripts -| Command | Effect | -| --------------------- | ---------------------------------------------------------- | -| `bun run lint:fix` | Apply Biome's safe fixes across the repo | -| `bun run lint:ci` | `biome ci` — lint the whole repo exactly as CI would | -| `bun run format` | Format the repo with Prettier | -| `bun run db:generate` | Regenerate the Prisma client into `apps/api/src/generated` | -| `bun run db:migrate` | Create and apply a migration (development) | -| `bun run db:studio` | Open Prisma Studio | +| Command | Effect | +| --------------------- | ------------------------------------------------------------------- | +| `bun run lint:fix` | Apply Biome fixes: lint, formatting and import sorting (whole repo) | +| `bun run lint:ci` | `biome ci` — check the whole repo exactly as CI does | +| `bun run format` | Format with Biome (`format:check` to verify only) | +| `bun run db:generate` | Regenerate the Prisma client into `apps/api/src/generated` | +| `bun run db:migrate` | Create and apply a migration (development) | +| `bun run db:studio` | Open Prisma Studio | ## Auth diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index d4525ad..4e501d9 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -1,5 +1,5 @@ -import { cors } from 'hono/cors' import { Hono } from 'hono' +import { cors } from 'hono/cors' import { requestId } from 'hono/request-id' import { secureHeaders } from 'hono/secure-headers' @@ -9,7 +9,7 @@ import { errorHandler, notFoundHandler } from '@/lib/problem-details' import { healthModule } from '@/modules/health' import type { AppEnv } from '@/types' -const allowedOrigins = (process.env.CORS_ORIGIN ?? 'http://localhost:5173') +const allowedOrigins = (process.env.CORS_ORIGIN ?? 'http://localhost:7153') .split(',') .map((origin) => origin.trim()) .filter(Boolean) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index a52a442..83c801b 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -1,7 +1,7 @@ import { createApp } from '@/app' import { logger } from '@/lib/logger' -const port = Number(process.env.PORT ?? 3000) +const port = Number(process.env.PORT ?? 4100) const app = createApp() diff --git a/apps/api/src/lib/problem-details.ts b/apps/api/src/lib/problem-details.ts index 9c831da..067dcd3 100644 --- a/apps/api/src/lib/problem-details.ts +++ b/apps/api/src/lib/problem-details.ts @@ -1,4 +1,4 @@ -import { problem, problemTypes, type ProblemDetails } from '@superlist/shared' +import { type ProblemDetails, problem, problemTypes } from '@superlist/shared' import type { Context } from 'hono' import { HTTPException } from 'hono/http-exception' diff --git a/apps/api/src/lib/result-json.ts b/apps/api/src/lib/result-json.ts index ab4d502..555177c 100644 --- a/apps/api/src/lib/result-json.ts +++ b/apps/api/src/lib/result-json.ts @@ -1,4 +1,4 @@ -import { problem, type ProblemDetails, type Result } from '@superlist/shared' +import { type ProblemDetails, problem, type Result } from '@superlist/shared' import type { Context } from 'hono' import { problemResponse } from '@/lib/problem-details' diff --git a/apps/api/src/lib/validate.ts b/apps/api/src/lib/validate.ts index bdb002e..becd518 100644 --- a/apps/api/src/lib/validate.ts +++ b/apps/api/src/lib/validate.ts @@ -1,5 +1,5 @@ -import { zValidator, type Hook } from '@hono/zod-validator' -import { problems, type FieldErrors } from '@superlist/shared' +import { type Hook, zValidator } from '@hono/zod-validator' +import { type FieldErrors, problems } from '@superlist/shared' import type { Context, Env, ValidationTargets } from 'hono' import type { ZodError, ZodType } from 'zod' diff --git a/apps/api/src/modules/health/get-status/use-case.ts b/apps/api/src/modules/health/get-status/use-case.ts index 6fb8221..f926761 100644 --- a/apps/api/src/modules/health/get-status/use-case.ts +++ b/apps/api/src/modules/health/get-status/use-case.ts @@ -1,4 +1,4 @@ -import { Ok, type Result, type ProblemDetails } from '@superlist/shared' +import { Ok, type ProblemDetails, type Result } from '@superlist/shared' export type HealthStatus = { status: 'ok' diff --git a/apps/web/src/components/layout/app-header.tsx b/apps/web/src/components/layout/app-header.tsx index 708bebf..5773a5d 100644 --- a/apps/web/src/components/layout/app-header.tsx +++ b/apps/web/src/components/layout/app-header.tsx @@ -1,9 +1,8 @@ import { useRouterState } from '@tanstack/react-router' import { SearchIcon } from 'lucide-react' - +import { ThemeToggle } from '@/components/theme-toggle' import { Separator } from '@/components/ui/separator' import { SidebarTrigger } from '@/components/ui/sidebar' -import { ThemeToggle } from '@/components/theme-toggle' function usePageTitle() { const pathname = useRouterState({ select: (state) => state.location.pathname }) diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx index 562dfbd..d1aa050 100644 --- a/apps/web/src/components/layout/app-sidebar.tsx +++ b/apps/web/src/components/layout/app-sidebar.tsx @@ -1,6 +1,6 @@ import { Link, useRouterState } from '@tanstack/react-router' -import { LayoutDashboardIcon, ListTodoIcon, SettingsIcon } from 'lucide-react' import type { LucideIcon } from 'lucide-react' +import { LayoutDashboardIcon, ListTodoIcon, SettingsIcon } from 'lucide-react' import { NavUser } from '@/components/layout/nav-user' import { diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsx index b232628..b357560 100644 --- a/apps/web/src/components/ui/alert.tsx +++ b/apps/web/src/components/ui/alert.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' import { cva, type VariantProps } from 'class-variance-authority' import { cn } from 'cn' +import * as React from 'react' const alertVariants = cva( "group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", @@ -65,4 +65,4 @@ function AlertAction({ className, ...props }: React.ComponentProps<'div'>) { ) } -export { Alert, AlertTitle, AlertDescription, AlertAction } +export { Alert, AlertAction, AlertDescription, AlertTitle } diff --git a/apps/web/src/components/ui/avatar.tsx b/apps/web/src/components/ui/avatar.tsx index 5a3cf8f..21b4d44 100644 --- a/apps/web/src/components/ui/avatar.tsx +++ b/apps/web/src/components/ui/avatar.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' import { cn } from 'cn' import { Avatar as AvatarPrimitive } from 'radix-ui' +import * as React from 'react' function Avatar({ className, @@ -90,4 +90,4 @@ function AvatarGroupCount({ className, ...props }: React.ComponentProps<'div'>) ) } -export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge } +export { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } diff --git a/apps/web/src/components/ui/badge.tsx b/apps/web/src/components/ui/badge.tsx index bae30bb..240234c 100644 --- a/apps/web/src/components/ui/badge.tsx +++ b/apps/web/src/components/ui/badge.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' import { cva, type VariantProps } from 'class-variance-authority' import { cn } from 'cn' import { Slot } from 'radix-ui' +import * as React from 'react' const badgeVariants = cva( 'group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!', diff --git a/apps/web/src/components/ui/breadcrumb.tsx b/apps/web/src/components/ui/breadcrumb.tsx index aff707a..c113b29 100644 --- a/apps/web/src/components/ui/breadcrumb.tsx +++ b/apps/web/src/components/ui/breadcrumb.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' import { cn } from 'cn' -import { Slot } from 'radix-ui' import { ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react' +import { Slot } from 'radix-ui' +import * as React from 'react' function Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>) { return