|
| 1 | +# Contributing to `@supabase/edge-functions` |
| 2 | + |
| 3 | +Thank you for your interest in contributing to `@supabase/edge-functions`! This document provides guidelines and instructions for contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Getting Started](#getting-started) |
| 8 | +- [Development Setup](#development-setup) |
| 9 | +- [Project Structure](#project-structure) |
| 10 | +- [Development Workflow](#development-workflow) |
| 11 | +- [Testing](#testing) |
| 12 | +- [Code Style](#code-style) |
| 13 | +- [Submitting Changes](#submitting-changes) |
| 14 | +- [Release Process](#release-process) |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +TBD |
| 19 | + |
| 20 | +## Development Setup |
| 21 | + |
| 22 | +### Prerequisites |
| 23 | + |
| 24 | +- **Node.js**: 20.x or higher |
| 25 | +- **pnpm** |
| 26 | + |
| 27 | +### Installation |
| 28 | + |
| 29 | +1. Fork and clone the repository: |
| 30 | + |
| 31 | +```bash |
| 32 | +git clone https://github.com/YOUR_USERNAME/edge-functions.git |
| 33 | +cd edge-functions |
| 34 | +``` |
| 35 | + |
| 36 | +2. Install dependencies: |
| 37 | + |
| 38 | +```bash |
| 39 | +pnpm install |
| 40 | +``` |
| 41 | + |
| 42 | +3. Build the project to verify setup: |
| 43 | + |
| 44 | +```bash |
| 45 | +pnpm build |
| 46 | +``` |
| 47 | + |
| 48 | +## Development Workflow |
| 49 | + |
| 50 | +### Building |
| 51 | + |
| 52 | +Build the library for distribution: |
| 53 | + |
| 54 | +```bash |
| 55 | +pnpm build |
| 56 | +``` |
| 57 | + |
| 58 | +Watch mode for development (rebuilds on file changes): |
| 59 | + |
| 60 | +```bash |
| 61 | +pnpm run dev |
| 62 | +``` |
| 63 | + |
| 64 | +### Formatting |
| 65 | + |
| 66 | +Format all code using Prettier: |
| 67 | + |
| 68 | +```bash |
| 69 | +pnpm format |
| 70 | +``` |
| 71 | + |
| 72 | +## Submitting Changes |
| 73 | + |
| 74 | +### Commit Messages |
| 75 | + |
| 76 | +We use [Conventional Commits](https://www.conventionalcommits.org/) for automated releases. Format: |
| 77 | + |
| 78 | +```text |
| 79 | +<type>(<scope>): <description> |
| 80 | +
|
| 81 | +[optional body] |
| 82 | +
|
| 83 | +[optional footer] |
| 84 | +``` |
| 85 | + |
| 86 | +**Types:** |
| 87 | + |
| 88 | +- `feat`: New feature (triggers minor version bump) |
| 89 | +- `fix`: Bug fix (triggers patch version bump) |
| 90 | +- `docs`: Documentation changes only |
| 91 | +- `test`: Adding or updating tests |
| 92 | +- `chore`: Maintenance tasks, dependency updates |
| 93 | +- `refactor`: Code changes that neither fix bugs nor add features |
| 94 | +- `perf`: Performance improvements |
| 95 | +- `ci`: CI/CD configuration changes |
| 96 | + |
| 97 | +**Breaking changes:** |
| 98 | + |
| 99 | +- Use `feat!:` or `fix!:` for breaking changes (triggers major version bump) |
| 100 | +- Or include `BREAKING CHANGE:` in the commit footer |
| 101 | + |
| 102 | +**Examples:** |
| 103 | + |
| 104 | +```bash |
| 105 | +feat: add support for view operations |
| 106 | +fix: handle empty namespace list correctly |
| 107 | +docs: update README with new examples |
| 108 | +test: add integration tests for table updates |
| 109 | +feat!: change auth config structure |
| 110 | + |
| 111 | +BREAKING CHANGE: auth configuration now uses a discriminated union |
| 112 | +``` |
| 113 | + |
| 114 | +### Pull Request Process |
| 115 | + |
| 116 | +1. **Create a branch** from `main`: |
| 117 | + |
| 118 | + ```bash |
| 119 | + git checkout -b feat/my-feature |
| 120 | + ``` |
| 121 | + |
| 122 | +2. **Make your changes** following the guidelines above |
| 123 | + |
| 124 | +3. **Commit** using conventional commit format: |
| 125 | + |
| 126 | + ```bash |
| 127 | + git commit -m "feat: add support for XYZ" |
| 128 | + ``` |
| 129 | + |
| 130 | +4. **Push** to your fork: |
| 131 | + |
| 132 | + ```bash |
| 133 | + git push origin feat/my-feature |
| 134 | + ``` |
| 135 | + |
| 136 | +5. **Open a Pull Request** with: |
| 137 | + - Clear title following conventional commit format |
| 138 | + - Description of what changed and why |
| 139 | + - Reference any related issues (e.g., "Fixes #123") |
| 140 | + - Screenshots/examples if adding user-facing features |
| 141 | + |
| 142 | +6. **Respond to feedback** - maintainers may request changes |
| 143 | + |
| 144 | +### PR Guidelines |
| 145 | + |
| 146 | +- Keep PRs focused - one feature or fix per PR |
| 147 | +- Update documentation if you change public APIs |
| 148 | +- Add tests for new functionality |
| 149 | +- Ensure all CI checks pass |
| 150 | +- Rebase on `main` if needed to resolve conflicts |
| 151 | +- Be responsive to review feedback |
| 152 | + |
| 153 | +## Release Process |
| 154 | + |
| 155 | +This project uses [release-please](https://github.com/googleapis/release-please) for automated releases. You don't need to manually manage versions or changelogs. |
| 156 | + |
| 157 | +### How It Works |
| 158 | + |
| 159 | +1. **You commit** using conventional commit format (see above) |
| 160 | + |
| 161 | +2. **release-please creates/updates a release PR** automatically when changes are pushed to `main` |
| 162 | + - Updates version in `package.json` |
| 163 | + - Updates `CHANGELOG.md` |
| 164 | + - Generates release notes |
| 165 | + |
| 166 | +3. **Maintainer merges the release PR** when ready to release |
| 167 | + - Creates a GitHub release and git tag |
| 168 | + - Automatically publishes to npm with provenance |
| 169 | + |
| 170 | +### Version Bumps |
| 171 | + |
| 172 | +Versions follow [Semantic Versioning](https://semver.org/): |
| 173 | + |
| 174 | +- **Major (1.0.0 → 2.0.0)**: Breaking changes (`feat!:`, `fix!:`, or `BREAKING CHANGE:`) |
| 175 | +- **Minor (1.0.0 → 1.1.0)**: New features (`feat:`) |
| 176 | +- **Patch (1.0.0 → 1.0.1)**: Bug fixes (`fix:`) |
| 177 | + |
| 178 | +Commits with types like `docs:`, `test:`, `chore:` don't trigger releases on their own. |
| 179 | + |
| 180 | +### For Maintainers Only |
| 181 | + |
| 182 | +Publishing is fully automated via GitHub Actions: |
| 183 | + |
| 184 | +1. Merge the release-please PR when ready |
| 185 | +2. GitHub Actions will automatically publish to npm with provenance |
| 186 | +3. No manual `npm publish` needed |
| 187 | + |
| 188 | +## Questions? |
| 189 | + |
| 190 | +- Open an [issue](https://github.com/supabase/edge-functions/issues) for bugs or feature requests |
| 191 | +- Check existing issues and PRs before creating new ones |
| 192 | +- Tag your issues appropriately (`bug`, `enhancement`, `documentation`, etc.) |
| 193 | + |
| 194 | +## License |
| 195 | + |
| 196 | +By contributing to `@supabase/edge-functions`, you agree that your contributions will be licensed under the MIT License. |
0 commit comments