|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Common Development Commands |
| 6 | + |
| 7 | +### Initial Setup |
| 8 | + |
| 9 | +```bash |
| 10 | +yarn install |
| 11 | +yarn build |
| 12 | +``` |
| 13 | + |
| 14 | +### Development |
| 15 | + |
| 16 | +```bash |
| 17 | +# Watch all packages for changes |
| 18 | +yarn dev |
| 19 | + |
| 20 | +# Run the expo example app with Storybook |
| 21 | +yarn example |
| 22 | +``` |
| 23 | + |
| 24 | +### Testing |
| 25 | + |
| 26 | +```bash |
| 27 | +# Run unit tests across all packages |
| 28 | +yarn test |
| 29 | + |
| 30 | +# Run tests in CI mode |
| 31 | +yarn test:ci |
| 32 | + |
| 33 | +``` |
| 34 | + |
| 35 | +### Linting and Code Quality |
| 36 | + |
| 37 | +```bash |
| 38 | +# Run ESLint across the codebase |
| 39 | +yarn lint |
| 40 | +``` |
| 41 | + |
| 42 | +### Release Process |
| 43 | + |
| 44 | +```bash |
| 45 | +# Version packages (maintainers only) |
| 46 | +yarn version-packages |
| 47 | + |
| 48 | +# Publish to npm |
| 49 | +yarn publish:latest # For stable releases |
| 50 | +yarn publish:next # For pre-releases |
| 51 | +yarn publish:alpha # For alpha releases |
| 52 | +``` |
| 53 | + |
| 54 | +## Architecture Overview |
| 55 | + |
| 56 | +This is a **Yarn workspaces monorepo** managed by Lerna containing React Native Storybook packages: |
| 57 | + |
| 58 | +### Core Packages |
| 59 | + |
| 60 | +- **@storybook/react-native** - Main package providing Storybook functionality for React Native |
| 61 | +- **@storybook/react-native-ui** - Full UI components for on-device Storybook |
| 62 | +- **@storybook/react-native-ui-lite** - Lightweight UI components |
| 63 | +- **@storybook/react-native-ui-common** - Shared UI components |
| 64 | +- **@storybook/react-native-theming** - Theming utilities |
| 65 | + |
| 66 | +### On-Device Addons |
| 67 | + |
| 68 | +- **@storybook/addon-ondevice-actions** - Log component interactions |
| 69 | +- **@storybook/addon-ondevice-backgrounds** - Change story backgrounds |
| 70 | +- **@storybook/addon-ondevice-controls** - Dynamically edit component props |
| 71 | +- **@storybook/addon-ondevice-notes** - Add markdown documentation to stories |
| 72 | + |
| 73 | +### Build System |
| 74 | + |
| 75 | +- Uses **tsup** for TypeScript compilation |
| 76 | +- Targets ES2022 with CommonJS output |
| 77 | +- Each package has its own `tsup.config.ts` |
| 78 | +- Running `yarn prepare` in a package builds it |
| 79 | + |
| 80 | +### Metro Configuration |
| 81 | + |
| 82 | +The `withStorybook` wrapper is crucial for React Native Storybook: |
| 83 | + |
| 84 | +- Enables `unstable_allowRequireContext` for dynamic story imports |
| 85 | +- Automatically generates `storybook.requires.ts` file |
| 86 | +- Optional WebSocket server for remote control |
| 87 | +- Can be conditionally enabled/disabled via options |
| 88 | + |
| 89 | +### Key Concepts |
| 90 | + |
| 91 | +1. **CSF (Component Story Format)**: Standard story syntax used across Storybook |
| 92 | +2. **On-device UI**: Native UI that runs directly on mobile devices |
| 93 | +3. **Story requires generation**: Automatic generation of story imports via Metro |
| 94 | +4. **Portable stories**: Reuse stories in unit tests |
| 95 | +5. **WebSocket support**: Remote control stories from external devices |
0 commit comments