-
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.
Compute variable name for import equals from v2ClientName (#426)
- Loading branch information
Showing
10 changed files
with
95 additions
and
9 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 | ||
--- | ||
|
||
Compute variable name for import equals from v2ClientName |
16 changes: 16 additions & 0 deletions
16
scripts/generateNewClientTests/getServiceImportEqualsWithNameInput.ts
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,16 @@ | ||
import { CLIENTS_TO_TEST } from "./config"; | ||
import { getClientDeepImportPath } from "./getClientDeepImportPath"; | ||
import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix"; | ||
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode"; | ||
|
||
export const getServiceImportEqualsWithNameInput = (codegenComment: string) => { | ||
let content = `${codegenComment}\n`; | ||
|
||
for (const clientName of CLIENTS_TO_TEST) { | ||
const importName = getClientNameWithLocalSuffix(clientName); | ||
content += `import ${importName} = require("${getClientDeepImportPath(clientName)}");\n`; | ||
} | ||
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix)); | ||
|
||
return content; | ||
}; |
13 changes: 13 additions & 0 deletions
13
scripts/generateNewClientTests/getServiceImportEqualsWithNameOutput.ts
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 { CLIENTS_TO_TEST } from "./config"; | ||
import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix"; | ||
import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode"; | ||
import { getV3PackageImportEqualsCode } from "./getV3PackageImportEqualsCode"; | ||
|
||
export const getServiceImportEqualsWithNameOutput = (codegenComment: string) => { | ||
let content = `${codegenComment};\n`; | ||
|
||
content += getV3PackageImportEqualsCode(CLIENTS_TO_TEST, { useLocalSuffix: true }); | ||
content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix)); | ||
|
||
return content; | ||
}; |
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
9 changes: 9 additions & 0 deletions
9
src/transforms/v2-to-v3/__fixtures__/new-client/service-import-equals-with-name.input.ts
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,9 @@ | ||
// This file is generated by scripts/generateNewClientTests/index.ts | ||
// Do not edit this file directly. Instead, edit the script and run it to regenerate this file. | ||
"use strict"; | ||
import ACMClient = require("aws-sdk/clients/acm"); | ||
import AccessAnalyzerClient = require("aws-sdk/clients/accessanalyzer"); | ||
import DiscoveryClient = require("aws-sdk/clients/discovery"); | ||
new ACMClient(); | ||
new AccessAnalyzerClient(); | ||
new DiscoveryClient(); |
24 changes: 24 additions & 0 deletions
24
src/transforms/v2-to-v3/__fixtures__/new-client/service-import-equals-with-name.output.ts
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,24 @@ | ||
// This file is generated by scripts/generateNewClientTests/index.ts | ||
// Do not edit this file directly. Instead, edit the script and run it to regenerate this file. | ||
"use strict";; | ||
import AWS_ACM = require("@aws-sdk/client-acm"); | ||
|
||
const { | ||
ACM: ACMClient | ||
} = AWS_ACM; | ||
|
||
import AWS_AccessAnalyzer = require("@aws-sdk/client-accessanalyzer"); | ||
|
||
const { | ||
AccessAnalyzer: AccessAnalyzerClient | ||
} = AWS_AccessAnalyzer; | ||
|
||
import AWS_Discovery = require("@aws-sdk/client-application-discovery-service"); | ||
|
||
const { | ||
ApplicationDiscoveryService: DiscoveryClient | ||
} = AWS_Discovery; | ||
|
||
new ACMClient(); | ||
new AccessAnalyzerClient(); | ||
new DiscoveryClient(); |
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
4 changes: 4 additions & 0 deletions
4
src/transforms/v2-to-v3/modules/getImportEqualsLocalNameSuffix.ts
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,4 @@ | ||
export const getImportEqualsLocalNameSuffix = (v2ClientName: string, v3ClientPackageName: string) => | ||
v3ClientPackageName.startsWith("@aws-sdk/client-") | ||
? v2ClientName | ||
: v3ClientPackageName.substring(9).replace(/-/g, "_"); |