Created
June 11, 2015 09:44
-
-
Save PanayotCankov/219b6a2db9fa814781da to your computer and use it in GitHub Desktop.
Automatically generate CHANGELOG.md
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
import https = require('https'); | |
import fs = require('fs'); | |
var options = { | |
hostname: 'api.github.com', | |
path: '/repos/NativeScript/ios-runtime/issues?milestone=3&state=closed', | |
method: 'GET', | |
headers: { | |
"User-Agent": "AutoRN" | |
} | |
}; | |
var msg = ""; | |
var req = https.request(options, function (res) { | |
res.on('data', function (d) { | |
msg += d; | |
}); | |
res.on('end', function (d) { | |
var output = fs.createWriteStream("CHANGELOG.md"); | |
var issues = JSON.parse(msg); | |
var bugs = issues.filter(i => i.labels.filter(l => l.name == "T:Bug").length > 0); | |
var features = issues.filter(i => i.labels.filter(l => l.name == "T:Feature").length > 0); | |
var md = ""; | |
printSection("Bug Fixes", bugs); | |
printSection("Features", features); | |
function printSection(title, issues) { | |
if (issues.length > 0) { | |
md += title + "\r\n"; | |
md += "=========\r\n"; | |
issues.forEach(printIssue); | |
md += "\r\n"; | |
} | |
} | |
function printIssue(i) { | |
md += "\r\n"; | |
md += "#### [(#" + i.number + ")](" + i.html_url + ") " + i.title + "\r\n"; | |
md += i.body + "\r\n"; | |
} | |
fs.writeFileSync("CHANGELOG.md", md); | |
}); | |
}); | |
req.end(); | |
req.on('error', function (e) { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment