Comparing version 1.0.4 to 1.0.5
@@ -12,3 +12,14 @@ "use strict"; | ||
function generateFile(typeMap, fileDesc) { | ||
const moduleName = fileDesc.name.replace('.proto', '.ts').replace(/\//g, '_'); | ||
// Google's protofiles are organized like Java, where package == the folder the file | ||
// is in, and file == a specific service within the package. I.e. you can have multiple | ||
// company/foo.proto and company/bar.proto files, where package would be 'company'. | ||
// | ||
// We'll match that stucture by setting up the module path as: | ||
// | ||
// company/foo.proto --> company/foo.ts | ||
// company/bar.proto --> company/bar.ts | ||
// | ||
// We'll also assume that the fileDesc.name is already the `company/foo.proto` path, with | ||
// the package already implicitly in it, so we won't re-append/strip/etc. it out/back in. | ||
const moduleName = fileDesc.name.replace('\.proto', '.ts'); | ||
let file = ts_poet_1.FileSpec.create(moduleName); | ||
@@ -183,3 +194,3 @@ // first make all the type declarations | ||
.addParameter('message', fullName) | ||
.addParameter('writer', 'Writer@protobufjs/minimal', { defaultValueField: ts_poet_1.CodeBlock.of('new Writer()') }) | ||
.addParameter('writer', 'Writer@protobufjs/minimal', { defaultValueField: ts_poet_1.CodeBlock.of('Writer.create()') }) | ||
.returns('Writer@protobufjs/minimal'); | ||
@@ -186,0 +197,0 @@ // then add a case for each field |
@@ -186,3 +186,5 @@ "use strict"; | ||
for (const file of request.protoFile) { | ||
const moduleName = file.name.replace('.proto', '').replace(/\//g, '_'); | ||
// We assume a file.name of google/protobuf/wrappers.proto --> a module path of google/protobuf/wrapper.ts | ||
const moduleName = file.name.replace('.proto', ''); | ||
// So given a fullName like FooMessage_InnerMessage, proto will see that as package.name.FooMessage.InnerMessage | ||
function saveMapping(fullName) { | ||
@@ -189,0 +191,0 @@ typeMap.set(file.package + '.' + fullName.replace(/_/g, '.'), [moduleName, fullName]); |
{ | ||
"name": "ts-proto", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/plugin.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
781545
11292