"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImlDescriptorParser = void 0;
const path = require("path");
const ImlParser_1 = require("./ImlParser");
const utils_1 = require("../utils");
class ImlDescriptorParser {
    constructor(pluginDir, pluginName, excludeTestDependencies) {
        this.descriptor = this.parseFile(pluginDir, pluginName, excludeTestDependencies);
    }
    getPluginDescriptor() {
        return this.descriptor;
    }
    parseFile(pluginDir, pluginName, excludeTestDependencies) {
        const pathToIml = path.join(pluginDir, `${pluginName}.iml`);
        const imlParser = new ImlParser_1.ImlParser(pathToIml);
        const dependencies = imlParser
            .getReferencedModules()
            .filter((module) => {
            const includeDependency = !excludeTestDependencies || !module.isTestScoped;
            if (!includeDependency) {
                utils_1.debug(`(DependencyParser) [${pluginName}] excluding test dependency: ${module.moduleName}`);
            }
            return includeDependency;
        })
            .map((module) => {
            return {
                name: module.moduleName,
            };
        });
        return {
            name: pluginName,
            dependencies: dependencies,
        };
    }
}
exports.ImlDescriptorParser = ImlDescriptorParser;
//# sourceMappingURL=ImlDescriptorParser.js.map