// SPEC-597-EXEMPT: canonical mapping (npm-package↔framework, keyword catalogue)
// — must enumerate framework names by design; no detection logic to migrate.
// pattern-loader.ts — Load deprecation patterns from JSON config files (SPEC-041)
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
// Resolve the config directory relative to this file
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const CONFIG_BASE = join(__dirname, '..', '..', '..', 'src', 'config', 'deprecation-patterns');
const SUPPORTED_ECOSYSTEMS = ['nodejs', 'python', 'browser', 'go', 'java', 'rust', 'dotnet'];
/**
 * Load deprecation patterns for a given ecosystem from the JSON config files.
 * Returns an empty array if the ecosystem is not supported, or if the file is not found or malformed.
 */
export async function loadDeprecationPatterns(ecosystem, extraPatternSets = []) {
    if (!SUPPORTED_ECOSYSTEMS.includes(ecosystem)) {
        return [];
    }
    const setsToLoad = [ecosystem, ...extraPatternSets];
    const allPatterns = [];
    for (const set of setsToLoad) {
        const filePath = join(CONFIG_BASE, `${set}.json`);
        try {
            const content = await readFile(filePath, 'utf-8');
            const parsed = JSON.parse(content);
            allPatterns.push(...parsed);
        }
        catch {
            // Gracefully ignore missing or malformed pattern files
        }
    }
    return allPatterns;
}
//# sourceMappingURL=pattern-loader.js.map