diff --git a/packages/cli/package.json b/packages/cli/package.json index eea982e..70f4b5f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@grpc.ts/cli", - "version": "1.2.0", + "version": "1.2.1", "license": "MIT", "directories": { "lib": "lib" diff --git a/packages/cli/src/tasks/createContent/createImports.ts b/packages/cli/src/tasks/createContent/createImports.ts index 2910b33..86c32af 100644 --- a/packages/cli/src/tasks/createContent/createImports.ts +++ b/packages/cli/src/tasks/createContent/createImports.ts @@ -21,6 +21,10 @@ export function createImports({ messageDependentTypes, serviceDependentTypes, }: ICreateImportsParams) { + if (!hasService && !hasGrpcTimestamp && !hasService) { + return ''; + } + const corePackage = '@grpc.ts/core'; const dependentTypes = mergeObj(messageDependentTypes, serviceDependentTypes); diff --git a/packages/cli/src/tasks/createContent/index.ts b/packages/cli/src/tasks/createContent/index.ts index aeb82a3..931d298 100644 --- a/packages/cli/src/tasks/createContent/index.ts +++ b/packages/cli/src/tasks/createContent/index.ts @@ -93,7 +93,7 @@ export async function createContent( }; }); - const fileName = combine( + const fileNameWithoutExt = combine( { joinWith: '.', }, @@ -101,7 +101,15 @@ export async function createContent( filePath.lastIndexOf('/') + 1, filePath.length - '.proto'.length, ), - 'interface.ts', + 'interface', + ); + + const fileName = combine( + { + joinWith: '.', + }, + fileNameWithoutExt, + 'ts', ); cachedPackageOutputs[packageName] = fileName; @@ -112,7 +120,7 @@ export async function createContent( generatedFilenames.push({ packageName, - filename: fileName, + filename: fileNameWithoutExt, }); writeFile(interfaceFilename, await format(fileContent), { @@ -146,7 +154,7 @@ export async function createContent( `./${filename}.${hasEngine ? 'js' : 'ts'}`; result.typesVersions[`${packageName}`] = [ - `./${filename}.${hasEngine ? '.d.ts' : '.ts'}`, + `./${filename}.${hasEngine ? 'd.ts' : 'ts'}`, ]; return result; diff --git a/packages/cli/src/utils/objectUtils.ts b/packages/cli/src/utils/objectUtils.ts index ca6c5f8..299b453 100644 --- a/packages/cli/src/utils/objectUtils.ts +++ b/packages/cli/src/utils/objectUtils.ts @@ -5,8 +5,10 @@ export function mergeObj(source: any, target: any): any { if (sourceVal) { if (Array.isArray(sourceVal) && Array.isArray(value)) { source[key].push(...value); - } else { + } else if (typeof sourceVal === 'object') { Object.assign(source[key], value); + } else { + source[key] = value; } } else { source[key] = value;