-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter client names received from new expressions and TS Types (#329)
- Loading branch information
Showing
6 changed files
with
26 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 | ||
--- | ||
|
||
Filter client names received from new expressions and TS Types |
5 changes: 5 additions & 0 deletions
5
src/transforms/v2-to-v3/__fixtures__/misc/unsupported-feature.input.js
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 @@ | ||
// ToDo: Update when transformation is added. | ||
// Current test verifies error is not thrown. | ||
import AWS from "aws-sdk"; | ||
|
||
const credentials = new AWS.SharedIniFileCredentials({ profile: "my-profile" }); |
5 changes: 5 additions & 0 deletions
5
src/transforms/v2-to-v3/__fixtures__/misc/unsupported-feature.output.js
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 @@ | ||
// ToDo: Update when transformation is added. | ||
// Current test verifies error is not thrown. | ||
import AWS from "aws-sdk"; | ||
|
||
const credentials = new AWS.SharedIniFileCredentials({ profile: "my-profile" }); |
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
2 changes: 1 addition & 1 deletion
2
...es/getV2ClientNamesFromTSQualifiedName.ts → ...ient-names/getNamesFromTSQualifiedName.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
14 changes: 9 additions & 5 deletions
14
src/transforms/v2-to-v3/client-names/getV2ClientNamesFromGlobal.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,14 +1,18 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
|
||
import { getV2ClientNamesFromNewExpr } from "./getV2ClientNamesFromNewExpr"; | ||
import { getV2ClientNamesFromTSQualifiedName } from "./getV2ClientNamesFromTSQualifiedName"; | ||
import { CLIENT_NAMES } from "../config"; | ||
import { getNamesFromNewExpr } from "./getNamesFromNewExpr"; | ||
import { getNamesFromTSQualifiedName } from "./getNamesFromTSQualifiedName"; | ||
|
||
export const getV2ClientNamesFromGlobal = ( | ||
j: JSCodeshift, | ||
source: Collection<unknown>, | ||
v2GlobalName: string | ||
): string[] => { | ||
const namesFromNewExpr = getV2ClientNamesFromNewExpr(j, source, v2GlobalName); | ||
const namesFromTSQualifiedName = getV2ClientNamesFromTSQualifiedName(j, source, v2GlobalName); | ||
return [...new Set([...namesFromNewExpr, ...namesFromTSQualifiedName])]; | ||
const namesFromNewExpr = getNamesFromNewExpr(j, source, v2GlobalName); | ||
const namesFromTSQualifiedName = getNamesFromTSQualifiedName(j, source, v2GlobalName); | ||
|
||
return [...new Set([...namesFromNewExpr, ...namesFromTSQualifiedName])].filter((name) => | ||
CLIENT_NAMES.includes(name) | ||
); | ||
}; |