aws / aws/aws-sdk-js-codemod

[Feature]: Provide an option to transform only specific clients

Open
#589 0 comments 1 reaction 0 assignees View on GitHub
enhancement p2
Dominant language
TypeScript
Stars
89
Forks
13
Avg merge
9h 59m
Merged PRs (30d)
1

Description

### 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

```js
import AWS from "aws-sdk";

const s3Client = new AWS.S3();
const ddbClient = new AWS.DynamoDB();
```

Then, the output should be:

```js
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:
```console
$ 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:
```console
$ 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

Contributor guide

Open the contributing guide

Research direction

Start at the v2-to-v3 CLI entry point and its option parsing, then trace how client transforms are selected. Use the S3/DynamoDB example as the check: with --clients s3, S3 changes while DynamoDB remains v2; verify the command on JavaScript inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.