Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-code-gen

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-code-gen - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

92

build/base.js

@@ -235,48 +235,2 @@ "use strict";

const moduleSuffix = typescript ? 'ts' : 'js';
const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir);
if (typescript) {
yield fs.writeFile(grpcObjPath, [
fileTip,
`import * as grpc from '@grpc/grpc-js';`,
`import { Metadata } from '@grpc/grpc-js/build/src/metadata';`,
`import * as fs from 'fs';`,
`import { forOwn } from 'lodash';`,
`import { loadFromJson } from 'load-proto';\n`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`let config;`,
`if (fs.existsSync(require.resolve('${getImportPath(grpcObjPath, configFilePath)}'))) {`,
` config = require('${getImportPath(grpcObjPath, configFilePath)}');`,
`}`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(`,
` root,`,
` (config && config.loaderOptions) || { defaults: true },`,
`));\n`,
`// fix: grpc-message header split by comma
Metadata.prototype.getMap = function() {
const result: any = {};
forOwn((this as any).internalRepr, (values, key) => {
if (values.length > 0) {
// const v = values[0];
result[key] = values.map((v: any) => {
return v instanceof Buffer ? v.slice() : v;
}).join(',')
}
});
return result;
}
`,
`export default grpcObject;`,
].join('\n'));
}
else {
yield fs.writeFile(grpcObjPath, [
fileTip,
`const grpc = require('@grpc/grpc-js');`,
`const { loadFromJson } = require('load-proto');`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(root));`,
`module.exports = grpcObject;`,
`module.exports.default = grpcObject;`,
].join('\n'));
}
const result = pbjs_1.inspectNamespace(root);

@@ -313,2 +267,48 @@ if (!result) {

if (serviceCode) {
const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir);
if (typescript) {
yield fs.writeFile(grpcObjPath, [
fileTip,
`import * as grpc from '@grpc/grpc-js';`,
`import { Metadata } from '@grpc/grpc-js/build/src/metadata';`,
`import * as fs from 'fs';`,
`import { forOwn } from 'lodash';`,
`import { loadFromJson } from 'load-proto';\n`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`let config;`,
`if (fs.existsSync(require.resolve('${getImportPath(grpcObjPath, configFilePath)}'))) {`,
` config = require('${getImportPath(grpcObjPath, configFilePath)}');`,
`}`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(`,
` root,`,
` (config && config.loaderOptions) || { defaults: true },`,
`));\n`,
`// fix: grpc-message header split by comma
Metadata.prototype.getMap = function() {
const result: any = {};
forOwn((this as any).internalRepr, (values, key) => {
if (values.length > 0) {
// const v = values[0];
result[key] = values.map((v: any) => {
return v instanceof Buffer ? v.slice() : v;
}).join(',')
}
});
return result;
}
`,
`export default grpcObject;`,
].join('\n'));
}
else {
yield fs.writeFile(grpcObjPath, [
fileTip,
`const grpc = require('@grpc/grpc-js');`,
`const { loadFromJson } = require('load-proto');`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(root));`,
`module.exports = grpcObject;`,
`module.exports.default = grpcObject;`,
].join('\n'));
}
const typesPath = getAbsPath('types.ts', baseDir);

@@ -315,0 +315,0 @@ yield fs.writeFile(typesPath, fileTip + '\n'

{
"name": "grpc-code-gen",
"version": "3.3.0",
"version": "3.3.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "https://github.com/yunkeCN/grpc-code-gen.git",

@@ -289,48 +289,2 @@ import * as fs from 'fs-extra';

const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir);
if (typescript) {
await fs.writeFile(grpcObjPath, [
fileTip,
`import * as grpc from '@grpc/grpc-js';`,
`import { Metadata } from '@grpc/grpc-js/build/src/metadata';`,
`import * as fs from 'fs';`,
`import { forOwn } from 'lodash';`,
`import { loadFromJson } from 'load-proto';\n`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`let config;`,
`if (fs.existsSync(require.resolve('${getImportPath(grpcObjPath, configFilePath)}'))) {`,
` config = require('${getImportPath(grpcObjPath, configFilePath)}');`,
`}`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(`,
` root,`,
` (config && config.loaderOptions) || { defaults: true },`,
`));\n`,
`// fix: grpc-message header split by comma
Metadata.prototype.getMap = function() {
const result: any = {};
forOwn((this as any).internalRepr, (values, key) => {
if (values.length > 0) {
// const v = values[0];
result[key] = values.map((v: any) => {
return v instanceof Buffer ? v.slice() : v;
}).join(',')
}
});
return result;
}
`,
`export default grpcObject;`,
].join('\n'));
} else {
await fs.writeFile(grpcObjPath, [
fileTip,
`const grpc = require('@grpc/grpc-js');`,
`const { loadFromJson } = require('load-proto');`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(root));`,
`module.exports = grpcObject;`,
`module.exports.default = grpcObject;`,
].join('\n'));
}
const result = inspectNamespace(root);

@@ -378,2 +332,48 @@

if (serviceCode) {
const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir);
if (typescript) {
await fs.writeFile(grpcObjPath, [
fileTip,
`import * as grpc from '@grpc/grpc-js';`,
`import { Metadata } from '@grpc/grpc-js/build/src/metadata';`,
`import * as fs from 'fs';`,
`import { forOwn } from 'lodash';`,
`import { loadFromJson } from 'load-proto';\n`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`let config;`,
`if (fs.existsSync(require.resolve('${getImportPath(grpcObjPath, configFilePath)}'))) {`,
` config = require('${getImportPath(grpcObjPath, configFilePath)}');`,
`}`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(`,
` root,`,
` (config && config.loaderOptions) || { defaults: true },`,
`));\n`,
`// fix: grpc-message header split by comma
Metadata.prototype.getMap = function() {
const result: any = {};
forOwn((this as any).internalRepr, (values, key) => {
if (values.length > 0) {
// const v = values[0];
result[key] = values.map((v: any) => {
return v instanceof Buffer ? v.slice() : v;
}).join(',')
}
});
return result;
}
`,
`export default grpcObject;`,
].join('\n'));
} else {
await fs.writeFile(grpcObjPath, [
fileTip,
`const grpc = require('@grpc/grpc-js');`,
`const { loadFromJson } = require('load-proto');`,
`const root = require('${getImportPath(grpcObjPath, jsonPath)}');\n`,
`const grpcObject = grpc.loadPackageDefinition(loadFromJson(root));`,
`module.exports = grpcObject;`,
`module.exports.default = grpcObject;`,
].join('\n'));
}
const typesPath = getAbsPath('types.ts', baseDir);

@@ -380,0 +380,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc