"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathUtils = void 0;
const path_1 = __importDefault(require("path"));
const config_service_1 = require("../services/config/config.service");
class PathUtils {
    /** Returns the root directory path of the project (not the cli) */
    static getRootDir() {
        return path_1.default.resolve(".");
    }
    static getAppsDir() {
        return path_1.default.join(this.getRootDir(), "apps");
    }
    static getComponentsDir() {
        return path_1.default.join(this.getRootDir(), "components");
    }
    static getModificationsDir() {
        return path_1.default.join(this.getRootDir(), "modifications");
    }
    static getDistDir() {
        return path_1.default.join(this.getRootDir(), "dist");
    }
    static getConfigDir() {
        return path_1.default.join(this.getRootDir(), "config");
    }
    /** Returns the path to the main CLI configuration file */
    static getCliConfigPath() {
        return path_1.default.join(this.getConfigDir(), "iocd.cli.config.json");
    }
    /** Returns the path to the forge configuration file */
    static getForgeConfigPath() {
        return path_1.default.join(this.getConfigDir(), "forge.config.js");
    }
    /** Returns the path to the license file */
    static getLicensePath() {
        return path_1.default.join(this.getConfigDir(), "iocd.license.key");
    }
    static getComponentDir(componentName) {
        return path_1.default.join(this.getComponentsDir(), componentName);
    }
    static getModificationDir(componentName) {
        return path_1.default.join(this.getModificationsDir(), componentName);
    }
    /** On iocd root dir. Note that on mac os this is Contents inside the app bundle (and not the app bundle itself) */
    static getIOCDDir() {
        const iocdDir = this.getComponentDir("iocd");
        if (process.platform === "darwin") {
            return path_1.default.join(iocdDir, config_service_1.ConfigManager.config.mac.appBundleName, "Contents");
        }
        return iocdDir;
    }
    static getIOCDResourcesDir() {
        const iocdDir = this.getIOCDDir();
        let resourcesPath;
        if (process.platform === "darwin") {
            // macOS: .app/Contents/Resources/metadata.json
            resourcesPath = path_1.default.join(iocdDir, "Resources");
        }
        else {
            // Windows/Linux: resources/metadata.json
            resourcesPath = path_1.default.join(iocdDir, "resources");
        }
        return resourcesPath;
    }
    static getIOCDAssetsDir() {
        return path_1.default.join(this.getIOCDDir(), "assets");
    }
    static getIOCDConfigDir() {
        return path_1.default.join(this.getIOCDDir(), "config");
    }
    static getIOCDExePath() {
        const iocdDir = this.getIOCDDir();
        if (process.platform === "darwin") {
            const exeName = config_service_1.ConfigManager.config.mac.appBundleName.replace(".app", "");
            return path_1.default.join(iocdDir, "MacOS", exeName);
        }
        else if (process.platform === "win32") {
            return path_1.default.join(iocdDir, config_service_1.ConfigManager.config.win.exe.exeName);
        }
        else {
            throw new Error(`Unsupported platform: ${process.platform}`);
        }
    }
    /** MacOS only - gets the path to the .app bundle */
    static getIOCDAppBundlePath() {
        if (process.platform === "darwin") {
            return path_1.default.join(this.getComponentDir("iocd"), config_service_1.ConfigManager.config.mac.appBundleName);
        }
        throw new Error(`Unsupported platform (${process.platform})`);
    }
}
exports.PathUtils = PathUtils;
//# sourceMappingURL=path.js.map