Created
March 10, 2020 18:56
-
-
Save arikfr/d29c2bfcbbd5f0391ba34197ab75fc07 to your computer and use it in GitHub Desktop.
Changelog generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Octokit = require("@octokit/rest"); | |
const createCsvWriter = require("csv-writer").createObjectCsvWriter; | |
const octokit = new Octokit({ | |
auth: "token " + process.env.GITHUB_TOKEN | |
}); | |
async function getCommits(since) { | |
const options = octokit.repos.listCommits.endpoint.merge({ | |
owner: "getredash", | |
repo: "redash", | |
since | |
}); | |
const data = await octokit.paginate(options); | |
return data; | |
} | |
function parseCommit(commit) { | |
const parsed = {}; | |
const match = commit.commit.message.match(/(.*) \(#([0-9]*)\)(.*)/ms); | |
if (match) { | |
parsed.message = match[1]; | |
parsed.pr = match[2]; | |
// parsed.extra = match[3]; | |
} else { | |
parsed.message = commit.commit.message; | |
parsed.pr = null; | |
// parsed.extra = null; | |
} | |
parsed.extra = commit.sha; | |
parsed.author_email = commit.commit.author.email; | |
parsed.author_username = commit.author.login; | |
parsed.date = commit.commit.author.date; | |
return parsed; | |
} | |
function parseCommits(commits) { | |
return commits.map(parseCommit); | |
} | |
(async function() { | |
// const response = await getCommits("2019-03-24T13:58:00Z"); | |
const response = await getCommits("2019-08-08T07:44:44Z"); | |
const commits = parseCommits(response); | |
const header = [ | |
"message", | |
"pr", | |
"author_email", | |
"author_username", | |
"date", | |
"extra" | |
].map(header => { | |
return { id: header, title: header }; | |
}); | |
const csvWriter = createCsvWriter({ | |
path: "commits.csv", | |
header | |
}); | |
await csvWriter.writeRecords(commits); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "changelog", | |
"version": "1.0.0", | |
"lockfileVersion": 1, | |
"requires": true, | |
"dependencies": { | |
"@octokit/endpoint": { | |
"version": "3.1.3", | |
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-3.1.3.tgz", | |
"integrity": "sha512-vAWzeoj9Lzpl3V3YkWKhGzmDUoMfKpyxJhpq74/ohMvmLXDoEuAGnApy/7TRi3OmnjyX2Lr+e9UGGAD0919ohA==", | |
"requires": { | |
"deepmerge": "3.2.0", | |
"is-plain-object": "^2.0.4", | |
"universal-user-agent": "^2.0.1", | |
"url-template": "^2.0.8" | |
} | |
}, | |
"@octokit/request": { | |
"version": "2.4.1", | |
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-2.4.1.tgz", | |
"integrity": "sha512-nN8W24ZXEpJQJoVgMsGZeK9FOzxkc39Xn9ykseUpPpPMNEDFSvqfkCeqqKrjUiXRm72ubGLWG1SOz0aJPcgGww==", | |
"requires": { | |
"@octokit/endpoint": "^3.1.1", | |
"deprecation": "^1.0.1", | |
"is-plain-object": "^2.0.4", | |
"node-fetch": "^2.3.0", | |
"once": "^1.4.0", | |
"universal-user-agent": "^2.0.1" | |
} | |
}, | |
"@octokit/rest": { | |
"version": "16.17.1", | |
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.17.1.tgz", | |
"integrity": "sha512-cRosFoYEXraBsXe+FDHFW4b98RM0WuvSv9HUsbV69E+j8aRGAU/4FudEdpgBSIiXv8HvUOLlo6fAdJmmJHSVKw==", | |
"requires": { | |
"@octokit/request": "2.4.1", | |
"before-after-hook": "^1.4.0", | |
"btoa-lite": "^1.0.0", | |
"deprecation": "^1.0.1", | |
"lodash.get": "^4.4.2", | |
"lodash.set": "^4.3.2", | |
"lodash.uniq": "^4.5.0", | |
"octokit-pagination-methods": "^1.1.0", | |
"once": "^1.4.0", | |
"universal-user-agent": "^2.0.0", | |
"url-template": "^2.0.8" | |
} | |
}, | |
"axios": { | |
"version": "0.18.0", | |
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", | |
"integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", | |
"requires": { | |
"follow-redirects": "^1.3.0", | |
"is-buffer": "^1.1.5" | |
} | |
}, | |
"before-after-hook": { | |
"version": "1.4.0", | |
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-1.4.0.tgz", | |
"integrity": "sha512-l5r9ir56nda3qu14nAXIlyq1MmUSs0meCIaFAh8HwkFwP1F8eToOuS3ah2VAHHcY04jaYD7FpJC5JTXHYRbkzg==" | |
}, | |
"btoa-lite": { | |
"version": "1.0.0", | |
"resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", | |
"integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" | |
}, | |
"cross-spawn": { | |
"version": "6.0.5", | |
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", | |
"integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", | |
"requires": { | |
"nice-try": "^1.0.4", | |
"path-key": "^2.0.1", | |
"semver": "^5.5.0", | |
"shebang-command": "^1.2.0", | |
"which": "^1.2.9" | |
} | |
}, | |
"csv-writer": { | |
"version": "1.2.0", | |
"resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.2.0.tgz", | |
"integrity": "sha512-ZU7eZ26y7oIOXwFHhTNnT/tF6RXMdQnuTGofzNTe1cvXacZm3Ixd7Oa9mOp2f1t39Ezfzg0h5tqfOjXM180BOg==" | |
}, | |
"debug": { | |
"version": "3.2.6", | |
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", | |
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", | |
"requires": { | |
"ms": "^2.1.1" | |
} | |
}, | |
"deepmerge": { | |
"version": "3.2.0", | |
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.2.0.tgz", | |
"integrity": "sha512-6+LuZGU7QCNUnAJyX8cIrlzoEgggTM6B7mm+znKOX4t5ltluT9KLjN6g61ECMS0LTsLW7yDpNoxhix5FZcrIow==" | |
}, | |
"deprecation": { | |
"version": "1.0.1", | |
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-1.0.1.tgz", | |
"integrity": "sha512-ccVHpE72+tcIKaGMql33x5MAjKQIZrk+3x2GbJ7TeraUCZWHoT+KSZpoC+JQFsUBlSTXUrBaGiF0j6zVTepPLg==" | |
}, | |
"execa": { | |
"version": "0.10.0", | |
"resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", | |
"integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", | |
"requires": { | |
"cross-spawn": "^6.0.0", | |
"get-stream": "^3.0.0", | |
"is-stream": "^1.1.0", | |
"npm-run-path": "^2.0.0", | |
"p-finally": "^1.0.0", | |
"signal-exit": "^3.0.0", | |
"strip-eof": "^1.0.0" | |
} | |
}, | |
"follow-redirects": { | |
"version": "1.7.0", | |
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", | |
"integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", | |
"requires": { | |
"debug": "^3.2.6" | |
} | |
}, | |
"get-stream": { | |
"version": "3.0.0", | |
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", | |
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" | |
}, | |
"is-buffer": { | |
"version": "1.1.6", | |
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", | |
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" | |
}, | |
"is-plain-object": { | |
"version": "2.0.4", | |
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", | |
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", | |
"requires": { | |
"isobject": "^3.0.1" | |
} | |
}, | |
"is-stream": { | |
"version": "1.1.0", | |
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", | |
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" | |
}, | |
"isexe": { | |
"version": "2.0.0", | |
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", | |
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" | |
}, | |
"isobject": { | |
"version": "3.0.1", | |
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", | |
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" | |
}, | |
"lodash.get": { | |
"version": "4.4.2", | |
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", | |
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" | |
}, | |
"lodash.set": { | |
"version": "4.3.2", | |
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", | |
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" | |
}, | |
"lodash.uniq": { | |
"version": "4.5.0", | |
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", | |
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" | |
}, | |
"macos-release": { | |
"version": "2.0.0", | |
"resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.0.0.tgz", | |
"integrity": "sha512-iCM3ZGeqIzlrH7KxYK+fphlJpCCczyHXc+HhRVbEu9uNTCrzYJjvvtefzeKTCVHd5AP/aD/fzC80JZ4ZP+dQ/A==" | |
}, | |
"ms": { | |
"version": "2.1.1", | |
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", | |
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" | |
}, | |
"nice-try": { | |
"version": "1.0.5", | |
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", | |
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" | |
}, | |
"node-fetch": { | |
"version": "2.3.0", | |
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", | |
"integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" | |
}, | |
"npm-run-path": { | |
"version": "2.0.2", | |
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", | |
"integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", | |
"requires": { | |
"path-key": "^2.0.0" | |
} | |
}, | |
"octokit-pagination-methods": { | |
"version": "1.1.0", | |
"resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz", | |
"integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==" | |
}, | |
"once": { | |
"version": "1.4.0", | |
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", | |
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", | |
"requires": { | |
"wrappy": "1" | |
} | |
}, | |
"os-name": { | |
"version": "3.0.0", | |
"resolved": "https://registry.npmjs.org/os-name/-/os-name-3.0.0.tgz", | |
"integrity": "sha512-7c74tib2FsdFbQ3W+qj8Tyd1R3Z6tuVRNNxXjJcZ4NgjIEQU9N/prVMqcW29XZPXGACqaXN3jq58/6hoaoXH6g==", | |
"requires": { | |
"macos-release": "^2.0.0", | |
"windows-release": "^3.1.0" | |
} | |
}, | |
"p-finally": { | |
"version": "1.0.0", | |
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", | |
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" | |
}, | |
"path-key": { | |
"version": "2.0.1", | |
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", | |
"integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" | |
}, | |
"semver": { | |
"version": "5.6.0", | |
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", | |
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" | |
}, | |
"shebang-command": { | |
"version": "1.2.0", | |
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", | |
"integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", | |
"requires": { | |
"shebang-regex": "^1.0.0" | |
} | |
}, | |
"shebang-regex": { | |
"version": "1.0.0", | |
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", | |
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" | |
}, | |
"signal-exit": { | |
"version": "3.0.2", | |
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", | |
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" | |
}, | |
"strip-eof": { | |
"version": "1.0.0", | |
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", | |
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" | |
}, | |
"universal-user-agent": { | |
"version": "2.0.3", | |
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-2.0.3.tgz", | |
"integrity": "sha512-eRHEHhChCBHrZsA4WEhdgiOKgdvgrMIHwnwnqD0r5C6AO8kwKcG7qSku3iXdhvHL3YvsS9ZkSGN8h/hIpoFC8g==", | |
"requires": { | |
"os-name": "^3.0.0" | |
} | |
}, | |
"url-template": { | |
"version": "2.0.8", | |
"resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", | |
"integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE=" | |
}, | |
"which": { | |
"version": "1.3.1", | |
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", | |
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", | |
"requires": { | |
"isexe": "^2.0.0" | |
} | |
}, | |
"windows-release": { | |
"version": "3.1.0", | |
"resolved": "https://registry.npmjs.org/windows-release/-/windows-release-3.1.0.tgz", | |
"integrity": "sha512-hBb7m7acFgQPQc222uEQTmdcGLeBmQLNLFIh0rDk3CwFOBrfjefLzEfEfmpMq8Af/n/GnFf3eYf203FY1PmudA==", | |
"requires": { | |
"execa": "^0.10.0" | |
} | |
}, | |
"wrappy": { | |
"version": "1.0.2", | |
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", | |
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "changelog", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@octokit/rest": "^16.17.1", | |
"axios": "^0.18.0", | |
"csv-writer": "^1.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment