npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

smart-gitignore

v1.2.0

Published

Smart .gitignore generator with automatic stack detection

Readme

smart-gitignore

License: MIT Node.js Version

Smart .gitignore generator based on automatic detection of your project's technology stack.

🎯 Purpose

smart-gitignore automatically analyzes your project directory, detects the technologies used (Java, Node.js, Docker, Ruby, IDEs, etc.) and generates or updates an appropriate .gitignore file using templates from GitHub/gitignore (primary source), with fallback to gitignore.io and local templates.

Why use it?

  • Automatic detection: No need to know which stacks to add manually
  • Smart merge: Preserves existing comments and rules
  • No duplicates: Automatically removes duplicate entries
  • Robust fallback: GitHub → gitignore.io → local templates
  • Updated templates: Uses official GitHub/gitignore templates
  • Extensible: Easy to add new detections

🚀 How to Use

Global Installation (Optional)

npm install -g smart-gitignore

Usage via npx (Recommended)

npx smart-gitignore

Options

npx smart-gitignore [options]

Options:
  -d, --dir <path>    Directory to scan (default: current directory)
  -f, --force         Overwrite existing .gitignore without merging
  -v, --verbose       Verbose mode
  -h, --help          Display help
  -V, --version       Display version

Examples

# Generate .gitignore in current directory
npx smart-gitignore

# Scan specific directory
npx smart-gitignore --dir /path/to/project

# Overwrite existing .gitignore
npx smart-gitignore --force

# Verbose mode for debugging
npx smart-gitignore --verbose

🔍 Stack Detection

smart-gitignore automatically detects the following technologies:

Languages & Frameworks

  • Java: pom.xml, build.gradle, .java files
  • Node.js: package.json, yarn.lock, pnpm-lock.yaml, package-lock.json
  • Ruby: Gemfile, Rakefile, .ruby-version
  • Python: requirements.txt, Pipfile, pyproject.toml, manage.py
  • Go: go.mod, go.sum
  • Rust: Cargo.toml, Cargo.lock
  • PHP: composer.json, composer.lock
  • .NET: .csproj, .sln, project.json

Tools & Environments

  • Maven: pom.xml
  • Gradle: build.gradle, settings.gradle
  • Docker: Dockerfile, docker-compose.yml
  • Yarn: yarn.lock
  • pnpm: pnpm-lock.yaml
  • npm: package-lock.json

IDEs

  • IntelliJ IDEA: .idea/
  • VS Code: .vscode/
  • Eclipse: .eclipse/, .settings/, .project, .classpath

Others

  • dotenv: .env, .env.local, .env.development, .env.production

📁 Project Structure

smart-gitignore/
├── src/
│   ├── scanner.ts        # File detection in directory
│   ├── detector.ts       # File → stack mapping
│   ├── generator.ts      # API call + fallback
│   ├── merger.ts         # Safe .gitignore merge
│   └── index.ts          # CLI entrypoint
├── templates/            # Local fallback templates
│   ├── default.gitignore
│   ├── node.gitignore
│   └── java.gitignore
├── dist/                 # Compiled code (generated)
├── package.json
├── tsconfig.json
├── README.md
└── LICENSE

🔧 Development

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn

Setup

# Clone the repository
git clone https://github.com/Otto-Schmitz/smart-gitignore.git
cd smart-gitignore

# Install dependencies
npm install

# Compile TypeScript
npm run build

# Run locally
npm run dev

Available Scripts

npm run build      # Compile TypeScript to JavaScript
npm run start      # Run compiled version
npm run dev        # Run with ts-node (development)

🗺️ Roadmap

Version 1.0 (MVP) ✅

  • [x] Automatic stack detection
  • [x] Integration with gitignore.io API
  • [x] Fallback to local templates
  • [x] Smart merge of existing .gitignore
  • [x] Duplicate removal
  • [x] User comment preservation

Version 1.1 (Planned)

  • [ ] Support for more languages (Kotlin, Swift, Dart, etc.)
  • [ ] API template caching
  • [ ] Interactive mode for stack selection
  • [ ] Existing .gitignore validation

Version 2.0 (Future)

  • [ ] VS Code extension
  • [ ] IntelliJ IDEA plugin
  • [ ] Git hooks integration
  • [ ] REST API for CI/CD usage
  • [ ] Support for multiple .gitignore files (subdirectories)

🤝 Contributing

Contributions are welcome! Feel free to:

  1. Report bugs: Open an issue describing the problem
  2. Suggest features: Share your ideas in an issue
  3. Submit PRs:
    • Fork the project
    • Create a branch for your feature (git checkout -b feature/new-feature)
    • Commit your changes (git commit -m 'Add new feature')
    • Push to the branch (git push origin feature/new-feature)
    • Open a Pull Request

Adding New Detections

To add a new stack detection, edit src/detector.ts:

private readonly detectionMap: Map<string, string[]> = new Map([
  // ... existing detections
  ['your-file.ext', ['your-stack']],
]);

Adding Local Templates

Add .gitignore files in the templates/ folder with the stack name:

templates/
  └── your-stack.gitignore

📝 License

This project is licensed under the MIT License.

🙏 Acknowledgments

📧 Contact

For questions, suggestions, or issues, open an issue on GitHub.


Made with ❤️ by the open-source community