Skip to content

Commit

Permalink
Add prepublish script to test changed package names exist on npm
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Nov 5, 2024
1 parent 3cafbf5 commit f7520f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"generate:map": "tsx scripts/generateClientTypesMap",
"generate:tests": "tsx scripts/generateNewClientTests",
"lint": "biome lint --write",
"prepublish": "tsx scripts/testChangedPackageNames",
"release": "npm run build && changeset publish",
"test": "vitest"
},
Expand Down
27 changes: 27 additions & 0 deletions scripts/testChangedPackageNames/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { CLIENT_PACKAGE_NAMES_MAP as PACKAGE_NAMES_MAP_TO_PUBLISH } from "../../src/transforms/v2-to-v3/config";
import { mkdtemp } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { exec } from "node:child_process";
import { promisify } from "node:util";

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) {
await execAsync(`npm show @aws-sdk/${packageName} version`);
}
})();

0 comments on commit f7520f3

Please sign in to comment.