From 1d4efd81d689b4487783ee115fee8524022c2b92 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 20 Oct 2023 07:37:46 -0700 Subject: [PATCH] chore: pass importType to replaceAwsCredentials --- .../v2-to-v3/apis/replaceAwsCredentials.ts | 12 +++++++++--- src/transforms/v2-to-v3/transformer.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts b/src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts index 62bfeab82..23ce6af2d 100644 --- a/src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts +++ b/src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts @@ -1,11 +1,17 @@ import { Collection, JSCodeshift } from "jscodeshift"; import { AWS_CREDENTIALS_MAP } from "../config"; +import { ImportType } from "../modules"; import { getAwsCredentialsNewExpressions } from "./getAwsCredentialsNewExpressions"; +export interface ReplaceAwsCredentialsOptions { + v2GlobalName?: string; + importType: ImportType; +} + export const replaceAwsCredentials = ( j: JSCodeshift, source: Collection, - v2GlobalName?: string + { v2GlobalName }: ReplaceAwsCredentialsOptions ) => { if (!v2GlobalName) return; @@ -17,8 +23,8 @@ export const replaceAwsCredentials = ( const credsNewExpressionCount = credsNewExpressions.size(); if (credsNewExpressionCount > 0) { - // addClientNamedModule(j, source, { - // ...options, + // ToDo: Call importType agnostic addNamedModule + // addNamedModule(j, source, { // importedName: v3ProviderName, // v3ClientPackageName: "@aws-sdk/credential-provider", // }); diff --git a/src/transforms/v2-to-v3/transformer.ts b/src/transforms/v2-to-v3/transformer.ts index 02f2dacfd..1e387b474 100644 --- a/src/transforms/v2-to-v3/transformer.ts +++ b/src/transforms/v2-to-v3/transformer.ts @@ -92,7 +92,7 @@ const transformer = async (file: FileInfo, api: API) => { replaceClientCreation(j, source, { ...v2Options, v3ClientName }); replaceDocClientCreation(j, source, v2Options); } - replaceAwsCredentials(j, source, v2GlobalName); + replaceAwsCredentials(j, source, { v2GlobalName, importType }); replaceAwsUtilFunctions(j, source, v2GlobalName); removeGlobalModule(j, source, { v2GlobalName, importType });