-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove client import if clients are not created (#301)
- Loading branch information
Showing
7 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Remove client import if clients are not created |
2 changes: 1 addition & 1 deletion
2
src/transforms/v2-to-v3/__fixtures__/api-basic-type/global-import.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import AWS_S3, { S3 } from "@aws-sdk/client-s3"; | ||
import AWS_S3 from "@aws-sdk/client-s3"; | ||
|
||
const testTags: AWS_S3.Tag[] = [{ Key: "key", Value: "value" }]; |
2 changes: 1 addition & 1 deletion
2
src/transforms/v2-to-v3/__fixtures__/api-basic-type/service-import-deep.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import AWS_S3, { S3 } from "@aws-sdk/client-s3"; | ||
import AWS_S3 from "@aws-sdk/client-s3"; | ||
|
||
const testTags: AWS_S3.Tag[] = [{ Key: "key", Value: "value" }]; |
2 changes: 1 addition & 1 deletion
2
src/transforms/v2-to-v3/__fixtures__/api-basic-type/service-import.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import AWS_S3, { S3 } from "@aws-sdk/client-s3"; | ||
import AWS_S3 from "@aws-sdk/client-s3"; | ||
|
||
const testTags: AWS_S3.Tag[] = [{ Key: "key", Value: "value" }]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/transforms/v2-to-v3/modules/getClientTSTypeRefCount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
|
||
import { getV2ClientTSTypeRef } from "../utils"; | ||
import { V3ClientModulesOptions } from "./types"; | ||
|
||
export const getClientTSTypeRefCount = ( | ||
j: JSCodeshift, | ||
source: Collection<unknown>, | ||
{ v2ClientName, v2ClientLocalName, v2GlobalName }: V3ClientModulesOptions | ||
): number => { | ||
let clientTSTypeRefCount = 0; | ||
|
||
if (v2GlobalName) { | ||
const clienTSTypeRefFromGlobalName = source.find( | ||
j.TSTypeReference, | ||
getV2ClientTSTypeRef({ v2ClientName, v2GlobalName }) | ||
); | ||
clientTSTypeRefCount += clienTSTypeRefFromGlobalName.length; | ||
} | ||
|
||
const clienTSTypeRefFromClientLocalName = source.find( | ||
j.TSTypeReference, | ||
getV2ClientTSTypeRef({ v2ClientLocalName }) | ||
); | ||
clientTSTypeRefCount += clienTSTypeRefFromClientLocalName.length; | ||
|
||
return clientTSTypeRefCount; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters