diff --git a/package-lock.json b/package-lock.json index c8828d0e..abe44514 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aws-sdk-js-codemod", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "aws-sdk-js-codemod", - "version": "2.4.1", + "version": "2.4.2", "license": "MIT-0", "dependencies": { "jscodeshift": "17.1.1" diff --git a/package.json b/package.json index 707aa98e..090513d9 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "generate:map": "tsx scripts/generateClientTypesMap", "generate:tests": "tsx scripts/generateNewClientTests", "lint": "biome lint --write", + "prepublishOnly": "tsx scripts/testChangedPackageNames", "release": "npm run build && changeset publish", "test": "vitest" }, diff --git a/scripts/testChangedPackageNames/index.ts b/scripts/testChangedPackageNames/index.ts new file mode 100644 index 00000000..1eebc8fa --- /dev/null +++ b/scripts/testChangedPackageNames/index.ts @@ -0,0 +1,29 @@ +import { exec } from "node:child_process"; +import { mkdtemp } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { promisify } from "node:util"; +import { CLIENT_PACKAGE_NAMES_MAP as PACKAGE_NAMES_MAP_TO_PUBLISH } from "../../src/transforms/v2-to-v3/config"; + +const execAsync = promisify(exec); + +(async () => { + // Create temporary directory + const tempDir = await mkdtemp(join(tmpdir(), "testChangedPackageNames-")); + await execAsync("npm install aws-sdk-js-codemod@latest", { cwd: tempDir }); + + const { CLIENT_PACKAGE_NAMES_MAP: PACKAGE_NAMES_MAP_LATEST } = await import( + join(tempDir, "node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/config") + ); + + const changedPackageNames = Object.keys(PACKAGE_NAMES_MAP_TO_PUBLISH) + .filter((key) => PACKAGE_NAMES_MAP_TO_PUBLISH[key] !== PACKAGE_NAMES_MAP_LATEST[key]) + .map((key) => PACKAGE_NAMES_MAP_TO_PUBLISH[key]); + + console.log(`Changed package names: ${changedPackageNames.join(", ")}`); + for (const packageName of changedPackageNames) { + const npmPackageName = `@aws-sdk/${packageName}`; + await execAsync(`npm show ${npmPackageName} version`); + console.log(`${npmPackageName} exists`); + } +})();