[Feature]: aws-sdk not changed after converted
- Dominant language
- TypeScript
- Stars
- 89
- Forks
- 13
- Avg merge
- 9h 59m
- Merged PRs (30d)
- 1
Description
### Self-service
- [ ] I'd be willing to implement a fix
### Describe the bug
I'd like to update my nodejs version from 16.x to 18.x.
And when I run `npx aws-sdk-js-codemod -t v2-to-v3`, he statement `var AWS = require("aws-sdk"); ` not changed after converted.
### Steps to reproduce
source fie
```javascript
var AWS = require("aws-sdk");
var endpoint = new AWS.Endpoint(domain);
var request = new AWS.HttpRequest(endpoint, region);
request.method = method;
request.path += index;
request.body = "";
request.headers["host"] = domain;
request.headers["Content-Type"] = "application/json";
request.headers["Content-Length"] = Buffer.byteLength(request.body);
var credentials = new AWS.EnvironmentCredentials("AWS");
var signer = new AWS.Signers.V4(request, "es");
signer.addAuthorization(credentials, new Date());
var client = new AWS.HttpClient();
client.handleRequest(
request,
null,
function (response) {
console.log(response.statusCode + " " + response.statusMessage);
var responseBody = "";
response.on("data", function (chunk) {
responseBody += chunk;
});
response.on("end", function (chunk) {
success(responseBody);
});
},
function (error) {
console.log("Error: " + error);
}
);
```
output
```javascript
var AWS = require("aws-sdk");
const { fromEnv } = require("@aws-sdk/credential-providers");
var endpoint = new AWS.Endpoint(domain);
var request = new AWS.HttpRequest(endpoint, region);
request.method = method;
request.path += index;
request.body = "";
request.headers["host"] = domain;
request.headers["Content-Type"] = "application/json";
request.headers["Content-Length"] = Buffer.byteLength(request.body);
var credentials = // JS SDK v3 switched credential providers from classes to functions.
// This is the closest approximation from codemod of what your application needs.
// Reference: https://www.npmjs.com/package/@aws-sdk/credential-providers
fromEnv("AWS");
var signer = new AWS.Signers.V4(request, "es");
signer.addAuthorization(credentials, new Date());
var client = new AWS.HttpClient();
client.handleRequest(
request,
null,
function (response) {
console.log(response.statusCode + " " + response.statusMessage);
var responseBody = "";
response.on("data", function (chunk) {
responseBody += chunk;
});
response.on("end", function (chunk) {
success(responseBody);
});
},
function (error) {
console.log("Error: " + error);
}
);
```
### Observed behavior
```console
$ npx aws-sdk-js-codemod -t v2-to-v3 part.js
╔════════════════════════════════════════════════════════╗
║ Please review the code change thoroughly for required ║
║ functionality before deploying it to production. ║
║ ║
║ If the transformation is not complete or is incorrect, ║
║ please report the issue on GitHub. ║
╚════════════════════════════════════════════════════════╝
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
All done.
Results:
0 errors
0 unmodified
0 skipped
1 ok
Time elapsed: 0.244seconds
```
### Expected behavior
require("aws-sdk"); should changed to something from '@aws-sdk/XXX' right?
And `AWS.Signers` ,`AWS.HttpRequest` , `AWS.Endpoint` should changed relevantly
### Environment
```shell
npx aws-sdk-js-codemod --version
aws-sdk-js-codemod: 1.0.0
- jscodeshift: 0.15.0
- recast: 0.23.4
```
### Additional context
_No response_
Contributor guide
Research direction
Reproduce the issue with the supplied part.js example by running the npx aws-sdk-js-codemod -t v2-to-v3 command. Start at the v2-to-v3 transform entry point and compare handling of require("aws-sdk"), AWS.Signers, AWS.HttpRequest, and AWS.Endpoint; done means the relevant APIs are converted consistently and the reported example no longer leaves the AWS v2 usage unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, nodejs, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100