wildfire chat server source initial submit
This commit is contained in:
Executable
+92
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
module.exports = bundle;
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path");
|
||||
|
||||
var browserify = require("browserify");
|
||||
|
||||
var header = require("gulp-header");
|
||||
var gulpif = require("gulp-if");
|
||||
var sourcemaps = require("gulp-sourcemaps");
|
||||
var uglify = require("gulp-uglify");
|
||||
|
||||
var buffer = require("vinyl-buffer");
|
||||
var vinylfs = require("vinyl-fs");
|
||||
var source = require("vinyl-source-stream");
|
||||
|
||||
var pkg = require(path.join(__dirname, "..", "package.json"));
|
||||
|
||||
/*eslint-disable no-template-curly-in-string*/
|
||||
var license = [
|
||||
"/*!",
|
||||
" * protobuf.js v${version} (c) 2016, daniel wirtz",
|
||||
" * compiled ${date}",
|
||||
" * licensed under the bsd-3-clause license",
|
||||
" * see: https://github.com/dcodeio/protobuf.js for details",
|
||||
" */"
|
||||
].join("\n") + "\n";
|
||||
/*eslint-enable no-template-curly-in-string*/
|
||||
|
||||
var prelude = fs.readFileSync(require.resolve("../lib/prelude.js")).toString("utf8");
|
||||
|
||||
/**
|
||||
* Bundles the library.
|
||||
* @param {Object} options Bundler options
|
||||
* @param {string} options.entry Entry file
|
||||
* @param {string} options.target Target directory
|
||||
* @param {boolean} [options.compress=false] Whether to minify or not
|
||||
* @param {string[]} [options.exclude] Excluded source files
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function bundle(options) {
|
||||
if (!options || !options.entry || !options.target)
|
||||
throw TypeError("missing options");
|
||||
var bundler = browserify({
|
||||
entries: options.entry,
|
||||
insertGlobalVars: false,
|
||||
detectGlobals: false,
|
||||
debug: true,
|
||||
prelude: prelude,
|
||||
preludePath: "./lib/prelude.js"
|
||||
})
|
||||
.external("long");
|
||||
if (options.exclude)
|
||||
options.exclude.forEach(bundler.exclude, bundler);
|
||||
return bundler
|
||||
.plugin(require("browserify-wrap"), {
|
||||
// undefined var and global strict-mode for uglify
|
||||
prefix: "(function(undefined){\"use strict\";",
|
||||
suffix: "})();"
|
||||
})
|
||||
.plugin(require("bundle-collapser/plugin"))
|
||||
.bundle()
|
||||
.pipe(source(options.compress ? "protobuf.min.js" : "protobuf.js"))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(
|
||||
gulpif(options.compress, uglify({
|
||||
mangle: {
|
||||
eval: true,
|
||||
properties: {
|
||||
regex: /^_/
|
||||
}
|
||||
},
|
||||
compress: {
|
||||
keep_fargs: false,
|
||||
unsafe: true
|
||||
},
|
||||
output: {
|
||||
max_line_len: 0x7fffffff
|
||||
}
|
||||
}))
|
||||
)
|
||||
.pipe(header(license, {
|
||||
date: (new Date()).toUTCString().replace("GMT", "UTC").toLowerCase(),
|
||||
version: pkg.version
|
||||
}))
|
||||
.pipe(sourcemaps.write(".", { sourceRoot: "" }))
|
||||
.pipe(vinylfs.dest(options.target))
|
||||
.on("log", console.log)
|
||||
.on("error", console.error);
|
||||
}
|
||||
Executable
+150
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
var gitSemverTags = require("git-semver-tags"),
|
||||
gitRawCommits = require("git-raw-commits"),
|
||||
minimist = require("minimist");
|
||||
|
||||
var basedir = path.join(__dirname, "..");
|
||||
var pkg = require(basedir + "/package.json");
|
||||
|
||||
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|correctly/i,
|
||||
"New": /added|initial/i,
|
||||
"CLI": /pbjs|pbts|CLI/,
|
||||
"Docs": /README/i,
|
||||
"Other": null
|
||||
};
|
||||
var breakingFallback = /removed|stripped|dropped/i;
|
||||
|
||||
var repo = "https://github.com/dcodeIO/protobuf.js";
|
||||
|
||||
gitSemverTags(function(err, tags) {
|
||||
if (err)
|
||||
throw err;
|
||||
|
||||
var categories = {};
|
||||
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: from,
|
||||
to: to,
|
||||
merges: false,
|
||||
format: "%B%n#%H"
|
||||
});
|
||||
|
||||
commits.on("error", function(err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
commits.on("data", function(chunk) {
|
||||
var message = chunk.toString("utf8").trim();
|
||||
var match = /#([0-9a-f]{40})$/.exec(message);
|
||||
var hash;
|
||||
if (match) {
|
||||
message = message.substring(0, message.length - match[1].length).trim();
|
||||
hash = match[1];
|
||||
}
|
||||
message.split(";").forEach(function(message) {
|
||||
if (/^(Merge pull request |Post-merge)/.test(message))
|
||||
return;
|
||||
var match = /^(\w+):/i.exec(message = message.trim());
|
||||
var category;
|
||||
if (match && match[1] in validCategories) {
|
||||
category = match[1];
|
||||
message = message.substring(match[1].length + 1).trim();
|
||||
} else {
|
||||
var keys = Object.keys(validCategories);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var re = validCategories[keys[i]];
|
||||
if (re && re.test(message)) {
|
||||
category = keys[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
message = message.replace(/^(\w+):/i, "").trim();
|
||||
}
|
||||
if (!category) {
|
||||
if (breakingFallback.test(message))
|
||||
category = "Breaking";
|
||||
else
|
||||
category = "Other";
|
||||
}
|
||||
var nl = message.indexOf("\n");
|
||||
if (nl > -1)
|
||||
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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
commits.on("end", function() {
|
||||
output.push("# [" + tag + "](" + repo + "/releases/tag/" + tag + ")\n");
|
||||
Object.keys(categories).forEach(function(category) {
|
||||
var messages = categories[category];
|
||||
if (!messages.length)
|
||||
return;
|
||||
output.push("\n## " + category + "\n");
|
||||
messages.forEach(function(message) {
|
||||
var text = message.text.replace(/#(\d+)/g, "[#$1](" + repo + "/issues/$1)");
|
||||
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);
|
||||
});
|
||||
});
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var pbjs = require("../cli/pbjs");
|
||||
|
||||
[
|
||||
"google/protobuf/api.proto",
|
||||
"google/protobuf/descriptor.proto",
|
||||
"google/protobuf/source_context.proto",
|
||||
"google/protobuf/type.proto",
|
||||
|
||||
"google/api/annotations.proto",
|
||||
"google/api/http.proto"
|
||||
]
|
||||
.forEach(function(file) {
|
||||
var out = file.replace(/\.proto$/, ".json");
|
||||
pbjs.main([
|
||||
"--target", "json",
|
||||
"--sparse",
|
||||
"--out", out,
|
||||
file
|
||||
], function(err) {
|
||||
if (err)
|
||||
throw err;
|
||||
process.stdout.write("pbjs: " + file + " -> " + out + "\n");
|
||||
});
|
||||
});
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
pbjs = require("../cli/pbjs"),
|
||||
pbts = require("../cli/pbts");
|
||||
|
||||
[
|
||||
{ file: "tests/data/comments.proto", flags: [] },
|
||||
{ file: "tests/data/convert.proto", flags: [] },
|
||||
{ file: "tests/data/mapbox/vector_tile.proto", flags: [] },
|
||||
{ file: "tests/data/package.proto", flags: [] },
|
||||
{ file: "tests/data/rpc.proto", flags: [ "es6" ] },
|
||||
{ file: "tests/data/rpc.proto", flags: [] },
|
||||
{ file: "tests/data/rpc-reserved.proto", flags: [] },
|
||||
{ file: "tests/data/test.proto", flags: [] },
|
||||
{ file: "bench/data/bench.proto", flags: ["no-create", "no-verify", "no-delimited", "no-convert", "no-comments"], out: "bench/data/static_pbjs.js" }
|
||||
]
|
||||
.forEach(function({ file, flags, out }) {
|
||||
var basename = file.replace(/\.proto$/, "");
|
||||
if (!out)
|
||||
out = [ basename ].concat(flags).join("-") + ".js";
|
||||
pbjs.main([
|
||||
"--target", "static-module",
|
||||
"--wrap", "commonjs",
|
||||
"--root", "test_" + path.basename(basename, ".js"),
|
||||
file
|
||||
].concat(flags.map(function(flag) {
|
||||
return "--" + flag;
|
||||
})), function(err, output) {
|
||||
if (err)
|
||||
throw err;
|
||||
var pathToProtobufjs = path.relative(path.dirname(out), "minimal").replace(/\\/g, "/");
|
||||
fs.writeFileSync(out, output.replace(/"protobufjs\/minimal"/g, JSON.stringify(pathToProtobufjs)));
|
||||
process.stdout.write("pbjs: " + file + " -> " + out + "\n");
|
||||
try {
|
||||
require(path.join(__dirname, "..", out));
|
||||
} catch (err) {
|
||||
if (!flags.includes("es6")) {
|
||||
process.stderr.write("ERROR: " + err.message + "\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
process.stdout.write("\n");
|
||||
|
||||
[
|
||||
{ file: "tests/data/comments.js" },
|
||||
{ file: "tests/data/convert.js" },
|
||||
{ file: "tests/data/mapbox/vector_tile.js" },
|
||||
{ file: "tests/data/package.js" },
|
||||
{ file: "tests/data/rpc.js" },
|
||||
{ file: "tests/data/rpc-es6.js" },
|
||||
{ file: "tests/data/rpc-reserved.js" },
|
||||
{ file: "tests/data/test.js" },
|
||||
{ file: "ext/descriptor/index.js", ext: true }
|
||||
]
|
||||
.forEach(function({ file, ext }) {
|
||||
var out = file.replace(/\.js$/, ".d.ts"),
|
||||
args = [ "--no-comments" ];
|
||||
pbts.main(args.concat(file), function(err, output) {
|
||||
if (err)
|
||||
throw err;
|
||||
var pathToProtobufjs = path.relative(path.dirname(out), "").replace(/\\/g, "/");
|
||||
output = output.replace(/"protobufjs"/g, JSON.stringify(pathToProtobufjs));
|
||||
fs.writeFileSync(out, output);
|
||||
process.stdout.write("pbts: " + file + " -> " + out + "\n");
|
||||
});
|
||||
});
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
var gulp = require("gulp"),
|
||||
bundle = require("./bundle");
|
||||
|
||||
function defineTask(name, entry, target) {
|
||||
gulp.task(name + "-bundle", bundle.bind(this, {
|
||||
entry : entry,
|
||||
target : target
|
||||
}));
|
||||
gulp.task(name + "-minify", bundle.bind(this, {
|
||||
entry : entry,
|
||||
target : target,
|
||||
compress : true
|
||||
}));
|
||||
gulp.task(name, gulp.series(
|
||||
name + "-bundle",
|
||||
name + "-minify"
|
||||
), function(done) { done(); });
|
||||
}
|
||||
|
||||
defineTask("full" , "../src/index" , "../dist" );
|
||||
defineTask("light" , "../src/index-light" , "../dist/light" );
|
||||
defineTask("minimal", "../src/index-minimal", "../dist/minimal");
|
||||
|
||||
gulp.task("default", gulp.parallel(
|
||||
"full",
|
||||
"light",
|
||||
"minimal"
|
||||
, function(done) { done(); }));
|
||||
|
||||
/* var typedoc = require("gulp-typedoc");
|
||||
gulp.task("typedoc", function() {
|
||||
return gulp
|
||||
.src(["../index.d.ts"])
|
||||
.pipe(typedoc({
|
||||
module: "commonjs",
|
||||
target: "es5",
|
||||
mode: "file",
|
||||
theme: "default",
|
||||
includeDeclarations: true,
|
||||
excludePrivate: true,
|
||||
out: "../tsdocs",
|
||||
name: "protobuf.js"
|
||||
}))
|
||||
}); */
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
/*eslint-disable no-console*/
|
||||
"use strict";
|
||||
|
||||
var ghpages = require("gh-pages"),
|
||||
path = require("path");
|
||||
|
||||
ghpages.publish(path.join(__dirname, "..", "docs"), {
|
||||
logger: function(message) {
|
||||
console.log(message);
|
||||
}
|
||||
}, function(err) {
|
||||
if (err)
|
||||
console.error(err);
|
||||
else
|
||||
console.log("done");
|
||||
});
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs"),
|
||||
pkg = require(path.join(__dirname, "..", "package.json"));
|
||||
|
||||
// ensure that there is a node_modules folder for cli dependencies
|
||||
try { fs.mkdirSync(path.join(__dirname, "..", "cli", "node_modules")); } catch (e) {/**/}
|
||||
|
||||
// check version scheme used by dependents
|
||||
if (!pkg.versionScheme)
|
||||
return;
|
||||
|
||||
var warn = process.stderr.isTTY
|
||||
? "\x1b[30m\x1b[43mWARN\x1b[0m \x1b[35m" + path.basename(process.argv[1], ".js") + "\x1b[0m"
|
||||
: "WARN " + path.basename(process.argv[1], ".js");
|
||||
|
||||
var basePkg;
|
||||
try {
|
||||
basePkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")));
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
[
|
||||
"dependencies",
|
||||
"devDependencies",
|
||||
"optionalDependencies",
|
||||
"peerDependencies"
|
||||
]
|
||||
.forEach(function(check) {
|
||||
var version = basePkg && basePkg[check] && basePkg[check][pkg.name];
|
||||
if (typeof version === "string" && version.charAt(0) !== pkg.versionScheme)
|
||||
process.stderr.write(pkg.name + " " + warn + " " + pkg.name + "@" + version + " is configured as a dependency of " + basePkg.name + ". use " + pkg.name + "@" + pkg.versionScheme + version.substring(1) + " instead for API compatibility.\n");
|
||||
});
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
// ensure LF on bin files
|
||||
[
|
||||
path.join(__dirname, "..", "bin", "pbjs"),
|
||||
path.join(__dirname, "..", "bin", "pbts")
|
||||
]
|
||||
.forEach(function(file) {
|
||||
fs.writeFileSync(file, fs.readFileSync(file).toString("utf8").replace(/\r?\n/g, "\n"), "utf8");
|
||||
});
|
||||
Reference in New Issue
Block a user