diff --git a/package.json b/package.json index e9a303a1..5a780954 100644 --- a/package.json +++ b/package.json @@ -5,18 +5,20 @@ "author": "Salesforce", "bugs": "https://github.com/forcedotcom/cli/issues", "dependencies": { - "@oclif/core": "^0.5.21", - "@salesforce/core": "v3-beta", + "@oclif/core": "^0.5.26", + "@salesforce/core": "^3.3.4", + "cli-ux": "^5.6.3", "open": "^8.2.0", "tslib": "^2" }, "devDependencies": { "@oclif/plugin-command-snapshot": "2.2.2", "@oclif/test": "^1.2.8", - "@salesforce/cli-plugins-testkit": "^1.1.4", + "@salesforce/cli-plugins-testkit": "^1.2.0", "@salesforce/dev-config": "^2.1.2", "@salesforce/dev-scripts": "^0.9.18", "@salesforce/plugin-command-reference": "^1.3.0", + "@salesforce/plugin-config": "^2.0.4", "@salesforce/prettier-config": "^0.0.2", "@salesforce/ts-sinon": "1.3.21", "@types/shelljs": "^0.8.8", @@ -75,7 +77,8 @@ "devPlugins": [ "@oclif/plugin-help", "@oclif/plugin-command-snapshot", - "@salesforce/plugin-command-reference" + "@salesforce/plugin-command-reference", + "@salesforce/plugin-config" ], "topics": { "env": { @@ -102,7 +105,7 @@ "test:command-reference": "./bin/dev commandreference:generate --erroronwarnings", "test:deprecation-policy": "./bin/dev snapshot:compare", "test:json-schema": "./bin/dev schema:compare", - "test:nuts": "yarn build && nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel", + "test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel", "version": "oclif readme" }, "husky": { diff --git a/src/commands/env/list.ts b/src/commands/env/list.ts index 4fc11285..fa60a426 100644 --- a/src/commands/env/list.ts +++ b/src/commands/env/list.ts @@ -7,7 +7,7 @@ import { Command, Flags } from '@oclif/core'; import { cli, Table } from 'cli-ux'; -import { AuthInfo, SfOrg, Messages, SfdxError } from '@salesforce/core'; +import { AuthInfo, SfOrg, Messages, SfdxError, ConfigAggregator } from '@salesforce/core'; Messages.importMessagesDirectory(__dirname); const messages = Messages.loadMessages('@salesforce/plugin-env', 'list'); @@ -51,11 +51,15 @@ export default class EnvList extends Command { public async run(): Promise { const { flags } = await this.parse(EnvList); - let authorizations: SfOrg[]; + let authorizations: Array; + const config = (await ConfigAggregator.create()).getConfigInfo(); try { if (await AuthInfo.hasAuthentications()) { authorizations = await AuthInfo.listAllAuthorizations(); + for (const auth of authorizations) { + auth.configs = config.filter((c) => c.value === auth.alias || c.value === auth.username).map((c) => c.key); + } const hasErrors = authorizations.some((auth) => !!auth.error); const columns = { alias: { @@ -71,11 +75,14 @@ export default class EnvList extends Command { oauthMethod: { header: 'OAuth Method', }, + configs: { + header: 'Config', + get: (row: { configs?: string[] }) => (row.configs ? row.configs.join(', ') : ''), + }, } as Table.table.Columns>; if (hasErrors) { columns.error = { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access - get: (row) => row.error ?? '', + get: (row: { error?: string }) => row.error ?? '', } as Table.table.Columns>; } diff --git a/test/commands/env/display.nut.ts b/test/commands/env/display.nut.ts index 37169302..e8ac81d5 100644 --- a/test/commands/env/display.nut.ts +++ b/test/commands/env/display.nut.ts @@ -5,17 +5,23 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as path from 'path'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; -import { ConfigAggregator } from '@salesforce/core'; +import { SfdxPropertyKeys } from '@salesforce/core'; +import { env } from '@salesforce/kit'; import { expect } from 'chai'; describe('env display NUTs', () => { let session: TestSession; let usernameOrAlias: string; before(async () => { + env.setString('TESTKIT_EXECUTABLE_PATH', path.join(process.cwd(), 'bin', 'dev')); session = await TestSession.create({}); - usernameOrAlias = ConfigAggregator.getValue('defaultdevhubusername').value as string; + const config = execCmd>(`config get ${SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME} --json`, { + cli: 'sf', + }).jsonOutput; + usernameOrAlias = config[0].value; if (!usernameOrAlias) throw Error('no default username set'); }); diff --git a/test/commands/env/list.nut.ts b/test/commands/env/list.nut.ts index 545376db..5e87db84 100644 --- a/test/commands/env/list.nut.ts +++ b/test/commands/env/list.nut.ts @@ -5,17 +5,23 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as path from 'path'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; -import { ConfigAggregator } from '@salesforce/core'; +import { SfdxPropertyKeys } from '@salesforce/core'; +import { env } from '@salesforce/kit'; import { expect } from 'chai'; describe('env list NUTs', () => { let session: TestSession; let usernameOrAlias: string; before(async () => { + env.setString('TESTKIT_EXECUTABLE_PATH', path.join(process.cwd(), 'bin', 'dev')); session = await TestSession.create({}); - usernameOrAlias = ConfigAggregator.getValue('defaultdevhubusername').value as string; + const config = execCmd>(`config get ${SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME} --json`, { + cli: 'sf', + }).jsonOutput; + usernameOrAlias = config[0].value; if (!usernameOrAlias) throw Error('no default username set'); }); diff --git a/test/commands/env/open.nut.ts b/test/commands/env/open.nut.ts index 64609665..554a4e5b 100644 --- a/test/commands/env/open.nut.ts +++ b/test/commands/env/open.nut.ts @@ -5,17 +5,23 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as path from 'path'; import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; -import { ConfigAggregator } from '@salesforce/core'; +import { SfdxPropertyKeys } from '@salesforce/core'; +import { env } from '@salesforce/kit'; import { expect } from 'chai'; describe('env open NUTs', () => { let session: TestSession; let usernameOrAlias: string; before(async () => { + env.setString('TESTKIT_EXECUTABLE_PATH', path.join(process.cwd(), 'bin', 'dev')); session = await TestSession.create({}); - usernameOrAlias = ConfigAggregator.getValue('defaultdevhubusername').value as string; + const config = execCmd>(`config get ${SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME} --json`, { + cli: 'sf', + }).jsonOutput; + usernameOrAlias = config[0].value; if (!usernameOrAlias) throw Error('no default username set'); }); diff --git a/yarn.lock b/yarn.lock index 06ecab3d..1326ab70 100644 --- a/yarn.lock +++ b/yarn.lock @@ -454,7 +454,7 @@ is-wsl "^2.1.1" tslib "^2.0.0" -"@oclif/core@^0.5.19", "@oclif/core@^0.5.21": +"@oclif/core@^0.5.19": version "0.5.21" resolved "https://registry.npmjs.org/@oclif/core/-/core-0.5.21.tgz#9686b899fb8431275f3aa357ff110f8e6f2c968d" integrity sha512-bfwh2ow3XeTgYXjV0h2dn5mq9261WZ/iaY0p2wL2lvRfMAFvGc1AbN5Wfd5s2hDhvU+dMP7fbHB1ymbTBJM5Ig== @@ -477,6 +477,29 @@ widest-line "^3.1.0" wrap-ansi "^7.0.0" +"@oclif/core@^0.5.26": + version "0.5.26" + resolved "https://registry.npmjs.org/@oclif/core/-/core-0.5.26.tgz#9fe166a70aec59308f6fa12540fc6eee88246b8a" + integrity sha512-huHSYO67jbhh4SJda8xB8ia9G/i7jpfNpI7NwGnHv5RLyeoA3DcPNr1bU8wwvvD4+xKk2u7XjjKFtoR2sZR4eA== + dependencies: + "@oclif/linewrap" "^1.0.0" + chalk "^4.1.0" + clean-stack "^3.0.0" + cli-ux "^5.1.0" + debug "^4.1.1" + fs-extra "^9.0.1" + get-package-type "^0.1.0" + globby "^11.0.1" + indent-string "^4.0.0" + is-wsl "^2.1.1" + lodash.template "^4.4.0" + semver "^7.3.2" + string-width "^4.2.0" + strip-ansi "^6.0.0" + tslib "^2.0.0" + widest-line "^3.1.0" + wrap-ansi "^7.0.0" + "@oclif/dev-cli@^1": version "1.26.0" resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.26.0.tgz#e3ec294b362c010ffc8948003d3770955c7951fd" @@ -626,18 +649,17 @@ mv "~2" safe-json-stringify "~1" -"@salesforce/cli-plugins-testkit@^1.1.4": - version "1.1.5" - resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-1.1.5.tgz#d4ff270e3dce6bc9b2abdb9fbd7c315a24be541c" - integrity sha512-FgUsyQlP6y8sqBD6k7loj1i+xbuKlRI6LDKU7R1YCdRH5rSRJejrO3jheaasLeT3uoWerAyqrfmvQTV/GlDywQ== +"@salesforce/cli-plugins-testkit@^1.2.0": + version "1.2.1" + resolved "https://registry.npmjs.org/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-1.2.1.tgz#c25ba3780f9e42386d8b563519b2fb8278b26088" + integrity sha512-hD1VdDT2qUIPTy+pGU8Ot43TJwMMBrkrysgh8Wuf8KRcF9UtNv76mdg2f+6aYKmKmMeJQVhnnswb43RJXns2Dg== dependencies: - "@salesforce/core" "^2.20.3" - "@salesforce/kit" "^1.4.5" - "@salesforce/ts-types" "^1.5.5" + "@salesforce/core" "^2.24.0" + "@salesforce/kit" "^1.5.13" + "@salesforce/ts-types" "^1.5.17" archiver "^5.2.0" debug "^4.3.1" shelljs "^0.8.4" - sinon "^10.0.0" strip-ansi "6.0.0" "@salesforce/command@^3.0.0": @@ -656,7 +678,7 @@ chalk "^2.4.2" cli-ux "^4.9.3" -"@salesforce/core@^2.2.0", "@salesforce/core@^2.20.3", "@salesforce/core@^2.23.4": +"@salesforce/core@^2.2.0", "@salesforce/core@^2.23.4": version "2.24.0" resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.24.0.tgz#b414731223fbd418e4db065959f73662dfd2a1bc" integrity sha512-bdN9RNeS/8msA8U+F/6GEEteGNeE/uwc/av9nFSL0u+jyzA9llKnqKcuuAKa8YKuS1WHYfWs4mDNXST1gj+c1A== @@ -673,10 +695,31 @@ mkdirp "1.0.4" sfdx-faye "^1.0.9" -"@salesforce/core@v3-beta": - version "3.3.3" - resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.3.3.tgz#8c0acdf0268d3c634e48c54c2caf6b883f1e7059" - integrity sha512-eUbkLO+40o5B9EmrAReaS8jJLY2OkrZZlaVzDOXb4VpnsCOLjvI2aZHrDoIoghm99u7/8Usggkvfo4o1N4Ga9w== +"@salesforce/core@^2.24.0": + version "2.26.1" + resolved "https://registry.npmjs.org/@salesforce/core/-/core-2.26.1.tgz#00ecf0d989308786dcee648da231c528e6346c09" + integrity sha512-Ltswt8HWqIOS0NKZ7ggsYXD8X/nq/6uYO8REzj7g7HdZR+/GIrFUzRdJZ9ACjVGZpjkYLNN6E7ncyoy/Uudiww== + dependencies: + "@salesforce/bunyan" "^2.0.0" + "@salesforce/kit" "^1.5.0" + "@salesforce/schemas" "^1.0.1" + "@salesforce/ts-types" "^1.5.13" + "@types/graceful-fs" "^4.1.5" + "@types/jsforce" "^1.9.29" + "@types/mkdirp" "^1.0.1" + debug "^3.1.0" + graceful-fs "^4.2.4" + jsen "0.6.6" + jsforce "^1.10.1" + jsonwebtoken "8.5.0" + mkdirp "1.0.4" + sfdx-faye "^1.0.9" + ts-retry-promise "^0.6.0" + +"@salesforce/core@^3.3.4": + version "3.3.4" + resolved "https://registry.npmjs.org/@salesforce/core/-/core-3.3.4.tgz#9d8bb10b4691d52b70c3b56e7155ffa7272271ab" + integrity sha512-rs5Vev5dO1CUEVhy4MSNPtmbVN9JZI7ypc99OAmjcVCf56140o9up8XrIGjdaDZh6Xa78hGmBXs/WNZ3cchwXg== dependencies: "@salesforce/bunyan" "^2.0.0" "@salesforce/kit" "^1.5.8" @@ -740,7 +783,7 @@ typescript "^4.1.3" xunit-file "^1.0.0" -"@salesforce/kit@^1.2.2", "@salesforce/kit@^1.4.5", "@salesforce/kit@^1.5.0", "@salesforce/kit@^1.5.8": +"@salesforce/kit@^1.2.2", "@salesforce/kit@^1.5.0", "@salesforce/kit@^1.5.8": version "1.5.14" resolved "https://registry.yarnpkg.com/@salesforce/kit/-/kit-1.5.14.tgz#013853ffc53e10e7add2abfa266372b29fda8317" integrity sha512-vGzNltfWo7wtaDR0Drgf3nAMWsJ5ZheM4LODfFZeorsFk4Xj8J6hPJWuMcYUT07yCenECQalOjT0SU3p77QgYA== @@ -748,6 +791,14 @@ "@salesforce/ts-types" "^1.5.13" tslib "^2.2.0" +"@salesforce/kit@^1.5.13": + version "1.5.17" + resolved "https://registry.npmjs.org/@salesforce/kit/-/kit-1.5.17.tgz#4fd9c50ba2e072c50d319654f86f86808c544795" + integrity sha512-Uuh+v7WPSo+L21moVprl+jbDTl3ndmcJM5et/vFLZW4ur6CCJCJSoReM9ttF1qZuQskyCyhVZo6/aMZrVUe+rQ== + dependencies: + "@salesforce/ts-types" "^1.5.20" + tslib "^2.2.0" + "@salesforce/plugin-command-reference@^1.3.0": version "1.3.4" resolved "https://registry.yarnpkg.com/@salesforce/plugin-command-reference/-/plugin-command-reference-1.3.4.tgz#a67358868c512784542cdc7cd802778150322103" @@ -762,6 +813,17 @@ handlebars "^4.7.3" tslib "^1" +"@salesforce/plugin-config@^2.0.4": + version "2.0.4" + resolved "https://registry.npmjs.org/@salesforce/plugin-config/-/plugin-config-2.0.4.tgz#cefde0b73eeb077ca603c227b4605fde0b9b0f95" + integrity sha512-HX/ds/M2g0UJrRIRCbDOr+9HuTD88SXbBe6kIVIy64LnqQz8Q8f8HYY2/c0zzxJ4Hq2VZIoANbY/1g7w/ppofA== + dependencies: + "@oclif/core" "^0.5.26" + "@salesforce/core" "^3.3.4" + chalk "^4.1.1" + cli-ux "^5.6.3" + tslib "^2" + "@salesforce/prettier-config@^0.0.2": version "0.0.2" resolved "https://registry.yarnpkg.com/@salesforce/prettier-config/-/prettier-config-0.0.2.tgz#ded39bf7cb75238edc9db6dd093649111350f8bc" @@ -781,7 +843,7 @@ sinon "^5.1.1" tslib "^2.2.0" -"@salesforce/ts-types@^1.2.0", "@salesforce/ts-types@^1.5.13", "@salesforce/ts-types@^1.5.20", "@salesforce/ts-types@^1.5.5": +"@salesforce/ts-types@^1.2.0", "@salesforce/ts-types@^1.5.13", "@salesforce/ts-types@^1.5.17", "@salesforce/ts-types@^1.5.20": version "1.5.20" resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-1.5.20.tgz#f6875a710ceca48223b240026a14af6d3b39882f" integrity sha512-Ov6um4CWd63EvkRavkHG0J/P9XYL55sdkDWPMr7+AIgqh5flHxDRz09/C4e9M94aX30rzJxW4TVX6EBf4Cu2BQ== @@ -842,7 +904,7 @@ lodash.get "^4.4.2" type-detect "^4.0.8" -"@sinonjs/samsam@^6.0.1", "@sinonjs/samsam@^6.0.2": +"@sinonjs/samsam@^6.0.2": version "6.0.2" resolved "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.0.2.tgz#a0117d823260f282c04bff5f8704bdc2ac6910bb" integrity sha512-jxPRPp9n93ci7b8hMfJOFDPRLFYadN6FSpeROFTR4UNF4i5b+EK6m4QXPO46BDhFgRy1JuS87zAnFOzCUwMJcQ== @@ -1861,6 +1923,38 @@ cli-ux@^5.1.0, cli-ux@^5.2.1: supports-hyperlinks "^2.1.0" tslib "^2.0.0" +cli-ux@^5.6.3: + version "5.6.3" + resolved "https://registry.npmjs.org/cli-ux/-/cli-ux-5.6.3.tgz#eecdb2e0261171f2b28f2be6b18c490291c3a287" + integrity sha512-/oDU4v8BiDjX2OKcSunGH0iGDiEtj2rZaGyqNuv9IT4CgcSMyVWAMfn0+rEHaOc4n9ka78B0wo1+N1QX89f7mw== + dependencies: + "@oclif/command" "^1.6.0" + "@oclif/errors" "^1.2.1" + "@oclif/linewrap" "^1.0.0" + "@oclif/screen" "^1.0.3" + ansi-escapes "^4.3.0" + ansi-styles "^4.2.0" + cardinal "^2.1.1" + chalk "^4.1.0" + clean-stack "^3.0.0" + cli-progress "^3.4.0" + extract-stack "^2.0.0" + fs-extra "^8.1" + hyperlinker "^1.0.0" + indent-string "^4.0.0" + is-wsl "^2.2.0" + js-yaml "^3.13.1" + lodash "^4.17.11" + natural-orderby "^2.0.1" + object-treeify "^1.1.4" + password-prompt "^1.1.2" + semver "^7.3.2" + string-width "^4.2.0" + strip-ansi "^6.0.0" + supports-color "^8.1.0" + supports-hyperlinks "^2.1.0" + tslib "^2.0.0" + cli-width@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" @@ -5531,7 +5625,7 @@ nise@^4.1.0: just-extend "^4.0.2" path-to-regexp "^1.7.0" -nise@^5.0.1, nise@^5.1.0: +nise@^5.1.0: version "5.1.0" resolved "https://registry.npmjs.org/nise/-/nise-5.1.0.tgz#713ef3ed138252daef20ec035ab62b7a28be645c" integrity sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ== @@ -6842,18 +6936,6 @@ sinon@10.0.0: nise "^4.1.0" supports-color "^7.1.0" -sinon@^10.0.0: - version "10.0.1" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-10.0.1.tgz#0d1a13ecb86f658d15984f84273e57745b1f4c57" - integrity sha512-1rf86mvW4Mt7JitEIgmNaLXaWnrWd/UrVKZZlL+kbeOujXVf9fmC4kQEQ/YeHoiIA23PLNngYWK+dngIx/AumA== - dependencies: - "@sinonjs/commons" "^1.8.1" - "@sinonjs/fake-timers" "^7.0.4" - "@sinonjs/samsam" "^6.0.1" - diff "^4.0.2" - nise "^5.0.1" - supports-color "^7.1.0" - sinon@^11.1.1: version "11.1.1" resolved "https://registry.npmjs.org/sinon/-/sinon-11.1.1.tgz#99a295a8b6f0fadbbb7e004076f3ae54fc6eab91" @@ -7266,9 +7348,9 @@ strip-json-comments@~2.0.1: resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= -supports-color@8.1.1: +supports-color@8.1.1, supports-color@^8.1.0: version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== dependencies: has-flag "^4.0.0"