Skip to content

Commit 817cd5b

Browse files
committed
fix: skip-connection-status flag works
1 parent cea6bb6 commit 817cd5b

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-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: 7 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;
@@ -156,8 +154,7 @@ describe('orgListUtil tests', () => {
156154
});
157155

158156
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);
157+
const orgs = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
161158

162159
expect(orgs.scratchOrgs[0]).to.not.haveOwnProperty('clientSecret');
163160
expect(orgs.scratchOrgs[1]).to.not.haveOwnProperty('clientSecret');
@@ -166,15 +163,13 @@ describe('orgListUtil tests', () => {
166163
});
167164

168165
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);
166+
await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, true);
171167
expect(retrieveScratchOrgInfoFromDevHubStub.calledOnce).to.be.true;
172168
expect(spies.get('reduceScratchOrgInfo').calledOnce).to.be.true;
173169
});
174170

175171
it('execute queries should add information to grouped orgs', async () => {
176-
const flags = { verbose: true };
177-
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, flags);
172+
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, true);
178173
expect(retrieveScratchOrgInfoFromDevHubStub.calledOnce).to.be.true;
179174
expect(spies.get('reduceScratchOrgInfo').calledOnce).to.be.true;
180175
expect(orgGroups.scratchOrgs[0].signupUsername).to.equal(orgAuthConfigFields.username);
@@ -198,7 +193,7 @@ describe('orgListUtil tests', () => {
198193
stubMethod(sandbox, Org.prototype, 'getUsername').returns(devHubConfigFields.username);
199194
stubMethod(sandbox, Org.prototype, 'refreshAuth').rejects({ message: 'bad auth' });
200195

201-
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, {});
196+
const orgGroups = await OrgListUtil.readLocallyValidatedMetaConfigsGroupedByOrgType(fileNames, false);
202197
expect(orgGroups.nonScratchOrgs).to.have.length(1);
203198
expect(orgGroups.nonScratchOrgs[0].connectedStatus).to.equal('bad auth');
204199
expect(checkNonScratchOrgIsDevHub.called).to.be.false;
@@ -208,7 +203,7 @@ describe('orgListUtil tests', () => {
208203
determineConnectedStatusForNonScratchOrg.restore();
209204
stubMethod(sandbox, Org, 'create').rejects({ message: 'bad file' });
210205

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

0 commit comments

Comments
 (0)