aws-sdk-js-codemod
aws-sdk-js-codemod copied to clipboard
[Feature]: Provide an option to transform only specific clients
Self-service
- [ ] I'd be willing to implement this feature
Problem
Application code may use multiple JS SDK clients. Transforming all of them in one pass might be difficult, and user might want to transform specific clients.
For example, in the following code user might want to transform only S3 client
import AWS from "aws-sdk";
const s3Client = new AWS.S3();
const ddbClient = new AWS.DynamoDB();
Then, the output should be:
import AWS from "aws-sdk";
import { S3 } from "@aws-sdk/client-s3";
const s3Client = new S3();
const ddbClient = new AWS.DynamoDB();
Solution
Provide an option which user can pass at top-level when running codemod.
The option can be clients and it can be passed as follows:
$ npx aws-sdk-js-codemod@latest -t v2-to-v3 --clients s3 **/*.js
Alternatives
If user has written application code in such a way, that it's separated into folders based on clients they can run existing codemod on specific folders.
For example:
$ npx aws-sdk-js-codemod@latest -t v2-to-v3 src/s3/*.js
However, this requires application code to be refactored. We can't expect users to do that.
Additional context
Example code: https://github.com/aws-solutions/qnabot-on-aws/blob/7fb99e0c716ad7c6702f630f46d5626ad3cb5a69/bin/build.js#L10-L11