Skip to content

Commit 42f49b4

Browse files
feat: update dependencies / general cleanup (#1356)
Co-authored-by: Alexander Fenster <[email protected]>
1 parent 0f8008c commit 42f49b4

40 files changed

+19050
-18571
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/* text eol=lf
2+
dist/* binary

.github/workflows/test.yml

+31-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,34 @@ on:
55
- master
66
pull_request:
77
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: "12"
15+
- name: "Install dependencies"
16+
run: npm install
17+
- name: "Lint sources"
18+
run: npm run lint:sources -- --max-warnings 0
19+
- name: "Lint types"
20+
run: npm run lint:types
21+
build:
22+
runs-on: ubuntu-latest
23+
needs: lint
24+
steps:
25+
- uses: actions/checkout@v1
26+
- uses: actions/setup-node@v1
27+
with:
28+
node-version: "12"
29+
- name: "Install dependencies"
30+
run: npm install
31+
- name: "Build distribution files"
32+
run: npm run build
833
test:
9-
name: "Test"
1034
runs-on: ubuntu-latest
35+
needs: build
1136
strategy:
1237
matrix:
1338
node_version: ["4", "4.3.2", "6", "8", "10", "12"]
@@ -18,12 +43,13 @@ jobs:
1843
node-version: ${{ matrix.node_version }}
1944
- name: "Install dependencies"
2045
run: npm install
21-
- name: "Run tests"
22-
run: npm test
46+
- name: "Test sources"
47+
run: npm run test:sources
48+
- name: "Test types"
49+
run: npm run test:types
2350
bench:
24-
name: "Bench"
2551
runs-on: ubuntu-latest
26-
needs: test
52+
needs: build
2753
steps:
2854
- uses: actions/checkout@v1
2955
- uses: actions/setup-node@v1

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
.nyc_output
2+
.vscode
13
*.log
24
npm-debug.*
35
node_modules/
46
cli/node_modules/
7+
cli/package-lock.json
58
docs/
69
coverage/
710
sandbox/

.vscode/settings.json

-4
This file was deleted.

bench/data/static_pbjs.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ $root.Test = (function() {
2424
Test.encode = function encode(message, writer) {
2525
if (!writer)
2626
writer = $Writer.create();
27-
if (message.string != null && message.hasOwnProperty("string"))
27+
if (message.string != null && Object.hasOwnProperty.call(message, "string"))
2828
writer.uint32(10).string(message.string);
29-
if (message.uint32 != null && message.hasOwnProperty("uint32"))
29+
if (message.uint32 != null && Object.hasOwnProperty.call(message, "uint32"))
3030
writer.uint32(16).uint32(message.uint32);
31-
if (message.inner != null && message.hasOwnProperty("inner"))
31+
if (message.inner != null && Object.hasOwnProperty.call(message, "inner"))
3232
$root.Test.Inner.encode(message.inner, writer.uint32(26).fork()).ldelim();
33-
if (message.float != null && message.hasOwnProperty("float"))
33+
if (message.float != null && Object.hasOwnProperty.call(message, "float"))
3434
writer.uint32(37).float(message.float);
3535
return writer;
3636
};
@@ -78,11 +78,11 @@ $root.Test = (function() {
7878
Inner.encode = function encode(message, writer) {
7979
if (!writer)
8080
writer = $Writer.create();
81-
if (message.int32 != null && message.hasOwnProperty("int32"))
81+
if (message.int32 != null && Object.hasOwnProperty.call(message, "int32"))
8282
writer.uint32(8).int32(message.int32);
83-
if (message.innerInner != null && message.hasOwnProperty("innerInner"))
83+
if (message.innerInner != null && Object.hasOwnProperty.call(message, "innerInner"))
8484
$root.Test.Inner.InnerInner.encode(message.innerInner, writer.uint32(18).fork()).ldelim();
85-
if (message.outer != null && message.hasOwnProperty("outer"))
85+
if (message.outer != null && Object.hasOwnProperty.call(message, "outer"))
8686
$root.Outer.encode(message.outer, writer.uint32(26).fork()).ldelim();
8787
return writer;
8888
};
@@ -127,11 +127,11 @@ $root.Test = (function() {
127127
InnerInner.encode = function encode(message, writer) {
128128
if (!writer)
129129
writer = $Writer.create();
130-
if (message.long != null && message.hasOwnProperty("long"))
130+
if (message.long != null && Object.hasOwnProperty.call(message, "long"))
131131
writer.uint32(8).int64(message.long);
132-
if (message["enum"] != null && message.hasOwnProperty("enum"))
132+
if (message["enum"] != null && Object.hasOwnProperty.call(message, "enum"))
133133
writer.uint32(16).int32(message["enum"]);
134-
if (message.sint32 != null && message.hasOwnProperty("sint32"))
134+
if (message.sint32 != null && Object.hasOwnProperty.call(message, "sint32"))
135135
writer.uint32(24).sint32(message.sint32);
136136
return writer;
137137
};
@@ -201,7 +201,7 @@ $root.Outer = (function() {
201201
writer.bool(message.bool[i]);
202202
writer.ldelim();
203203
}
204-
if (message.double != null && message.hasOwnProperty("double"))
204+
if (message.double != null && Object.hasOwnProperty.call(message, "double"))
205205
writer.uint32(17).double(message.double);
206206
return writer;
207207
};

cli/lib/tsd-jsdoc/publish.js

+71-59
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ function begin(element, is_interface) {
318318
seen[element.longname] = element;
319319
} else
320320
writeln();
321-
if (element.scope !== "global" || options.module)
322-
return;
323-
write("export ");
321+
// ????: something changed in JSDoc 3.6.0? so that @exports + @enum does
322+
// no longer yield a 'global' scope, but is some sort of unscoped module
323+
// element now. The additional condition added below works around this.
324+
if ((element.scope === "global" || element.isEnum && element.scope === undefined) && !options.module)
325+
write("export ");
324326
}
325327

326328
// writes the function signature describing element
@@ -432,6 +434,11 @@ function handleElement(element, parent) {
432434
handleClass(element, parent);
433435
else switch (element.kind) {
434436
case "module":
437+
if (element.isEnum) {
438+
handleEnum(element, parent);
439+
break;
440+
}
441+
// eslint-disable-line no-fallthrough
435442
case "namespace":
436443
handleNamespace(element, parent);
437444
break;
@@ -569,69 +576,74 @@ function handleClass(element, parent) {
569576
}
570577
}
571578

572-
// handles a namespace or class member
573-
function handleMember(element, parent) {
579+
// handles an enum
580+
function handleEnum(element) {
574581
begin(element);
575582

576-
if (element.isEnum) {
577-
var stringEnum = false;
578-
element.properties.forEach(function(property) {
579-
if (isNaN(property.defaultvalue)) {
580-
stringEnum = true;
581-
}
582-
});
583-
if (stringEnum) {
584-
writeln("type ", element.name, " =");
585-
++indent;
586-
element.properties.forEach(function(property, i) {
587-
write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
588-
});
589-
--indent;
590-
writeln(";");
591-
} else {
592-
writeln("enum ", element.name, " {");
593-
++indent;
594-
element.properties.forEach(function(property, i) {
595-
write(property.name);
596-
if (property.defaultvalue !== undefined)
597-
write(" = ", JSON.stringify(property.defaultvalue));
598-
if (i < element.properties.length - 1)
599-
writeln(",");
600-
else
601-
writeln();
602-
});
603-
--indent;
604-
writeln("}");
583+
var stringEnum = false;
584+
element.properties.forEach(function(property) {
585+
if (isNaN(property.defaultvalue)) {
586+
stringEnum = true;
605587
}
606-
588+
});
589+
if (stringEnum) {
590+
writeln("type ", element.name, " =");
591+
++indent;
592+
element.properties.forEach(function(property, i) {
593+
write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
594+
});
595+
--indent;
596+
writeln(";");
607597
} else {
598+
writeln("enum ", element.name, " {");
599+
++indent;
600+
element.properties.forEach(function(property, i) {
601+
write(property.name);
602+
if (property.defaultvalue !== undefined)
603+
write(" = ", JSON.stringify(property.defaultvalue));
604+
if (i < element.properties.length - 1)
605+
writeln(",");
606+
else
607+
writeln();
608+
});
609+
--indent;
610+
writeln("}");
611+
}
612+
}
608613

609-
var inClass = isClassLike(parent);
610-
if (inClass) {
611-
write(element.access || "public", " ");
612-
if (element.scope === "static")
613-
write("static ");
614-
if (element.readonly)
615-
write("readonly ");
616-
} else
617-
write(element.kind === "constant" ? "const " : "let ");
614+
// handles a namespace or class member
615+
function handleMember(element, parent) {
616+
if (element.isEnum) {
617+
handleEnum(element);
618+
return;
619+
}
620+
begin(element);
618621

619-
write(element.name);
620-
if (element.optional)
621-
write("?");
622-
write(": ");
622+
var inClass = isClassLike(parent);
623+
if (inClass) {
624+
write(element.access || "public", " ");
625+
if (element.scope === "static")
626+
write("static ");
627+
if (element.readonly)
628+
write("readonly ");
629+
} else
630+
write(element.kind === "constant" ? "const " : "let ");
623631

624-
if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
625-
writeln("{");
626-
++indent;
627-
element.properties.forEach(function(property, i) {
628-
writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
629-
});
630-
--indent;
631-
writeln("};");
632-
} else
633-
writeln(getTypeOf(element), ";");
634-
}
632+
write(element.name);
633+
if (element.optional)
634+
write("?");
635+
write(": ");
636+
637+
if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
638+
writeln("{");
639+
++indent;
640+
element.properties.forEach(function(property, i) {
641+
writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
642+
});
643+
--indent;
644+
writeln("};");
645+
} else
646+
writeln(getTypeOf(element), ";");
635647
}
636648

637649
// handles a function or method

cli/package-lock.json

-20
This file was deleted.

cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version": "6.7.0"}
1+
{"version": "6.9.0"}

cli/package.standalone.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "protobufjs-cli",
33
"description": "Translates between file formats and generates static code as well as TypeScript definitions.",
4-
"version": "6.7.0",
4+
"version": "6.9.0",
55
"author": "Daniel Wirtz <[email protected]>",
66
"repository": {
77
"type": "git",
@@ -15,18 +15,18 @@
1515
"pbts": "bin/pbts"
1616
},
1717
"peerDependencies": {
18-
"protobufjs": "~6.7.0"
18+
"protobufjs": "~6.9.0"
1919
},
2020
"dependencies": {
21-
"chalk": "^1.1.3",
22-
"escodegen": "^1.8.1",
23-
"espree": "^3.1.3",
24-
"estraverse": "^4.2.0",
25-
"glob": "^7.1.1",
26-
"jsdoc": "^3.4.2",
21+
"chalk": "^3.0.0",
22+
"escodegen": "^1.13.0",
23+
"espree": "^6.1.2",
24+
"estraverse": "^4.3.0",
25+
"glob": "^7.1.6",
26+
"jsdoc": "^3.6.3",
2727
"minimist": "^1.2.0",
28-
"semver": "^5.3.0",
29-
"tmp": "0.0.31",
30-
"uglify-js": "^2.8.15"
28+
"semver": "^7.1.2",
29+
"tmp": "^0.1.0",
30+
"uglify-js": "^3.7.7"
3131
}
32-
}
32+
}

cli/pbts.js

-4
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ exports.main = function(args, callback) {
151151
"// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.",
152152
""
153153
);
154-
output.push(
155-
"import * as Long from \"long\";",
156-
""
157-
);
158154
if (argv.global)
159155
output.push(
160156
"export as namespace " + argv.global + ";",

cli/targets/static.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ function buildEnum(ref, enm) {
675675
var comment = [
676676
enm.comment || enm.name + " enum.",
677677
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@name " + exportName(enm),
678-
config.forceEnumString ? "@enum {number}" : "@enum {string}",
678+
config.forceEnumString ? "@enum {string}" : "@enum {number}",
679679
];
680680
Object.keys(enm.values).forEach(function(key) {
681681
var val = config.forceEnumString ? key : enm.values[key];

config/istanbul.json

-5
This file was deleted.

0 commit comments

Comments
 (0)