UNPKG

jiranch

Version:

Easily create Git branches from your sprint issues

1 lines 2.93 kB
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function i(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,i)}u((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&i[0]?n.return:i[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;switch(n=0,s&&(i=[2&i[0],s.value]),i[0]){case 0:case 1:s=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(s=o.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){o.label=i[1];break}if(6===i[0]&&o.label<s[1]){o.label=s[1],s=i;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(i);break}s[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetchIssues=void 0;var utils_1=require("./utils"),ora_1=__importDefault(require("ora"));function resolveJql(e,t){var r=e.allIssues,n=(0,utils_1.getConfig)().userId,s=[];return t&&s.push("Sprint = ".concat(t)),s.push("assignee in (".concat(n,")")),r||s.push("status in (".concat((0,utils_1.getConfig)().todoStatuses,")")),"search?jql=".concat(s.join(" AND ")," order by created DESC")}function fetchIssues(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,s,a,o;return __generator(this,(function(i){switch(i.label){case 0:return r=(0,ora_1.default)("Loading sprint issues...").start(),n=(0,utils_1.jiraApi)({path:resolveJql(e,null==t?void 0:t.id)}),[4,require("node-fetch")(n,{headers:(0,utils_1.getHeaders)()}).then(utils_1.toJson)];case 1:if((s=i.sent()).errorMessages)throw r.stop(),new Error(s.errorMessages);return a=t?'Sprint "'.concat(t.name,'" issues loaded.'):"Issues loaded.",r.succeed(a),o=s.issues.map((function(e){return e.fields.subtasks})).flat(),[2,{sprint:t,issues:__spreadArray(__spreadArray([],s.issues,!0),o,!0)}]}}))}))}exports.fetchIssues=fetchIssues;