|
| 1 | +--- |
| 2 | +description: "Guidelines for split commits in packages directory for semantic-release compatibility" |
| 3 | +globs: "packages/**/*" |
| 4 | +--- |
| 5 | + |
| 6 | +# Packages Split Commits Rule |
| 7 | + |
| 8 | +## Overview |
| 9 | +This rule ensures proper commit structure for the packages directory to maintain semantic-release compatibility in a monorepo setup. |
| 10 | + |
| 11 | +## Critical Requirements |
| 12 | + |
| 13 | +### 1. **Separate Commits Per Package** |
| 14 | +When making changes that affect multiple packages, create separate commits for each package: |
| 15 | + |
| 16 | +```bash |
| 17 | +# ❌ WRONG - Single commit affecting multiple packages |
| 18 | +git commit -m "feat: add new feature to both pp-dev and create-pp-dev" |
| 19 | + |
| 20 | +# ✅ CORRECT - Separate commits per package |
| 21 | +git commit -m "feat(pp-dev): add new authentication middleware" |
| 22 | +git commit -m "feat(create-pp-dev): update templates with new auth feature" |
| 23 | +``` |
| 24 | + |
| 25 | +### 2. **Package-Specific Commit Messages** |
| 26 | +Use the package name as the scope in commit messages: |
| 27 | + |
| 28 | +```bash |
| 29 | +# ✅ CORRECT examples |
| 30 | +feat(pp-dev): add new CLI command |
| 31 | +fix(create-pp-dev): resolve template generation issue |
| 32 | +docs(pp-dev): update API documentation |
| 33 | +chore(create-pp-dev): update dependencies |
| 34 | +``` |
| 35 | + |
| 36 | +### 3. **File Path Considerations** |
| 37 | +When committing changes, be specific about which package is affected: |
| 38 | + |
| 39 | +```bash |
| 40 | +# For pp-dev changes |
| 41 | +git add packages/pp-dev/ |
| 42 | +git commit -m "feat(pp-dev): your message" |
| 43 | + |
| 44 | +# For create-pp-dev changes |
| 45 | +git add packages/create-pp-dev/ |
| 46 | +git commit -m "feat(create-pp-dev): your message" |
| 47 | + |
| 48 | +# For template changes |
| 49 | +git add packages/create-pp-dev/template-*/ |
| 50 | +git commit -m "feat(create-pp-dev): update template configurations" |
| 51 | +``` |
| 52 | + |
| 53 | +## Why This Matters |
| 54 | + |
| 55 | +### Semantic Release Monorepo Behavior |
| 56 | +- **semantic-release-monorepo** analyzes commits per package |
| 57 | +- Each package gets its own version bump based on its specific commits |
| 58 | +- Mixed commits can cause incorrect version calculations |
| 59 | +- Package-specific commits ensure accurate changelog generation |
| 60 | + |
| 61 | +### Version Bump Logic |
| 62 | +- `feat(pp-dev):` → triggers MINOR version bump for pp-dev |
| 63 | +- `fix(create-pp-dev):` → triggers PATCH version bump for create-pp-dev |
| 64 | +- Mixed commits may cause unexpected version bumps |
| 65 | + |
| 66 | +## Package Structure |
| 67 | + |
| 68 | +### Current Packages |
| 69 | +- **pp-dev**: Core development tool (`packages/pp-dev/`) |
| 70 | +- **create-pp-dev**: Template generator (`packages/create-pp-dev/`) |
| 71 | + |
| 72 | +### Template Dependencies |
| 73 | +When updating template files, ensure the parent package is also updated: |
| 74 | +```bash |
| 75 | +# Update template files |
| 76 | +git add packages/create-pp-dev/template-*/ |
| 77 | +git commit -m "feat(create-pp-dev): update template dependencies" |
| 78 | + |
| 79 | +# Update main package.json if needed |
| 80 | +git add packages/create-pp-dev/package.json |
| 81 | +git commit -m "chore(create-pp-dev): update pp-dev dependency version" |
| 82 | +``` |
| 83 | + |
| 84 | +## Commit Message Format |
| 85 | + |
| 86 | +### Required Format |
| 87 | +``` |
| 88 | +<type>(<package>): <subject> |
| 89 | +``` |
| 90 | + |
| 91 | +### Valid Types |
| 92 | +- `feat` - New features (MINOR version bump) |
| 93 | +- `fix` - Bug fixes (PATCH version bump) |
| 94 | +- `docs` - Documentation changes (NO version bump) |
| 95 | +- `style` - Code style changes (NO version bump) |
| 96 | +- `refactor` - Code refactoring (NO version bump) |
| 97 | +- `perf` - Performance improvements (NO version bump) |
| 98 | +- `test` - Adding/updating tests (NO version bump) |
| 99 | +- `chore` - Maintenance tasks (NO version bump) |
| 100 | +- `ci` - CI/CD changes (NO version bump) |
| 101 | +- `build` - Build system changes (NO version bump) |
| 102 | + |
| 103 | +### Valid Package Scopes |
| 104 | +- `pp-dev` - Changes to the pp-dev package |
| 105 | +- `create-pp-dev` - Changes to the create-pp-dev package |
| 106 | + |
| 107 | +## Examples |
| 108 | + |
| 109 | +### ✅ Good Examples |
| 110 | +```bash |
| 111 | +feat(pp-dev): add new authentication middleware |
| 112 | +fix(pp-dev): resolve memory leak in data processing |
| 113 | +docs(pp-dev): update installation instructions |
| 114 | +chore(create-pp-dev): update all template dependencies |
| 115 | +feat(create-pp-dev): add new Next.js template variant |
| 116 | +``` |
| 117 | + |
| 118 | +### ❌ Bad Examples |
| 119 | +```bash |
| 120 | +feat: add new feature to both packages |
| 121 | +fix: resolve issues in pp-dev and create-pp-dev |
| 122 | +chore: update dependencies |
| 123 | +feat(pp-dev,create-pp-dev): add new feature |
| 124 | +``` |
| 125 | + |
| 126 | +## Workflow Integration |
| 127 | + |
| 128 | +### Release Process |
| 129 | +1. Make package-specific commits |
| 130 | +2. Push to appropriate branch (main for stable, develop for beta) |
| 131 | +3. semantic-release-monorepo analyzes each package independently |
| 132 | +4. Each package gets versioned based on its own commit history |
| 133 | +5. GitHub Actions workflow publishes packages separately |
| 134 | + |
| 135 | +### Branch Strategy |
| 136 | +- **main**: Stable releases (v1.0.0, v1.1.0, etc.) |
| 137 | +- **develop**: Beta releases (v1.1.0-beta.1, v1.1.0-beta.2, etc.) |
| 138 | + |
| 139 | +## Enforcement |
| 140 | + |
| 141 | +### Pre-commit Hooks |
| 142 | +Consider adding pre-commit hooks to enforce this rule: |
| 143 | +```bash |
| 144 | +# Check if commit affects multiple packages |
| 145 | +if git diff --cached --name-only | grep -E '^packages/' | cut -d'/' -f2 | sort -u | wc -l | grep -v '^1$'; then |
| 146 | + echo "Error: Commit affects multiple packages. Please split into separate commits." |
| 147 | + exit 1 |
| 148 | +fi |
| 149 | +``` |
| 150 | + |
| 151 | +### Code Review Checklist |
| 152 | +- [ ] Each commit affects only one package |
| 153 | +- [ ] Commit message includes correct package scope |
| 154 | +- [ ] No mixed changes across packages in single commit |
| 155 | +- [ ] Template changes are committed with create-pp-dev scope |
0 commit comments