aws / aws-sdk-js-codemod

Codemod scripts to update AWS SDK for JavaScript APIs.
MIT No Attribution
73 stars 10 forks source link

Update prerelease script to test changed clients #970

Closed trivikr closed 1 week ago

trivikr commented 1 week ago

Issue

Refs: https://github.com/aws/aws-sdk-js-codemod/issues/950#issuecomment-2461262854

Description

Prerelease script which tests updated client names and package names

Testing

No clients have changed in the current release

$ npx tsx scripts/testUpdatedIdentifiers
Changed package names: [  ]
Changed clients: [  ]

Simulated check after adding deprecated client

$ git diff
diff --git a/src/transforms/v2-to-v3/config/CLIENT_NAMES.ts b/src/transforms/v2-to-v3/config/CLIENT_NAMES.ts
index b4b0777..e14274b 100644
--- a/src/transforms/v2-to-v3/config/CLIENT_NAMES.ts
+++ b/src/transforms/v2-to-v3/config/CLIENT_NAMES.ts
@@ -382,4 +382,5 @@ export const CLIENT_NAMES = [
   "WorkSpacesThinClient",
   "WorkSpacesWeb",
   "XRay",
+  "BackupStorage",
 ];
diff --git a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
index ea8a175..373cf45 100644
--- a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
+++ b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts
@@ -143,4 +143,5 @@ export const CLIENT_PACKAGE_NAMES_MAP: Record<string, string> = {
   WAFRegional: "client-waf-regional",
   WellArchitected: "client-wellarchitected",
   WorkMailMessageFlow: "client-workmailmessageflow",
+  BackupStorage: "client-backupstorage",
 };

$ npx tsx scripts/testUpdatedIdentifiers
Changed package names: [  ]
Changed clients: [ BackupStorage ]
Client 'BackupStorage' exists in '@aws-sdk/client-backupstorage'.

Simulated check for incorrect client name

$ diff --git a/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts b/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts
index 42bdcb1..44f8366 100644
--- a/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts
+++ b/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts
@@ -32,5 +32,5 @@ export const CLIENT_NAMES_MAP: Record<string, string> = {
   SESV2: "SESv2",
   SavingsPlans: "Savingsplans",
   StepFunctions: "SFN",
-  TranscribeService: "Transcribe",
+  TranscribeService: "S3",

$ npx tsx scripts/testUpdatedIdentifiers
Changed package names: [  ]
Changed clients: [ S3 ]
node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: node index.mjs
file:///private/var/folders/42/54jl1_3x4hz06cf7bc_kzd4h0000gn/T/codemod-br8Fiw/index.mjs:1
import { S3 } from "@aws-sdk/client-transcribe"
         ^^
SyntaxError: Named export 'S3' not found. The requested module '@aws-sdk/client-transcribe' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@aws-sdk/client-transcribe';
const { S3 } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:177:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:260:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)

Node.js v22.10.0

    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1104:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:518:28)
    at Pipe.<anonymous> (node:net:343:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'node index.mjs',
  stdout: '',
  stderr: 'file:///private/var/folders/42/54jl1_3x4hz06cf7bc_kzd4h0000gn/T/codemod-br8Fiw/index.mjs:1\n' +
    'import { S3 } from "@aws-sdk/client-transcribe"\n' +
    '         ^^\n' +
    "SyntaxError: Named export 'S3' not found. The requested module '@aws-sdk/client-transcribe' is a CommonJS module, which may not support all module.exports as named exports.\n" +
    'CommonJS modules can always be imported via the default export, for example using:\n' +
    '\n' +
    "import pkg from '@aws-sdk/client-transcribe';\n" +
    'const { S3 } = pkg;\n' +
    '\n' +
    '    at ModuleJob._instantiate (node:internal/modules/esm/module_job:177:21)\n' +
    '    at async ModuleJob.run (node:internal/modules/esm/module_job:260:5)\n' +
    '    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)\n' +
    '    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n' +
    '\n' +
    'Node.js v22.10.0\n'
}

Node.js v22.10.0

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

changeset-bot[bot] commented 1 week ago

⚠️ No Changeset found

Latest commit: 22880f7ac58b1b3982297811a37a0377e5766fe6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR