-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(credential-providers): use pinned version for client peerDependen…
…cies (#6060)
- Loading branch information
Showing
2 changed files
with
24 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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); |