@interopio/iocd-cli
Version:
CLI tool for setting up, building and packaging io.Connect Desktop platforms
81 lines • 3.21 kB
JavaScript
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 getComponentsDir() {
return path_1.default.resolve('components');
}
static getModificationsDir() {
return path_1.default.resolve('modifications');
}
static getDistDir() {
return path_1.default.resolve('dist');
}
static getConfigDir() {
return path_1.default.resolve('config');
}
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
;