Comparing version 1.173.0 to 1.174.0
@@ -101,3 +101,3 @@ import { ToStringOpts } from "ts-poet/build/Code"; | ||
export declare function optionsFromParameter(parameter: string | undefined): Options; | ||
export declare function getTsPoetOpts(options: Options): ToStringOpts; | ||
export declare function getTsPoetOpts(options: Options, tsProtoVersion: string, protocVersion: string, fileName?: string): ToStringOpts; | ||
export declare function addTypeToMessages(options: Options): boolean; |
@@ -248,7 +248,16 @@ "use strict"; | ||
} | ||
function getTsPoetOpts(options) { | ||
function getTsPoetOpts(options, tsProtoVersion, protocVersion, fileName) { | ||
const { importSuffix, esModuleInterop } = options; | ||
const pbjs = "protobufjs/minimal" + importSuffix; | ||
return { | ||
prefix: `/* eslint-disable */`, | ||
// Comment block at the top of every source file, since these comments require specific | ||
// syntax incompatible with ts-poet, we will hard-code the string and prepend to the | ||
// generator output. | ||
prefix: `// Code generated by protoc-gen-ts_proto. DO NOT EDIT. | ||
// versions: | ||
// protoc-gen-ts_proto ${tsProtoVersion} | ||
// protoc ${protocVersion} | ||
${fileName ? `// source: ${fileName}` : ""} | ||
/* eslint-disable */`, | ||
dprintOptions: { preferSingleLine: true, lineWidth: 120 }, | ||
@@ -255,0 +264,0 @@ forceRequireImport: esModuleInterop ? [] : ["long"], |
@@ -17,2 +17,3 @@ "use strict"; | ||
const request = ts_proto_descriptors_1.CodeGeneratorRequest.decode(stdin); | ||
const { protocVersion, tsProtoVersion } = await (0, utils_1.getVersions)(request); | ||
const options = (0, options_1.optionsFromParameter)(request.parameter); | ||
@@ -46,3 +47,3 @@ const typeMap = (0, types_1.createTypeMap)(request, options); | ||
const [path, code] = (0, main_1.generateFile)({ ...ctx, currentFile: (0, context_1.createFileContext)(file) }, file); | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options), path }); | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options, tsProtoVersion, protocVersion, file.name), path }); | ||
return { name: path, content }; | ||
@@ -55,3 +56,3 @@ })); | ||
const code = (0, generate_type_registry_1.generateTypeRegistry)(ctx); | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options), path }); | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options, tsProtoVersion, protocVersion), path }); | ||
files.push({ name: path, content }); | ||
@@ -61,3 +62,3 @@ } | ||
for (const [path, code] of (0, utils_1.generateIndexFiles)(filesToGenerate, options)) { | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options), path }); | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options, tsProtoVersion, protocVersion), path }); | ||
files.push({ name: path, content }); | ||
@@ -64,0 +65,0 @@ } |
@@ -17,3 +17,2 @@ /// <reference types="node" /> | ||
export declare function maybeAddComment(options: Pick<Options, "comments">, desc: Partial<Pick<SourceDescription, "leadingComments" | "trailingComments">>, chunks: Code[], deprecated?: boolean, prefix?: string): void; | ||
export declare function prefixDisableLinter(spec: string): string; | ||
export declare function maybePrefixPackage(fileDesc: FileDescriptorProto, rest: string): string; | ||
@@ -82,1 +81,5 @@ /** | ||
export declare function withAndMaybeCheckIsNull(options: Pick<Options, "useNullAsOptional">, typeName: string): string; | ||
export declare function getVersions(request: CodeGeneratorRequest): Promise<{ | ||
protocVersion: string; | ||
tsProtoVersion: string; | ||
}>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withAndMaybeCheckIsNull = exports.withAndMaybeCheckIsNotNull = exports.withOrMaybeCheckIsNull = exports.withOrMaybeCheckIsNotNull = exports.maybeCheckIsNull = exports.maybeCheckIsNotNull = exports.nullOrUndefined = exports.arrowFunction = exports.tryCatchBlock = exports.impProto = exports.impFile = exports.getPropertyAccessor = exports.safeAccessor = exports.getFieldName = exports.getFieldJsonName = exports.FormattedMethodDescriptor = exports.assertInstanceOf = exports.maybePrefixPackage = exports.prefixDisableLinter = exports.maybeAddComment = exports.upperFirst = exports.lowerFirst = exports.singular = exports.fail = exports.readToBuffer = exports.generateIndexFiles = exports.protoFilesToGenerate = void 0; | ||
exports.getVersions = exports.withAndMaybeCheckIsNull = exports.withAndMaybeCheckIsNotNull = exports.withOrMaybeCheckIsNull = exports.withOrMaybeCheckIsNotNull = exports.maybeCheckIsNull = exports.maybeCheckIsNotNull = exports.nullOrUndefined = exports.arrowFunction = exports.tryCatchBlock = exports.impProto = exports.impFile = exports.getPropertyAccessor = exports.safeAccessor = exports.getFieldName = exports.getFieldJsonName = exports.FormattedMethodDescriptor = exports.assertInstanceOf = exports.maybePrefixPackage = exports.maybeAddComment = exports.upperFirst = exports.lowerFirst = exports.singular = exports.fail = exports.readToBuffer = exports.generateIndexFiles = exports.protoFilesToGenerate = void 0; | ||
const path = require("path"); | ||
@@ -119,9 +119,2 @@ const ts_poet_1 = require("ts-poet"); | ||
exports.maybeAddComment = maybeAddComment; | ||
// Comment block at the top of every source file, since these comments require specific | ||
// syntax incompatible with ts-poet, we will hard-code the string and prepend to the | ||
// generator output. | ||
function prefixDisableLinter(spec) { | ||
return `/* eslint-disable */\n${spec}`; | ||
} | ||
exports.prefixDisableLinter = prefixDisableLinter; | ||
function maybePrefixPackage(fileDesc, rest) { | ||
@@ -293,1 +286,17 @@ const prefix = fileDesc.package === "" ? "" : `${fileDesc.package}.`; | ||
exports.withAndMaybeCheckIsNull = withAndMaybeCheckIsNull; | ||
async function getVersions(request) { | ||
var _a; | ||
let protocVersion = "unknown"; | ||
if (request.compilerVersion) { | ||
const { major, minor, patch } = request.compilerVersion; | ||
protocVersion = `v${major}.${minor}.${patch}`; | ||
} | ||
const path = "../package.json"; | ||
const packageJson = await Promise.resolve(`${path}`).then(s => require(s)); | ||
const tsProtoVersion = `v${(_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version) !== null && _a !== void 0 ? _a : "unknown"}`; | ||
return { | ||
protocVersion, | ||
tsProtoVersion, | ||
}; | ||
} | ||
exports.getVersions = getVersions; |
{ | ||
"name": "ts-proto", | ||
"version": "1.173.0", | ||
"version": "1.174.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/plugin.js", |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
393928
6814
1035
2