"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments)).next());
    });
};
class DeployOnDeviceCommand {
    constructor($platformService, $platformCommandParameter, $options, $errors, $mobileHelper) {
        this.$platformService = $platformService;
        this.$platformCommandParameter = $platformCommandParameter;
        this.$options = $options;
        this.$errors = $errors;
        this.$mobileHelper = $mobileHelper;
        this.allowedParameters = [];
    }
    execute(args) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.$platformService.deployPlatform(args[0], true);
        });
    }
    canExecute(args) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!args || !args.length || args.length > 1) {
                return false;
            }
            if (!(yield this.$platformCommandParameter.validate(args[0]))) {
                return false;
            }
            if (this.$mobileHelper.isAndroidPlatform(args[0]) && 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 this.$platformService.validateOptions(args[0]);
        });
    }
}
exports.DeployOnDeviceCommand = DeployOnDeviceCommand;
$injector.registerCommand("deploy", DeployOnDeviceCommand);
