Skip to content

Commit

Permalink
Add import for credential provider
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Oct 20, 2023
1 parent 56f6f4f commit ea7f92d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/transforms/v2-to-v3/apis/replaceAwsCredentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Collection, JSCodeshift } from "jscodeshift";
import { AWS_CREDENTIALS_MAP } from "../config";
import { ImportType } from "../modules";
import { ImportType, addNamedModule } from "../modules";
import { getAwsCredentialsNewExpressions } from "./getAwsCredentialsNewExpressions";

export interface ReplaceAwsCredentialsOptions {
Expand All @@ -11,7 +11,7 @@ export interface ReplaceAwsCredentialsOptions {
export const replaceAwsCredentials = (
j: JSCodeshift,
source: Collection<unknown>,
{ v2GlobalName }: ReplaceAwsCredentialsOptions
{ v2GlobalName, importType }: ReplaceAwsCredentialsOptions
) => {
if (!v2GlobalName) return;

Expand All @@ -23,11 +23,11 @@ export const replaceAwsCredentials = (
const credsNewExpressionCount = credsNewExpressions.size();

if (credsNewExpressionCount > 0) {
// ToDo: Call importType agnostic addNamedModule
// addNamedModule(j, source, {
// importedName: v3ProviderName,
// v3ClientPackageName: "@aws-sdk/credential-provider",
// });
addNamedModule(j, source, {
importType,
importedName: v3ProviderName,
packageName: "@aws-sdk/credential-providers",
});
credsNewExpressions.replaceWith(({ node }) =>
j.callExpression(j.identifier(v3ProviderName), node.arguments)
);
Expand Down
1 change: 1 addition & 0 deletions src/transforms/v2-to-v3/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./addClientModules";
export * from "./addNamedModule";
export * from "./getGlobalNameFromModule";
export * from "./getImportEqualsDeclarationType";
export * from "./getImportSpecifiers";
Expand Down

0 comments on commit ea7f92d

Please sign in to comment.