Skip to content

Commit

Permalink
fix(credential-providers): use pinned version for client peerDependen…
Browse files Browse the repository at this point in the history
…cies (#6060)
  • Loading branch information
trivikr authored May 3, 2024
1 parent e627b9e commit 20098c1
Show file tree
Hide file tree
Showing 2 changed files with 24 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
);
22 changes: 20 additions & 2 deletions scripts/update-versions/getUpdatedPackageJsonSection.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
// @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.
const moduleName = packageName.substring(packageName.indexOf("/") + 1);
const authProviderPrefixArray = ["credential-provider", "token-provider"];
if (
authProviderPrefixArray.some((authProviderPrefix) => moduleName.startsWith(authProviderPrefix)) &&
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 20098c1

Please sign in to comment.