"use strict";
class BuildCommandBase {
    constructor($options, $platformService) {
        this.$options = $options;
        this.$platformService = $platformService;
    }
    executeCore(args) {
        return (() => {
            let platform = args[0].toLowerCase();
            this.$platformService.buildPlatform(platform, null, true).wait();
            if (this.$options.copyTo) {
                this.$platformService.copyLastOutput(platform, this.$options.copyTo, { isForDevice: this.$options.forDevice });
            }
        }).future()();
    }
}
exports.BuildCommandBase = BuildCommandBase;
class BuildIosCommand extends BuildCommandBase {
    constructor($options, $platformsData, $platformService) {
        super($options, $platformService);
        this.$options = $options;
        this.$platformsData = $platformsData;
        this.allowedParameters = [];
    }
    execute(args) {
        return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
    }
}
exports.BuildIosCommand = BuildIosCommand;
$injector.registerCommand("build|ios", BuildIosCommand);
class BuildAndroidCommand extends BuildCommandBase {
    constructor($options, $platformsData, $errors, $platformService) {
        super($options, $platformService);
        this.$options = $options;
        this.$platformsData = $platformsData;
        this.$errors = $errors;
        this.allowedParameters = [];
    }
    execute(args) {
        return this.executeCore([this.$platformsData.availablePlatforms.Android]);
    }
    canExecute(args) {
        return (() => {
            if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
                this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
            }
            return args.length === 0;
        }).future()();
    }
}
exports.BuildAndroidCommand = BuildAndroidCommand;
$injector.registerCommand("build|android", BuildAndroidCommand);
