Permalink
Browse files

Integrated changelog into build process, now also has 'npm run make' …

…for everything, see #574
  • Loading branch information...
dcodeIO committed Dec 20, 2016
1 parent d581257 commit 333f0221814be976874862dc83d0b216e07d4012

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -4 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
BIN +0 Bytes (100%) dist/runtime/protobuf.min.js.gz
Binary file not shown.
@@ -27,6 +27,7 @@
"scripts": {
"bench": "node bench",
"build": "gulp",
"changelog": "node scripts/changelog -w",
"docs": "jsdoc -c jsdoc.docs.json -R README.md",
"lint": "eslint src",
"pages": "node scripts/pages",
@@ -35,7 +36,8 @@
"test": "tape tests/*.js | tap-spec",
"types": "node bin/pbts --name protobufjs --out types/protobuf.js.d.ts src && tsc types/test.ts --lib es2015 --noEmit",
"zuul": "zuul --ui tape --no-coverage --concurrency 4 -- tests/*.js",
"zuul-local": "zuul --ui tape --concurrency 1 --local 8080 --disable-tunnel -- tests/*.js"
"zuul-local": "zuul --ui tape --concurrency 1 --local 8080 --disable-tunnel -- tests/*.js",
"make": "npm run lint && npm run test && npm run types && npm run build && npm run changelog"
},
"dependencies": {
"@protobufjs/aspromise": "^1.0.3",
@@ -1,19 +1,36 @@
var path = require("path"),
fs = require("fs");
var gitSemverTags = require("git-semver-tags"),
gitRawCommits = require("git-raw-commits");
gitRawCommits = require("git-raw-commits"),
minimist = require("minimist");
var pkg = require("../package.json");
var basedir = path.join(__dirname, "..");
var pkg = require(basedir + "/package.json");
var breakingFallback = /removed|stripped|dropped/i;
var argv = minimist(process.argv, {
alias: {
tag : "t",
write : "w"
},
string: [ "tag" ],
boolean: [ "write" ],
default: {
tag: null,
write: false
}
});
// categories to be used in the future and regexes for lazy / older subjects
var validCategories = {
"Breaking": null,
"Fixed": /fix|properly|prevent/i,
"Fixed": /fix|properly|prevent|correctly/i,
"New": /added|initial/i,
"CLI": /pbjs|pbts/,
"CLI": /pbjs|pbts|CLI/,
"Docs": /README/i,
"Other": null
};
var breakingFallback = /removed|stripped|dropped/i;
var repo = "https://github.com/dcodeIO/protobuf.js";
@@ -25,10 +42,23 @@ gitSemverTags(function(err, tags) {
Object.keys(validCategories).forEach(function(category) {
categories[category] = [];
});
var output = [];
var from = tags[0];
var to = "HEAD";
var tag;
if (argv.tag) {
var idx = tags.indexOf(argv.tag);
if (idx < 0)
throw Error("no such tag: " + argv.tag);
from = tags[idx + 1];
tag = to = tags[idx];
} else
tag = pkg.version;
var commits = gitRawCommits({
from: tags[0],
to: 'HEAD',
from: from,
to: to,
merges: false,
format: "%B%n#%H"
});
@@ -74,6 +104,7 @@ gitSemverTags(function(err, tags) {
message = message.substring(0, nl).trim();
if (!hash || message.length < 12)
return;
message = message.replace(/\[ci skip\]/, "").trim();
categories[category].push({
text: message,
hash: hash
@@ -82,16 +113,35 @@ gitSemverTags(function(err, tags) {
});
commits.on("end", function() {
console.log("# [" + pkg.version + "](" + repo + "/releases/tag/" + pkg.version + ")");
output.push("# [" + tag + "](" + repo + "/releases/tag/" + tag + ")\n");
Object.keys(categories).forEach(function(category) {
var messages = categories[category];
if (!messages.length)
return;
console.log("\n## " + category);
output.push("\n## " + category + "\n");
messages.forEach(function(message) {
var text = message.text.replace(/#(\d+)/g, "[#$1](" + repo + "/issues/$1)");
console.log("[:hash:](" + repo + "/commit/" + message.hash + ") " + text + "<br />");
output.push("[:hash:](" + repo + "/commit/" + message.hash + ") " + text + "<br />\n");
});
});
var current;
try {
current = fs.readFileSync(basedir + "/CHANGELOG.md").toString("utf8");
} catch (e) {
current = "";
}
var re = new RegExp("^# \\[" + tag + "\\]");
if (re.test(current)) { // regenerated, replace
var pos = current.indexOf("# [", 1);
if (pos > -1)
current = current.substring(pos).trim();
else
current = "";
}
var contents = output.join("") + "\n" + current;
if (argv.write)
fs.writeFileSync(basedir + "/CHANGELOG.md", contents, "utf8");
else
process.stdout.write(contents);
});
});
@@ -9,8 +9,7 @@ var MapFieldPrototype = Field.extend(MapField);
MapField.className = "MapField";
var Enum = require("./enum"),
types = require("./types"),
var types = require("./types"),
util = require("./util");
/**
@@ -1,5 +1,5 @@
// $> pbts --name protobufjs --out types/protobuf.js.d.ts src
// Generated Tue, 20 Dec 2016 00:04:16 UTC
// Generated Tue, 20 Dec 2016 13:19:01 UTC
declare module "protobufjs" {
/**

0 comments on commit 333f022

Please sign in to comment.