Skip to content

Commit

Permalink
Integrated changelog into build process, now also has 'npm run make' …
Browse files Browse the repository at this point in the history
…for everything, see #574
  • Loading branch information
dcodeIO committed Dec 20, 2016
1 parent d581257 commit 333f022
Show file tree
Hide file tree
Showing 13 changed files with 270 additions and 25 deletions.
197 changes: 196 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/runtime/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/runtime/protobuf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/runtime/protobuf.min.js.gz
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
70 changes: 60 additions & 10 deletions scripts/changelog.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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"
});
Expand Down Expand Up @@ -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
Expand All @@ -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);
});
});
3 changes: 1 addition & 2 deletions src/mapfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/**
Expand Down
2 changes: 1 addition & 1 deletion types/protobuf.js.d.ts
Original file line number Diff line number Diff line change
@@ -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" {

/**
Expand Down

0 comments on commit 333f022

Please sign in to comment.