|
| 1 | +# Contributing to Globlin |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Globlin! This document provides guidelines and instructions for contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [Getting Started](#getting-started) |
| 9 | +- [Development Setup](#development-setup) |
| 10 | +- [Development Workflow](#development-workflow) |
| 11 | +- [Testing](#testing) |
| 12 | +- [Benchmarking](#benchmarking) |
| 13 | +- [Code Style](#code-style) |
| 14 | +- [Submitting Changes](#submitting-changes) |
| 15 | +- [Reporting Bugs](#reporting-bugs) |
| 16 | +- [Feature Requests](#feature-requests) |
| 17 | + |
| 18 | +## Code of Conduct |
| 19 | + |
| 20 | +This project adheres to a code of conduct that all contributors are expected to follow. Please be respectful and constructive in all interactions. |
| 21 | + |
| 22 | +## Getting Started |
| 23 | + |
| 24 | +Globlin is a hybrid Rust/Node.js project that uses NAPI-RS to create native bindings. Before contributing, familiarize yourself with: |
| 25 | + |
| 26 | +- [Node.js](https://nodejs.org/) (v20.0.0 or higher) |
| 27 | +- [Rust](https://www.rust-lang.org/) (latest stable) |
| 28 | +- [NAPI-RS](https://napi.rs/) for native bindings |
| 29 | +- The [glob v13 API](https://github.com/isaacs/node-glob) that we aim to replace |
| 30 | + |
| 31 | +## Development Setup |
| 32 | + |
| 33 | +### Prerequisites |
| 34 | + |
| 35 | +- Node.js 20.x or 22.x |
| 36 | +- Rust (latest stable version) |
| 37 | +- Cargo (comes with Rust) |
| 38 | +- A C/C++ compiler toolchain for your platform |
| 39 | + |
| 40 | +### Installation |
| 41 | + |
| 42 | +1. Clone the repository: |
| 43 | +```bash |
| 44 | +git clone https://github.com/CapSoftware/globlin.git |
| 45 | +cd globlin |
| 46 | +``` |
| 47 | + |
| 48 | +2. Install Node.js dependencies: |
| 49 | +```bash |
| 50 | +npm install |
| 51 | +``` |
| 52 | + |
| 53 | +3. Build the native module and TypeScript: |
| 54 | +```bash |
| 55 | +npm run build |
| 56 | +``` |
| 57 | + |
| 58 | +For development builds (faster, with debug symbols): |
| 59 | +```bash |
| 60 | +npm run build:debug |
| 61 | +``` |
| 62 | + |
| 63 | +## Development Workflow |
| 64 | + |
| 65 | +### Project Structure |
| 66 | + |
| 67 | +``` |
| 68 | +globlin/ |
| 69 | +├── src/ # Rust source code |
| 70 | +├── js/ # TypeScript source code |
| 71 | +├── tests/ # Test files |
| 72 | +├── benches/ # Benchmark files |
| 73 | +├── docs/ # Documentation |
| 74 | +└── www/ # Website/landing page |
| 75 | +``` |
| 76 | + |
| 77 | +### Making Changes |
| 78 | + |
| 79 | +1. Create a new branch for your changes: |
| 80 | +```bash |
| 81 | +git checkout -b feature/your-feature-name |
| 82 | +``` |
| 83 | + |
| 84 | +2. Make your changes in the appropriate directory: |
| 85 | + - Rust code: `src/` |
| 86 | + - TypeScript code: `js/` |
| 87 | + - Tests: `tests/` |
| 88 | + - Documentation: `docs/` |
| 89 | + |
| 90 | +3. Build your changes: |
| 91 | +```bash |
| 92 | +npm run build |
| 93 | +``` |
| 94 | + |
| 95 | +4. Run tests to ensure everything works: |
| 96 | +```bash |
| 97 | +npm test |
| 98 | +``` |
| 99 | + |
| 100 | +### Building |
| 101 | + |
| 102 | +- **Full build** (native + TypeScript): |
| 103 | + ```bash |
| 104 | + npm run build |
| 105 | + ``` |
| 106 | + |
| 107 | +- **Native module only**: |
| 108 | + ```bash |
| 109 | + npm run build:native |
| 110 | + ``` |
| 111 | + |
| 112 | +- **TypeScript only**: |
| 113 | + ```bash |
| 114 | + npm run build:ts |
| 115 | + ``` |
| 116 | + |
| 117 | +- **Debug build** (faster compilation): |
| 118 | + ```bash |
| 119 | + npm run build:debug |
| 120 | + ``` |
| 121 | + |
| 122 | +## Testing |
| 123 | + |
| 124 | +### Running Tests |
| 125 | + |
| 126 | +- **Run all tests**: |
| 127 | + ```bash |
| 128 | + npm test |
| 129 | + ``` |
| 130 | + |
| 131 | +- **Watch mode** (for development): |
| 132 | + ```bash |
| 133 | + npm run test:watch |
| 134 | + ``` |
| 135 | + |
| 136 | +- **With coverage**: |
| 137 | + ```bash |
| 138 | + npm run test:coverage |
| 139 | + ``` |
| 140 | + |
| 141 | +- **Type tests**: |
| 142 | + ```bash |
| 143 | + npm run test:types |
| 144 | + ``` |
| 145 | + |
| 146 | +### Writing Tests |
| 147 | + |
| 148 | +- Place test files in the `tests/` directory |
| 149 | +- Use descriptive test names that explain what is being tested |
| 150 | +- Follow the existing test patterns in the codebase |
| 151 | +- Ensure tests pass on all supported platforms (Linux, macOS, Windows) |
| 152 | + |
| 153 | +Example test structure: |
| 154 | +```typescript |
| 155 | +import { describe, it, expect } from 'vitest' |
| 156 | +import { glob } from '../js/index.js' |
| 157 | + |
| 158 | +describe('feature name', () => { |
| 159 | + it('should do something specific', async () => { |
| 160 | + const results = await glob('pattern') |
| 161 | + expect(results).toEqual(['expected', 'results']) |
| 162 | + }) |
| 163 | +}) |
| 164 | +``` |
| 165 | + |
| 166 | +## Benchmarking |
| 167 | + |
| 168 | +Globlin emphasizes performance. When making changes that could affect performance, run benchmarks: |
| 169 | + |
| 170 | +### Running Benchmarks |
| 171 | + |
| 172 | +- **Quick benchmark** (small fixture): |
| 173 | + ```bash |
| 174 | + npm run bench:small |
| 175 | + ``` |
| 176 | + |
| 177 | +- **Standard benchmark** (medium fixture, 20k files): |
| 178 | + ```bash |
| 179 | + npm run bench:medium |
| 180 | + ``` |
| 181 | + |
| 182 | +- **Full benchmark** (large fixture, 100k files): |
| 183 | + ```bash |
| 184 | + npm run bench:large |
| 185 | + ``` |
| 186 | + |
| 187 | +- **Comparison with fast-glob**: |
| 188 | + ```bash |
| 189 | + npm run bench:vs-fg |
| 190 | + ``` |
| 191 | + |
| 192 | +### Setting Up Fixtures |
| 193 | + |
| 194 | +Before running benchmarks, you may need to generate test fixtures: |
| 195 | + |
| 196 | +```bash |
| 197 | +npm run bench:setup |
| 198 | +``` |
| 199 | + |
| 200 | +For the large fixture (100k files): |
| 201 | +```bash |
| 202 | +npm run bench:setup:huge |
| 203 | +``` |
| 204 | + |
| 205 | +## Code Style |
| 206 | + |
| 207 | +### TypeScript |
| 208 | + |
| 209 | +- We use ESLint and Prettier for TypeScript code |
| 210 | +- Run linting: |
| 211 | + ```bash |
| 212 | + npm run lint:ts |
| 213 | + ``` |
| 214 | +- Auto-fix issues: |
| 215 | + ```bash |
| 216 | + npm run lint:fix |
| 217 | + ``` |
| 218 | +- Format code: |
| 219 | + ```bash |
| 220 | + npm run format:ts |
| 221 | + ``` |
| 222 | + |
| 223 | +### Rust |
| 224 | + |
| 225 | +- We use Clippy and rustfmt for Rust code |
| 226 | +- Run Clippy: |
| 227 | + ```bash |
| 228 | + npm run lint:rust |
| 229 | + ``` |
| 230 | +- Format code: |
| 231 | + ```bash |
| 232 | + npm run format:rust |
| 233 | + ``` |
| 234 | + |
| 235 | +### Combined |
| 236 | + |
| 237 | +- **Lint everything**: |
| 238 | + ```bash |
| 239 | + npm run lint |
| 240 | + ``` |
| 241 | + |
| 242 | +- **Format everything**: |
| 243 | + ```bash |
| 244 | + npm run format |
| 245 | + ``` |
| 246 | + |
| 247 | +- **Check formatting** (CI): |
| 248 | + ```bash |
| 249 | + npm run format:check |
| 250 | + ``` |
| 251 | + |
| 252 | +## Submitting Changes |
| 253 | + |
| 254 | +### Pull Request Process |
| 255 | + |
| 256 | +1. **Before submitting**: |
| 257 | + - Ensure all tests pass: `npm test` |
| 258 | + - Run linting: `npm run lint` |
| 259 | + - Format code: `npm run format` |
| 260 | + - Update documentation if needed |
| 261 | + - Add/update tests for your changes |
| 262 | + |
| 263 | +2. **Commit guidelines**: |
| 264 | + - Write clear, descriptive commit messages |
| 265 | + - Use conventional commit format when possible: |
| 266 | + - `feat:` for new features |
| 267 | + - `fix:` for bug fixes |
| 268 | + - `docs:` for documentation changes |
| 269 | + - `perf:` for performance improvements |
| 270 | + - `test:` for test changes |
| 271 | + - `refactor:` for code refactoring |
| 272 | + - `chore:` for maintenance tasks |
| 273 | + |
| 274 | +3. **Submit your PR**: |
| 275 | + - Push your branch to your fork |
| 276 | + - Open a pull request against the `main` branch |
| 277 | + - Fill out the PR template with: |
| 278 | + - Clear description of changes |
| 279 | + - Related issue numbers (if applicable) |
| 280 | + - Screenshots/benchmarks (if applicable) |
| 281 | + - Breaking changes (if any) |
| 282 | + |
| 283 | +4. **Review process**: |
| 284 | + - Maintainers will review your PR |
| 285 | + - Address any feedback or requested changes |
| 286 | + - Once approved, a maintainer will merge your PR |
| 287 | + |
| 288 | +### PR Checklist |
| 289 | + |
| 290 | +- [ ] Tests pass locally (`npm test`) |
| 291 | +- [ ] Code is linted (`npm run lint`) |
| 292 | +- [ ] Code is formatted (`npm run format`) |
| 293 | +- [ ] Documentation is updated (if needed) |
| 294 | +- [ ] CHANGELOG.md is updated (for significant changes) |
| 295 | +- [ ] Benchmarks run (for performance-related changes) |
| 296 | +- [ ] PR description clearly explains the changes |
| 297 | + |
| 298 | +## Reporting Bugs |
| 299 | + |
| 300 | +When reporting bugs, please include: |
| 301 | + |
| 302 | +1. **Description**: Clear description of the bug |
| 303 | +2. **Steps to reproduce**: Minimal code example that demonstrates the issue |
| 304 | +3. **Expected behavior**: What you expected to happen |
| 305 | +4. **Actual behavior**: What actually happened |
| 306 | +5. **Environment**: |
| 307 | + - Node.js version (`node --version`) |
| 308 | + - Operating system and version |
| 309 | + - Globlin version |
| 310 | + - Any relevant error messages or stack traces |
| 311 | + |
| 312 | +Use the [GitHub issue tracker](https://github.com/CapSoftware/globlin/issues) to report bugs. |
| 313 | + |
| 314 | +## Feature Requests |
| 315 | + |
| 316 | +We welcome feature requests! When proposing a new feature: |
| 317 | + |
| 318 | +1. **Check existing issues**: Ensure it hasn't been requested already |
| 319 | +2. **Describe the use case**: Why is this feature needed? |
| 320 | +3. **Propose a solution**: How should it work? |
| 321 | +4. **Consider compatibility**: How does it affect the glob v13 API compatibility? |
| 322 | +5. **Performance impact**: Consider performance implications |
| 323 | + |
| 324 | +## API Compatibility |
| 325 | + |
| 326 | +Globlin aims to be a **drop-in replacement** for glob v13. When contributing: |
| 327 | + |
| 328 | +- Maintain 100% API compatibility with glob v13 |
| 329 | +- Don't break existing behavior unless fixing a bug |
| 330 | +- If adding new features, ensure they're additive and optional |
| 331 | +- Test against the glob test suite when possible |
| 332 | + |
| 333 | +## Performance Considerations |
| 334 | + |
| 335 | +Globlin's primary goal is performance. When contributing: |
| 336 | + |
| 337 | +- Consider the performance impact of your changes |
| 338 | +- Run benchmarks for performance-related changes |
| 339 | +- Optimize for the common case (large directories, simple patterns) |
| 340 | +- Profile your changes if adding new features |
| 341 | +- Document any performance trade-offs |
| 342 | + |
| 343 | +## Platform Support |
| 344 | + |
| 345 | +Ensure your changes work on all supported platforms: |
| 346 | + |
| 347 | +- **Operating Systems**: Linux, macOS, Windows |
| 348 | +- **Architectures**: x64, ARM64 |
| 349 | +- **Node.js versions**: 20.x, 22.x |
| 350 | + |
| 351 | +## Getting Help |
| 352 | + |
| 353 | +- **Questions**: Open a [discussion](https://github.com/CapSoftware/globlin/discussions) |
| 354 | +- **Chat**: Join our community (link TBD) |
| 355 | +- **Documentation**: Check the [docs](docs/) directory |
| 356 | + |
| 357 | +## License |
| 358 | + |
| 359 | +By contributing to Globlin, you agree that your contributions will be licensed under the MIT License. |
| 360 | + |
| 361 | +--- |
| 362 | + |
| 363 | +Thank you for contributing to Globlin! |
0 commit comments