-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: hide secrets in yarn config
commands
#1228
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2592278
feat: hide secrets in `yarn config` commands
paul-soporan 18eaf11
chore(release-workflow): set releases
paul-soporan 8a6173b
refactor: change `getSecret` to `getForDisplay`
paul-soporan 9b49f39
test: add test for hiding secrets
paul-soporan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
releases: | ||
"@yarnpkg/plugin-essentials": prerelease | ||
"@yarnpkg/cli": prerelease | ||
"@yarnpkg/core": prerelease | ||
|
||
declined: | ||
- "@yarnpkg/plugin-compat" | ||
- "@yarnpkg/plugin-constraints" | ||
- "@yarnpkg/plugin-dlx" | ||
- "@yarnpkg/plugin-exec" | ||
- "@yarnpkg/plugin-file" | ||
- "@yarnpkg/plugin-git" | ||
- "@yarnpkg/plugin-github" | ||
- "@yarnpkg/plugin-http" | ||
- "@yarnpkg/plugin-init" | ||
- "@yarnpkg/plugin-interactive-tools" | ||
- "@yarnpkg/plugin-link" | ||
- "@yarnpkg/plugin-node-modules" | ||
- "@yarnpkg/plugin-npm" | ||
- "@yarnpkg/plugin-npm-cli" | ||
- "@yarnpkg/plugin-pack" | ||
- "@yarnpkg/plugin-patch" | ||
- "@yarnpkg/plugin-pnp" | ||
- "@yarnpkg/plugin-stage" | ||
- "@yarnpkg/plugin-typescript" | ||
- "@yarnpkg/plugin-version" | ||
- "@yarnpkg/plugin-workspace-tools" | ||
- "@yarnpkg/builder" | ||
- "@yarnpkg/doctor" | ||
- "@yarnpkg/pnpify" |
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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {xfs, PortablePath} from '@yarnpkg/fslib'; | ||
import NpmPlugin from '@yarnpkg/plugin-npm'; | ||
|
||
import {Configuration, SECRET} from '../sources/Configuration'; | ||
|
||
async function initializeConfiguration<T>(value: unknown, cb: (dir: PortablePath) => Promise<T>) { | ||
return await xfs.mktempPromise(async dir => { | ||
await Configuration.updateConfiguration(dir, value); | ||
|
||
return await cb(dir); | ||
}); | ||
} | ||
|
||
describe(`Configuration`, () => { | ||
it(`should hide secrets`, async () => { | ||
await initializeConfiguration({ | ||
npmAuthToken: `my-token`, | ||
npmScopes: { | ||
myScope: { | ||
npmAuthToken: `my-token`, | ||
}, | ||
}, | ||
}, async dir => { | ||
const configuration = await Configuration.find(dir, { | ||
modules: new Map([[`@yarnpkg/plugin-npm`, NpmPlugin]]), | ||
plugins: new Set([`@yarnpkg/plugin-npm`]), | ||
}); | ||
|
||
const firstToken = configuration.getForDisplay(`npmAuthToken`); | ||
const secondToken = configuration.getForDisplay(`npmScopes`).get(`myScope`).get(`npmAuthToken`); | ||
|
||
expect(firstToken).toEqual(SECRET); | ||
expect(secondToken).toEqual(SECRET); | ||
}); | ||
}); | ||
}); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While keeping a unit test here is fine, I tend to prefer integration tests.
The reason for that is that because they are typically wider in scope, they also test behaviours closer from what real-life users will experience. For example, while you did test that
getForDisplay
works, you didn't test that it actually gets used byyarn config get
. As a result, it's quite possible for someone to make an accidental regression during a refactoring.Food for thought 🙂