Skip to content

[rush-lib] Add support for custom CredentialCache paths #5240

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

Merged
merged 12 commits into from
Jun 10, 2025

Conversation

delilahw
Copy link
Member

@delilahw delilahw commented May 30, 2025

Summary

The CredentialCache does not rely on the Rush user configuration; it can be used outside @rush/rush-sdk (e.g. by importing directly from @microsoft/rush-lib instead). 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.json path. This allows CredentialCache to be used in non-Rush codebases, or when we prefer a different location.

Details

  • Add a cacheFilePath?: string option to the CredentialCache.
    • When this option is omitted (or falsy), the default path ~/.rush-user/credentials.json is used.
  • Move the inline Jest snapshots to a separate file.

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/.

delilahw added 3 commits May 30, 2025 14:16
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 delilahw marked this pull request as ready for review May 30, 2025 06:05
Reverts unintended change in lockfile path.
Copy link
Member Author

@delilahw delilahw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 iclanton merged commit df3ea98 into microsoft:main Jun 10, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants