From 5d40b1d1cae8a11b265b40f9a1b74ec869efab76 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Mon, 2 Dec 2024 23:48:10 -0800 Subject: [PATCH] extra cleanup --- packages/core/src/cli/lib/init-helpers.ts | 2 +- packages/core/src/cli/lib/schema-scaffold.ts | 2 +- packages/core/src/config-engine/config-engine.ts | 2 +- packages/core/src/config-engine/type-generation.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/cli/lib/init-helpers.ts b/packages/core/src/cli/lib/init-helpers.ts index 7c7ea93d..91f7263a 100644 --- a/packages/core/src/cli/lib/init-helpers.ts +++ b/packages/core/src/cli/lib/init-helpers.ts @@ -358,7 +358,7 @@ export async function initDmnoForService(workspaceInfo: ScannedWorkspaceInfo, se let recommendedServiceName: string | undefined; if (workspaceInfo.isMonorepo) { if (service.isRoot) recommendedServiceName = 'root'; - else recommendedServiceName = service.name.replace(/^@[^/]+\//, ''); + // not passing a `recommendedServiceName` results in the scaffolded file having a comment instead explaining it will inherit from package.json } // we used to prompt the user here to pick/confirm the service name, but it was a bit confusing diff --git a/packages/core/src/cli/lib/schema-scaffold.ts b/packages/core/src/cli/lib/schema-scaffold.ts index 6d9fce46..79eb5dc0 100644 --- a/packages/core/src/cli/lib/schema-scaffold.ts +++ b/packages/core/src/cli/lib/schema-scaffold.ts @@ -169,7 +169,7 @@ export function generateDmnoConfigInitialCode(opts: { opts.isRoot && ' settings: {\n redactSensitiveLogs: true,\n interceptSensitiveLeakRequests: true,\n preventClientLeaks: true,\n },', opts.serviceName ? ` name: '${opts.serviceName}',` - : (opts.isMonorepo ? ' // no name specified - inherit from package.json' : undefined), + : (opts.isMonorepo ? ' // no `name` specified - will inherit from package.json' : undefined), !opts.isRoot && ' pick: [],', ' schema: {', ...schemaConfigAsCode.split('\n').map((line) => ` ${line}`), diff --git a/packages/core/src/config-engine/config-engine.ts b/packages/core/src/config-engine/config-engine.ts index aabd9436..b842e3a0 100644 --- a/packages/core/src/config-engine/config-engine.ts +++ b/packages/core/src/config-engine/config-engine.ts @@ -377,7 +377,7 @@ export class DmnoService { } this.serviceName = this.rawConfig.name; } else { - this.serviceName = opts.isRoot ? 'root' : this.packageName; + this.serviceName = this.packageName; } } } diff --git a/packages/core/src/config-engine/type-generation.ts b/packages/core/src/config-engine/type-generation.ts index 9f52f81d..aa5603ba 100644 --- a/packages/core/src/config-engine/type-generation.ts +++ b/packages/core/src/config-engine/type-generation.ts @@ -29,7 +29,7 @@ export async function generateServiceTypes(service: DmnoService, writeToFile = f // write global file which defines a DMNO_CONFIG global // this used in our config.mts files and in front-end apps where we inject rollup rewrites await fs.promises.writeFile(`${typeGenFolderPath}/global.d.ts`, `${AUTOGENERATED_FILE_BANNER} -import { DmnoGeneratedConfigSchema } from './schema.d'; +import type { DmnoGeneratedConfigSchema } from './schema.d.ts'; declare global { /** ${service.serviceName} config global obj */ @@ -40,7 +40,7 @@ declare global { // write global file which defines a DMNO_CONFIG global // this used in our config.mts files and in front-end apps where we inject rollup rewrites await fs.promises.writeFile(`${typeGenFolderPath}/global-public.d.ts`, `${AUTOGENERATED_FILE_BANNER} -import { DmnoGeneratedPublicConfigSchema } from './schema.d'; +import type { DmnoGeneratedPublicConfigSchema } from './schema.d.ts'; declare global { /** ${service.serviceName} config global obj - public (non-sensitive) items only */