Add source code files (detectors, generators, CLI)

This commit is contained in:
2026-02-01 20:15:28 +00:00
parent 5a4aefc823
commit 44dcb977ab

778
src/data/patterns.py Normal file
View File

@@ -0,0 +1,778 @@
"""Comprehensive pattern templates for .gitignore generation."""
from typing import Dict, List
LANGUAGE_PATTERNS: Dict[str, List[str]] = {
"python": [
"# Byte-compiled / optimized / DLL files",
"__pycache__/",
"*.py[cod]",
"*$py.class",
"*.so",
".Python",
"build/",
"develop-eggs/",
"dist/",
"downloads/",
"eggs/",
".eggs/",
"lib/",
"lib64/",
"parts/",
"sdist/",
"var/",
"wheels/",
"*.egg-info/",
".installed.cfg",
"*.egg",
"MANIFEST",
"# PyInstaller",
"*.manifest",
"*.spec",
"# Installer logs",
"pip-log.txt",
"pip-delete-this-directory.txt",
"# Unit test / coverage reports",
"htmlcov/",
".tox/",
".nox/",
".coverage",
".coverage.*",
".coveragerc",
"cover/",
"*.py.bak",
"regress*/",
"venv/",
"env/",
".venv/",
".env/",
".env.local",
],
"nodejs": [
"# Logs",
"logs",
"*.log",
"npm-debug.log*",
"yarn-debug.log*",
"yarn-error.log*",
"lerna-debug.log*",
".pnpm-debug.log*",
"# Runtime data",
"pids",
"*.pid",
"*.seed",
"*.pid.lock",
"coverage",
".nyc_output",
"# Directory for instrumented libs generated by jscoverage/JSCover",
"lib-cov",
"# Coverage directory used by tools like istanbul",
"*.lcov",
".nycrc",
"# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)",
".grunt",
"# Bower dependency directory (https://bower.io/)",
"bower_components",
"# node-waf configuration",
".lock-wscript",
"# Compiled binary addons (https://nodejs.org/api/addons.html)",
"build/Release",
"# Dependency directories",
"node_modules/",
"jspm_packages/",
"# Snowpack dependency directory (https://snowpack.dev/)",
"web_modules/",
"# TypeScript cache",
"*.tsbuildinfo",
"# Optional eslint cache",
".eslintcache",
"# Optional REPL history",
".node_repl_history",
"# Output of 'npm pack'",
"*.tgz",
".yarn-integrity",
],
"go": [
"# Binaries for programs and plugins",
"*.exe",
"*.exe~",
"*.dll",
"*.so",
"*.dylib",
"# Test binary",
"*.test",
"# Output of the go coverage program",
"*.out",
"# Go workspace file",
"go.work",
"# Vendor directory (if using Go modules)",
"vendor/",
"# Go cache directory",
".cache/",
"# Bin directory",
"bin/",
],
"java": [
"# Compiled class files",
"*.class",
"# Log files",
"*.log",
"# BlueJ files",
"*.ctxt",
"# Mobile Tools for Java (J2ME)",
".mtj.tmp/",
"# Package Files",
"*.jar",
"*.war",
"*.nar",
"*.ear",
"*.zip",
"*.tar.gz",
"*.rar",
"# Build files",
"build/",
"# Gradle files",
".gradle/",
"build/",
"# Native library files",
"*.hprof",
"# .idea files",
".idea/",
"*.iml",
"*.ipr",
"*.iws",
".project",
".classpath",
".settings/",
],
"rust": [
"# Build",
"target/",
"Cargo.lock",
"bin/",
"doc/",
"coverage/",
"# Backup files",
"*.rs.bk",
],
"csharp": [
"# Build results",
"[Dd]ebug/",
"[Rr]elease/",
"x64/",
"x86/",
"bld/",
"[Bb]in/",
"[Oo]bj/",
".vs/",
".vscode/",
"# Visual Studio 2015",
"packages/",
"*.nupkg",
],
"cpp": [
"# Compiled object files",
"*.o",
"*.o.*",
"# Compiled dynamic libraries",
"*.so",
"*.dylib",
"# Compiled static libraries",
"*.a",
"# Linker response files",
"*.lai",
"# Executables",
"*.exe",
"*.out",
"*.app",
"build/",
"CMakeFiles/",
"Makefile",
"cmake_install.cmake",
"Testing/",
],
"ruby": [
"*.gem",
"*.rbc",
"/coverage/",
"/InstalledFiles/",
"/pkg/",
"/spec/reports/",
"/spec/examples.txt",
"test/tmp/",
"test/version_tmp/",
"tmp/",
"vendor/bundle/",
"build/",
".bundle/",
"Gemfile.lock",
],
"php": [
"vendor/",
"composer.lock",
"phpunit.cache/",
"coverage/",
".phpunit.result.cache",
],
"dart": [
".dart_tool/",
".packages",
"build/",
"pubspec.lock",
],
"swift": [
"*.xcworkspace/",
"xcuserdata/",
"*.xcuserstate",
"*.xcscmblueprint",
"*.xcscheme",
"Pods/",
"Podfile.lock",
"build/",
".swiftpm/",
],
"kotlin": [
".gradle/",
"build/",
"!gradle/wrapper/gradle-wrapper.jar",
"!**/src/main/**/build/",
"!**/src/test/**/build/",
],
"scala": [
"target/",
"lib_managed/",
"src_managed/",
".bloop/",
".metals/",
],
"perl": [
"Build/",
"_build/",
"inc/",
"MANIFEST",
"MANIFEST.bak",
"META.yml",
"MYMETA.yml",
"MYMETA.json",
"nytprof/",
],
"r": [
".Rhistory",
".Rapp.history",
"*.Rcheck/",
"packrat/",
"renv/",
".Rproj.user/",
],
"elixir": [
"_build/",
"deps/",
"*.ez",
"cover/",
".fetch",
"mix.lock",
],
"clojure": [
"target/",
"classes/",
"checkouts/",
"pom.xml",
"pom.xml.asc",
"*.jar",
"*.class",
".lein-repl-history",
".lein-plugins/",
".gitignore",
],
"lua": [
"*.lua.bak",
"luac.out",
],
"haskell": [
"dist/",
"dist-newstyle/",
"*.o",
"*.hi",
"*.hie",
"*.bowerrc",
],
}
FRAMEWORK_PATTERNS: Dict[str, List[str]] = {
"django": [
"# Django stuff",
"*.log",
"local_settings.py",
"db.sqlite3",
"db.sqlite3-journal",
"# Media",
"media/",
"# Static",
"staticfiles/",
"# Python",
"__pycache__/",
"*.pyc",
"*.pyo",
"*.pyd",
".Python",
"venv/",
"env/",
".venv/",
"# PyInstaller",
"*.manifest",
"*.spec",
"# Migrations",
"migrations/",
"!migrations/__init__.py",
],
"flask": [
"# Flask stuff",
"instance/",
".webassets-cache",
"*.sqlite3",
"*.db",
"*.sqlite3-journal",
],
"fastapi": [
"# FastAPI stuff",
"*.sqlite3",
"*.db",
"*.sqlite3-journal",
],
"react": [
"# React stuff",
"build/",
".next/",
"out/",
"dist/",
],
"vue": [
"# Vue stuff",
"dist/",
"node_modules/",
".eslintcache",
],
"angular": [
"# Angular stuff",
"dist/",
"test",
"karma.conf.js",
"*.js.bak",
"*.local",
],
"express": [
"# Express stuff",
"node_modules/",
"npm-debug.log*",
"yarn-debug.log*",
"yarn-error.log*",
"logs/",
"*.log",
],
"nextjs": [
"# Next.js stuff",
".next/",
"out/",
"build/",
"dist/",
],
"nuxt": [
"# Nuxt.js stuff",
".nuxt/",
".output/",
"data/",
".env",
],
"svelte": [
"# Svelte stuff",
"build/",
".svelte-kit/",
"package/",
],
"gatsby": [
"# Gatsby stuff",
"public/",
".cache/",
"node_modules/",
],
"astro": [
"# Astro stuff",
"dist/",
".astro/",
],
"gin": [
"# Gin stuff",
"bin/",
],
"spring": [
"# Spring stuff",
"target/",
"!.mvn/wrapper/maven-wrapper.jar",
"!**/src/main/**/target/",
"!**/src/test/**/target/",
],
"rails": [
"# Rails stuff",
"/log/*.log",
"/tmp",
"config/database.yml",
"config/secrets.yml",
"config/master.key",
"config/environments/*.local.yml",
"/public/system",
"/public/packs",
"/public/packs-test",
"/public/assets",
"/public/assets/.sprockets-manifest-*.json",
"/vendor/bundle",
"/node_modules",
"/tmp",
"storage/",
"log/*.log",
"tmp/",
"config/master.key",
"config/credentials.yml.enc",
"config/credentials.yml.production.yml.enc",
"config/force_ssl.yml",
],
"laravel": [
"# Laravel stuff",
"/vendor",
"node_modules/",
"/storage",
"/bootstrap/cache",
"*.log",
".env",
"public/storage",
"public/hot",
".env.backup",
],
"dotnet": [
"# .NET stuff",
"**/*.user",
"**/*.userosscache",
"**/*.suo",
"bin/",
"obj/",
"*.cache",
".nuget/",
],
"quasar": [
"# Quasar stuff",
"dist/",
".quasar/",
"node_modules/",
],
"sveltekit": [
"# SvelteKit stuff",
".svelte-kit/",
"build/",
".env",
".env.*",
"!.env.example",
],
"remix": [
"# Remix stuff",
".cache/",
"build/",
"public/build/",
"node_modules/",
],
"vite": [
"# Vite stuff",
"dist/",
"node_modules/",
".env.local",
],
"nestjs": [
"# NestJS stuff",
"dist/",
"node_modules/",
"*.log",
],
}
IDE_PATTERNS: Dict[str, List[str]] = {
"vscode": [
".vscode/",
"!.vscode/extensions.json",
"!.vscode/settings.json",
],
"jetbrains": [
".idea/",
"*.iml",
"*.ipr",
"*.iws",
".project",
".classpath",
".settings/",
"*.sublime-workspace",
"*.sublime-project",
],
"pycharm": [
".idea/",
"*.iml",
"*.ipr",
"*.iws",
".project",
".classpath",
".settings/",
],
"webstorm": [
".idea/",
"*.iml",
"*.ipr",
"*.iws",
".project",
".classpath",
".settings/",
],
"intellij": [
".idea/",
"*.iml",
"*.ipr",
"*.iws",
".project",
".classpath",
".settings/",
],
"eclipse": [
".project",
".classpath",
".settings/",
"*.pydevproject",
"*.pydevproject",
],
"netbeans": [
"nbproject/",
"build/",
"nbbuild/",
"dist/",
"nbdist/",
".netbeans/",
],
"sublime": [
"*.sublime-workspace",
"*.sublime-project",
"sftp-config.json",
],
"vim": [
"*~",
"*.swp",
"*.swo",
"*~",
],
"emacs": [
"#*#",
".#*",
"*~",
"/auto/",
"/elpa/",
"/eln/",
],
"atom": [
".atom/",
"*.atom",
"atom.sh",
],
"spacemacs": [
".spacemacs*",
".spaceemacs",
],
}
OS_PATTERNS: Dict[str, List[str]] = {
"macos": [
"# macOS",
".DS_Store",
".AppleDouble",
".LSOverride",
"._*",
".DocumentRevisions-V100",
".fseventsd",
".Spotlight-V100",
".TemporaryItems",
".Trashes",
".VolumeIcon.icns",
".com.apple.timemachine.donotpresent",
".AppleDB",
".AppleDesktop",
"apdisk",
],
"windows": [
"# Windows",
"Thumbs.db",
"Thumbs.db:encryptable",
"ehthumbs.db",
"Desktop.ini",
"$RECYCLE.BIN/",
"*.lnk",
"*.tmp",
"*.temp",
"*.log",
"*.user",
],
"linux": [
"# Linux",
"*~",
".fuse_hidden*",
".Trash-*",
".nfs*",
],
}
LANGUAGE_INDICATOR_FILES: Dict[str, List[str]] = {
"python": ["requirements.txt", "setup.py", "setup.cfg", "pyproject.toml", "Pipfile", "tox.ini", "pytest.ini", "pyrightconfig.json", "mypy.ini"],
"nodejs": ["package.json", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", ".nvmrc", ".pnpmfile.cjs", ".npmrc"],
"go": ["go.mod", "go.sum", "Gopkg.toml", "Gopkg.lock", "go.work"],
"java": ["pom.xml", "build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts", "gradlew", "gradlew.bat"],
"rust": ["Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "rust-toolchain"],
"csharp": ["*.csproj", "*.sln", "*.csproj.user", "*.sln.docstates", "Directory.Build.props", "Directory.Build.targets"],
"cpp": ["CMakeLists.txt", "CMakeLists.txt.in", "Makefile", "configure", "*.cmake", "*.in"],
"ruby": ["Gemfile", "Gemfile.lock", "Rakefile", "config.ru", ".ruby-version", ".ruby-gemset"],
"php": ["composer.json", "composer.lock", "package.json", "artisan", "phpunit.xml", "phpunit.xml.dist"],
"dart": ["pubspec.yaml", "pubspec.lock", ".dart_tool"],
"swift": ["Package.swift", "*.xcodeproj", "*.xcworkspace"],
"kotlin": ["build.gradle.kts", "settings.gradle.kts", "gradlew", "gradlew.bat"],
"scala": ["build.sbt", "project/", "*.sbt", "project/build.properties"],
"perl": ["Makefile.PL", "Build.PL", "META.yml", "MYMETA.yml", "*.pm", "cpanfile"],
"r": ["DESCRIPTION", "NAMESPACE", "*.Rproj", "renv.lock"],
"elixir": ["mix.exs", "mix.lock", "config/config.exs"],
"clojure": ["project.clj", "deps.edn", "build.boot", "pom.xml"],
"lua": ["*.lua", ".luacheckrc"],
"haskell": ["*.cabal", "stack.yaml", "cabal.project", "*.hs"],
}
FRAMEWORK_INDICATOR_FILES: Dict[str, List[str]] = {
"django": ["manage.py", "django-admin.py", "wsgi.py", "asgi.py", "urls.py", "settings.py", "requirements.txt"],
"flask": ["app.py", "wsgi.py", "__init__.py", "requirements.txt"],
"fastapi": ["main.py", "app.py", "__init__.py", "requirements.txt"],
"react": ["package.json", "tsconfig.json", "vite.config.ts", "webpack.config.js"],
"vue": ["vue.config.js", "vite.config.ts", "package.json"],
"angular": ["angular.json", "tsconfig.json", "package.json"],
"express": ["index.js", "app.js", "server.js", "package.json"],
"nextjs": ["next.config.js", "next.config.mjs", "package.json"],
"nuxt": ["nuxt.config.ts", "nuxt.config.js", "package.json"],
"svelte": ["svelte.config.js", "vite.config.ts", "package.json"],
"gatsby": ["gatsby-config.js", "gatsby-config.ts", "package.json"],
"astro": ["astro.config.mjs", "astro.config.js", "package.json"],
"gin": ["main.go", "go.mod"],
"spring": ["pom.xml", "build.gradle", "src/main/java", "src/main/resources"],
"rails": ["config.ru", "Rakefile", "Gemfile", "bin/rails", "config/application.rb"],
"laravel": ["artisan", "composer.json", "bootstrap/app.php", "config/app.php"],
"dotnet": ["*.csproj", "*.sln", "global.json", "Directory.Build.props"],
"quasar": ["quasar.config.js", "quasar.config.ts", "package.json"],
"sveltekit": ["svelte.config.js", "vite.config.ts", "package.json"],
"remix": ["remix.config.js", "package.json", "tsconfig.json"],
"vite": ["vite.config.ts", "vite.config.js", "package.json"],
"nestjs": ["nest-cli.json", "tsconfig.json", "package.json"],
}
FRAMEWORK_MARKERS: Dict[str, Dict[str, list]] = {
"django": {
"files": ["manage.py", "django-admin.py", "wsgi.py", "asgi.py"],
"content_markers": [
("django", "from django"),
("import_django", "import django"),
],
},
"flask": {
"files": ["app.py", "wsgi.py", "__init__.py"],
"content_markers": [
("from_flask", "from flask"),
("import_flask", "import flask"),
("Flask", "class.*\(Flask\)"),
],
},
"fastapi": {
"files": ["main.py", "app.py", "__init__.py"],
"content_markers": [
("from_fastapi", "from fastapi"),
("import_fastapi", "import fastapi"),
("FastAPI", "FastAPI\("),
],
},
"react": {
"files": ["package.json", "tsconfig.json", "webpack.config.js"],
"content_markers": [
("react", "\"react\""),
("react_dom", "\"react-dom\""),
],
},
"vue": {
"files": ["vue.config.js", "vite.config.ts", "package.json"],
"content_markers": [
("vue", "\"vue\""),
("vue_compiler", "@vue/compiler-sfc"),
],
},
"angular": {
"files": ["angular.json", "tsconfig.json", "package.json"],
"content_markers": [
("angular_core", "@angular/core"),
("ngModule", "NgModule"),
],
},
"express": {
"files": ["index.js", "app.js", "server.js", "package.json"],
"content_markers": [
("express", "\"express\""),
("require_express", "require\\('express\\')"),
],
},
"nextjs": {
"files": ["next.config.js", "next.config.mjs", "package.json"],
"content_markers": [
("next", "\"next\""),
("next_router", "next/router"),
],
},
"gin": {
"files": ["main.go", "go.mod"],
"content_markers": [
("gin_gonic", "\"github.com/gin-gonic/gin\""),
],
},
"spring": {
"files": ["pom.xml", "build.gradle", "src/main/java"],
"content_markers": [
("springframework", "org.springframework"),
("SpringBootApplication", "@SpringBootApplication"),
],
},
"rails": {
"files": ["config.ru", "Rakefile", "Gemfile", "bin/rails"],
"content_markers": [
("rails", "gem ['\"]rails['\"]"),
("Rails_application", "Rails\\.application"),
],
},
"laravel": {
"files": ["artisan", "composer.json", "bootstrap/app.php"],
"content_markers": [
("laravel_framework", "\"laravel/framework\""),
],
},
"nestjs": {
"files": ["nest-cli.json", "tsconfig.json", "package.json"],
"content_markers": [
("nestjs_core", "@nestjs/core"),
("nestjs_common", "@nestjs/common"),
],
},
}
PRIORITY_ORDER = [
"os",
"ide",
"language",
"framework",
]