UNPKG

jiranch

Version:

Easily create Git branches from your sprint issues

1 lines 1.49 kB
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.pluck=exports.jiraApi=exports.lastChar=exports.sanitizeBranchName=exports.getHeaders=exports.getConfig=exports.toJson=exports.exec=void 0;var shared_1=require("../shared"),node_child_process_1=require("node:child_process"),util_1=__importDefault(require("util"));function toJson(e){return e.json()}function getConfig(){return(0,shared_1.getConfigStore)().all}function getHeaders(e){var t=void 0===e?getConfig():e,r=t.email,o=t.token,a=Buffer.from("".concat(r,":").concat(o)).toString("base64");return{"Content-Type":"application/json",Authorization:"Basic ".concat(a)}}function sanitizeBranchName(e){var t=e.trim().toLowerCase().replace(/[\W_]+/g,"-").substring(0,40);return"-"===lastChar(t)&&(t=t.substring(0,t.length-1)),t}function lastChar(e){return e?e.charAt(e.length-1):""}exports.exec=util_1.default.promisify(node_child_process_1.exec),exports.toJson=toJson,exports.getConfig=getConfig,exports.getHeaders=getHeaders,exports.sanitizeBranchName=sanitizeBranchName,exports.lastChar=lastChar;var apiTypesMap={api:"api/3",agile:"agile/1.0"};function jiraApi(e){var t=e.path,r=e.type,o=void 0===r?"api":r,a=e.apiPath,i=void 0===a?getConfig().apiPath:a;return"".concat(i,"/rest/").concat(apiTypesMap[o],"/").concat(t)}function pluck(e){return function(t){return t[e]}}exports.jiraApi=jiraApi,exports.pluck=pluck;