"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MigrateCommand = void 0;
const yok_1 = require("../common/yok");
class MigrateCommand {
    constructor($devicePlatformsConstants, $migrateController, $projectData, $logger) {
        this.$devicePlatformsConstants = $devicePlatformsConstants;
        this.$migrateController = $migrateController;
        this.$projectData = $projectData;
        this.$logger = $logger;
        this.allowedParameters = [];
        this.$projectData.initializeProjectData();
    }
    execute(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const migrationData = {
                projectDir: this.$projectData.projectDir,
                platforms: [
                    this.$devicePlatformsConstants.Android,
                    this.$devicePlatformsConstants.iOS,
                ],
            };
            const shouldMigrateResult = yield this.$migrateController.shouldMigrate(migrationData);
            if (!shouldMigrateResult) {
                this.$logger.printMarkdown('__Project is compatible with NativeScript "v7.0.0". To get the latest NativeScript packages execute "ns update".__');
                return;
            }
            yield this.$migrateController.migrate(migrationData);
        });
    }
}
exports.MigrateCommand = MigrateCommand;
yok_1.injector.registerCommand("migrate", MigrateCommand);
