Skip to content

Latest commit

 

History

History
221 lines (153 loc) · 4.96 KB

File metadata and controls

221 lines (153 loc) · 4.96 KB

Contributing to create-pull-request

Thank you for your interest in contributing to create-pull-request! This document provides guidelines and information about the development workflow.

Development Setup

Prerequisites

  • Node.js >= 20
  • npm (comes with Node.js)

Getting Started

  1. Fork the repository

    git clone https://github.com/yourusername/create-pull-request.git
    cd create-pull-request
  2. Install dependencies

    npm install
  3. Run tests

    npm test
  4. Test the CLI

    node create-pull-request.js --help

Windows Compatibility

The project is configured to work correctly on Windows, macOS, and Linux. If you encounter line ending issues on Windows, ensure your Git configuration is set up correctly:

# Configure Git to handle line endings automatically
git config --global core.autocrlf false
git config --global core.eol lf

The project includes:

  • .gitattributes - Ensures consistent line endings across platforms
  • CI configuration - Automatically handles line endings in GitHub Actions
  • Cross-platform testing - Tests run on all three major operating systems

Testing

We use Vitest for testing. The test suite includes:

  • Unit tests for all core functions
  • Integration tests for complete workflows
  • Edge case testing for error handling
  • Mocked dependencies for isolated testing

Running Tests

# Run tests in watch mode (recommended during development)
npm test

# Run tests once
npm run test:run

# Run tests with coverage report
npm run test:coverage

# Run tests in watch mode with coverage
npm run test:watch

Coverage Thresholds

The project maintains the following coverage thresholds:

  • Statements: 70%
  • Branches: 85%
  • Functions: 85%
  • Lines: 70%

Continuous Integration (CI)

The project uses GitHub Actions for CI/CD. The workflow runs:

Test Matrix

  • Node.js versions: 20.x, 22.x, latest
  • Operating systems: Ubuntu, macOS, Windows
  • Total combinations: 9 different environments

CI Jobs

  1. Test Job

    • Runs all tests on the matrix combinations
    • Generates coverage reports
  2. Lint Job

    • Validates package.json
    • Tests CLI functionality
    • Performs basic sanity checks

Workflow Triggers

The CI runs on:

  • Push to main and develop branches
  • Pull requests targeting main and develop

Code Quality

Coverage Requirements

All new code should maintain or improve test coverage. The CI will fail if coverage drops below the thresholds.

Browser Support

When adding new browser support, ensure:

  1. Add browser to SUPPORTED_BROWSERS in create-pull-request.js
  2. Update tests in create-pull-request.test.js
  3. Update README with new browser information
  4. Test manually that the browser opens correctly

Platform Support

When adding new platform support:

  1. Add platform handler to SUPPORTED_PLATFORMS
  2. Add comprehensive tests for URL generation
  3. Update documentation in README
  4. Test with real repositories from that platform

Pull Request Process

  1. Create a feature branch

    git checkout -b feature/your-feature-name
  2. Make your changes

    • Write code following existing patterns
    • Add tests for new functionality
    • Update documentation as needed
  3. Test your changes

    npm run test:coverage
  4. Commit your changes

    git commit -m "feat: add amazing new feature"
  5. Push and create PR

    git push origin feature/your-feature-name
  6. Wait for CI

    • All tests must pass
    • Coverage must meet thresholds
    • CLI functionality must work

Development Tips

Testing Strategy

  • Test the happy path: Ensure normal usage works
  • Test edge cases: Invalid inputs, network errors, etc.
  • Test integration: Complete workflows from start to finish
  • Mock external dependencies: Keep tests fast and reliable

Debugging Tests

# Run a specific test file
npx vitest create-pull-request.test.js

# Run tests with specific pattern
npx vitest --grep "normalizeGitUrl"

# Run tests with debug output
npx vitest --reporter=verbose

Local Development

# Link the package locally for testing
npm link

# Now you can test the CLI globally
create-pull-request --help

# Unlink when done
npm unlink

Release Process

  1. Ensure all tests pass
  2. Update version in package.json
  3. Create release notes
  4. Tag the release
  5. Publish to npm

Getting Help

Code of Conduct

Please be respectful and professional in all interactions. We want to maintain a welcoming environment for all contributors.


Thank you for contributing! 🎉