From fdf5603f7d2850b4f035029ef6685a34cd2a9ebd Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:47:28 -0700 Subject: [PATCH] chore(scripts): update new-client/service-import-equals-with-name --- .../getServiceImportEqualsWithNameOutput.ts | 15 +++++++++++++-- .../getV3PackageImportEqualsCode.ts | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/generateNewClientTests/getServiceImportEqualsWithNameOutput.ts b/scripts/generateNewClientTests/getServiceImportEqualsWithNameOutput.ts index 87340d499..ea7a7a85b 100644 --- a/scripts/generateNewClientTests/getServiceImportEqualsWithNameOutput.ts +++ b/scripts/generateNewClientTests/getServiceImportEqualsWithNameOutput.ts @@ -1,3 +1,14 @@ -import { getServiceImportEqualsOutput } from "./getServiceImportEqualsOutput"; +import { CLIENTS_TO_TEST } from "./config"; +import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix"; +import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode"; +import { getV3PackageImportEqualsCode } from "./getV3PackageImportEqualsCode"; -export const getServiceImportEqualsWithNameOutput = getServiceImportEqualsOutput; +export const getServiceImportEqualsWithNameOutput = () => { + let content = ``; + + content += getV3PackageImportEqualsCode(CLIENTS_TO_TEST, { useLocalSuffix: true }); + content += "\n"; + content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix)); + + return content; +}; diff --git a/scripts/generateNewClientTests/getV3PackageImportEqualsCode.ts b/scripts/generateNewClientTests/getV3PackageImportEqualsCode.ts index 3ef25fd9f..e4b5cbbc8 100644 --- a/scripts/generateNewClientTests/getV3PackageImportEqualsCode.ts +++ b/scripts/generateNewClientTests/getV3PackageImportEqualsCode.ts @@ -4,9 +4,18 @@ import { CLIENT_PACKAGE_NAMES_MAP, } from "../../src/transforms/v2-to-v3/config"; import { getDefaultLocalName } from "../../src/transforms/v2-to-v3/utils"; +import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix"; -export const getV3PackageImportEqualsCode = (clientsToTest: typeof CLIENT_NAMES) => { +export interface V3PackageImportEqualsCodeOptions { + useLocalSuffix?: boolean; +} + +export const getV3PackageImportEqualsCode = ( + clientsToTest: typeof CLIENT_NAMES, + options?: V3PackageImportEqualsCodeOptions +) => { let content = ``; + const { useLocalSuffix = false } = options || {}; for (const v2ClientName of clientsToTest) { const v3ClientDefaultLocalName = getDefaultLocalName(v2ClientName); @@ -14,7 +23,8 @@ export const getV3PackageImportEqualsCode = (clientsToTest: typeof CLIENT_NAMES) content += `import ${v3ClientDefaultLocalName} = require("${v3ClientPackageName}");\n`; const v3ClientName = CLIENT_NAMES_MAP[v2ClientName]; - content += `import ${v3ClientName} = ${[v3ClientDefaultLocalName, v3ClientName].join(".")};\n`; + const importName = useLocalSuffix ? getClientNameWithLocalSuffix(v2ClientName) : v3ClientName; + content += `import ${importName} = ${[v3ClientDefaultLocalName, v3ClientName].join(".")};\n`; } return content;