Skip to content

Commit

Permalink
chore: move v2-to-v3 utils into folders (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Dec 22, 2022
1 parent 11b1012 commit 0c9cfd1
Show file tree
Hide file tree
Showing 35 changed files with 44 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-grapes-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Refactor to move v2-to-v3 utils into folders
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { PACKAGE_NAME } from "../config";
import { getV2ServiceModulePath } from "../get";
import { AddV3ClientModuleOptions } from "./addV3ClientModule";
import { PACKAGE_NAME } from "./config";
import { getV2ServiceModulePath } from "./getV2ServiceModulePath";

export const addV3ClientImport = (
j: JSCodeshift,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { containsRequire } from "../containsRequire";
import { addV3ClientImport } from "./addV3ClientImport";
import { addV3ClientRequire } from "./addV3ClientRequire";
import { containsRequire } from "./containsRequire";

export interface AddV3ClientModuleOptions {
v2ClientName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Collection, Identifier, JSCodeshift, ObjectPattern, Property } from "jscodeshift";

import { PACKAGE_NAME } from "../config";
import { getRequireVariableDeclaration, getV2ServiceModulePath } from "../get";
import { AddV3ClientModuleOptions } from "./addV3ClientModule";
import { PACKAGE_NAME } from "./config";
import { getRequireVariableDeclaration } from "./getRequireVariableDeclaration";
import { getV2ServiceModulePath } from "./getV2ServiceModulePath";

export const addV3ClientRequire = (
j: JSCodeshift,
Expand Down
1 change: 1 addition & 0 deletions src/transforms/v2-to-v3/utils/add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./addV3ClientModule";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClientMetadataMap } from "../types";
import { getV3ClientName } from "./getV3ClientName";
import { getV3ClientPackageName } from "./getV3ClientPackageName";
import { ClientMetadataMap } from "./types";

export const getClientMetadata = (v2ClientNames: string[]): ClientMetadataMap =>
Object.entries(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { PACKAGE_NAME } from "./config";
import { containsRequire } from "./containsRequire";
import { PACKAGE_NAME } from "../config";
import { containsRequire } from "../containsRequire";
import { getImportIdentifierName } from "./getImportIdentifierName";
import { getRequireIdentifierName } from "./getRequireIdentifierName";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { CLIENT_NAMES } from "./config";
import { containsRequire } from "./containsRequire";
import { CLIENT_NAMES } from "../config";
import { containsRequire } from "../containsRequire";
import { getImportIdentifierName } from "./getImportIdentifierName";
import { getRequireIdentifierName } from "./getRequireIdentifierName";
import { getV2ServiceModulePath } from "./getV2ServiceModulePath";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PACKAGE_NAME } from "./config";
import { PACKAGE_NAME } from "../config";

export const getV2ServiceModulePath = (v2ClientName: string) =>
`${PACKAGE_NAME}/clients/${v2ClientName.toLowerCase()}`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLIENT_NAMES_MAP } from "./config";
import { CLIENT_NAMES_MAP } from "../config";
import { getV3ClientName } from "./getV3ClientName";

describe(getV3ClientName.name, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLIENT_NAMES_MAP } from "./config";
import { CLIENT_NAMES_MAP } from "../config";

// Returns v3 client name for the provided v2 client name.
export const getV3ClientName = (clientName: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLIENT_PACKAGE_NAMES_MAP } from "./config";
import { CLIENT_PACKAGE_NAMES_MAP } from "../config";
import { getV3ClientPackageName } from "./getV3ClientPackageName";

describe(getV3ClientPackageName.name, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CLIENT_PACKAGE_NAMES_MAP } from "./config";
import { CLIENT_PACKAGE_NAMES_MAP } from "../config";

// Returns v3 client package name for the provided v2 client name.
export const getV3ClientPackageName = (clientName: string) => {
Expand Down
8 changes: 8 additions & 0 deletions src/transforms/v2-to-v3/utils/get/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from "./getClientMetadata";
export * from "./getRequireVariableDeclaration";
export * from "./getV2ClientIdentifiers";
export * from "./getV2ClientIdThisExpressions";
export * from "./getV2ClientNames";
export * from "./getV2DefaultModuleName";
export * from "./getV2ServiceModuleNames";
export * from "./getV2ServiceModulePath";
16 changes: 4 additions & 12 deletions src/transforms/v2-to-v3/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
export * from "./addV3ClientModule";
export * from "./containsRequire";
export * from "./getClientMetadata";
export * from "./getV2ClientNames";
export * from "./getV2DefaultModuleName";
export * from "./getV2ServiceModuleNames";
export * from "./add";
export * from "./get";
export * from "./isTypeScriptFile";
export * from "./removeDefaultModuleIfNotUsed";
export * from "./removePromiseCalls";
export * from "./removeV2ClientModule";
export * from "./replaceClientCreation";
export * from "./replaceTSTypeReference";
export * from "./types";
export * from "./remove";
export * from "./replace";
3 changes: 3 additions & 0 deletions src/transforms/v2-to-v3/utils/remove/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./removeDefaultModuleIfNotUsed";
export * from "./removePromiseCalls";
export * from "./removeV2ClientModule";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { PACKAGE_NAME } from "./config";
import { containsRequire } from "./containsRequire";
import { PACKAGE_NAME } from "../config";
import { containsRequire } from "../containsRequire";
import { removeImportIdentifierName } from "./removeImportIdentifierName";
import { removeRequireIdentifierName } from "./removeRequireIdentifierName";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { CallExpression, Collection, JSCodeshift, MemberExpression } from "jscodeshift";

import { getV2ClientIdentifiers } from "./getV2ClientIdentifiers";
import { getV2ClientIdThisExpressions } from "./getV2ClientIdThisExpressions";
import { getV2ClientIdentifiers, getV2ClientIdThisExpressions } from "../get";

export interface RemovePromiseCallsOptions {
v2ClientName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Collection, Identifier, JSCodeshift, VariableDeclarator } from "jscodeshift";

import { getRequireVariableDeclaration } from "./getRequireVariableDeclaration";
import { getRequireVariableDeclaration } from "../get";

export interface RemoveRequireIdentifierNameOptions {
identifierName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { containsRequire } from "./containsRequire";
import { getV2ServiceModulePath } from "./getV2ServiceModulePath";
import { containsRequire } from "../containsRequire";
import { getV2ServiceModulePath } from "../get";
import { removeImportIdentifierName } from "./removeImportIdentifierName";
import { removeRequireIdentifierName } from "./removeRequireIdentifierName";

Expand Down
2 changes: 2 additions & 0 deletions src/transforms/v2-to-v3/utils/replace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./replaceClientCreation";
export * from "./replaceTSTypeReference";

0 comments on commit 0c9cfd1

Please sign in to comment.