Skip to content

Commit

Permalink
chore: pass importType to replaceAwsCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Oct 20, 2023
1 parent 129501d commit 1d4efd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts
Original file line number Diff line number Diff line change
@@ -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<unknown>,
v2GlobalName?: string
{ v2GlobalName }: ReplaceAwsCredentialsOptions
) => {
if (!v2GlobalName) return;

Expand All @@ -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",
// });
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/v2-to-v3/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down

0 comments on commit 1d4efd8

Please sign in to comment.