typescript-assistant
Version:
Combines and integrates professional Typescript tools into your project
67 lines • 3.4 kB
JavaScript
;
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.createReleaseCommand = void 0;
const child_process_1 = require("child_process");
const path_1 = require("path");
const inquirer_1 = require("inquirer");
function createReleaseCommand(deps) {
const { git, taskRunner, logger } = deps;
return {
execute() {
return __awaiter(this, void 0, void 0, function* () {
let pristine = yield git.isPristine();
if (!pristine) {
throw new Error("There are uncommitted changes in the working tree");
}
let npm = path_1.sep === "\\" ? "npm.cmd" : "npm";
let onBranch = yield git.isOnBranch();
if (onBranch) {
let answers = yield (0, inquirer_1.prompt)({
type: "confirm",
name: "confirm",
message: "You are not on master, do you want to do a pre-release?",
});
if (!answers["confirm"]) {
return true;
}
let tag = yield git.getBranchName();
yield taskRunner.runTask(npm, ["version", "prerelease", "--preid", tag], {
name: "npm",
logger,
}).result;
}
else {
let answers = yield (0, inquirer_1.prompt)({
type: "list",
name: "bump",
message: "What type of bump would you like to do?",
choices: ["patch", "minor", "major"],
});
let importance = answers["bump"];
// 'npm version' also does a 'git commit' and 'git tag'
(0, child_process_1.execSync)([npm, "version", importance, "--commit-hooks", "false"].join(" "), { stdio: [0, 1, 2], cwd: process.cwd() });
}
yield git.execute(["push", "--no-verify"]);
yield git.execute(["push", "--tags", "--no-verify"]);
let publishArguments = onBranch
? ["publish", "--tag", "dev"]
: ["publish"];
publishArguments.push("--commit-hooks", "false");
// Using execSync to allow user interaction to do 2 factor authentication
(0, child_process_1.execSync)([npm, ...publishArguments].join(" "), { stdio: [0, 1, 2] });
return true;
});
},
};
}
exports.createReleaseCommand = createReleaseCommand;
//# sourceMappingURL=release.js.map