Skip to content

Commit

Permalink
chore(scripts): use pinned version for client peerDependencies in cre…
Browse files Browse the repository at this point in the history
…dential providers
  • Loading branch information
trivikr committed May 3, 2024
1 parent bfa8626 commit e6f202a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 4 additions & 5 deletions scripts/update-versions/getUpdatedPackageJson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ export const getUpdatedPackageJson = (packageJson, depToVersionHash) =>
.reduce(
(acc, sectionName) => ({
...acc,
[sectionName]: getUpdatedPackageJsonSection(
packageJson[sectionName],
depToVersionHash,
sectionName === "peerDependencies"
),
[sectionName]: getUpdatedPackageJsonSection(packageJson[sectionName], depToVersionHash, {
isPeer: sectionName === "peerDependencies",
packageName: packageJson.name,
}),
}),
packageJson
);
14 changes: 12 additions & 2 deletions scripts/update-versions/getUpdatedPackageJsonSection.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
// @ts-check
export const getUpdatedPackageJsonSection = (section, depToVersionHash, isPeer = false) =>
export const getUpdatedPackageJsonSection = (section, depToVersionHash, { isPeer, packageName }) =>
Object.entries(section)
.filter(([key, value]) => key.startsWith("@aws-sdk/") && !value.startsWith("file:"))
.reduce((acc, [key]) => {
const newVersion = depToVersionHash[key];
if (newVersion) {
acc[key] = isPeer && newVersion !== "*" ? `^${newVersion}` : newVersion;
if (newVersion === "*" || !isPeer) {
acc[key] = newVersion;
return acc;
}

if (packageName.startsWith("@aws-sdk/credential-provider") && key.startsWith("@aws-sdk/client-")) {
acc[key] = newVersion;
return acc;
}

acc[key] = `^${newVersion}`;
}
return acc;
}, section);

0 comments on commit e6f202a

Please sign in to comment.