diff --git a/.pnp.js b/.pnp.js index 08cfa6df3650..9bbf57a92cb6 100755 --- a/.pnp.js +++ b/.pnp.js @@ -210,7 +210,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/plugin-interactive-tools", ["workspace:packages/plugin-interactive-tools"]], ["@yarnpkg/plugin-link", ["virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-link", "workspace:packages/plugin-link"]], ["@yarnpkg/plugin-node-modules", ["virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-node-modules", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-node-modules", "workspace:packages/plugin-node-modules"]], - ["@yarnpkg/plugin-npm", ["virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm", "workspace:packages/plugin-npm"]], + ["@yarnpkg/plugin-npm", ["virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm", "workspace:packages/plugin-npm"]], ["@yarnpkg/plugin-npm-cli", ["virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-npm-cli", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm-cli", "workspace:packages/plugin-npm-cli"]], ["@yarnpkg/plugin-pack", ["virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-pack", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-pack", "workspace:packages/plugin-pack"]], ["@yarnpkg/plugin-patch", ["virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-patch", "virtual:f4e4f4a9a0213f122880195b39adaee7de5cb560c1d806ebc8bace6a3124e5b8f820bbb89ebecd4d535caeb6f527d343143210aa405689c118ff2813b78998a0#workspace:packages/plugin-patch", "workspace:packages/plugin-patch"]], @@ -6096,7 +6096,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/plugin-init", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-init"], ["@yarnpkg/plugin-link", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-link"], ["@yarnpkg/plugin-node-modules", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-node-modules"], - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-npm-cli", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm-cli"], ["@yarnpkg/plugin-pack", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-pack"], ["@yarnpkg/plugin-patch", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-patch"], @@ -6138,7 +6138,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/plugin-init", "virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-init"], ["@yarnpkg/plugin-link", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-link"], ["@yarnpkg/plugin-node-modules", "virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-node-modules"], - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-npm-cli", "virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-npm-cli"], ["@yarnpkg/plugin-pack", "virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-pack"], ["@yarnpkg/plugin-patch", "virtual:f4e4f4a9a0213f122880195b39adaee7de5cb560c1d806ebc8bace6a3124e5b8f820bbb89ebecd4d535caeb6f527d343143210aa405689c118ff2813b78998a0#workspace:packages/plugin-patch"], @@ -6177,6 +6177,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/libzip", "workspace:packages/yarnpkg-libzip"], ["@yarnpkg/parsers", "workspace:packages/yarnpkg-parsers"], ["@yarnpkg/plugin-link", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-link"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-pnp", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-pnp"], ["@yarnpkg/pnp", "workspace:packages/yarnpkg-pnp"], ["@yarnpkg/shell", "workspace:packages/yarnpkg-shell"], @@ -6935,10 +6936,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }] ]], ["@yarnpkg/plugin-npm", [ - ["virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm", { - "packageLocation": "./.yarn/$$virtual/@yarnpkg-plugin-npm-virtual-d0a5a66e87/1/packages/plugin-npm/", + ["virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm", { + "packageLocation": "./.yarn/$$virtual/@yarnpkg-plugin-npm-virtual-572569575a/1/packages/plugin-npm/", "packageDependencies": [ - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@types/inquirer", "npm:0.0.43"], ["@types/semver", "npm:7.1.0"], ["@yarnpkg/core", "workspace:packages/yarnpkg-core"], @@ -6978,7 +6979,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/cli", "workspace:packages/yarnpkg-cli"], ["@yarnpkg/core", "workspace:packages/yarnpkg-core"], ["@yarnpkg/fslib", "workspace:packages/yarnpkg-fslib"], - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-pack", "virtual:4864d30fc563f2fd1b72a5e3869493c5f50bf38f98ed3886173d80c044d981c3f68220dbf17f2b5fc5b4c5fba7d0af2e003926efe3487086484049f41c449852#workspace:packages/plugin-pack"], ["clipanion", "npm:2.1.5"], ["inquirer", "npm:6.2.1"], @@ -7007,7 +7008,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/cli", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/yarnpkg-cli"], ["@yarnpkg/core", "workspace:packages/yarnpkg-core"], ["@yarnpkg/fslib", "workspace:packages/yarnpkg-fslib"], - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-pack", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-pack"], ["clipanion", "npm:2.1.5"], ["inquirer", "npm:6.2.1"], @@ -7036,7 +7037,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@yarnpkg/cli", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/yarnpkg-cli"], ["@yarnpkg/core", "workspace:packages/yarnpkg-core"], ["@yarnpkg/fslib", "workspace:packages/yarnpkg-fslib"], - ["@yarnpkg/plugin-npm", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-npm"], + ["@yarnpkg/plugin-npm", "virtual:712d04b0098634bdb13868ff8f85b327022bd7d3880873ada8c0ae56847ed36cf9da1fd74a88519380129cec528fe2bd2201426bc28ac9d4a8cc6734ff25c538#workspace:packages/plugin-npm"], ["@yarnpkg/plugin-pack", "virtual:54c8b951e743ea46368d98ac86d4c1ac7d1aa57c9d31cbf6424fa2d918257654f26f71d51dbfe63844c533e97635ff97de50fd37e6e4bf74f2603a98754d6d22#workspace:packages/plugin-pack"], ["clipanion", "npm:2.1.5"], ["inquirer", "npm:6.2.1"], diff --git a/.yarn/versions/54448882.yml b/.yarn/versions/54448882.yml new file mode 100644 index 000000000000..00c8db08e45d --- /dev/null +++ b/.yarn/versions/54448882.yml @@ -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" diff --git a/packages/plugin-essentials/sources/commands/config.ts b/packages/plugin-essentials/sources/commands/config.ts index 0169e41b7ac4..3d267474f923 100644 --- a/packages/plugin-essentials/sources/commands/config.ts +++ b/packages/plugin-essentials/sources/commands/config.ts @@ -1,8 +1,8 @@ -import {BaseCommand} from '@yarnpkg/cli'; -import {Configuration, MessageName, SettingsType, StreamReport} from '@yarnpkg/core'; -import {miscUtils} from '@yarnpkg/core'; -import {Command, Usage} from 'clipanion'; -import {inspect} from 'util'; +import {BaseCommand} from '@yarnpkg/cli'; +import {Configuration, MessageName, StreamReport} from '@yarnpkg/core'; +import {miscUtils} from '@yarnpkg/core'; +import {Command, Usage} from 'clipanion'; +import {inspect} from 'util'; // eslint-disable-next-line arca/no-default-export export default class ConfigCommand extends BaseCommand { @@ -40,17 +40,6 @@ export default class ConfigCommand extends BaseCommand { strict: false, }); - const getValue = (key: string) => { - const isSecret = configuration.settings.get(key)!.type === SettingsType.SECRET; - const rawValue = configuration.values.get(key)!; - - if (isSecret && typeof rawValue === `string`) { - return `********`; - } else { - return rawValue; - } - }; - const report = await StreamReport.start({ configuration, json: this.json, @@ -69,7 +58,7 @@ export default class ConfigCommand extends BaseCommand { for (const key of keys) { const data = configuration.settings.get(key); - const effective = getValue(key); + const effective = configuration.getForDisplay(key); const source = configuration.sources.get(key); if (this.verbose) { @@ -107,11 +96,11 @@ export default class ConfigCommand extends BaseCommand { }, 0); for (const [key, description] of keysAndDescriptions) { - report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${description.padEnd(maxDescriptionLength, ` `)} ${inspect(getValue(key), inspectConfig)}`); + report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${description.padEnd(maxDescriptionLength, ` `)} ${inspect(configuration.getForDisplay(key), inspectConfig)}`); } } else { for (const key of keys) { - report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${inspect(getValue(key), inspectConfig)}`); + report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${inspect(configuration.getForDisplay(key), inspectConfig)}`); } } } diff --git a/packages/plugin-essentials/sources/commands/config/set.ts b/packages/plugin-essentials/sources/commands/config/set.ts index 08f849aa0808..ae2767a545dd 100644 --- a/packages/plugin-essentials/sources/commands/config/set.ts +++ b/packages/plugin-essentials/sources/commands/config/set.ts @@ -59,10 +59,12 @@ export default class ConfigSetCommand extends BaseCommand { [this.name]: value, }); + const updatedConfiguration = await Configuration.find(this.context.cwd, this.context.plugins); + // @ts-ignore: The Node typings forgot one field inspect.styles.name = `cyan`; - report.reportInfo(MessageName.UNNAMED, `Successfully set ${this.name} to:\n${inspect(value, { + report.reportInfo(MessageName.UNNAMED, `Successfully set ${this.name} to:\n${inspect(updatedConfiguration.getForDisplay(this.name), { depth: Infinity, colors: true, compact: false, diff --git a/packages/yarnpkg-core/package.json b/packages/yarnpkg-core/package.json index 95903e365e88..56e8090a7b23 100644 --- a/packages/yarnpkg-core/package.json +++ b/packages/yarnpkg-core/package.json @@ -42,6 +42,7 @@ "@types/tunnel": "^0.0.0", "@yarnpkg/cli": "workspace:^2.0.0-rc.32", "@yarnpkg/plugin-link": "workspace:^2.0.0-rc.11", + "@yarnpkg/plugin-npm": "workspace:^2.0.0-rc.18", "@yarnpkg/plugin-pnp": "workspace:^2.0.0-rc.20" }, "scripts": { diff --git a/packages/yarnpkg-core/sources/Configuration.ts b/packages/yarnpkg-core/sources/Configuration.ts index d26175dfdc24..f706811f0db9 100644 --- a/packages/yarnpkg-core/sources/Configuration.ts +++ b/packages/yarnpkg-core/sources/Configuration.ts @@ -61,6 +61,7 @@ const IGNORED_ENV_VARIABLES = new Set([ export const ENVIRONMENT_PREFIX = `yarn_`; export const DEFAULT_RC_FILENAME = toFilename(`.yarnrc.yml`); export const DEFAULT_LOCK_FILENAME = toFilename(`yarn.lock`); +export const SECRET = `********`; export enum SettingsType { ANY = 'ANY', @@ -523,6 +524,42 @@ function getDefaultValue(configuration: Configuration, definition: SettingsDefin } } +function hideSecrets(rawValue: unknown, definition: SettingsDefinitionNoDefault) { + if (definition.type === SettingsType.SECRET && typeof rawValue === `string`) + return SECRET; + + if (definition.isArray && Array.isArray(rawValue)) { + const newValue: Array = []; + + for (const value of rawValue) + newValue.push(hideSecrets(value, definition)); + + return newValue; + } + + if (definition.type === SettingsType.MAP && rawValue instanceof Map) { + const newValue: Map = new Map(); + + for (const [key, value] of rawValue.entries()) + newValue.set(key, hideSecrets(value, definition.valueDefinition)); + + return newValue; + } + + if (definition.type === SettingsType.SHAPE && rawValue instanceof Map) { + const newValue: Map = new Map(); + + for (const [key, value] of rawValue.entries()) { + const propertyDefinition = definition.properties[key]; + newValue.set(key, hideSecrets(value, propertyDefinition)); + } + + return newValue; + } + + return rawValue; +}; + function getEnvironmentSettings() { const environmentSettings: {[key: string]: any} = {}; @@ -929,6 +966,16 @@ export class Configuration { return this.values.get(key) as T; } + getForDisplay(key: string) { + const rawValue = this.get(key); + const definition = this.settings.get(key); + + if (typeof definition === `undefined`) + throw new UsageError(`Couldn't find a configuration settings named "${key}"`); + + return hideSecrets(rawValue, definition) as T; + } + getSubprocessStreams(logFile: PortablePath, {header, prefix, report}: {header?: string, prefix: string, report: Report}) { let stdout: Writable; let stderr: Writable; diff --git a/packages/yarnpkg-core/tests/Configuration.test.ts b/packages/yarnpkg-core/tests/Configuration.test.ts new file mode 100644 index 000000000000..b3b77ca63b93 --- /dev/null +++ b/packages/yarnpkg-core/tests/Configuration.test.ts @@ -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(value: unknown, cb: (dir: PortablePath) => Promise) { + 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); + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index 7b29cb8f8b31..5dc7504303d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5144,6 +5144,7 @@ __metadata: "@yarnpkg/libzip": "workspace:^2.0.0-rc.11" "@yarnpkg/parsers": "workspace:^2.0.0-rc.11" "@yarnpkg/plugin-link": "workspace:^2.0.0-rc.11" + "@yarnpkg/plugin-npm": "workspace:^2.0.0-rc.18" "@yarnpkg/plugin-pnp": "workspace:^2.0.0-rc.20" "@yarnpkg/pnp": "workspace:^2.0.0-rc.19" "@yarnpkg/shell": "workspace:^2.0.0-rc.11"