hubot-jira-issue-fetcher
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -14,3 +14,3 @@ 'use strict'; | ||
var configuration = { | ||
host: process.env.JIRA_HOST, | ||
jiraHost: process.env.JIRA_HOST, | ||
projectsKeys: process.env.JIRA_PROJECTS_KEYS.split(','), | ||
@@ -27,3 +27,3 @@ jiraUser: process.env.JIRA_USER, | ||
var parser = (0, _messageParser2.default)(configuration); | ||
robot.listen(function (message) { | ||
robot.listen(function () { | ||
return true; | ||
@@ -34,2 +34,3 @@ }, function (res) { | ||
needDetailedInfo = isDirectMessage(message, robot); | ||
parser.parse(message, needDetailedInfo).then(function (attachments) { | ||
@@ -36,0 +37,0 @@ if (attachments) { |
@@ -23,3 +23,3 @@ 'use strict'; | ||
title: issue.key + ': ' + issue.fields.summary, | ||
title_link: 'https://' + config.host + '/browse/' + issue.key, | ||
title_link: 'https://' + config.jiraHost + '/browse/' + issue.key, | ||
text: issue.fields.description, | ||
@@ -38,3 +38,3 @@ fields: [{ | ||
color: getColorForStatus(issue.fields.status.name), | ||
text: '<https://' + config.host + '/browse/' + issue.key + '|' + issue.key + '> `' + issue.fields.status.name + '` ' + issue.fields.summary, | ||
text: '<https://' + config.jiraHost + '/browse/' + issue.key + '|' + issue.key + '> `' + issue.fields.status.name + '` ' + issue.fields.summary, | ||
mrkdwn_in: ['text'] | ||
@@ -41,0 +41,0 @@ }; |
@@ -8,34 +8,14 @@ 'use strict'; | ||
exports.default = function (config) { | ||
var AUTH = new Buffer(config.jiraUser + ':' + config.jiraPwd).toString('base64'); | ||
var jiraRestEndpoint = 'https://' + config.host + '/rest'; | ||
var jira = new _jiraClient2.default({ | ||
protocol: 'https', | ||
host: config.jiraHost, | ||
username: config.jiraUser, | ||
password: config.jiraPwd, | ||
apiVersion: '2', | ||
strictSSL: true | ||
}); | ||
function _getIssue(params) { | ||
var getUrl = jiraRestEndpoint + '/api/2/issue/' + params.key; | ||
return (0, _got2.default)(getUrl, { | ||
json: true, | ||
headers: { | ||
'Authorization': 'Basic ' + params.auth, | ||
'user-agent': 'AirVantasge JIRA bot' | ||
} | ||
}).then(function (res) { | ||
return res.body; | ||
}); | ||
} | ||
function _getIssuesByKeys(keys) { | ||
var searchUrl = jiraRestEndpoint + '/api/2/search'; | ||
var searchQuery = { | ||
jql: 'key in (' + keys.join(',') + ')' | ||
}; | ||
return _got2.default.post(searchUrl, { | ||
json: true, | ||
body: JSON.stringify(searchQuery), | ||
headers: { | ||
'Authorization': 'Basic ' + AUTH, | ||
'user-agent': 'AirVantage slack bot', | ||
'Content-type': 'application/json' | ||
} | ||
}).then(function (res) { | ||
return res.body.issues; | ||
return jira.searchJira('key in (' + keys.join(',') + ')').then(function (res) { | ||
return res.issues; | ||
}); | ||
@@ -45,5 +25,2 @@ } | ||
return { | ||
getIssue: function getIssue(params) { | ||
return _getIssue(params); | ||
}, | ||
getIssuesByKeys: function getIssuesByKeys(keys) { | ||
@@ -55,8 +32,6 @@ return _getIssuesByKeys(keys); | ||
var _got = require('got'); | ||
var _jiraClient = require('jira-client'); | ||
var _got2 = _interopRequireDefault(_got); | ||
var _jiraClient2 = _interopRequireDefault(_jiraClient); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -27,9 +27,11 @@ 'use strict'; | ||
}); | ||
var detailedInfo = void 0; | ||
function _extractIssueKeys(message) { | ||
var messageChunks = message ? message.split(" ") : []; | ||
return _lodash2.default.chain(messageChunks).map(function (chunk) { | ||
var keys = _lodash2.default.chain(messageChunks).map(function (chunk) { | ||
return _lodash2.default.map(config.projectsKeys, function (projectKey) { | ||
// Issue key detected | ||
if (chunk.indexOf(projectKey) === 0) { | ||
if (chunk.indexOf(projectKey + '-') === 0) { | ||
return chunk; | ||
@@ -40,6 +42,10 @@ } | ||
if (chunk.indexOf(projectKey) !== -1) { | ||
return chunk.split('https://' + config.host + '/browse/')[1]; | ||
return chunk.split('https://' + config.jiraHost + '/browse/')[1]; | ||
} | ||
}); | ||
}).flatten().compact().value(); | ||
detailedInfo = detailedInfo || keys && messageChunks.length === keys.length; | ||
return keys; | ||
} | ||
@@ -56,2 +62,3 @@ | ||
parse: function parse(message, needDetailedInfo) { | ||
detailedInfo = needDetailedInfo; | ||
var issueKeys = _extractIssueKeys(message); | ||
@@ -62,3 +69,3 @@ | ||
var messages = void 0; | ||
if (needDetailedInfo) { | ||
if (detailedInfo) { | ||
messages = messageFormatter.buildDetailedMessages(issues); | ||
@@ -65,0 +72,0 @@ } else { |
{ | ||
"name": "hubot-jira-issue-fetcher", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Bot fetching JIRA issue details", | ||
@@ -16,2 +16,3 @@ "main": "index.js", | ||
"got": "^6.6.3", | ||
"jira-client": "^4.2.0", | ||
"lodash": "^4.17.2" | ||
@@ -24,2 +25,3 @@ }, | ||
"babel-preset-latest": "^6.16.0", | ||
"eslint": "^3.14.0", | ||
"grunt": "^1.0.1", | ||
@@ -26,0 +28,0 @@ "grunt-release": "^0.14.0" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138619
3
7
212
+ Addedjira-client@^4.2.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjira-client@4.2.0(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.10.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedrequest-promise@3.0.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)