Skip to content
Permalink
Browse files
feat: update dependencies / general cleanup (#1356)
Co-authored-by: Alexander Fenster <fenster@google.com>
  • Loading branch information
dcodeIO and alexander-fenster committed Apr 17, 2020
1 parent 0f8008c commit 42f49b43f692c24c2bc1ae081b4d1ad9fa173cd7
@@ -0,0 +1,2 @@
bin/* text eol=lf
dist/* binary
@@ -5,9 +5,34 @@ on:
- master
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: "12"
- name: "Install dependencies"
run: npm install
- name: "Lint sources"
run: npm run lint:sources -- --max-warnings 0
- name: "Lint types"
run: npm run lint:types
build:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: "12"
- name: "Install dependencies"
run: npm install
- name: "Build distribution files"
run: npm run build
test:
name: "Test"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node_version: ["4", "4.3.2", "6", "8", "10", "12"]
@@ -18,12 +43,13 @@ jobs:
node-version: ${{ matrix.node_version }}
- name: "Install dependencies"
run: npm install
- name: "Run tests"
run: npm test
- name: "Test sources"
run: npm run test:sources
- name: "Test types"
run: npm run test:types
bench:
name: "Bench"
runs-on: ubuntu-latest
needs: test
needs: build
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
@@ -1,7 +1,10 @@
.nyc_output
.vscode
*.log
npm-debug.*
node_modules/
cli/node_modules/
cli/package-lock.json
docs/
coverage/
sandbox/

This file was deleted.

@@ -24,13 +24,13 @@ $root.Test = (function() {
Test.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.string != null && message.hasOwnProperty("string"))
if (message.string != null && Object.hasOwnProperty.call(message, "string"))
writer.uint32(10).string(message.string);
if (message.uint32 != null && message.hasOwnProperty("uint32"))
if (message.uint32 != null && Object.hasOwnProperty.call(message, "uint32"))
writer.uint32(16).uint32(message.uint32);
if (message.inner != null && message.hasOwnProperty("inner"))
if (message.inner != null && Object.hasOwnProperty.call(message, "inner"))
$root.Test.Inner.encode(message.inner, writer.uint32(26).fork()).ldelim();
if (message.float != null && message.hasOwnProperty("float"))
if (message.float != null && Object.hasOwnProperty.call(message, "float"))
writer.uint32(37).float(message.float);
return writer;
};
@@ -78,11 +78,11 @@ $root.Test = (function() {
Inner.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.int32 != null && message.hasOwnProperty("int32"))
if (message.int32 != null && Object.hasOwnProperty.call(message, "int32"))
writer.uint32(8).int32(message.int32);
if (message.innerInner != null && message.hasOwnProperty("innerInner"))
if (message.innerInner != null && Object.hasOwnProperty.call(message, "innerInner"))
$root.Test.Inner.InnerInner.encode(message.innerInner, writer.uint32(18).fork()).ldelim();
if (message.outer != null && message.hasOwnProperty("outer"))
if (message.outer != null && Object.hasOwnProperty.call(message, "outer"))
$root.Outer.encode(message.outer, writer.uint32(26).fork()).ldelim();
return writer;
};
@@ -127,11 +127,11 @@ $root.Test = (function() {
InnerInner.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.long != null && message.hasOwnProperty("long"))
if (message.long != null && Object.hasOwnProperty.call(message, "long"))
writer.uint32(8).int64(message.long);
if (message["enum"] != null && message.hasOwnProperty("enum"))
if (message["enum"] != null && Object.hasOwnProperty.call(message, "enum"))
writer.uint32(16).int32(message["enum"]);
if (message.sint32 != null && message.hasOwnProperty("sint32"))
if (message.sint32 != null && Object.hasOwnProperty.call(message, "sint32"))
writer.uint32(24).sint32(message.sint32);
return writer;
};
@@ -201,7 +201,7 @@ $root.Outer = (function() {
writer.bool(message.bool[i]);
writer.ldelim();
}
if (message.double != null && message.hasOwnProperty("double"))
if (message.double != null && Object.hasOwnProperty.call(message, "double"))
writer.uint32(17).double(message.double);
return writer;
};
@@ -318,9 +318,11 @@ function begin(element, is_interface) {
seen[element.longname] = element;
} else
writeln();
if (element.scope !== "global" || options.module)
return;
write("export ");
// ????: something changed in JSDoc 3.6.0? so that @exports + @enum does
// no longer yield a 'global' scope, but is some sort of unscoped module
// element now. The additional condition added below works around this.
if ((element.scope === "global" || element.isEnum && element.scope === undefined) && !options.module)
write("export ");
}

// writes the function signature describing element
@@ -432,6 +434,11 @@ function handleElement(element, parent) {
handleClass(element, parent);
else switch (element.kind) {
case "module":
if (element.isEnum) {
handleEnum(element, parent);
break;
}
// eslint-disable-line no-fallthrough
case "namespace":
handleNamespace(element, parent);
break;
@@ -569,69 +576,74 @@ function handleClass(element, parent) {
}
}

// handles a namespace or class member
function handleMember(element, parent) {
// handles an enum
function handleEnum(element) {
begin(element);

if (element.isEnum) {
var stringEnum = false;
element.properties.forEach(function(property) {
if (isNaN(property.defaultvalue)) {
stringEnum = true;
}
});
if (stringEnum) {
writeln("type ", element.name, " =");
++indent;
element.properties.forEach(function(property, i) {
write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
});
--indent;
writeln(";");
} else {
writeln("enum ", element.name, " {");
++indent;
element.properties.forEach(function(property, i) {
write(property.name);
if (property.defaultvalue !== undefined)
write(" = ", JSON.stringify(property.defaultvalue));
if (i < element.properties.length - 1)
writeln(",");
else
writeln();
});
--indent;
writeln("}");
var stringEnum = false;
element.properties.forEach(function(property) {
if (isNaN(property.defaultvalue)) {
stringEnum = true;
}

});
if (stringEnum) {
writeln("type ", element.name, " =");
++indent;
element.properties.forEach(function(property, i) {
write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
});
--indent;
writeln(";");
} else {
writeln("enum ", element.name, " {");
++indent;
element.properties.forEach(function(property, i) {
write(property.name);
if (property.defaultvalue !== undefined)
write(" = ", JSON.stringify(property.defaultvalue));
if (i < element.properties.length - 1)
writeln(",");
else
writeln();
});
--indent;
writeln("}");
}
}

var inClass = isClassLike(parent);
if (inClass) {
write(element.access || "public", " ");
if (element.scope === "static")
write("static ");
if (element.readonly)
write("readonly ");
} else
write(element.kind === "constant" ? "const " : "let ");
// handles a namespace or class member
function handleMember(element, parent) {
if (element.isEnum) {
handleEnum(element);
return;
}
begin(element);

write(element.name);
if (element.optional)
write("?");
write(": ");
var inClass = isClassLike(parent);
if (inClass) {
write(element.access || "public", " ");
if (element.scope === "static")
write("static ");
if (element.readonly)
write("readonly ");
} else
write(element.kind === "constant" ? "const " : "let ");

if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
writeln("{");
++indent;
element.properties.forEach(function(property, i) {
writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
});
--indent;
writeln("};");
} else
writeln(getTypeOf(element), ";");
}
write(element.name);
if (element.optional)
write("?");
write(": ");

if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
writeln("{");
++indent;
element.properties.forEach(function(property, i) {
writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
});
--indent;
writeln("};");
} else
writeln(getTypeOf(element), ";");
}

// handles a function or method

This file was deleted.

@@ -1 +1 @@
{"version": "6.7.0"}
{"version": "6.9.0"}
@@ -1,7 +1,7 @@
{
"name": "protobufjs-cli",
"description": "Translates between file formats and generates static code as well as TypeScript definitions.",
"version": "6.7.0",
"version": "6.9.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
@@ -15,18 +15,18 @@
"pbts": "bin/pbts"
},
"peerDependencies": {
"protobufjs": "~6.7.0"
"protobufjs": "~6.9.0"
},
"dependencies": {
"chalk": "^1.1.3",
"escodegen": "^1.8.1",
"espree": "^3.1.3",
"estraverse": "^4.2.0",
"glob": "^7.1.1",
"jsdoc": "^3.4.2",
"chalk": "^3.0.0",
"escodegen": "^1.13.0",
"espree": "^6.1.2",
"estraverse": "^4.3.0",
"glob": "^7.1.6",
"jsdoc": "^3.6.3",
"minimist": "^1.2.0",
"semver": "^5.3.0",
"tmp": "0.0.31",
"uglify-js": "^2.8.15"
"semver": "^7.1.2",
"tmp": "^0.1.0",
"uglify-js": "^3.7.7"
}
}
}
@@ -151,10 +151,6 @@ exports.main = function(args, callback) {
"// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.",
""
);
output.push(
"import * as Long from \"long\";",
""
);
if (argv.global)
output.push(
"export as namespace " + argv.global + ";",
@@ -675,7 +675,7 @@ function buildEnum(ref, enm) {
var comment = [
enm.comment || enm.name + " enum.",
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@name " + exportName(enm),
config.forceEnumString ? "@enum {number}" : "@enum {string}",
config.forceEnumString ? "@enum {string}" : "@enum {number}",
];
Object.keys(enm.values).forEach(function(key) {
var val = config.forceEnumString ? key : enm.values[key];

This file was deleted.

Loading

0 comments on commit 42f49b4

Please sign in to comment.