[rush-lib] Add support for custom CredentialCache paths#5240
Merged
iclanton merged 12 commits intomicrosoft:mainfrom Jun 10, 2025
Merged
[rush-lib] Add support for custom CredentialCache paths#5240iclanton merged 12 commits intomicrosoft:mainfrom
CredentialCache paths#5240iclanton merged 12 commits intomicrosoft:mainfrom
Conversation
The `CredentialCache` does not rely on the Rush user configuration. It can be used outside of `@rush/rush-sdk` by directly importing it from `@microsoft/rush-lib`. To support such use cases, we should allow the consumer to specify a file path for their cache, rather than the fixed `~/.rush-user/credentials.json` path. Non-breaking change because the default path remains the same, and we add support for additional options in `ICredentialCacheOptions`. | `ICredentialCacheOptions.cacheDirectory` | `.cacheName` | Resulting Path | |-|-|-| | `undefined` | `undefined` | `~/.rush-user/credentials.json` (default) | | `undefined` | `custom-name` | `~/.rush-user/custom-name.json` | | `/custom-dir` | `undefined` | `/custom-dir/credentials.json` | | `/custom-dir` | `custom-name` | `/custom-dir/custom-name.json` |
delilahw
commented
May 30, 2025
iclanton
reviewed
Jun 3, 2025
delilahw
commented
Jun 4, 2025
Reverts unintended change in lockfile path.
iclanton
reviewed
Jun 10, 2025
iclanton
reviewed
Jun 10, 2025
common/changes/@microsoft/rush/feat-credcache-custom-paths_2025-05-30-04-23.json
Outdated
Show resolved
Hide resolved
delilahw
commented
Jun 10, 2025
Member
Author
delilahw
left a comment
There was a problem hiding this comment.
Thanks so much @iclanton for the suggestions!! I've rebased your commits from delilahw#1 to include them in this PR, which should resolve all of the comments. 😇
iclanton
approved these changes
Jun 10, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
CredentialCachedoes not rely on the Rush user configuration; it can be used outside@rush/rush-sdk(e.g. by importing directly from@microsoft/rush-libinstead). To support these use cases, we should allow the consumer to pass a custom file path for their cache, rather than using the fixed~/.rush-user/credentials.jsonpath. This allowsCredentialCacheto be used in non-Rush codebases, or when we prefer a different location.Details
cacheFilePath?: stringoption to the CredentialCache.~/.rush-user/credentials.jsonis used.How it was tested
Added new tests to verify that default and custom paths are respected.
Impacted documentation
Only the extracted API is affected: https://api.rushstack.io/pages/rush-lib.credentialcache/.