diff --git a/src/transforms/v2-to-v3/modules/getImportEqualsLocalNameSuffix.ts b/src/transforms/v2-to-v3/modules/getImportEqualsLocalNameSuffix.ts deleted file mode 100644 index e06ad4138..000000000 --- a/src/transforms/v2-to-v3/modules/getImportEqualsLocalNameSuffix.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const getImportEqualsLocalNameSuffix = ( - v2ClientName: string, - v3ClientPackageName: string -) => - v3ClientPackageName.startsWith("@aws-sdk/client-") - ? v2ClientName - : v3ClientPackageName.substring(9).replace(/-/g, "_"); diff --git a/src/transforms/v2-to-v3/modules/importEqualsModule/addClientDefaultModule.ts b/src/transforms/v2-to-v3/modules/importEqualsModule/addClientDefaultModule.ts index 75b861e68..7bd5e9d0e 100644 --- a/src/transforms/v2-to-v3/modules/importEqualsModule/addClientDefaultModule.ts +++ b/src/transforms/v2-to-v3/modules/importEqualsModule/addClientDefaultModule.ts @@ -1,10 +1,9 @@ import { Collection, JSCodeshift } from "jscodeshift"; -import { getDefaultLocalName } from "../../utils"; import { getImportEqualsDeclaration } from "../getImportEqualsDeclaration"; import { getImportEqualsDeclarationType } from "../getImportEqualsDeclarationType"; -import { getImportEqualsLocalNameSuffix } from "../getImportEqualsLocalNameSuffix"; import { ClientModulesOptions } from "../types"; +import { getImportEqualsDefaultName } from "./getImportEqualsDefaultName"; export type ClientDefaultModuleOptions = Omit; @@ -13,8 +12,7 @@ export const addClientDefaultModule = ( source: Collection, { v2ClientLocalName, v2ClientName, v2GlobalName, v3ClientPackageName }: ClientDefaultModuleOptions ) => { - const localNameSuffix = getImportEqualsLocalNameSuffix(v2ClientName, v3ClientPackageName); - const defaultLocalName = getDefaultLocalName(localNameSuffix); + const defaultLocalName = getImportEqualsDefaultName(v3ClientPackageName); const existingImportEquals = source.find( j.TSImportEqualsDeclaration, getImportEqualsDeclarationType(v3ClientPackageName) diff --git a/src/transforms/v2-to-v3/modules/importEqualsModule/addClientNamedModule.ts b/src/transforms/v2-to-v3/modules/importEqualsModule/addClientNamedModule.ts index 38de8793f..2c3443856 100644 --- a/src/transforms/v2-to-v3/modules/importEqualsModule/addClientNamedModule.ts +++ b/src/transforms/v2-to-v3/modules/importEqualsModule/addClientNamedModule.ts @@ -1,10 +1,9 @@ import { Collection, JSCodeshift } from "jscodeshift"; -import { getDefaultLocalName } from "../../utils"; import { getImportEqualsDeclarationType } from "../getImportEqualsDeclarationType"; -import { getImportEqualsLocalNameSuffix } from "../getImportEqualsLocalNameSuffix"; import { ClientModulesOptions, ImportSpecifierOptions } from "../types"; import { addClientDefaultModule } from "./addClientDefaultModule"; +import { getImportEqualsDefaultName } from "./getImportEqualsDefaultName"; export const addClientNamedModule = ( j: JSCodeshift, @@ -12,10 +11,9 @@ export const addClientNamedModule = ( options: ClientModulesOptions & ImportSpecifierOptions ) => { const { importedName, localName = importedName, ...v3ClientModulesOptions } = options; - const { v2ClientName, v3ClientPackageName } = v3ClientModulesOptions; + const { v3ClientPackageName } = v3ClientModulesOptions; - const localNameSuffix = getImportEqualsLocalNameSuffix(v2ClientName, v3ClientPackageName); - const defaultLocalName = getDefaultLocalName(localNameSuffix); + const defaultLocalName = getImportEqualsDefaultName(v3ClientPackageName); const existingDeclaration = source.find(j.TSImportEqualsDeclaration, { type: "TSImportEqualsDeclaration", diff --git a/src/transforms/v2-to-v3/modules/importEqualsModule/getImportEqualsDefaultName.ts b/src/transforms/v2-to-v3/modules/importEqualsModule/getImportEqualsDefaultName.ts new file mode 100644 index 000000000..127c8390f --- /dev/null +++ b/src/transforms/v2-to-v3/modules/importEqualsModule/getImportEqualsDefaultName.ts @@ -0,0 +1,2 @@ +export const getImportEqualsDefaultName = (packageName: string) => + ["AWS", ...packageName.split("/").pop()!.split("-")].join("_"); diff --git a/src/transforms/v2-to-v3/modules/index.ts b/src/transforms/v2-to-v3/modules/index.ts index 85b778f4c..70efb0f99 100644 --- a/src/transforms/v2-to-v3/modules/index.ts +++ b/src/transforms/v2-to-v3/modules/index.ts @@ -1,7 +1,6 @@ export * from "./addClientModules"; export * from "./getGlobalNameFromModule"; export * from "./getImportEqualsDeclarationType"; -export * from "./getImportEqualsLocalNameSuffix"; export * from "./getImportSpecifiers"; export * from "./getImportType"; export * from "./getRequireDeclaratorsWithProperty"; diff --git a/src/transforms/v2-to-v3/utils/getDefaultLocalName.ts b/src/transforms/v2-to-v3/utils/getDefaultLocalName.ts deleted file mode 100644 index 3d6adf8ed..000000000 --- a/src/transforms/v2-to-v3/utils/getDefaultLocalName.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const getDefaultLocalName = (localNameSuffix: string) => - `AWS_${localNameSuffix.replace(".", "")}`; diff --git a/src/transforms/v2-to-v3/utils/index.ts b/src/transforms/v2-to-v3/utils/index.ts index 6bffdbe5f..82f30cdc3 100644 --- a/src/transforms/v2-to-v3/utils/index.ts +++ b/src/transforms/v2-to-v3/utils/index.ts @@ -1,4 +1,3 @@ export * from "./getClientDeepImportPath"; export * from "./getClientNewExpression"; -export * from "./getDefaultLocalName"; export * from "./isTypeScriptFile";