@ngx-grpc/protoc-gen-ng
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -0,1 +1,21 @@ | ||
# [0.4.0](https://github.com/ngx-grpc/protoc-gen-ng/compare/v0.3.2...v0.4.0) (2020-01-02) | ||
### Features | ||
* add explicit type definition for injection tokens ([885bab8](https://github.com/ngx-grpc/protoc-gen-ng/commit/885bab8548ee8014313ea01c7b0b79279b4531c9)) | ||
* improve names transformations ([c2ab777](https://github.com/ngx-grpc/protoc-gen-ng/commit/c2ab777e3d898e2b490450e6629b819e15a6b542)) | ||
### Performance Improvements | ||
* move all service client config tokens to a separate file to skip loading all generated code into the initial bundle ([40de9d6](https://github.com/ngx-grpc/protoc-gen-ng/commit/40de9d6a80df276f02a6bd1a1af4eba535b01c34)) | ||
* omit passing default values to the binary writer ([15cd3e8](https://github.com/ngx-grpc/protoc-gen-ng/commit/15cd3e8a2cd7b3848ae584439effe6b623ce11e0)) | ||
### BREAKING CHANGES | ||
* all tokens are moved to a separate *.pbconf.ts file | ||
* the name transformation is more greedy, some of the class, attribute and method names can be different now | ||
## [0.3.2](https://github.com/ngx-grpc/protoc-gen-ng/compare/v0.3.1...v0.3.2) (2019-12-13) | ||
@@ -2,0 +22,0 @@ |
@@ -10,9 +10,2 @@ #!/usr/bin/env node | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -24,7 +17,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var path_1 = require("path"); | ||
var prettier = __importStar(require("prettier")); | ||
var protoc_plugin_1 = __importDefault(require("protoc-plugin")); | ||
var config_1 = require("./config"); | ||
var proto_1 = require("./input/proto"); | ||
var logger_1 = require("./logger"); | ||
var proto_1 = require("./proto/proto"); | ||
var config_file_1 = require("./output/config-file"); | ||
var printer_1 = require("./output/misc/printer"); | ||
var protobuf_file_1 = require("./output/protobuf-file"); | ||
var wkt_meta_json_1 = __importDefault(require("./wkt.meta.json")); | ||
@@ -55,12 +50,19 @@ function main() { | ||
}); | ||
return protos.map(function (proto) { | ||
var types = __spreadArrays(proto.enumTypeList, proto.messageTypeList, proto.serviceList); | ||
var generated = "// THIS IS A GENERATED FILE\n // DO NOT MODIFY IT! YOUR CHANGES WILL BE LOST\n\n/*\n To configure the services you need to provider a configuration for each of them.\n\n E.g. you can create a module where you configure all of them and then import this module into your AppModule:\n\n const grpcSettings = { host: environment.grpcHost };\n\n @NgModule({\n providers: [\n" + proto.serviceList.map(function (s) { return " { provide: " + s.getConfigInjectionTokenName() + ", useValue: grpcSettings },"; }).sort().join('\n') + "\n ],\n })\n export class GrpcConfigModule { }\n*/\n\n /* tslint:disable */\n /* eslint-disable */\n import { Inject, Injectable, InjectionToken } from '@angular/core';\n import { GrpcCallType, GrpcClient, GrpcClientSettings, GrpcHandler } from '@ngx-grpc/core';\n import { BinaryReader, BinaryWriter, ByteSource } from 'google-protobuf';\n import { AbstractClientBase, Error, GrpcWebClientBase, Metadata, Status } from 'grpc-web';\n import { Observable } from 'rxjs';\n " + proto.getImportedDependencies() + "\n\n " + types.map(function (t) { return t.toString(); }).join('\n\n') + "\n"; | ||
return { | ||
name: proto.getGeneratedFileBaseName() + '.ts', | ||
content: prettier.format(generated, { parser: 'typescript', singleQuote: true }), | ||
}; | ||
}); | ||
return protos.reduce(function (res, proto) { | ||
var basename = proto.getGeneratedFileBaseName(); | ||
var files = []; | ||
if (proto.serviceList.length) { | ||
var configPrinter = new printer_1.Printer(); | ||
var configFile = new config_file_1.ConfigFile(proto); | ||
configFile.print(configPrinter); | ||
files.push({ name: basename + 'conf.ts', content: configPrinter.finalize() }); | ||
} | ||
var pbPrinter = new printer_1.Printer(); | ||
var pbFile = new protobuf_file_1.ProtobufFile(proto); | ||
pbFile.print(pbPrinter); | ||
files.push({ name: basename + '.ts', content: pbPrinter.finalize() }); | ||
return __spreadArrays(res, files); | ||
}, []); | ||
}); | ||
} | ||
main(); |
@@ -21,2 +21,5 @@ "use strict"; | ||
function camelize(str) { | ||
if (str.toUpperCase() === str) { | ||
str = str.toLowerCase(); | ||
} | ||
return str | ||
@@ -46,1 +49,6 @@ .replace(STRING_CAMELIZE_REGEXP, function (_match, _separator, chr) { | ||
exports.pascalize = pascalize; | ||
function camelizeSafe(name) { | ||
var escaped = ['default', 'var', 'let', 'const', 'function', 'class'].includes(name) ? 'pb_' + name : name; | ||
return camelize(escaped); | ||
} | ||
exports.camelizeSafe = camelizeSafe; |
{ | ||
"name": "@ngx-grpc/protoc-gen-ng", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"author": "smnbbrv", | ||
@@ -27,4 +27,4 @@ "license": "MIT", | ||
"test:coverage": "jest --coverage", | ||
"test:generate": "rimraf ./test/out/* && protoc --plugin=protoc-gen-ng=$(pwd)/dist/main.js --ng_out=./test/out -I test/proto $(find test/proto -iname \"*.proto\")", | ||
"test:generate-grpc-web": "rimraf ./test/out-grpc-web/* && protoc -I=test/proto --js_out=import_style=commonjs:test/out-grpc-web --grpc-web_out=import_style=typescript,mode=grpcweb:test/out-grpc-web $(find test/proto -iname \"*.proto\")", | ||
"test:generate": "mkdir -p ./test/out && rimraf ./test/out/* && protoc --plugin=protoc-gen-ng=$(pwd)/dist/main.js --ng_out=./test/out -I test/proto $(find test/proto -iname \"*.proto\")", | ||
"test:generate-grpc-web": "mkdir -p ./test/out-grpc-web && rimraf ./test/out-grpc-web/* && protoc -I=test/proto --js_out=import_style=commonjs:test/out-grpc-web --grpc-web_out=import_style=typescript,mode=grpcweb:test/out-grpc-web $(find test/proto -iname \"*.proto\")", | ||
"wktgen:macosx": "mkdir -p dev-null && export WKT=$(dirname $(dirname $(greadlink -f $(which protoc))))/include && protoc --plugin=protoc-gen-wkt=$(pwd)/wktgen.js --wkt_out=./dev-null -I $WKT $(find $WKT -iname \"*.proto\")", | ||
@@ -31,0 +31,0 @@ "release": "semantic-release" |
934442
39
28144