Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(credential-providers): use latest version for client peerDependencies #6099

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/update-versions/getUpdatedPackageJson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ export const getUpdatedPackageJson = (packageJson, depToVersionHash) =>
.reduce(
(acc, sectionName) => ({
...acc,
[sectionName]: getUpdatedPackageJsonSection(packageJson[sectionName], depToVersionHash, {
isPeer: sectionName === "peerDependencies",
packageName: packageJson.name,
}),
[sectionName]: getUpdatedPackageJsonSection(
packageJson[sectionName],
depToVersionHash,
sectionName === "peerDependencies"
),
}),
packageJson
);
22 changes: 2 additions & 20 deletions scripts/update-versions/getUpdatedPackageJsonSection.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
// @ts-check
export const getUpdatedPackageJsonSection = (section, depToVersionHash, { isPeer, packageName }) =>
export const getUpdatedPackageJsonSection = (section, depToVersionHash, isPeer = false) =>
Object.entries(section)
.filter(([key, value]) => key.startsWith("@aws-sdk/") && !value.startsWith("file:"))
.reduce((acc, [key]) => {
const newVersion = depToVersionHash[key];
if (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}`;
acc[key] = isPeer && newVersion !== "*" ? `^${newVersion}` : newVersion;
}
return acc;
}, section);
Loading