import * as path from "node:path";
import { pathExists, readJsonOrNull } from "../../utils/index.js";
/**
 * Detector for TypeScript projects
 * Detects by presence of tsconfig.json or typescript dependency
 */
export class TypeScriptDetector {
    type = "typescript";
    /**
     * Detect if the project uses TypeScript
     * @param destDir - Project directory to check
     * @returns True if TypeScript is detected
     */
    async detect(destDir) {
        // Check for tsconfig.json
        const tsconfigPath = path.join(destDir, "tsconfig.json");
        if (await pathExists(tsconfigPath)) {
            return true;
        }
        // Check for typescript in package.json
        const packageJsonPath = path.join(destDir, "package.json");
        const packageJson = await readJsonOrNull(packageJsonPath);
        if (!packageJson) {
            return false;
        }
        return (packageJson.dependencies?.["typescript"] !== undefined ||
            packageJson.devDependencies?.["typescript"] !== undefined);
    }
}
//# sourceMappingURL=typescript.js.map