Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/four-badgers-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Use 'not supported' constant for early return
12 changes: 3 additions & 9 deletions src/transforms/v2-to-v3/apis/addNotSupportedClientComments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Collection, JSCodeshift } from "jscodeshift";

import { FUNCTION_TYPE_LIST, S3 } from "../config";
import { FUNCTION_TYPE_LIST, NOT_SUPPORTED_COMMENT, S3 } from "../config";
import { ClientIdentifier } from "../types";
import { getClientApiCallExpression } from "./getClientApiCallExpression";
import { getClientWaiterCallExpression } from "./getClientWaiterCallExpression";
Expand Down Expand Up @@ -29,11 +29,7 @@ export const addNotSupportedClientComments = (

if (FUNCTION_TYPE_LIST.includes(args[args.length - 1].type)) {
const comments = callExpression.node.comments || [];
comments.push(
j.commentLine(
" Waiters with callbacks are not supported in AWS SDK for JavaScript (v3)."
)
);
comments.push(j.commentLine(` Waiters with callbacks are ${NOT_SUPPORTED_COMMENT}.`));
comments.push(
j.commentLine(
" Please convert to `await client.waitFor(state, params).promise()`, and re-run aws-sdk-js-codemod."
Expand Down Expand Up @@ -68,9 +64,7 @@ export const addNotSupportedClientComments = (
if (FUNCTION_TYPE_LIST.includes(args[args.length - 1].type)) {
const comments = callExpression.node.comments || [];
comments.push(
j.commentLine(
` ${apiDescription} with callbacks are not supported in AWS SDK for JavaScript (v3).`
)
j.commentLine(` ${apiDescription} with callbacks are ${NOT_SUPPORTED_COMMENT}.`)
);
comments.push(
j.commentLine(
Expand Down
2 changes: 2 additions & 0 deletions src/transforms/v2-to-v3/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export const FUNCTION_TYPE_LIST = [
"ArrowFunctionExpression",
];
export const STRING_LITERAL_TYPE_LIST = ["Literal", "StringLiteral"];

export const NOT_SUPPORTED_COMMENT = "not supported in AWS SDK for JavaScript (v3)";
4 changes: 2 additions & 2 deletions src/transforms/v2-to-v3/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
getClientNamesFromGlobal,
getClientNamesRecord,
} from "./client-names";
import { S3 } from "./config";
import { NOT_SUPPORTED_COMMENT, S3 } from "./config";
import { addClientModules, getGlobalNameFromModule, getImportType, removeModules } from "./modules";
import { removeTypesFromTSQualifiedName, replaceTSTypeReference } from "./ts-type";
import {
Expand Down Expand Up @@ -70,7 +70,7 @@ const transformer = async (file: FileInfo, api: API) => {
addNotSupportedClientComments(j, source, { v2ClientName, clientIdentifiers });
}

if (source.toSource() !== file.source) {
if (source.toSource().includes(NOT_SUPPORTED_COMMENT)) {
return source.toSource();
}

Expand Down