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 cff6ff6
Show file tree
Hide file tree
Showing 2 changed files with 19 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
);
17 changes: 15 additions & 2 deletions scripts/update-versions/getUpdatedPackageJsonSection.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// @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;
// Use exact version if it's asterisk or not a peer dependency.
if (newVersion === "*" || !isPeer) {
acc[key] = newVersion;
return acc;
}

// Use exact version for client peerDependencies in credential-provider packages.
if (packageName.startsWith("@aws-sdk/credential-provider") && key.startsWith("@aws-sdk/client-")) {
acc[key] = newVersion;
return acc;
}

// Use caret version for other peerDependencies.
acc[key] = `^${newVersion}`;
}
return acc;
}, section);

0 comments on commit cff6ff6

Please sign in to comment.