"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUberSignJava = exports.getApkToolExecutable = exports.getRootModuleDir = exports.sleep = exports.getAppName = exports.getProjectRootDir = exports.getRootDestinationFolder = exports.executeCommandAsync = exports.executeCommand = void 0;
const tslib_1 = require("tslib");
const process_1 = tslib_1.__importDefault(require("process"));
const fs_1 = tslib_1.__importDefault(require("fs"));
const path_1 = tslib_1.__importDefault(require("path"));
const child_process_1 = require("child_process");
const util = require('util');
const execAsync = util.promisify(require('child_process').exec);
function executeCommand(command, options) {
    (0, child_process_1.execSync)(command, { stdio: 'inherit', ...(options || {}) });
}
exports.executeCommand = executeCommand;
function executeCommandAsync(command, options) {
    return execAsync(command, options);
}
exports.executeCommandAsync = executeCommandAsync;
function getRootDestinationFolder() {
    return path_1.default.join(getProjectRootDir(), '.rn-incremental');
}
exports.getRootDestinationFolder = getRootDestinationFolder;
function getProjectRootDir() {
    return process_1.default.cwd();
}
exports.getProjectRootDir = getProjectRootDir;
function getAppName() {
    const projectRootDir = getProjectRootDir();
    const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectRootDir, 'package.json'), 'utf8'));
    // todo default app name improve passing from command line
    return packageJson.name;
}
exports.getAppName = getAppName;
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
exports.sleep = sleep;
function getRootModuleDir() {
    return path_1.default.join(__dirname, '..', '..');
}
exports.getRootModuleDir = getRootModuleDir;
function getApkToolExecutable() {
    return path_1.default.join(getRootModuleDir(), 'apktool');
}
exports.getApkToolExecutable = getApkToolExecutable;
function getUberSignJava() {
    return path_1.default.join(getRootModuleDir(), 'uber-apk-signer.jar');
}
exports.getUberSignJava = getUberSignJava;
