-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Placeholder for transforms with information in help (#12)
- Loading branch information
Showing
11 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Adds a placeholder for transforms with information under help option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./types"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export type PositionalOptionsType = "boolean" | "number" | "string"; | ||
|
||
export interface AwsSdkJsCodemodTransformOption { | ||
/** array of values, limit valid option arguments to a predefined set */ | ||
choices?: ReadonlyArray<boolean> | ReadonlyArray<number> | ReadonlyArray<string>; | ||
|
||
/** value, set a default value for the option */ | ||
default?: boolean | number | string; | ||
|
||
/** string, the option description for help content */ | ||
description: string; | ||
|
||
/** string, the type of the option */ | ||
type: PositionalOptionsType; | ||
} | ||
|
||
export interface AwsSdkJsCodemodTransform { | ||
/** string, the name of the transform */ | ||
name: string; | ||
|
||
/** string, the description of the transform for help content */ | ||
description: string; | ||
|
||
/** array of TransformOption, the which can be passed to the transform */ | ||
options: AwsSdkJsCodemodTransformOption[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const name = "v2-to-v3"; | ||
|
||
export const description = | ||
"Converts AWS SDK for JavaScript APIs in a Javascript/TypeScript codebase" + | ||
" from version 2 (v2) to version 3 (v3)."; | ||
|
||
// Additional options will come here, like running on specific clients. | ||
export const options = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { API, FileInfo } from "jscodeshift"; | ||
|
||
export default function transformer(file: FileInfo, api: API) { | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
|
||
// transform `root` here | ||
|
||
return root.toSource(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getBorderCharacters, table } from "table"; | ||
|
||
import { AwsSdkJsCodemodTransform } from "../transforms"; | ||
|
||
export const getHelpParagraph = (transforms: AwsSdkJsCodemodTransform[]) => | ||
`---------------------------------------------------------------------------------------------------- | ||
aws-sdk-js-codemod 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: | ||
${table( | ||
transforms.map(({ name, description }) => [name, description]), | ||
{ | ||
border: getBorderCharacters("void"), | ||
columns: [ | ||
{ width: 12, alignment: "right" }, | ||
{ width: 88, wrapWord: true }, | ||
], | ||
} | ||
)}Example: aws-sdk-js-codemod -t v2-to-v3 example.js | ||
----------------------------------------------------------------------------------------------------\n\n`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { readdirSync } from "fs"; | ||
import { join } from "path"; | ||
|
||
import { AwsSdkJsCodemodTransform } from "../transforms"; | ||
|
||
export const getTransforms = () => | ||
readdirSync(join(__dirname, "..", "transforms"), { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name) | ||
.map((dirName) => { | ||
const { name, description, options } = require(`../transforms/${dirName}/transform`); // eslint-disable-line | ||
return { name, description, options } as AwsSdkJsCodemodTransform; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./getHelpParagraph"; | ||
export * from "./getTransforms"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters