-
Notifications
You must be signed in to change notification settings - Fork 582
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): revert pinned credential client peer depen…
…dencies
- Loading branch information
Showing
2 changed files
with
7 additions
and
24 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,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); |