-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hide secrets in
yarn config
commands (#1228)
* feat: hide secrets in `yarn config` commands * chore(release-workflow): set releases * refactor: change `getSecret` to `getForDisplay` * test: add test for hiding secrets
- Loading branch information
1 parent
b22a72c
commit 4daea78
Showing
8 changed files
with
136 additions
and
29 deletions.
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