-
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.
Add prepublishOnly script to test changed package names exist on npm (#…
…964)
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`); | ||
} | ||
})(); |