"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const inquirer_1 = require("inquirer");
const base_1 = tslib_1.__importDefault(require("../base"));
const logger_1 = tslib_1.__importDefault(require("../utils/logger"));
const git_1 = require("../utils/git");
const constants_1 = require("../constants");
const utils_1 = require("../utils");
class Destroy extends base_1.default {
    async promptConfirmDestroy() {
        const response = await inquirer_1.prompt([
            {
                type: 'confirm',
                name: 'answer',
                message: 'Are you sure?',
                default: false,
            },
        ]);
        if (!response.answer) {
            this.exit(0);
        }
    }
    async run() {
        const { flags } = this.parse(Destroy);
        if (!flags.force) {
            await this.promptConfirmDestroy();
        }
        await utils_1.removeTutureSuite();
        git_1.removeGitHook();
        // Remove local tuture branch if exists.
        const { all: allBranches } = await git_1.git.branchLocal();
        if (allBranches.includes(constants_1.TUTURE_BRANCH)) {
            await git_1.git.branch(['-D', constants_1.TUTURE_BRANCH]);
            logger_1.default.log('success', 'Deleted tuture branch.');
        }
        logger_1.default.log('success', 'Tuture tutorial has been destroyed!');
    }
}
exports.default = Destroy;
Destroy.description = 'Delete all tuture files';
Destroy.flags = {
    help: command_1.flags.help({ char: 'h' }),
    force: command_1.flags.boolean({
        char: 'f',
        description: 'destroy without confirmation',
    }),
};
