Skip to content

Commit 8082197

Browse files
authored
Rename getV2ServiceModulePath to getClientDeepImportPath (#457)
1 parent 5b3cdc4 commit 8082197

9 files changed

+19
-20
lines changed

src/transforms/v2-to-v3/client-names/getV2ClientNamesRecordFromImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Collection, Identifier, ImportSpecifier, JSCodeshift } from "jscodeshif
33
import { CLIENT_NAMES, PACKAGE_NAME } from "../config";
44
import { getImportEqualsDeclaration } from "../modules";
55
import { getImportSpecifiers } from "../modules";
6-
import { getV2ServiceModulePath } from "../utils";
6+
import { getClientDeepImportPath } from "../utils";
77

88
export const getV2ClientNamesRecordFromImport = (
99
j: JSCodeshift,
@@ -25,7 +25,7 @@ export const getV2ClientNamesRecordFromImport = (
2525
}
2626

2727
for (const clientName of v2ClientNamesWithServiceModule) {
28-
const deepImportPath = getV2ServiceModulePath(clientName);
28+
const deepImportPath = getClientDeepImportPath(clientName);
2929

3030
const specifiersFromDeepImport = getImportSpecifiers(j, source, deepImportPath).filter(
3131
(specifier) =>

src/transforms/v2-to-v3/client-names/getV2ClientNamesRecordFromRequire.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
import { CLIENT_NAMES, OBJECT_PROPERTY_TYPE_LIST, PACKAGE_NAME } from "../config";
1111
import { getRequireDeclaratorsWithProperty } from "../modules";
12-
import { getV2ServiceModulePath } from "../utils";
12+
import { getClientDeepImportPath } from "../utils";
1313
import { getRequireIds } from "./getRequireIds";
1414

1515
export const getV2ClientNamesRecordFromRequire = (
@@ -58,8 +58,8 @@ export const getV2ClientNamesRecordFromRequire = (
5858
}
5959

6060
for (const clientName of v2ClientNamesWithServiceModule) {
61-
const deepRequirePath = getV2ServiceModulePath(clientName);
62-
const idsFromDefaultImport = getRequireIds(j, source, deepRequirePath).filter(
61+
const deepImportPath = getClientDeepImportPath(clientName);
62+
const idsFromDefaultImport = getRequireIds(j, source, deepImportPath).filter(
6363
(id) => id.type === "Identifier"
6464
);
6565
if (idsFromDefaultImport.length) {

src/transforms/v2-to-v3/modules/getV2ImportDeclaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

33
import { PACKAGE_NAME } from "../config";
4-
import { getV2ServiceModulePath } from "../utils";
4+
import { getClientDeepImportPath } from "../utils";
55

66
export interface GetV2ImportDeclarationOptions {
77
v2ClientName: string;
@@ -29,7 +29,7 @@ export const getV2ImportDeclaration = (
2929
}
3030

3131
if (
32-
sourceValue === getV2ServiceModulePath(v2ClientName) &&
32+
sourceValue === getClientDeepImportPath(v2ClientName) &&
3333
importDeclaration.value.specifiers?.some(
3434
(specifier) =>
3535
["ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(specifier.type) &&

src/transforms/v2-to-v3/modules/getV2ImportEqualsDeclaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift, TSExternalModuleReference } from "jscodeshift";
22

33
import { PACKAGE_NAME } from "../config";
4-
import { getV2ServiceModulePath } from "../utils";
4+
import { getClientDeepImportPath } from "../utils";
55
import { getImportEqualsDeclaration } from "./getImportEqualsDeclaration";
66

77
export interface GetV2ImportEqualsDeclarationOptions {
@@ -29,7 +29,7 @@ export const getV2ImportEqualsDeclaration = (
2929
}
3030

3131
if (
32-
expressionValue === getV2ServiceModulePath(v2ClientName) &&
32+
expressionValue === getClientDeepImportPath(v2ClientName) &&
3333
identifierName === v2ClientLocalName
3434
) {
3535
return true;

src/transforms/v2-to-v3/modules/getV2RequireDeclarator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

33
import { PACKAGE_NAME } from "../config";
4-
import { getV2ServiceModulePath } from "../utils";
4+
import { getClientDeepImportPath } from "../utils";
55
import { getRequireDeclaratorsWithIdentifier } from "./getRequireDeclaratorsWithIdentifier";
66
import { getRequireDeclaratorsWithObjectPattern } from "./getRequireDeclaratorsWithObjectPattern";
77
import { getRequireDeclaratorsWithProperty } from "./getRequireDeclaratorsWithProperty";
@@ -46,10 +46,9 @@ export const getV2RequireDeclarator = (
4646
return requireDeclaratorsWithProperty;
4747
}
4848

49-
const v2ServiceModulePath = getV2ServiceModulePath(v2ClientName);
5049
const requireDeclaratorsWithIdentifier = getRequireDeclaratorsWithIdentifier(j, source, {
5150
identifierName: v2ClientLocalName,
52-
sourceValue: v2ServiceModulePath,
51+
sourceValue: getClientDeepImportPath(v2ClientName),
5352
});
5453

5554
if (requireDeclaratorsWithIdentifier.size() > 0) {

src/transforms/v2-to-v3/modules/removeV2ClientModule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Collection, JSCodeshift } from "jscodeshift";
22

33
import { PACKAGE_NAME } from "../config";
44
import { getV2ClientTypeNames } from "../ts-type";
5-
import { getV2ServiceModulePath } from "../utils";
5+
import { getClientDeepImportPath } from "../utils";
66
import { hasImportEquals } from "./hasImportEquals";
77
import { hasRequire } from "./hasRequire";
88
import { removeImportDefault } from "./removeImportDefault";
@@ -24,9 +24,9 @@ export const removeV2ClientModule = (
2424
options: RemoveV2ClientModuleOptions
2525
) => {
2626
const { v2ClientName, v2ClientLocalName } = options;
27-
const serviceModulePath = getV2ServiceModulePath(v2ClientName);
27+
const deepImportPath = getClientDeepImportPath(v2ClientName);
2828

29-
const defaultOptions = { localName: v2ClientLocalName, sourceValue: serviceModulePath };
29+
const defaultOptions = { localName: v2ClientLocalName, sourceValue: deepImportPath };
3030
const namedOptions = { localName: v2ClientLocalName, sourceValue: PACKAGE_NAME };
3131

3232
if (hasRequire(j, source)) {
@@ -43,7 +43,7 @@ export const removeV2ClientModule = (
4343
for (const v2ClientTypeName of v2ClientTypeNames) {
4444
removeImportNamed(j, source, {
4545
localName: v2ClientTypeName,
46-
sourceValue: serviceModulePath,
46+
sourceValue: deepImportPath,
4747
});
4848
}
4949
}

src/transforms/v2-to-v3/ts-type/getV2ClientTypeNames.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, Identifier, JSCodeshift, TSQualifiedName, TSTypeReference } from "jscodeshift";
22

33
import { getImportSpecifiers } from "../modules";
4-
import { getClientTSTypeRef, getV2ServiceModulePath } from "../utils";
4+
import { getClientDeepImportPath, getClientTSTypeRef } from "../utils";
55

66
export interface GetV2ClientTypeNamesOptions {
77
v2ClientName: string;
@@ -41,7 +41,7 @@ export const getV2ClientTypeNames = (
4141
v2ClientTypeNames.push(...getRightIdentifierName(j, source, clientTSTypeRef));
4242

4343
v2ClientTypeNames.push(
44-
...getImportSpecifiers(j, source, getV2ServiceModulePath(v2ClientName))
44+
...getImportSpecifiers(j, source, getClientDeepImportPath(v2ClientName))
4545
.filter(
4646
(importSpecifier) =>
4747
importSpecifier.type === "ImportSpecifier" &&
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { PACKAGE_NAME } from "../config";
22

3-
export const getV2ServiceModulePath = (v2ClientName: string) =>
3+
export const getClientDeepImportPath = (v2ClientName: string) =>
44
`${PACKAGE_NAME}/clients/${v2ClientName.toLowerCase()}`;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
export * from "./getClientDeepImportPath";
12
export * from "./getClientNewExpression";
23
export * from "./getClientTSTypeRef";
3-
export * from "./getV2ServiceModulePath";
44
export * from "./getV3DefaultLocalName";
55
export * from "./isTypeScriptFile";

0 commit comments

Comments
 (0)