@interopio/iocd-cli
Version:
CLI tool for setting up, building and packaging io.Connect Desktop platforms
78 lines • 3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.startDevMode = startDevMode;
const modifications_service_1 = require("./modifications/modifications.service");
const child_process_1 = require("child_process");
const logger_1 = require("../utils/logger");
const child_process_2 = require("child_process");
const path_1 = require("../utils/path");
const fs_1 = require("fs");
const ensure_iocd_exists_1 = require("../utils/ensure.iocd.exists");
const logger = logger_1.Logger.getInstance();
async function startDevMode() {
logger.info('Will start io.cd in dev mode....');
(0, ensure_iocd_exists_1.ensureIOCDComponentExists)();
// copy modifications over components
await (0, modifications_service_1.applyModifications)("dev");
// sign ioconnect desktop if MacOS
await signIocdAppIfMacOs();
await launchIocdComponent();
}
async function signIocdAppIfMacOs() {
// Code signing is only needed on macOS
if (process.platform !== 'darwin') {
logger.debug('Skipping code signing - not on macOS');
return;
}
try {
logger.debug('Running on mac - will sign iocd component...');
const appBundlePath = path_1.PathUtils.getIOCDAppBundlePath();
logger.debug('Executable path:', appBundlePath);
await signAppPackage(appBundlePath);
logger.debug('Code signing completed');
}
catch (error) {
logger.error(`Code signing failed: ${error}`);
throw error;
}
}
async function launchIocdComponent() {
logger.info('Launching io.Connect Desktop...');
try {
let executablePath = path_1.PathUtils.getIOCDExePath();
if (!(0, fs_1.existsSync)(executablePath)) {
throw new Error(`Executable not found at path: ${executablePath}`);
}
logger.debug(`starting executable ${executablePath}`);
(0, child_process_2.spawnSync)(executablePath, {
stdio: 'inherit'
});
logger.info('io.Connect Desktop component launched successfully!');
logger.printLogLocation();
}
catch (error) {
logger.error('Failed to launch io.Connect Desktop component:', error);
throw error;
}
}
/**
* Sign a single app package using codesign
*/
async function signAppPackage(appPath) {
try {
logger.debug(`Signing ${appPath}...`);
// Use codesign with ad-hoc signing (no developer certificate required)
// --deep: Sign nested code recursively
// --force: Replace any existing signature
// --sign -: Use ad-hoc signing (no certificate)
const command = `codesign --deep --force --sign - "${appPath}"`;
logger.debug(`Executing: ${command}`);
(0, child_process_1.execSync)(command, { stdio: 'pipe' });
logger.debug(`Successfully signed ${appPath}`);
}
catch (error) {
logger.error(`Failed to sign ${appPath}: ${error}`);
throw error;
}
}
//# sourceMappingURL=dev.service.js.map
;