# GitHub Cloner - Development Guide

This guide is for developers who want to contribute to or modify the GitHub Cloner CLI tool.

## Project Structure

```
github-cloner/
├── src/
│   ├── cli.js              # Main CLI entry point
│   ├── github-cli-cloner.js # Core CLI logic
│   ├── axiosUtils.js       # GitHub API interactions
│   ├── gitUtils.js         # Git operations utilities
│   ├── branchMenu.js       # Branch management interface
│   ├── utils.js            # Helper functions
│   └── constants.js        # Configuration constants
├── bin/
│   └── github-cloner.js    # Binary executable
└── package.json
```

## Local Development Setup

1. Clone the repository:

   ```bash
   git clone git@github.com:relbns/github-cloner.git
   cd github-cloner
   ```

2. Install dependencies:

   ```bash
   npm install
   ```

3. Set up your GitHub token (required for development):

   ```bash
   export GITHUB_TOKEN=your_token_here
   ```

4. Run the CLI locally:
   ```bash
   npm start
   ```

## Development Guidelines

### Code Style

- Use ES modules (import/export)
- Maintain consistent error handling
- Add appropriate comments for complex logic
- Follow existing patterns for new features

### Testing Changes

1. Make your changes
2. Test locally using `npm start`
3. Test global installation:
   ```bash
   npm link
   clone  # Test your changes
   npm unlink  # When done testing
   ```

## Building New Features

1. **File Organization**

   - Add new utilities to appropriate utility files:
     - Git operations in `gitUtils.js`
     - API calls in `axiosUtils.js`
     - General utilities in `utils.js`
   - Add new constants to `constants.js`

2. **Adding Commands**

   - Extend the CLI in `cli.js`
   - Follow the Commander.js pattern

3. **UI Components**
   - Use Inquirer.js for interactive prompts
   - Maintain consistent styling with Chalk
   - Use Ora for loading spinners

## Release Process

New releases are automatically published to npm after successful merging of pull requests through our CI/CD pipeline.

No manual release steps are required. Simply:

1. Create your feature branch
2. Make your changes
3. Submit a pull request
4. After approval and merge, the release will be automated

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request

### Pull Request Guidelines

- Describe your changes
- Explain the problem you're solving
- Include any relevant issue numbers
- Test your changes thoroughly

## Troubleshooting

### Common Issues

1. **Token Issues**

   ```bash
   # Verify token is set
   echo $GITHUB_TOKEN

   # Check permissions
   curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user
   ```

2. **Installation Issues**

   ```bash
   # Clear npm cache
   npm cache clean --force

   # Reinstall dependencies
   rm -rf node_modules
   npm install
   ```

## License

MIT © [Ariel Benesh](https://github.com/relbns)
