Skip to content

ramblingenzyme/aws-sdk-js-codemod

 
 

Repository files navigation

aws-sdk-js-codemod

This repository contains a collection of codemod scripts for use with JSCodeshift that help update AWS SDK for JavaScript APIs.

The aws-sdk-js-codemod CLI is a lightweight wrapper over jscodeshift. It processes --help, --version and --transform options before passing them downstream.

You can provide names of the custom transforms instead of a local path or url:

 v2-to-v3  Converts AWS SDK for JavaScript APIs in a Javascript/TypeScript
           codebase from version 2 (v2) to version 3 (v3).

Prerequisites

To use aws-sdk-js-codemod, please install Node.js.

Usage

  • Optionally execute dry-run for the transform, and print transformed files on stdout:
    npx aws-sdk-js-codemod --dry --print -t v2-to-v3 PATH...
  • Run transform, and make changes to files:
    npx aws-sdk-js-codemod -t v2-to-v3 PATH...
  • To use the latest version of aws-sdk-js-codemod, clear your npx cache. You can either manually delete folder $(npm get cache)/_npx/*, or run clear-npx-cache.
    npx clear-npx-cache

Example

$ cat example.ts
import AWS from "aws-sdk";

const region = "us-west-2";
const client = new AWS.DynamoDB({ region });
client.listTables({}, (err, data) => {
  if (err) console.log(err, err.stack);
  else console.log(data);
});

$ npx aws-sdk-js-codemod -t v2-to-v3 example.ts

$ cat example.ts
import { DynamoDB } from "@aws-sdk/client-dynamodb";

const region = "us-west-2";
const client = new DynamoDB({ region });
client.listTables({}, (err, data) => {
  if (err) console.log(err, err.stack);
  else console.log(data);
});

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

Codemod scripts to update AWS SDK for JavaScript APIs.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.2%
  • JavaScript 6.8%