"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const buildIos_1 = require("../application/buildIos");
const buildAndroid_1 = require("../application/buildAndroid");
const iosUtils_1 = require("../application/iosUtils");
const logger_1 = tslib_1.__importDefault(require("../application/logger"));
class Build extends core_1.Command {
    async run() {
        const { flags } = await this.parse(Build);
        const shouldBuildAndroid = flags.android;
        const shouldBuildIos = flags.ios;
        const buildFlavor = flags.flavor;
        const release = flags.release;
        const incremental = flags.incremental;
        const start = performance.now();
        if (shouldBuildIos) {
            logger_1.default.info('Building ios app');
            (0, buildIos_1.buildIos)(buildFlavor, iosUtils_1.iosBuildPlatforms.simulator);
        }
        if (shouldBuildAndroid) {
            logger_1.default.info('Building android');
            await (0, buildAndroid_1.buildAndroid)(buildFlavor, incremental, release);
        }
        logger_1.default.info(`Build finished in ${((performance.now() - start) / 1000).toFixed(1)} seconds`);
    }
}
exports.default = Build;
Build.description = 'Create native builds for android and ios';
Build.examples = [
    '<%= config.bin %> <%= command.id %> -i -f=dev',
    '<%= config.bin %> <%= command.id %> -a -f=prod',
    '<%= config.bin %> <%= command.id %> -a -f=prod --release',
    '<%= config.bin %> <%= command.id %> -a --release',
    '<%= config.bin %> <%= command.id %> -a --incremental',
];
Build.flags = {
    ios: core_1.Flags.boolean({ char: 'i', description: 'Generate ios native build' }),
    android: core_1.Flags.boolean({ char: 'a', description: 'Generate android native build' }),
    flavor: core_1.Flags.string({ char: 'f', description: 'Specify flavor to build' }),
    release: core_1.Flags.boolean({ description: 'Optimized release build', default: false }),
    incremental: core_1.Flags.boolean({ char: 'I', description: 'Incremental build', default: false }),
};
