Skip to content

Commit 369d337

Browse files
authored
Update README with instructions to use aws-sdk-js-codemod (#16)
1 parent 9cd5712 commit 369d337

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

.changeset/many-jobs-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Update README with instructions to use aws-sdk-js-codemod

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
11
# aws-sdk-js-codemod
2-
Codemod scripts for AWS SDK for JavaScript
2+
3+
This repository contains a collection of codemod scripts for use with
4+
[JSCodeshift][jscodeshift] that help update [AWS SDK for JavaScript][aws-sdk-js]
5+
APIs.
6+
7+
The `aws-sdk-js-codemod` CLI is a lightweight wrapper over jscodeshift.
8+
It processes `--help`, `--version` and `--transform` options before passing them
9+
downstream.
10+
11+
You can provide names of the custom transforms instead of a local path or url:
12+
13+
v2-to-v3 Converts AWS SDK for JavaScript APIs in a Javascript/TypeScript
14+
codebase from version 2 (v2) to version 3 (v3).
15+
16+
## Prerequisites
17+
18+
To use aws-sdk-js-codemod, please install [Node.js][install-nodejs].
19+
20+
## Usage
21+
22+
- Optionally execute dry-run for the transform, and print transformed files on stdout:
23+
```console
24+
npx aws-sdk-js-codemod --dry --print -t v2-to-v3 PATH...
25+
```
26+
- Run transform:
27+
```console
28+
npx aws-sdk-js-codemod -t v2-to-v3 PATH...
29+
```
30+
31+
## Example
32+
33+
```console
34+
$ cat example.ts
35+
import AWS from "aws-sdk";
36+
37+
const region = "us-west-2";
38+
const client = new AWS.DynamoDB({ region });
39+
client.listTables({}, (err, data) => {
40+
if (err) console.log(err, err.stack);
41+
else console.log(data);
42+
});
43+
44+
$ npx aws-sdk-js-codemod -t v2-to-v3 example.ts
45+
46+
$ cat example.ts
47+
import AWS from "aws-sdk";
48+
49+
import { DynamoDB } from "@aws-sdk/client-dynamodb";
50+
51+
const region = "us-west-2";
52+
const client = new DynamoDB({ region });
53+
client.listTables({}, (err, data) => {
54+
if (err) console.log(err, err.stack);
55+
else console.log(data);
56+
});
57+
58+
```
59+
60+
[aws-sdk-js]: https://aws.amazon.com/sdk-for-javascript/
61+
[install-nodejs]: https://nodejs.dev/learn/how-to-install-nodejs
62+
[jscodeshift]: https://github.com/facebook/jscodeshift

0 commit comments

Comments
 (0)