From 2a6353fd8ad6d16215aeed31703dac63847f77d4 Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Tue, 20 Jul 2021 10:57:22 -0600 Subject: [PATCH 1/8] fix: renamte flag --environment to --target-env @W-9623159@ --- command-snapshot.json | 2 +- messages/display.md | 12 ++++++------ src/commands/env/display.ts | 15 ++++++++------- test/commands/env/display.test.ts | 10 +++++----- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/command-snapshot.json b/command-snapshot.json index 0bc89c1f..ff82d63e 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -2,7 +2,7 @@ { "command": "env:display", "plugin": "@salesforce/plugin-env", - "flags": ["environment", "json"] + "flags": ["json", "target-env"] }, { "command": "env:list", diff --git a/messages/display.md b/messages/display.md index cd982cf6..4f85a85e 100644 --- a/messages/display.md +++ b/messages/display.md @@ -1,26 +1,26 @@ # summary - + Display details about an environment. # description Specify an environment with either the username you used when you ran the "sf login" command or the environment's alias. Run "sf env list" to view all your environments and their aliases. -Output depends on the type of environment. For example, scratch org details include the access token, alias, username of the associated Dev Hub, the creation and expiration date, the generated scratch org username, and more. Compute environment details include the associated orgs, the list of functions, the project name, and more. +Output depends on the type of environment. For example, scratch org details include the access token, alias, username of the associated Dev Hub, the creation and expiration date, the generated scratch org username, and more. Compute environment details include the associated orgs, the list of functions, the project name, and more. # examples - Display details about a scratch org with alias my-scratch-org: - <%= config.bin %> <%= command.id %> --environment=my-scratch-org +<%= config.bin %> <%= command.id %> --environment=my-scratch-org - Specify a username instead of an alias: - <%= config.bin %> <%= command.id %> --environment=test-123456-abcdefg@example.com +<%= config.bin %> <%= command.id %> --environment=test-123456-abcdefg@example.com - Specify JSON format and redirect output into a file: - <%= config.bin %> <%= command.id %> --environment=my-scratch-org --json > tmp/MyOrdDesc.json +<%= config.bin %> <%= command.id %> --environment=my-scratch-org --json > tmp/MyOrdDesc.json # flags.environment.summary @@ -36,7 +36,7 @@ No environment found for %s. # error.NoDefaultEnv -No default environment found. Use -e or --environment to specify an environment to open. +No default environment found. Use -e or --target-env to specify an environment to open. # error.NoAuthsAvailable diff --git a/src/commands/env/display.ts b/src/commands/env/display.ts index 647b89b7..dfdfd266 100644 --- a/src/commands/env/display.ts +++ b/src/commands/env/display.ts @@ -17,7 +17,7 @@ export default class EnvDisplay extends Command { public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); public static flags = { - environment: Flags.string({ + 'target-env': Flags.string({ char: 'e', description: messages.getMessage('flags.environment.summary'), }), @@ -35,15 +35,16 @@ export default class EnvDisplay extends Command { if (await AuthInfo.hasAuthentications()) { authorizations = await AuthInfo.listAllAuthorizations(); - if (!flags.environment) { + const targetEnv = Reflect.get(flags, 'target-env') as string; + + if (!targetEnv) { // TODO this should be retrieved from sf config once we have those commands. If not found, still throw. throw messages.createError('error.NoDefaultEnv'); } - foundAuthorization = authorizations.filter((auth) => auth.username === flags.environment)[0]; - if (!foundAuthorization) { - foundAuthorization = authorizations.filter((auth) => auth.alias === flags.environment)[0]; - } + foundAuthorization = + authorizations.find((auth) => auth.username === targetEnv) ?? + authorizations.find((auth) => auth.alias === targetEnv); if (foundAuthorization) { const columns = { @@ -61,7 +62,7 @@ export default class EnvDisplay extends Command { ); } } else { - throw new SfdxError(messages.getMessage('error.NoEnvFound', [flags.environment])); + throw new SfdxError(messages.getMessage('error.NoEnvFound', [targetEnv])); } } else { throw messages.createError('error.NoAuthsAvailable'); diff --git a/test/commands/env/display.test.ts b/test/commands/env/display.test.ts index 429b529c..e8edb705 100644 --- a/test/commands/env/display.test.ts +++ b/test/commands/env/display.test.ts @@ -37,7 +37,7 @@ describe('display unit tests', () => { .stub(AuthInfo, 'hasAuthentications', async (): Promise => true) .stub(AuthInfo, 'listAllAuthorizations', async (): Promise>> => expectedSfOrgs) .stdout() - .command(['env:display', '--environment', expectedSfOrgs[0].username, '--json']) + .command(['env:display', '--target-env', expectedSfOrgs[0].username, '--json']) .it('should fetch requested username with json output', (ctx) => { const sfOrgs = JSON.parse(ctx.stdout) as Array>; expect(sfOrgs).to.be.deep.equal(expectedSfOrgs[0]); @@ -46,7 +46,7 @@ describe('display unit tests', () => { .stub(AuthInfo, 'hasAuthentications', async (): Promise => true) .stub(AuthInfo, 'listAllAuthorizations', async (): Promise>> => expectedSfOrgs) .stdout() - .command(['env:display', '--environment', expectedSfOrgs[0].username]) + .command(['env:display', '--target-env', expectedSfOrgs[0].username]) .it('should fetch requested username with human output', (ctx) => { const stdout = ctx.stdout; expectedSfOrgs.slice(0, 1).forEach((sfOrg) => { @@ -61,7 +61,7 @@ describe('display unit tests', () => { .stub(AuthInfo, 'hasAuthentications', async (): Promise => true) .stub(AuthInfo, 'listAllAuthorizations', async (): Promise>> => expectedSfOrgs) .stdout() - .command(['env:display', '--environment', expectedSfOrgs[1].alias]) + .command(['env:display', '--target-env', expectedSfOrgs[1].alias]) .it('should fetch requested alias with human output', (ctx) => { const stdout = ctx.stdout; expectedSfOrgs.slice(1).forEach((sfOrg) => { @@ -81,8 +81,8 @@ describe('display unit tests', () => { .command(['env:display']) .catch((error) => expect(error.message).to.to.include( - 'No default environment found. Use -e or --environment to specify an environment to open.' + 'No default environment found. Use -e or --target-env to specify an environment to open.' ) ) - .it('should throw error if --environment is not specified'); + .it('should throw error if --target-env is not specified'); }); From 5f2d496e097802c6b00e701937d551f028123438 Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Tue, 20 Jul 2021 11:07:04 -0600 Subject: [PATCH 2/8] chore: fix messages --- messages/display.md | 8 ++++---- src/commands/env/display.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/messages/display.md b/messages/display.md index 4f85a85e..833596ae 100644 --- a/messages/display.md +++ b/messages/display.md @@ -12,17 +12,17 @@ Output depends on the type of environment. For example, scratch org details incl - Display details about a scratch org with alias my-scratch-org: -<%= config.bin %> <%= command.id %> --environment=my-scratch-org +<%= config.bin %> <%= command.id %> --target-env=my-scratch-org - Specify a username instead of an alias: -<%= config.bin %> <%= command.id %> --environment=test-123456-abcdefg@example.com +<%= config.bin %> <%= command.id %> --target-env=test-123456-abcdefg@example.com - Specify JSON format and redirect output into a file: -<%= config.bin %> <%= command.id %> --environment=my-scratch-org --json > tmp/MyOrdDesc.json +<%= config.bin %> <%= command.id %> --target-env=my-scratch-org --json > tmp/MyOrdDesc.json -# flags.environment.summary +# flags.target-env.summary Environment alias or login user. diff --git a/src/commands/env/display.ts b/src/commands/env/display.ts index dfdfd266..7ce7263c 100644 --- a/src/commands/env/display.ts +++ b/src/commands/env/display.ts @@ -19,7 +19,7 @@ export default class EnvDisplay extends Command { public static flags = { 'target-env': Flags.string({ char: 'e', - description: messages.getMessage('flags.environment.summary'), + description: messages.getMessage('flags.target-env.summary'), }), }; From f6743dc2fa4c6eecb3be0ac74ab3b41e9509f216 Mon Sep 17 00:00:00 2001 From: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com> Date: Tue, 20 Jul 2021 10:43:34 -0700 Subject: [PATCH 3/8] fix help for "sf env display" --- messages/display.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/messages/display.md b/messages/display.md index 4f85a85e..7faf3f6c 100644 --- a/messages/display.md +++ b/messages/display.md @@ -12,17 +12,17 @@ Output depends on the type of environment. For example, scratch org details incl - Display details about a scratch org with alias my-scratch-org: -<%= config.bin %> <%= command.id %> --environment=my-scratch-org + <%= config.bin %> <%= command.id %> --target-env=my-scratch-org - Specify a username instead of an alias: -<%= config.bin %> <%= command.id %> --environment=test-123456-abcdefg@example.com + <%= config.bin %> <%= command.id %> --target-env=test-123456-abcdefg@example.com - Specify JSON format and redirect output into a file: -<%= config.bin %> <%= command.id %> --environment=my-scratch-org --json > tmp/MyOrdDesc.json + <%= config.bin %> <%= command.id %> --target-env=my-scratch-org --json > tmp/MyOrdDesc.json -# flags.environment.summary +# flags.target-env.summary Environment alias or login user. From efaa210d2679fc453505417d09ee3f717e970767 Mon Sep 17 00:00:00 2001 From: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com> Date: Tue, 20 Jul 2021 10:44:37 -0700 Subject: [PATCH 4/8] new name for --target-env flag description --- src/commands/env/display.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/env/display.ts b/src/commands/env/display.ts index dfdfd266..7ce7263c 100644 --- a/src/commands/env/display.ts +++ b/src/commands/env/display.ts @@ -19,7 +19,7 @@ export default class EnvDisplay extends Command { public static flags = { 'target-env': Flags.string({ char: 'e', - description: messages.getMessage('flags.environment.summary'), + description: messages.getMessage('flags.target-env.summary'), }), }; From ddf1e584705c8b1e9217b1ea428548372002b19a Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Wed, 21 Jul 2021 06:05:43 -0600 Subject: [PATCH 5/8] chore: prefer indexed access over reflect.get --- src/commands/env/display.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/env/display.ts b/src/commands/env/display.ts index 7ce7263c..5ffe0a3e 100644 --- a/src/commands/env/display.ts +++ b/src/commands/env/display.ts @@ -35,7 +35,7 @@ export default class EnvDisplay extends Command { if (await AuthInfo.hasAuthentications()) { authorizations = await AuthInfo.listAllAuthorizations(); - const targetEnv = Reflect.get(flags, 'target-env') as string; + const targetEnv = flags['target-env']; if (!targetEnv) { // TODO this should be retrieved from sf config once we have those commands. If not found, still throw. From 8374266d978f020abe1d116bd901c167b4d264e1 Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Wed, 21 Jul 2021 10:15:03 -0600 Subject: [PATCH 6/8] chore: renamte --evironment to --target-env in nuts --- test/commands/env/display.nut.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/commands/env/display.nut.ts b/test/commands/env/display.nut.ts index b77d6e6b..37169302 100644 --- a/test/commands/env/display.nut.ts +++ b/test/commands/env/display.nut.ts @@ -25,7 +25,7 @@ describe('env display NUTs', () => { }); it('should display dev hub', () => { - const command = `env display --environment ${usernameOrAlias}`; + const command = `env display --target-env ${usernameOrAlias}`; const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; expect(output).to.contain(usernameOrAlias); }); From 31556937f81838a5e807776df7746e2482d241db Mon Sep 17 00:00:00 2001 From: Peter Hale Date: Wed, 21 Jul 2021 10:22:26 -0600 Subject: [PATCH 7/8] chore: add nut job to test-and-release --- .circleci/config.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ed0df807..e30244fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ parameters: default: '' type: string repo_tag: - description: 'The tag of the module repo to checkout, '''' defaults to branch/PR' + description: "The tag of the module repo to checkout, '' defaults to branch/PR" default: '' type: string workflows: @@ -55,6 +55,18 @@ workflows: node_version: lts - os: windows node_version: maintenance + - release-management/test-nut: + name: nuts-on-linux + sfdx_version: latest + requires: + - release-management/test-package + - release-management/test-nut: + name: nuts-on-windows + sfdx_version: latest + os: windows + node_version: lts + requires: + - release-management/test-package - release-management/release-package: sign: true github-release: true From 8e091ec161d9d801719a2968839720590fbb69a1 Mon Sep 17 00:00:00 2001 From: peternhale Date: Wed, 21 Jul 2021 10:43:43 -0600 Subject: [PATCH 8/8] Update .circleci/config.yml Co-authored-by: Rodrigo Espinosa de los Monteros <1084688+RodEsp@users.noreply.github.com> --- .circleci/config.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e30244fc..f2f8fdbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,15 +56,15 @@ workflows: - os: windows node_version: maintenance - release-management/test-nut: - name: nuts-on-linux - sfdx_version: latest - requires: - - release-management/test-package - - release-management/test-nut: - name: nuts-on-windows - sfdx_version: latest - os: windows - node_version: lts + matrix: + parameters: + os: + - linux + - windows + sfdx_version: + - latest + node_version: + - latest requires: - release-management/test-package - release-management/release-package: