Skip to content

Commit 92cc87d

Browse files
authored
Merge pull request #777 from salesforcecli/sm/restore-skip-connection-status
fix: skip-connection-status flag works
2 parents cea6bb6 + 8be1d03 commit 92cc87d

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/commands/org/list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
6565
public async run(): Promise<OrgListResult> {
6666
const [{ flags }, fileNames] = await Promise.all([this.parse(OrgListCommand), getAuthFileNames()]);
6767
this.flags = flags;
68-
const metaConfigs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
68+
const metaConfigs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(
69+
fileNames,
70+
flags['skip-connection-status']
71+
);
6972
const groupedSortedOrgs = {
7073
devHubs: metaConfigs.devHubs.map(decorateWithDefaultStatus).sort(comparator),
7174
other: metaConfigs.other.map(decorateWithDefaultStatus).sort(comparator),

src/shared/orgListUtil.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
ConfigAggregator,
1919
OrgConfigProperties,
2020
} from '@salesforce/core';
21-
import { Dictionary, isObject } from '@salesforce/ts-types';
21+
import { isObject } from '@salesforce/ts-types';
2222
import { Record } from 'jsforce';
2323
import { omit } from '@salesforce/kit/lib';
2424
import { getAliasByUsername } from './utils';
@@ -69,7 +69,7 @@ export class OrgListUtil {
6969
*/
7070
public static async readLocallyValidatedMetaConfigsGroupedByOrgType(
7171
userFilenames: string[],
72-
flags: Dictionary<string | boolean>
72+
skipConnection = false
7373
): Promise<OrgGroupsFullyPopulated> {
7474
const contents: AuthInfo[] = await OrgListUtil.readAuthFiles(userFilenames);
7575
const orgs = await OrgListUtil.groupOrgs(contents);
@@ -78,7 +78,7 @@ export class OrgListUtil {
7878
const [nonScratchOrgs, scratchOrgs] = await Promise.all([
7979
Promise.all(
8080
orgs.nonScratchOrgs.map(async (fields) => {
81-
if (!flags.skipconnectionstatus && fields.username) {
81+
if (!skipConnection && fields.username) {
8282
// skip completely if we're skipping the connection
8383
fields.connectedStatus = await OrgListUtil.determineConnectedStatusForNonScratchOrg(fields.username);
8484
if (!fields.isDevHub && fields.connectedStatus === 'Connected') {

test/shared/orgListUtil.test.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ describe('orgListUtil tests', () => {
128128
});
129129

130130
it('readLocallyValidatedMetaConfigsGroupedByOrgType', async () => {
131-
const flags = {};
132-
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
131+
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
133132
expect(orgs.nonScratchOrgs.every((nonScratchOrg) => nonScratchOrg.connectedStatus !== undefined)).to.be.true;
134133
expect(orgs.scratchOrgs.length).to.equal(2);
135134
expect(orgs.scratchOrgs[0]).to.haveOwnProperty('username').to.equal('[email protected]');
@@ -143,8 +142,7 @@ describe('orgListUtil tests', () => {
143142
});
144143

145144
it('skipconnectionstatus', async () => {
146-
const flags = { skipconnectionstatus: true };
147-
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
145+
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, true);
148146

149147
// we didn't check the status, so the hub is still not known to be a devhub
150148
expect(orgs.nonScratchOrgs[0].isDevHub).to.be.false;
@@ -155,9 +153,17 @@ describe('orgListUtil tests', () => {
155153
expect(determineConnectedStatusForNonScratchOrg.called).to.be.false;
156154
});
157155

156+
it('skipconnectionstatus with default', async () => {
157+
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames);
158+
expect(orgs.nonScratchOrgs.every((org) => org.connectedStatus !== undefined)).to.be.true;
159+
expect(orgs.other.every((org) => org.connectedStatus !== undefined)).to.be.true;
160+
expect(orgs.sandboxes.every((org) => org.connectedStatus !== undefined)).to.be.true;
161+
162+
expect(determineConnectedStatusForNonScratchOrg.called).to.be.true;
163+
});
164+
158165
it('should omit sensitive information and catergorise active and non-active scracth orgs', async () => {
159-
const flags = {};
160-
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
166+
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
161167

162168
expect(orgs.scratchOrgs[0]).to.not.haveOwnProperty('clientSecret');
163169
expect(orgs.scratchOrgs[1]).to.not.haveOwnProperty('clientSecret');
@@ -166,15 +172,13 @@ describe('orgListUtil tests', () => {
166172
});
167173

168174
it('should execute queries to check for org information if --verbose is used', async () => {
169-
const flags = { verbose: true };
170-
await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
175+
await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, true);
171176
expect(retrieveScratchOrgInfoFromDevHubStub.calledOnce).to.be.true;
172177
expect(spies.get('reduceScratchOrgInfo').calledOnce).to.be.true;
173178
});
174179

175180
it('execute queries should add information to grouped orgs', async () => {
176-
const flags = { verbose: true };
177-
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
181+
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, true);
178182
expect(retrieveScratchOrgInfoFromDevHubStub.calledOnce).to.be.true;
179183
expect(spies.get('reduceScratchOrgInfo').calledOnce).to.be.true;
180184
expect(orgGroups.scratchOrgs[0].signupUsername).to.equal(orgAuthConfigFields.username);
@@ -198,7 +202,7 @@ describe('orgListUtil tests', () => {
198202
stubMethod(sandbox, Org.prototype, 'getUsername').returns(devHubConfigFields.username);
199203
stubMethod(sandbox, Org.prototype, 'refreshAuth').rejects({ message: 'bad auth' });
200204

201-
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, {});
205+
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
202206
expect(orgGroups.nonScratchOrgs).to.have.length(1);
203207
expect(orgGroups.nonScratchOrgs[0].connectedStatus).to.equal('bad auth');
204208
expect(checkNonScratchOrgIsDevHub.called).to.be.false;
@@ -208,7 +212,7 @@ describe('orgListUtil tests', () => {
208212
determineConnectedStatusForNonScratchOrg.restore();
209213
stubMethod(sandbox, Org, 'create').rejects({ message: 'bad file' });
210214

211-
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, {});
215+
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
212216
expect(orgGroups.nonScratchOrgs).to.have.length(1);
213217
expect(orgGroups.nonScratchOrgs[0].connectedStatus).to.equal('bad file');
214218
expect(checkNonScratchOrgIsDevHub.called).to.be.false;

0 commit comments

Comments
 (0)