Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 4x 4x 19x 16x 4x 4x 4x 4x 1x 3x 1x 1x 3x | import fs from 'fs-extra';
import path from 'path';
import { detectNodeStack } from './node-detector.js';
import { detectPythonStack } from './python-detector.js';
import { detectRustStack } from './rust-detector.js';
import { detectSwiftStack } from './swift-detector.js';
const DETECTORS = [
{ name: 'node', detector: detectNodeStack, files: ['package.json'] },
{ name: 'python', detector: detectPythonStack, files: ['requirements.txt', 'pyproject.toml'] },
{ name: 'rust', detector: detectRustStack, files: ['Cargo.toml'] },
{ name: 'swift', detector: detectSwiftStack, files: ['Podfile'] },
];
export async function detectStack(cwd = process.cwd()) {
const results = [];
for (const { name, detector, files } of DETECTORS) {
const hasIndicator = files.some(file => fs.pathExistsSync(path.join(cwd, file)));
if (hasIndicator) {
const result = await detector(cwd);
Eif (result.detected) {
results.push(result);
}
}
}
// Return highest confidence result
if (results.length === 0) {
return { detected: false };
}
results.sort((a, b) => {
const confidenceOrder = { high: 3, medium: 2, low: 1 };
return confidenceOrder[b.confidence] - confidenceOrder[a.confidence];
});
return results[0];
} |