gitignore-synthesizer
Version:
Generate smart .gitignore files based on your project's actual contents
36 lines (31 loc) • 974 B
JavaScript
import fs from 'fs/promises';
import path from 'path';
const frameworkFiles = {
node: ['package.json'],
react: ['package.json', 'src/index.js', 'src/index.jsx', 'src/App.js'],
vue: ['package.json', 'src/main.js', 'src/App.vue'],
angular: ['angular.json'],
nextjs: ['next.config.js'],
python: ['requirements.txt', 'setup.py'],
django: ['manage.py'],
flask: ['app.py'],
java: ['pom.xml', 'build.gradle'],
android: ['app/build.gradle', 'AndroidManifest.xml'],
flutter: ['pubspec.yaml'],
docker: ['Dockerfile', 'docker-compose.yml'],
};
export async function detectFrameworks(projectDir) {
const detected = [];
for (const [fw, files] of Object.entries(frameworkFiles)) {
for (const file of files) {
try {
await fs.access(path.join(projectDir, file));
detected.push(fw);
break;
} catch {
// not found, try next
}
}
}
return [...new Set(detected)];
}