@neo4j/practicle
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -17,2 +17,6 @@ #!/usr/bin/env node | ||
var _from = require("babel-runtime/core-js/array/from"); | ||
var _from2 = _interopRequireDefault(_from); | ||
var _set = require("babel-runtime/core-js/set"); | ||
@@ -22,6 +26,2 @@ | ||
var _from = require("babel-runtime/core-js/array/from"); | ||
var _from2 = _interopRequireDefault(_from); | ||
var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray"); | ||
@@ -258,7 +258,9 @@ | ||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(args) { | ||
var repoInfo, prs, releases, releaseTags, nextTag, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _ref7, _ref8, index, value, nextRelease, thisRelease, commits, commitsToPrs; | ||
var _this = this; | ||
return _regenerator2.default.wrap(function _callee6$(_context6) { | ||
var repoInfo, prs, releases, releaseSet, releaseTags, nextTag, _loop, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _ref7, _ref8, index, value, _ret; | ||
return _regenerator2.default.wrap(function _callee6$(_context7) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
@@ -268,9 +270,9 @@ repoInfo = (0, _github.extractFromGithubUrl)(args.repo); | ||
releases = void 0; | ||
_context6.prev = 3; | ||
_context6.next = 6; | ||
_context7.prev = 3; | ||
_context7.next = 6; | ||
return getAllPullRequests(repoInfo, args.labelFilter); | ||
case 6: | ||
prs = _context6.sent; | ||
_context6.next = 9; | ||
prs = _context7.sent; | ||
_context7.next = 9; | ||
return fetchAllTags(repoInfo, { | ||
@@ -281,19 +283,22 @@ filterString: args.releaseTagFilter || defaultReleaseTagFormat | ||
case 9: | ||
releases = _context6.sent; | ||
_context6.next = 16; | ||
releases = _context7.sent; | ||
_context7.next = 16; | ||
break; | ||
case 12: | ||
_context6.prev = 12; | ||
_context6.t0 = _context6["catch"](3); | ||
_context7.prev = 12; | ||
_context7.t0 = _context7["catch"](3); | ||
console.error("Something went wrong: " + _context6.t0.message); | ||
console.error("Something went wrong: " + _context7.t0.message); | ||
process.exit(1); | ||
case 16: | ||
releaseTags = [args.nextVersion].concat((0, _from2.default)(new _set2.default(releases.map(function (release) { | ||
releaseSet = new _set2.default(releases.map(function (release) { | ||
return release.name; | ||
})))); | ||
})); | ||
releaseSet.add(args.nextVersion); | ||
releaseTags = (0, _from2.default)(releaseSet); | ||
if ((0, _utils.isValidSemVer)(args.prevVersion)) { | ||
@@ -315,11 +320,66 @@ releaseTags = releaseTags.filter(function (name) { | ||
_loop = /*#__PURE__*/_regenerator2.default.mark(function _loop(index, value) { | ||
var nextRelease, thisRelease, commits, matchPR, commitsToPrs; | ||
return _regenerator2.default.wrap(function _loop$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
nextRelease = releaseTags[index + 1]; | ||
thisRelease = value === args.nextVersion ? args.releaseCommit : value; | ||
if (!(!value || !nextRelease)) { | ||
_context6.next = 4; | ||
break; | ||
} | ||
return _context6.abrupt("return", "break"); | ||
case 4: | ||
_context6.next = 6; | ||
return fetchCommitsBetween(nextRelease, thisRelease, repoInfo); | ||
case 6: | ||
commits = _context6.sent; | ||
matchPR = function matchPR(pr, commit) { | ||
if (pr.sha === commit.sha) return true; | ||
var nrMatch = commit.commit.message.match(/.*\(\#(.*)\)/); | ||
if (nrMatch && nrMatch[1]) { | ||
return parseInt(nrMatch[1]) === pr.number; | ||
} | ||
return false; | ||
}; | ||
commitsToPrs = commits.map(function (commit) { | ||
var pr = prs.find(function (pr) { | ||
return matchPR(pr, commit); | ||
}); | ||
return pr ? { | ||
...pr, | ||
author: commit && commit.author ? commit.author.login : "No Author" | ||
} : undefined; | ||
}).filter(function (_) { | ||
return _; | ||
}); | ||
if (commitsToPrs.length !== 0) { | ||
(0, _changelog.buildOutput)(commitsToPrs, value, repoInfo, args.outputPrLinks, args.outputAuthor); | ||
} | ||
case 10: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _loop, _this); | ||
}); | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context6.prev = 22; | ||
_context7.prev = 25; | ||
_iterator = (0, _getIterator3.default)(releaseTags.entries()); | ||
case 24: | ||
case 27: | ||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { | ||
_context6.next = 41; | ||
_context7.next = 39; | ||
break; | ||
@@ -332,48 +392,32 @@ } | ||
value = _ref8[1]; | ||
nextRelease = releaseTags[index + 1]; | ||
thisRelease = value === args.nextVersion ? args.releaseCommit : value; | ||
return _context7.delegateYield(_loop(index, value), "t1", 33); | ||
if (!(!value || !nextRelease)) { | ||
_context6.next = 33; | ||
case 33: | ||
_ret = _context7.t1; | ||
if (!(_ret === "break")) { | ||
_context7.next = 36; | ||
break; | ||
} | ||
return _context6.abrupt("break", 41); | ||
return _context7.abrupt("break", 39); | ||
case 33: | ||
_context6.next = 35; | ||
return fetchCommitsBetween(nextRelease, thisRelease, repoInfo); | ||
case 35: | ||
commits = _context6.sent; | ||
commitsToPrs = commits.map(function (commit) { | ||
return prs.find(function (pr) { | ||
return pr.sha === commit.sha; | ||
}); | ||
}).filter(function (_) { | ||
return _; | ||
}); | ||
if (commitsToPrs.length !== 0) { | ||
(0, _changelog.buildOutput)(commitsToPrs, value, repoInfo, args.outputPrLinks); | ||
} | ||
case 38: | ||
case 36: | ||
_iteratorNormalCompletion = true; | ||
_context6.next = 24; | ||
_context7.next = 27; | ||
break; | ||
case 41: | ||
_context6.next = 47; | ||
case 39: | ||
_context7.next = 45; | ||
break; | ||
case 43: | ||
_context6.prev = 43; | ||
_context6.t1 = _context6["catch"](22); | ||
case 41: | ||
_context7.prev = 41; | ||
_context7.t2 = _context7["catch"](25); | ||
_didIteratorError = true; | ||
_iteratorError = _context6.t1; | ||
_iteratorError = _context7.t2; | ||
case 47: | ||
_context6.prev = 47; | ||
_context6.prev = 48; | ||
case 45: | ||
_context7.prev = 45; | ||
_context7.prev = 46; | ||
@@ -384,7 +428,7 @@ if (!_iteratorNormalCompletion && _iterator.return) { | ||
case 50: | ||
_context6.prev = 50; | ||
case 48: | ||
_context7.prev = 48; | ||
if (!_didIteratorError) { | ||
_context6.next = 53; | ||
_context7.next = 51; | ||
break; | ||
@@ -395,14 +439,14 @@ } | ||
case 53: | ||
return _context6.finish(50); | ||
case 51: | ||
return _context7.finish(48); | ||
case 54: | ||
return _context6.finish(47); | ||
case 52: | ||
return _context7.finish(45); | ||
case 55: | ||
case 53: | ||
case "end": | ||
return _context6.stop(); | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee6, this, [[3, 12], [22, 43, 47, 55], [48,, 50, 54]]); | ||
}, _callee6, this, [[3, 12], [25, 41, 45, 53], [46,, 48, 52]]); | ||
})); | ||
@@ -409,0 +453,0 @@ |
@@ -27,9 +27,15 @@ "use strict"; | ||
var newLine = "\n"; | ||
var buildOutput = exports.buildOutput = function buildOutput(logs, header, repoInfo, outputPrLinks) { | ||
var buildOutput = exports.buildOutput = function buildOutput(logs, header, repoInfo, outputPrLinks, outputAuthor) { | ||
var out = "\n## " + header + "\n"; | ||
logs.forEach(function (_) { | ||
out += outputPrLinks ? newLine + ("- " + _.message + " PR: [#" + _.number + "](https://github.com/" + repoInfo.owner + "/" + repoInfo.repo + "/pull/" + _.number + ") " + _.issues).trim() + newLine : newLine + ("- " + _.message + " " + _.issues).trim() + newLine; | ||
out += outputPrLinks ? newLine + ("- " + _.message + " PR: [#" + _.number + "](https://github.com/" + repoInfo.owner + "/" + repoInfo.repo + "/pull/" + _.number + ") " + _.issues).trim() : newLine + ("- " + _.message + " " + _.issues).trim(); | ||
if (outputAuthor) { | ||
out += " (" + _.author + ")"; | ||
} | ||
out += newLine; | ||
}); | ||
console.log(out); | ||
}; |
@@ -52,2 +52,6 @@ "use strict"; | ||
}, | ||
"output-author": { | ||
alias: "oa", | ||
describe: "Adds the author of the PR to the changelog message" | ||
}, | ||
"prev-version": { | ||
@@ -54,0 +58,0 @@ alias: "pv", |
@@ -20,3 +20,5 @@ "use strict"; | ||
var tokenizedNextVersion = nextVersion.split("."); | ||
return prevVersion ? (0, _semverCompare2.default)(name, prevVersion) >= 0 : name.startsWith(prevVersion || [tokenizedNextVersion[0], tokenizedNextVersion[1]].join(".")); | ||
var afterPrevVersion = prevVersion ? (0, _semverCompare2.default)(name, prevVersion) >= 0 : name.startsWith(prevVersion || [tokenizedNextVersion[0], tokenizedNextVersion[1]].join(".")); | ||
var beforeNextVersion = (0, _semverCompare2.default)(name, nextVersion) <= 0; | ||
return afterPrevVersion && beforeNextVersion; | ||
}; | ||
@@ -23,0 +25,0 @@ |
{ | ||
"name": "@neo4j/practicle", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "the pr-activated-changelog-emitter - Generate a changelog from PR:s in a Github repo", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -47,2 +47,3 @@ <p align="center"> | ||
the change message | ||
--output-author, --oa Appends the PR author to the change message | ||
--prev-version, --pv The prev version to generate the | ||
@@ -49,0 +50,0 @@ changelog from. |
228439
792
183