Thank you for your interest in contributing to Payload Gatekeeper! This document provides guidelines and instructions for contributing to the project.
- Development Setup
- Branch Management & Versioning
- Code Style
- Testing
- Pull Request Process
- Release Process
- Node.js >= 18.0.0
- npm >= 8.0.0
- Git
-
Fork the repository
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/payload-gatekeeper.git cd payload-gatekeeper -
Install dependencies:
npm install
-
Run tests to verify setup:
npm test -
Start development:
npm run dev # Watch mode for TypeScript
We use branch names to automatically determine version bumps. When you create a PR and merge it to main, the version is automatically updated based on your branch prefix:
| Branch Prefix | Version Bump | Example | Use Case |
|---|---|---|---|
fix/* |
patch | 1.0.0 → 1.0.1 | Bug fixes |
bugfix/* |
patch | 1.0.0 → 1.0.1 | Bug fixes |
hotfix/* |
patch | 1.0.0 → 1.0.1 | Urgent fixes |
feature/* |
minor | 1.0.0 → 1.1.0 | New features |
feat/* |
minor | 1.0.0 → 1.1.0 | New features |
major/* |
major | 1.0.0 → 2.0.0 | Breaking changes |
breaking/* |
major | 1.0.0 → 2.0.0 | Breaking changes |
chore/* |
no bump | - | Maintenance tasks |
docs/* |
no bump | - | Documentation only |
test/* |
no bump | - | Test improvements |
ci/* |
no bump | - | CI/CD changes |
refactor/* |
no bump | - | Code refactoring |
style/* |
no bump | - | Code style changes |
# Bug fix - will bump patch version
git checkout -b fix/permission-check-error
# New feature - will bump minor version
git checkout -b feature/add-wildcard-support
# Breaking change - will bump major version
git checkout -b major/redesign-api
# Documentation - no version bump
git checkout -b docs/update-readmeWhen you merge a PR to main:
-
GitHub Actions automatically:
- Detects your branch prefix
- Bumps the version in package.json
- Creates a git commit with the new version
- Creates a git tag (e.g., v1.0.1)
- Creates a GitHub Release with auto-generated notes
-
npm Publishing (manual step):
- Go to Actions → "Publish to npm"
- Click "Run workflow"
- Optional: Run with dry-run first to test
- The current version from package.json will be published
- Never manually edit the version in package.json on feature branches
- Version bumps are automatic based on your branch name
- npm publishing is manual to ensure control over releases
- Commits from the bot include
[skip ci]to prevent loops - Dependabot PRs do NOT trigger version bumps (handled separately)
Dependabot automatically creates PRs for dependency updates. These are handled specially:
- No automatic version bump - Dependabot branches are ignored
- Commit prefix: All Dependabot commits start with
chore: - Labels: PRs are labeled with
dependenciesandautomated - Grouped updates: Dependencies are grouped to reduce PR noise
| Update Type | Recommended Action | Example Branch |
|---|---|---|
| Security fixes | Create fix/security-updates PR |
→ patch version |
| Major dependency update | Create feature/update-dependencies PR |
→ minor version |
| Breaking dependency changes | Create major/dependency-breaking-changes PR |
→ major version |
| Dev dependency updates only | Just merge, no release needed | → no version |
Example workflow for important dependency updates:
# After merging Dependabot PR
git checkout -b fix/security-updates
git commit --allow-empty -m "Release for security updates"
git push origin fix/security-updates
# Create PR → will trigger patch version- Use TypeScript for all new code
- Enable strict mode
- Provide proper types (avoid
any) - Document complex types
We use ESLint and Prettier. Run before committing:
npm run lint # Check for issues
npm run lint:fix # Auto-fix issues
npm run type-check # Check TypeScriptWhile not required for versioning (we use branch names), good commit messages help with release notes:
# Good
git commit -m "Fix permission check for wildcard operations"
git commit -m "Add support for custom operations"
git commit -m "Update TypeScript to 5.0"
# Less helpful
git commit -m "Fix bug"
git commit -m "Update code"npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # With coverage report- Write tests for all new features
- Maintain >80% code coverage
- Use descriptive test names
- Test edge cases
Example test structure:
describe('PermissionCheck', () => {
describe('wildcard permissions', () => {
it('should grant access with * permission', () => {
// Test implementation
})
})
})- Choose the right branch name (see Branch Management above)
- Ensure all tests pass:
npm test - Check linting:
npm run lint - Verify types:
npm run type-check - Update tests if needed
- Update documentation if needed
-
Create a feature branch with appropriate prefix:
git checkout -b feature/your-feature-name
-
Make your changes and commit:
git add . git commit -m "Description of changes"
-
Push to your fork:
git push origin feature/your-feature-name
-
Create Pull Request:
- Use a clear, descriptive title
- Reference any related issues
- Describe what changes and why
- Include screenshots if UI changes
-
PR will automatically:
- Run tests
- Check linting
- Check types
- Generate coverage report
Your PR merge will automatically:
- ✅ Bump version based on branch prefix
- ✅ Create git tag
- ✅ Create GitHub Release
- ⏸️ npm publish requires manual trigger
Based on your branch name, the system automatically:
-
Determines version bump:
fix/*→ patch (1.0.0 → 1.0.1)feature/*→ minor (1.0.0 → 1.1.0)major/*→ major (1.0.0 → 2.0.0)
-
Updates package.json with new version
-
Creates git tag (e.g., v1.0.1)
-
Creates GitHub Release with changelog
When ready to publish to npm:
- Go to Actions → "Publish to npm"
- Click "Run workflow"
- Options:
- Dry run: Test without publishing
- Tag: Choose npm tag (latest, beta, next, alpha)
- Click "Run workflow"
The workflow will:
- Verify version doesn't already exist
- Run tests
- Build package
- Publish to npm with provenance
For maintainers setting up npm publishing:
- Create npm account at npmjs.com
- Generate access token (Classic, Publish permission)
- Add as GitHub Secret:
NPM_TOKEN
- Open an issue
- Start a discussion
- Check existing PRs
By contributing, you agree that your contributions will be licensed under the MIT License.