This commit is contained in:
297
README.md
297
README.md
@@ -1,206 +1,175 @@
|
|||||||
# gitignore-generator
|
# Gitignore Generator
|
||||||
|
|
||||||
A CLI tool that automatically generates `.gitignore` files based on project type, tech stack, and IDE. It detects project structure, supports multiple languages/frameworks, generates IDE-specific ignores, allows customization via config file, and works offline with a curated collection.
|
A CLI tool that generates optimized `.gitignore` files with support for 50+ frameworks, IDE-specific templates, interactive custom builders, template management, and syntax validation. All processing is done locally with zero network dependencies.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Auto-detects project type from file structure
|
- **50+ Language/Framework Templates** - Python, JavaScript, Java, Go, Rust, C++, C#, Ruby, PHP, TypeScript, Swift, Kotlin, Scala, Dart, and more
|
||||||
- Multi-language/framework support (Python, JavaScript, TypeScript, Java, Go, Rust, .NET, PHP, Ruby)
|
- **IDE-Specific Templates** - VSCode, JetBrains (IntelliJ, PyCharm), Visual Studio, Vim, Emacs
|
||||||
- Framework-specific templates (Django, Flask, React, Vue, Angular, Rails, Laravel, Spring)
|
- **Interactive Mode** - Wizard-style interface for building custom .gitignore files
|
||||||
- IDE-specific ignore rules (VS Code, JetBrains, Visual Studio Code)
|
- **Template Management** - Add, remove, export custom templates
|
||||||
- Operating system-specific ignores (Linux, macOS, Windows)
|
- **Syntax Validation** - Detects common mistakes and potential issues
|
||||||
- Tool-specific templates (Docker, Gradle, Maven, Jupyter, Terraform)
|
- **Local-First** - All processing done locally, no network dependencies
|
||||||
- Interactive wizard mode for guided generation
|
|
||||||
- Configuration file support for customization
|
|
||||||
- Works completely offline
|
|
||||||
- Append or overwrite existing `.gitignore` files
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### From Source
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e .
|
||||||
|
```
|
||||||
|
|
||||||
|
### From PyPI
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install gitignore-generator
|
pip install gitignore-generator
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install from source:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/yourusername/gitignore-generator.git
|
|
||||||
cd gitignore-generator
|
|
||||||
pip install -e .
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Auto-detect and generate
|
### Generate a .gitignore from templates
|
||||||
|
|
||||||
Automatically detect your project type and generate a `.gitignore`:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gitignore-generator generate
|
gitignore generate python
|
||||||
```
|
gitignore generate python javascript
|
||||||
|
gitignore generate python --ide vscode
|
||||||
### Specify types manually
|
gitignore generate python -o my.gitignore
|
||||||
|
|
||||||
Generate for specific types:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Single type
|
|
||||||
gitignore-generator generate --language python
|
|
||||||
|
|
||||||
# Multiple types
|
|
||||||
gitignore-generator generate --language python --framework django --ide vscode
|
|
||||||
|
|
||||||
# Using positional arguments
|
|
||||||
gitignore-generator generate python django vscode
|
|
||||||
```
|
|
||||||
|
|
||||||
### Output options
|
|
||||||
|
|
||||||
Write to stdout instead of file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gitignore-generator generate python --stdout
|
|
||||||
```
|
|
||||||
|
|
||||||
Specify output file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gitignore-generator generate python -o custom.gitignore
|
|
||||||
```
|
|
||||||
|
|
||||||
Overwrite existing file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gitignore-generator generate python --overwrite
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### List available templates
|
### List available templates
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# List all templates
|
gitignore list
|
||||||
gitignore-generator list
|
gitignore list --category languages
|
||||||
|
gitignore list --category ides
|
||||||
# List by category
|
|
||||||
gitignore-generator list --category language
|
|
||||||
gitignore-generator list --category framework
|
|
||||||
gitignore-generator list --category ide
|
|
||||||
gitignore-generator list --category os
|
|
||||||
gitignore-generator list --category tools
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Detect project type
|
### Search for templates
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gitignore-generator detect
|
gitignore search python
|
||||||
|
gitignore search java
|
||||||
```
|
```
|
||||||
|
|
||||||
### Interactive wizard
|
### Interactive Mode
|
||||||
|
|
||||||
Run an interactive wizard for guided generation:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gitignore-generator wizard
|
gitignore interactive
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use configuration file
|
### Validate existing .gitignore
|
||||||
|
|
||||||
Specify a configuration file:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gitignore-generator --config .gitignorerc generate
|
gitignore validate .gitignore
|
||||||
|
```
|
||||||
|
|
||||||
|
### Template Management
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Add custom template
|
||||||
|
gitignore template-add my_template template_file.gitignore
|
||||||
|
|
||||||
|
# Remove custom template
|
||||||
|
gitignore template-remove my_template
|
||||||
|
|
||||||
|
# Export template to file
|
||||||
|
gitignore template-export python exported.gitignore
|
||||||
|
|
||||||
|
# Get template info
|
||||||
|
gitignore info python
|
||||||
|
```
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `generate [TEMPLATES...]` | Generate .gitignore from templates |
|
||||||
|
| `list` | List available templates |
|
||||||
|
| `search QUERY` | Search for templates |
|
||||||
|
| `interactive` | Launch interactive wizard |
|
||||||
|
| `validate FILE` | Validate .gitignore syntax |
|
||||||
|
| `template-add NAME FILE` | Add custom template |
|
||||||
|
| `template-remove NAME` | Remove custom template |
|
||||||
|
| `template-export NAME FILE` | Export template to file |
|
||||||
|
| `info TEMPLATE` | Show template information |
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
### Languages & Frameworks
|
||||||
|
|
||||||
|
- Python, JavaScript, Java, Go, Rust
|
||||||
|
- C++, C#, TypeScript, PHP, Ruby
|
||||||
|
- Swift, Kotlin, Scala, Dart
|
||||||
|
- Haskell, Elixir, Clojure, OCaml
|
||||||
|
- Perl, Lua, R
|
||||||
|
- .NET, Terraform, Ansible
|
||||||
|
- Docker, Kubernetes
|
||||||
|
|
||||||
|
### IDEs
|
||||||
|
|
||||||
|
- VSCode, JetBrains (IntelliJ, PyCharm, etc.)
|
||||||
|
- Visual Studio, Vim, Emacs
|
||||||
|
|
||||||
|
## Interactive Mode
|
||||||
|
|
||||||
|
The interactive mode guides you through creating a `.gitignore`:
|
||||||
|
|
||||||
|
1. Select a category (Languages, IDEs, or Custom)
|
||||||
|
2. Choose templates from the list
|
||||||
|
3. Add custom patterns
|
||||||
|
4. Preview and edit the result
|
||||||
|
5. Save to file
|
||||||
|
|
||||||
|
## Template Management
|
||||||
|
|
||||||
|
Custom templates are stored in `~/.config/gitignore-generator/templates/`.
|
||||||
|
|
||||||
|
### Environment Variables
|
||||||
|
|
||||||
|
| Variable | Description | Default |
|
||||||
|
|----------|-------------|---------|
|
||||||
|
| `GITIGNORE_DEFAULT_FILE` | Default output file | `.gitignore` |
|
||||||
|
| `TEMPLATE_DIR` | Template directory | `templates` |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Python project with VSCode
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gitignore generate python --ide vscode
|
||||||
|
```
|
||||||
|
|
||||||
|
### Full stack project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gitignore generate python javascript --ide jetbrains
|
||||||
|
```
|
||||||
|
|
||||||
|
### With custom output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gitignore generate .gitignore - java kotlin -of
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Create a `.gitignorerc` file in your project root or home directory:
|
Create a `.gitignore-generator/config.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
custom_templates:
|
template_dir: templates
|
||||||
my_template: |
|
default_output: .gitignore
|
||||||
# Custom template content
|
custom_templates_dir: ~/.config/gitignore-generator/templates
|
||||||
*.custom
|
|
||||||
.custom/
|
|
||||||
|
|
||||||
default_types:
|
|
||||||
- python
|
|
||||||
- vscode
|
|
||||||
|
|
||||||
exclude_patterns:
|
|
||||||
- "*.pyc"
|
|
||||||
|
|
||||||
include_patterns:
|
|
||||||
python:
|
|
||||||
- "src/"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Available Templates
|
|
||||||
|
|
||||||
### Languages
|
|
||||||
- Python
|
|
||||||
- JavaScript
|
|
||||||
- TypeScript
|
|
||||||
- Java
|
|
||||||
- Go
|
|
||||||
- Rust
|
|
||||||
- .NET
|
|
||||||
- PHP
|
|
||||||
- Ruby
|
|
||||||
|
|
||||||
### Frameworks
|
|
||||||
- Django
|
|
||||||
- Flask
|
|
||||||
- React
|
|
||||||
- Vue
|
|
||||||
- Angular
|
|
||||||
- Ruby on Rails
|
|
||||||
- Laravel
|
|
||||||
- Spring
|
|
||||||
|
|
||||||
### IDEs
|
|
||||||
- VS Code
|
|
||||||
- JetBrains
|
|
||||||
- Visual Studio Code
|
|
||||||
|
|
||||||
### Operating Systems
|
|
||||||
- Linux
|
|
||||||
- macOS
|
|
||||||
- Windows
|
|
||||||
|
|
||||||
### Tools
|
|
||||||
- Docker
|
|
||||||
- Gradle
|
|
||||||
- Maven
|
|
||||||
- Jupyter
|
|
||||||
- Terraform
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
### Setup
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/yourusername/gitignore-generator.git
|
|
||||||
cd gitignore-generator
|
|
||||||
pip install -e ".[dev]"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Running Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pytest tests/ -v
|
|
||||||
pytest tests/ --cov=src
|
|
||||||
```
|
|
||||||
|
|
||||||
### Adding New Templates
|
|
||||||
|
|
||||||
1. Create a new `.gitignore` file in the appropriate category directory under `src/templates/`
|
|
||||||
2. Add the template to the `TEMPLATE_MAP` in `src/generator.py`
|
|
||||||
3. Add detection patterns to `src/detector.py` if applicable
|
|
||||||
4. Add tests in the appropriate test file
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT License - see [LICENSE](LICENSE) file for details.
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
1. Fork the repository
|
||||||
|
2. Create a feature branch
|
||||||
|
3. Add your template to `templates/languages/` or `templates/ides/`
|
||||||
|
4. Update `templates/templates.json`
|
||||||
|
5. Run tests: `pytest tests/ -v`
|
||||||
|
6. Submit a pull request
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|||||||
Reference in New Issue
Block a user