UNPKG

projex

Version:
72 lines (71 loc) 3.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.release = void 0; const _api_1 = require("../../../../api/index"); const _shared_1 = require("../../../../shared/index"); const changelog_1 = require("./changelog"); const utils_1 = require("./utils"); const chalk_1 = __importDefault(require("chalk")); const release = async (options, tagName) => { const preConfirm = options.y || options.yes; const pushAutomatic = options.noPush; const automaticDeploy = options.noDeploy; const checkPreRelease = options.noCheckRelease; const noTag = options.noTag; const getVersion = options.getVersion; const noPreRelease = options.noPreRelease; const noPostRelease = options.noPostRelease; const getReleaseType = options.getReleaseType; const getOnlyVersionNumber = options.getOnlyVersionNumber; const utils = new utils_1.ReleaseUtils(); (0, _shared_1.checkGit)(); (0, _shared_1.checkIfInGitRepo)(); const { releaseType, oldVersion, newVersion, tagText, changelogVersion, changelog } = utils.getRelease(tagName); const pushCommandText = (0, _shared_1.pushCommand)(tagText, noTag); if (getOnlyVersionNumber) { return console.log(newVersion); } else if (getReleaseType) { return console.log(releaseType); } else if (getVersion) { return console.log(utils.versionFileUtils.getVersionInformation(oldVersion, newVersion, pushCommandText)); } else { if (!preConfirm && !(await utils.confirmRelease(String(newVersion)))) { _shared_1.log.verbose('aborted release.'); return; } try { await utils.preRelease({ noPreRelease, checkPreRelease, releaseType }); await utils.versionFileUtils.updateReleaseFilesVersion(newVersion); await utils.versionFileUtils.bump(newVersion); if ((0, changelog_1.shouldUpdateChangelog)(releaseType, tagName)) { utils.updateChangelog(changelogVersion, changelog); } if (!pushAutomatic) { await utils.versionFileUtils.addReleaseFiles(); await utils.versionFileUtils.add(); await utils.commit(tagText, releaseType); } if (!noTag) { await (0, _shared_1.tag)(tagText, utils.versionFileUtils.root); } if (!pushAutomatic) { await utils.push(tagText, noTag); } if (!automaticDeploy) { await utils.postRelease(noPostRelease); } } catch (e) { _shared_1.log.error(`${_api_1.Colors.ERROR('an error occurred while releasing the new version')} ${chalk_1.default.bold(newVersion)}.`); _shared_1.log.error(e); process.exit(1); } } }; exports.release = release;