-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform AWS.Endpoint to URL (#840)
- Loading branch information
Showing
13 changed files
with
60 additions
and
0 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": minor | ||
--- | ||
|
||
Transform AWS.Endpoint to URL |
3 changes: 3 additions & 0 deletions
3
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/global-import-equals.input.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,3 @@ | ||
import AWS = require("aws-sdk"); | ||
|
||
const endpoint = new AWS.Endpoint("http://localhost:8000/"); |
1 change: 1 addition & 0 deletions
1
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/global-import-equals.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
const endpoint = new URL("http://localhost:8000/"); |
3 changes: 3 additions & 0 deletions
3
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/global-import.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,3 @@ | ||
import AWS from "aws-sdk"; | ||
|
||
const endpoint = new AWS.Endpoint("http://localhost:8000/"); |
1 change: 1 addition & 0 deletions
1
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/global-import.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 @@ | ||
const endpoint = new URL("http://localhost:8000/"); |
3 changes: 3 additions & 0 deletions
3
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/named-import.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,3 @@ | ||
import { Endpoint } from "aws-sdk"; | ||
|
||
const endpoint = new Endpoint("http://localhost:8000/"); |
1 change: 1 addition & 0 deletions
1
src/transforms/v2-to-v3/__fixtures__/aws-endpoint/named-import.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 @@ | ||
const endpoint = new URL("http://localhost:8000/"); |
5 changes: 5 additions & 0 deletions
5
src/transforms/v2-to-v3/__fixtures__/config/endpoint.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 @@ | ||
import AWS from "aws-sdk"; | ||
|
||
const config = new AWS.Config({ | ||
endpoint: "http://localhost" | ||
}); |
3 changes: 3 additions & 0 deletions
3
src/transforms/v2-to-v3/__fixtures__/config/endpoint.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,3 @@ | ||
const config = { | ||
endpoint: "http://localhost" | ||
}; |
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
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,31 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
|
||
export const replaceAwsEndpoint = ( | ||
j: JSCodeshift, | ||
source: Collection<unknown>, | ||
v2GlobalName?: string | ||
) => { | ||
const endpointCtr = "Endpoint"; | ||
|
||
if (v2GlobalName) { | ||
source | ||
.find(j.NewExpression, { | ||
callee: { | ||
type: "MemberExpression", | ||
object: { type: "Identifier", name: v2GlobalName }, | ||
property: { type: "Identifier", name: endpointCtr }, | ||
}, | ||
}) | ||
.replaceWith((newExpression) => | ||
j.newExpression(j.identifier("URL"), newExpression.node.arguments) | ||
); | ||
} | ||
|
||
source | ||
.find(j.NewExpression, { | ||
callee: { type: "Identifier", name: endpointCtr }, | ||
}) | ||
.replaceWith((newExpression) => | ||
j.newExpression(j.identifier("URL"), newExpression.node.arguments) | ||
); | ||
}; |
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
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