"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 path_1 = __importDefault(require("path"));
const utils_1 = require("./utils");
const fs_1 = __importDefault(require("fs"));
const releaseBuilder_1 = __importDefault(require("./init/helpers/releaseBuilder"));
const releaseBuilder = new releaseBuilder_1.default();
const command = process.argv.slice(2);
let name = command[1];
if (command[0] === "release") {
    const releaseName = `exsp` + name.split("v")[1];
    utils_1.logger.info(` release ${releaseName}`);
    const dirPath = path_1.default.join(__dirname, `../../exsp-releases/${releaseName}`);
    if (!fs_1.default.existsSync(dirPath)) {
        utils_1.logger.error(`Release version ${name.split("v")[1]} done not exist!!!`);
    }
    console.log({ dirPath });
    releaseBuilder.createReleaseJSON(dirPath, (err, res) => __awaiter(void 0, void 0, void 0, function* () {
        if (err)
            utils_1.logger.info(err.message);
        const fileName = "release.json";
        releaseBuilder.isFileExistAndCreated(fileName, res);
        utils_1.logger.info(`Successfully Release version ${name.split("v")[1]}.!!!`);
        // process.exit(1);
    }));
}
else {
    utils_1.logger.error("Command Not Found");
    process.exit(1);
}
