"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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const file_1 = require("utils/file");
const chalk_1 = __importDefault(require("chalk"));
const semver_1 = __importDefault(require("semver"));
const inquirer_1 = __importDefault(require("inquirer"));
const git_1 = require("utils/git");
const npm_1 = require("utils/npm");
function commitTag() {
    return __awaiter(this, void 0, void 0, function* () {
        const { version } = (0, file_1.getPackageInfo)();
        const releaseVersion = version;
        const result = yield inquirer_1.default.prompt({
            type: 'list',
            name: 'incType',
            message: '自动升级版本，请选择升级版本类型',
            default: 'patch',
            choices: [
                {
                    name: `小版本（${releaseVersion} -> ${semver_1.default.inc(releaseVersion, 'patch')}）`,
                    value: 'patch',
                },
                {
                    name: `中版本（${releaseVersion} -> ${semver_1.default.inc(releaseVersion, 'minor')}）`,
                    value: 'minor',
                },
                {
                    name: `大版本（${releaseVersion} -> ${semver_1.default.inc(releaseVersion, 'major')}）`,
                    value: 'major',
                },
            ],
        });
        const incVersion = semver_1.default.inc(releaseVersion, result.incType);
        (0, npm_1.npm)(['version', result.incType]).then((res) => {
            if (res.status === 0) {
                if ((0, git_1.setTag)(incVersion)) {
                    console.log(chalk_1.default.green('标签添加成功'));
                }
                else {
                    console.log(chalk_1.default.red('标签添加失败'));
                }
            }
            else {
                console.log(chalk_1.default.red('标签添加失败'));
            }
        });
    });
}
exports.default = commitTag;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJz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