|
| 1 | +# Contributing to Lytics Lab |
| 2 | + |
| 3 | +Thank you for contributing to Lytics Lab! This guide will help you get started. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js 22.20.0 (managed via Volta) |
| 10 | +- Yarn 1.22.18 |
| 11 | + |
| 12 | +### Getting Started |
| 13 | + |
| 14 | +```bash |
| 15 | +# Clone the repository |
| 16 | +git clone https://github.com/lytics/lytics-lab.git |
| 17 | +cd lytics-lab |
| 18 | + |
| 19 | +# Install dependencies |
| 20 | +yarn install |
| 21 | + |
| 22 | +# Run tests |
| 23 | +yarn test |
| 24 | + |
| 25 | +# Run linting |
| 26 | +yarn lint |
| 27 | + |
| 28 | +# Type check |
| 29 | +yarn typecheck |
| 30 | + |
| 31 | +# Build all packages |
| 32 | +yarn build |
| 33 | +``` |
| 34 | + |
| 35 | +## Making Changes |
| 36 | + |
| 37 | +### 1. Create a Branch |
| 38 | + |
| 39 | +```bash |
| 40 | +git checkout -b issue/[number]-[description] |
| 41 | +``` |
| 42 | + |
| 43 | +### 2. Make Your Changes |
| 44 | + |
| 45 | +- Write clear, concise code |
| 46 | +- Add tests for new features |
| 47 | +- Update documentation as needed |
| 48 | +- Follow the existing code style (enforced by Biome) |
| 49 | + |
| 50 | +### 3. Run Quality Checks |
| 51 | + |
| 52 | +```bash |
| 53 | +# Run all checks locally before pushing |
| 54 | +yarn lint |
| 55 | +yarn typecheck |
| 56 | +yarn test |
| 57 | +yarn build |
| 58 | +``` |
| 59 | + |
| 60 | +## Changesets Workflow |
| 61 | + |
| 62 | +We use [Changesets](https://github.com/changesets/changesets) for versioning and publishing. This ensures clear changelogs and semantic versioning. |
| 63 | + |
| 64 | +### Creating a Changeset |
| 65 | + |
| 66 | +When you make changes that should be released, create a changeset: |
| 67 | + |
| 68 | +```bash |
| 69 | +yarn changeset |
| 70 | +``` |
| 71 | + |
| 72 | +This will prompt you to: |
| 73 | + |
| 74 | +1. **Select packages** - Which packages did you change? |
| 75 | +2. **Select bump type** - What type of change is this? |
| 76 | + - **patch** (1.0.0 → 1.0.1) - Bug fixes, minor changes |
| 77 | + - **minor** (1.0.0 → 1.1.0) - New features, backwards compatible |
| 78 | + - **major** (1.0.0 → 2.0.0) - Breaking changes |
| 79 | +3. **Write a summary** - Describe your changes (will appear in CHANGELOG) |
| 80 | + |
| 81 | +This creates a markdown file in `.changeset/` that will be committed with your PR. |
| 82 | + |
| 83 | +### Example Workflow |
| 84 | + |
| 85 | +```bash |
| 86 | +# 1. Make your changes |
| 87 | +git checkout -b feat/add-new-feature |
| 88 | + |
| 89 | +# 2. Create a changeset |
| 90 | +yarn changeset |
| 91 | +# Select: experience-editor |
| 92 | +# Choose: minor |
| 93 | +# Summary: "Add support for custom themes" |
| 94 | + |
| 95 | +# 3. Commit everything together |
| 96 | +git add . |
| 97 | +git commit -m "feat(experience-editor): add custom theme support" |
| 98 | +git push origin feat/add-new-feature |
| 99 | + |
| 100 | +# 4. Open a PR |
| 101 | +``` |
| 102 | + |
| 103 | +### What Happens Next? |
| 104 | + |
| 105 | +1. **Your PR is reviewed** - Maintainers review your code and changeset |
| 106 | +2. **PR is merged** - Your changeset is merged to main |
| 107 | +3. **Version PR is created** - A bot creates a "Version Packages" PR with: |
| 108 | + - Updated package versions |
| 109 | + - Updated CHANGELOGs |
| 110 | + - All pending changesets combined |
| 111 | +4. **Maintainer merges Version PR** - Packages are automatically published to npm |
| 112 | + |
| 113 | +### Changeset Guidelines |
| 114 | + |
| 115 | +**Do create a changeset when:** |
| 116 | + |
| 117 | +- Adding features |
| 118 | +- Fixing bugs |
| 119 | +- Making breaking changes |
| 120 | +- Updating dependencies that affect users |
| 121 | + |
| 122 | +**Don't create a changeset for:** |
| 123 | + |
| 124 | +- Documentation updates |
| 125 | +- Internal refactors (no API changes) |
| 126 | +- CI/build configuration changes |
| 127 | +- Development dependencies |
| 128 | + |
| 129 | +## Commit Message Convention |
| 130 | + |
| 131 | +We use [Conventional Commits](https://www.conventionalcommits.org/): |
| 132 | + |
| 133 | +``` |
| 134 | +<type>(<scope>): <subject> |
| 135 | +
|
| 136 | +<body> |
| 137 | +``` |
| 138 | + |
| 139 | +### Types |
| 140 | + |
| 141 | +- `feat` - New feature |
| 142 | +- `bug` - Bug fix |
| 143 | +- `maint` - Maintenance/refactoring |
| 144 | + |
| 145 | +### Scopes |
| 146 | + |
| 147 | +- `experience-editor` - Changes to experience-editor package |
| 148 | +- `recommendation-block` - Changes to recommendation-block package |
| 149 | +- `repo` - Repository-level changes |
| 150 | +- `ci` - CI/CD changes |
| 151 | +- `deps` - Dependency updates |
| 152 | +- `docs` - Documentation |
| 153 | +- `tests` - Test changes |
| 154 | + |
| 155 | +### Examples |
| 156 | + |
| 157 | +``` |
| 158 | +feat(experience-editor): add date range display condition |
| 159 | +
|
| 160 | +bug(recommendation-block): fix API timeout issue |
| 161 | +
|
| 162 | +maint(repo): upgrade to Biome 2.0 |
| 163 | +``` |
| 164 | + |
| 165 | +## Pull Request Process |
| 166 | + |
| 167 | +1. **Create a clear PR title** - Following conventional commit format |
| 168 | +2. **Include changeset** - Add changeset if user-facing changes |
| 169 | +3. **Fill out PR template** - Provide context and testing notes |
| 170 | +4. **Wait for CI** - All checks must pass |
| 171 | +5. **Address feedback** - Respond to review comments |
| 172 | +6. **Squash and merge** - Maintainers will merge when ready |
| 173 | + |
| 174 | +## Testing |
| 175 | + |
| 176 | +### Running Tests |
| 177 | + |
| 178 | +```bash |
| 179 | +# Run all tests |
| 180 | +yarn test |
| 181 | + |
| 182 | +# Run tests in watch mode |
| 183 | +yarn test:watch |
| 184 | + |
| 185 | +# Run tests with coverage |
| 186 | +yarn cover |
| 187 | + |
| 188 | +# Run tests for specific package |
| 189 | +cd packages/experience-editor |
| 190 | +yarn test |
| 191 | +``` |
| 192 | + |
| 193 | +### Writing Tests |
| 194 | + |
| 195 | +- Place tests in `__tests__` folders |
| 196 | +- Use descriptive test names |
| 197 | +- Follow existing patterns |
| 198 | +- Aim for good coverage of new code |
| 199 | + |
| 200 | +## Code Style |
| 201 | + |
| 202 | +We use [Biome](https://biomejs.dev/) for linting and formatting: |
| 203 | + |
| 204 | +```bash |
| 205 | +# Check for issues |
| 206 | +yarn lint |
| 207 | + |
| 208 | +# Auto-fix issues |
| 209 | +yarn lint:fix |
| 210 | + |
| 211 | +# Format code |
| 212 | +yarn format |
| 213 | +``` |
| 214 | + |
| 215 | +Your editor should auto-format on save if configured properly. |
| 216 | + |
| 217 | +## Need Help? |
| 218 | + |
| 219 | +- **Questions?** Open an issue with the "question" label |
| 220 | +- **Bug?** Open an issue with the "bug" label |
| 221 | +- **Feature idea?** Open an issue with the "enhancement" label |
| 222 | + |
| 223 | +## License |
| 224 | + |
| 225 | +By contributing, you agree that your contributions will be licensed under the project's license. |
0 commit comments