|
| 1 | +# Contributing to create-pull-request |
| 2 | + |
| 3 | +Thank you for your interest in contributing to create-pull-request! This document provides guidelines and information about the development workflow. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js >= 20 |
| 10 | +- npm (comes with Node.js) |
| 11 | + |
| 12 | +### Getting Started |
| 13 | + |
| 14 | +1. **Fork the repository** |
| 15 | + ```bash |
| 16 | + git clone https://github.com/yourusername/create-pull-request.git |
| 17 | + cd create-pull-request |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Install dependencies** |
| 21 | + ```bash |
| 22 | + npm install |
| 23 | + ``` |
| 24 | + |
| 25 | +3. **Run tests** |
| 26 | + ```bash |
| 27 | + npm test |
| 28 | + ``` |
| 29 | + |
| 30 | +4. **Test the CLI** |
| 31 | + ```bash |
| 32 | + node create-pull-request.js --help |
| 33 | + ``` |
| 34 | + |
| 35 | +## Testing |
| 36 | + |
| 37 | +We use [Vitest](https://vitest.dev/) for testing. The test suite includes: |
| 38 | + |
| 39 | +- **Unit tests** for all core functions |
| 40 | +- **Integration tests** for complete workflows |
| 41 | +- **Edge case testing** for error handling |
| 42 | +- **Mocked dependencies** for isolated testing |
| 43 | + |
| 44 | +### Running Tests |
| 45 | + |
| 46 | +```bash |
| 47 | +# Run tests in watch mode (recommended during development) |
| 48 | +npm test |
| 49 | + |
| 50 | +# Run tests once |
| 51 | +npm run test:run |
| 52 | + |
| 53 | +# Run tests with coverage report |
| 54 | +npm run test:coverage |
| 55 | + |
| 56 | +# Run tests in watch mode with coverage |
| 57 | +npm run test:watch |
| 58 | +``` |
| 59 | + |
| 60 | +### Coverage Thresholds |
| 61 | + |
| 62 | +The project maintains the following coverage thresholds: |
| 63 | + |
| 64 | +- **Statements**: 70% |
| 65 | +- **Branches**: 85% |
| 66 | +- **Functions**: 85% |
| 67 | +- **Lines**: 70% |
| 68 | + |
| 69 | +## Continuous Integration (CI) |
| 70 | + |
| 71 | +The project uses GitHub Actions for CI/CD. The workflow runs: |
| 72 | + |
| 73 | +### Test Matrix |
| 74 | + |
| 75 | +- **Node.js versions**: 20.x, 22.x, latest |
| 76 | +- **Operating systems**: Ubuntu, macOS, Windows |
| 77 | +- **Total combinations**: 9 different environments |
| 78 | + |
| 79 | +### CI Jobs |
| 80 | + |
| 81 | +1. **Test Job** |
| 82 | + - Runs all tests on the matrix combinations |
| 83 | + - Generates coverage reports |
| 84 | + - Uploads coverage to Codecov (Ubuntu + Node 20.x only) |
| 85 | + |
| 86 | +2. **Lint Job** |
| 87 | + - Validates package.json |
| 88 | + - Tests CLI functionality |
| 89 | + - Performs basic sanity checks |
| 90 | + |
| 91 | +### Workflow Triggers |
| 92 | + |
| 93 | +The CI runs on: |
| 94 | +- Push to `main` and `develop` branches |
| 95 | +- Pull requests targeting `main` and `develop` |
| 96 | + |
| 97 | +## Code Quality |
| 98 | + |
| 99 | +### Coverage Requirements |
| 100 | + |
| 101 | +All new code should maintain or improve test coverage. The CI will fail if coverage drops below the thresholds. |
| 102 | + |
| 103 | +### Browser Support |
| 104 | + |
| 105 | +When adding new browser support, ensure: |
| 106 | + |
| 107 | +1. **Add browser to `SUPPORTED_BROWSERS`** in `create-pull-request.js` |
| 108 | +2. **Update tests** in `create-pull-request.test.js` |
| 109 | +3. **Update README** with new browser information |
| 110 | +4. **Test manually** that the browser opens correctly |
| 111 | + |
| 112 | +### Platform Support |
| 113 | + |
| 114 | +When adding new platform support: |
| 115 | + |
| 116 | +1. **Add platform handler** to `SUPPORTED_PLATFORMS` |
| 117 | +2. **Add comprehensive tests** for URL generation |
| 118 | +3. **Update documentation** in README |
| 119 | +4. **Test with real repositories** from that platform |
| 120 | + |
| 121 | +## Pull Request Process |
| 122 | + |
| 123 | +1. **Create a feature branch** |
| 124 | + ```bash |
| 125 | + git checkout -b feature/your-feature-name |
| 126 | + ``` |
| 127 | + |
| 128 | +2. **Make your changes** |
| 129 | + - Write code following existing patterns |
| 130 | + - Add tests for new functionality |
| 131 | + - Update documentation as needed |
| 132 | + |
| 133 | +3. **Test your changes** |
| 134 | + ```bash |
| 135 | + npm run test:coverage |
| 136 | + ``` |
| 137 | + |
| 138 | +4. **Commit your changes** |
| 139 | + ```bash |
| 140 | + git commit -m "feat: add amazing new feature" |
| 141 | + ``` |
| 142 | + |
| 143 | +5. **Push and create PR** |
| 144 | + ```bash |
| 145 | + git push origin feature/your-feature-name |
| 146 | + ``` |
| 147 | + |
| 148 | +6. **Wait for CI** |
| 149 | + - All tests must pass |
| 150 | + - Coverage must meet thresholds |
| 151 | + - CLI functionality must work |
| 152 | + |
| 153 | +## Development Tips |
| 154 | + |
| 155 | +### Testing Strategy |
| 156 | + |
| 157 | +- **Test the happy path**: Ensure normal usage works |
| 158 | +- **Test edge cases**: Invalid inputs, network errors, etc. |
| 159 | +- **Test integration**: Complete workflows from start to finish |
| 160 | +- **Mock external dependencies**: Keep tests fast and reliable |
| 161 | + |
| 162 | +### Debugging Tests |
| 163 | + |
| 164 | +```bash |
| 165 | +# Run a specific test file |
| 166 | +npx vitest create-pull-request.test.js |
| 167 | + |
| 168 | +# Run tests with specific pattern |
| 169 | +npx vitest --grep "normalizeGitUrl" |
| 170 | + |
| 171 | +# Run tests with debug output |
| 172 | +npx vitest --reporter=verbose |
| 173 | +``` |
| 174 | + |
| 175 | +### Local Development |
| 176 | + |
| 177 | +```bash |
| 178 | +# Link the package locally for testing |
| 179 | +npm link |
| 180 | + |
| 181 | +# Now you can test the CLI globally |
| 182 | +create-pull-request --help |
| 183 | + |
| 184 | +# Unlink when done |
| 185 | +npm unlink |
| 186 | +``` |
| 187 | + |
| 188 | +## Release Process |
| 189 | + |
| 190 | +1. **Ensure all tests pass** |
| 191 | +2. **Update version** in `package.json` |
| 192 | +3. **Create release notes** |
| 193 | +4. **Tag the release** |
| 194 | +5. **Publish to npm** |
| 195 | + |
| 196 | +## Getting Help |
| 197 | + |
| 198 | +- **Issues**: [GitHub Issues](https://github.com/DannyFeliz/create-pull-request/issues) |
| 199 | +- **Discussions**: [GitHub Discussions](https://github.com/DannyFeliz/create-pull-request/discussions) |
| 200 | + |
| 201 | +## Code of Conduct |
| 202 | + |
| 203 | +Please be respectful and professional in all interactions. We want to maintain a welcoming environment for all contributors. |
| 204 | + |
| 205 | +--- |
| 206 | + |
| 207 | +Thank you for contributing! 🎉 |
0 commit comments