"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrepareCommand = void 0;
const command_base_1 = require("./command-base");
const yok_1 = require("../common/yok");
class PrepareCommand extends command_base_1.ValidatePlatformCommandBase {
    constructor($options, $prepareController, $platformValidationService, $projectData, $platformCommandParameter, $platformsDataService, $prepareDataService, $migrateController) {
        super($options, $platformsDataService, $platformValidationService, $projectData);
        this.$options = $options;
        this.$prepareController = $prepareController;
        this.$platformValidationService = $platformValidationService;
        this.$projectData = $projectData;
        this.$platformCommandParameter = $platformCommandParameter;
        this.$platformsDataService = $platformsDataService;
        this.$prepareDataService = $prepareDataService;
        this.$migrateController = $migrateController;
        this.allowedParameters = [this.$platformCommandParameter];
        this.dashedOptions = {
            watch: {
                type: "boolean",
                default: false,
                hasSensitiveValue: false,
            },
            hmr: { type: "boolean", default: false, hasSensitiveValue: false },
            whatever: {
                type: "boolean",
                default: false,
                hasSensitiveValue: false,
            },
        };
        this.$projectData.initializeProjectData();
    }
    async execute(args) {
        const platform = args[0];
        const prepareData = this.$prepareDataService.getPrepareData(this.$projectData.projectDir, platform, this.$options);
        await this.$prepareController.prepare(prepareData);
    }
    async canExecute(args) {
        const platform = args[0];
        const result = (await this.$platformCommandParameter.validate(platform)) &&
            (await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform));
        if (!this.$options.force) {
            await this.$migrateController.validate({
                projectDir: this.$projectData.projectDir,
                platforms: [platform],
            });
        }
        if (!result) {
            return false;
        }
        const canExecuteOutput = await super.canExecuteCommandBase(platform);
        return canExecuteOutput;
    }
}
exports.PrepareCommand = PrepareCommand;
yok_1.injector.registerCommand("prepare", PrepareCommand);
