diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..6b71b59 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,10 @@ +{ + "permissions": { + "allow": [ + "Bash(pnpm build:*)", + "Bash(pnpm test:*)", + "Bash(npm test:*)" + ], + "deny": [] + } +} \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b7ed9b5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,118 @@ +# FilePizza Development Guide + +A peer-to-peer file transfer application built with modern web technologies. + +## Prerequisites + +- [Node.js](https://nodejs.org/) (v18+) +- [pnpm](https://pnpm.io/) (preferred package manager) + +## Quick Start + +```bash +git clone https://github.com/kern/filepizza.git +cd filepizza +pnpm install +pnpm dev +``` + +## Available Commands + +### Development +- `pnpm dev` - Start development server +- `pnpm dev:full` - Start with Redis and COTURN for full WebRTC testing + +### Building & Testing +- `pnpm build` - Build for production +- `pnpm test` - Run unit tests with Vitest +- `pnpm test:watch` - Run tests in watch mode +- `pnpm test:e2e` - Run E2E tests with Playwright + +### Code Quality +- `pnpm lint:check` - Check ESLint rules +- `pnpm lint:fix` - Fix ESLint issues +- `pnpm format` - Format code with Prettier +- `pnpm format:check` - Check code formatting +- `pnpm type:check` - TypeScript type checking + +### Docker +- `pnpm docker:build` - Build Docker image +- `pnpm docker:up` - Start containers +- `pnpm docker:down` - Stop containers + +### CI Pipeline +- `pnpm ci` - Run full CI pipeline (lint, format, type-check, test, build, e2e, docker) + +## Tech Stack + +- **Framework**: Next.js 15 with App Router +- **UI**: React 19 + Tailwind CSS v4 +- **Language**: TypeScript +- **Testing**: Vitest (unit) + Playwright (E2E) +- **WebRTC**: PeerJS +- **State Management**: TanStack Query +- **Themes**: next-themes with View Transitions +- **Storage**: Redis (optional) + +## Project Structure + +``` +src/ +├── app/ # Next.js App Router pages +├── components/ # React components +├── hooks/ # Custom React hooks +├── utils/ # Utility functions +└── types.ts # TypeScript definitions +``` + +## Development Tips + +### Using pnpm + +This project uses pnpm as the package manager. Benefits include: +- Faster installs and smaller disk usage +- Strict dependency resolution +- Built-in workspace support + +Always use `pnpm` instead of `npm` or `yarn`: +```bash +pnpm install package-name +pnpm remove package-name +pnpm update +``` + +### Code Style + +- ESLint + TypeScript ESLint for linting +- Prettier for formatting +- Husky + lint-staged for pre-commit hooks +- Prefer TypeScript over JavaScript +- Use kebab-case for files, PascalCase for components + +### Testing Strategy + +- Unit tests for components and utilities (`tests/unit/`) +- E2E tests for critical user flows (`tests/e2e/`) +- Test files follow `*.test.ts[x]` naming convention + +### WebRTC Development + +For full WebRTC testing with TURN/STUN: +```bash +pnpm dev:full +``` + +This starts Redis and COTURN containers for testing peer connections behind NAT. + +## Key Dependencies + +- `next` - React framework +- `tailwindcss` - CSS framework +- `@tanstack/react-query` - Server state management +- `peerjs` - WebRTC abstraction +- `next-themes` - Theme switching +- `zod` - Schema validation +- `vitest` - Testing framework +- `playwright` - E2E testing + +Run `pnpm ci` before submitting PRs to ensure all checks pass. \ No newline at end of file diff --git a/package.json b/package.json index 0cfe084..7643a18 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "dev": "next", "dev:full": "docker compose up redis coturn -d && COTURN_ENABLED=true REDIS_URL=redis://localhost:6379 next", - "build": "next build", + "build": "next build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/", "start": "next start", "start:peerjs": "./bin/peerjs.js", "lint:check": "eslint 'src/**/*.ts[x]'", diff --git a/playwright.config.ts b/playwright.config.ts index 4338e61..cc72eb1 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -2,10 +2,14 @@ import { defineConfig } from '@playwright/test' export default defineConfig({ testDir: './tests/e2e', + workers: 1, // Run tests serially to avoid WebRTC port conflicts webServer: { command: 'node .next/standalone/server.js', - port: 3000, + url: 'http://localhost:3000', timeout: 120 * 1000, reuseExistingServer: true, }, + use: { + baseURL: 'http://localhost:3000', + }, }) diff --git a/src/components/ConnectionListItem.tsx b/src/components/ConnectionListItem.tsx index bbd54ba..ee9f2d0 100644 --- a/src/components/ConnectionListItem.tsx +++ b/src/components/ConnectionListItem.tsx @@ -61,7 +61,9 @@ export function ConnectionListItem({ diff --git a/src/components/CopyableInput.tsx b/src/components/CopyableInput.tsx index 9df1884..3e61682 100644 --- a/src/components/CopyableInput.tsx +++ b/src/components/CopyableInput.tsx @@ -16,6 +16,7 @@ export function CopyableInput({ {label}
diff --git a/src/components/DropZone.tsx b/src/components/DropZone.tsx index 7f84b2d..0bf4042 100644 --- a/src/components/DropZone.tsx +++ b/src/components/DropZone.tsx @@ -97,6 +97,7 @@ export default function DropZone({ multiple />