@@ -16,9 +16,16 @@ Messages.importMessagesDirectory(__dirname);
1616const messages = Messages . loadMessages ( '@salesforce/plugin-org' , 'list' ) ;
1717
1818export type OrgListResult = {
19+ /**
20+ * @deprecated
21+ * preserved for backward json compatibility. Duplicates devHubs, sandboxes, regularOrgs, which should be preferred*/
1922 nonScratchOrgs : ExtendedAuthFields [ ] ;
2023 scratchOrgs : FullyPopulatedScratchOrgFields [ ] ;
24+ sandboxes : ExtendedAuthFields [ ] ;
25+ regularOrgs : ExtendedAuthFields [ ] ;
26+ devHubs : ExtendedAuthFields [ ] ;
2127} ;
28+
2229export class OrgListCommand extends SfCommand < OrgListResult > {
2330 public static readonly summary = messages . getMessage ( 'summary' ) ;
2431 public static readonly examples = messages . getMessages ( 'examples' ) ;
@@ -56,6 +63,9 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
5663 this . flags = flags ;
5764 const metaConfigs = await OrgListUtil . readLocallyValidatedMetaConfigsGroupedByOrgType ( fileNames , flags ) ;
5865 const groupedSortedOrgs = {
66+ devHubs : metaConfigs . devHubs . map ( decorateWithDefaultStatus ) . sort ( comparator ) ,
67+ regularOrgs : metaConfigs . regularOrgs . map ( decorateWithDefaultStatus ) . sort ( comparator ) ,
68+ sandboxes : metaConfigs . sandboxes . map ( decorateWithDefaultStatus ) . sort ( comparator ) ,
5969 nonScratchOrgs : metaConfigs . nonScratchOrgs . map ( decorateWithDefaultStatus ) . sort ( comparator ) ,
6070 scratchOrgs : metaConfigs . scratchOrgs . map ( decorateWithDefaultStatus ) . sort ( comparator ) ,
6171 expiredScratchOrgs : metaConfigs . scratchOrgs . filter ( ( org ) => ! identifyActiveOrgByStatus ( org ) ) ,
@@ -70,13 +80,19 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
7080 }
7181
7282 const result = {
83+ regularOrgs : groupedSortedOrgs . regularOrgs ,
84+ sandboxes : groupedSortedOrgs . sandboxes ,
7385 nonScratchOrgs : groupedSortedOrgs . nonScratchOrgs ,
86+ devHubs : groupedSortedOrgs . devHubs ,
7487 scratchOrgs : flags . all
7588 ? groupedSortedOrgs . scratchOrgs
7689 : groupedSortedOrgs . scratchOrgs . filter ( identifyActiveOrgByStatus ) ,
7790 } ;
7891
79- this . printOrgTable ( result . nonScratchOrgs , flags [ 'skip-connection-status' ] ) ;
92+ // this.printOrgTable(result.nonScratchOrgs, flags['skip-connection-status']);
93+ this . printOrgTable ( result . devHubs , flags [ 'skip-connection-status' ] , 'DevHubs' ) ;
94+ this . printOrgTable ( result . regularOrgs , flags [ 'skip-connection-status' ] , 'Orgs' ) ;
95+ this . printOrgTable ( result . sandboxes , flags [ 'skip-connection-status' ] , 'Sandboxes' ) ;
8096
8197 this . printScratchOrgTable ( result . scratchOrgs ) ;
8298
@@ -112,10 +128,11 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
112128 ) ;
113129 }
114130
115- protected printOrgTable ( nonScratchOrgs : ExtendedAuthFields [ ] , skipconnectionstatus : boolean ) : void {
131+ protected printOrgTable ( nonScratchOrgs : ExtendedAuthFields [ ] , skipconnectionstatus : boolean , title : string ) : void {
116132 if ( ! nonScratchOrgs . length ) {
117- this . log ( messages . getMessage ( 'noResultsFound' ) ) ;
133+ this . info ( messages . getMessage ( 'noResultsFound' , [ title ] ) ) ;
118134 } else {
135+ this . info ( title ) ;
119136 const rows = nonScratchOrgs
120137 . map ( ( row ) => getStyledObject ( row ) )
121138 . map ( ( org ) =>
@@ -126,32 +143,28 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
126143 )
127144 ) ;
128145
129- this . table (
130- rows ,
131- {
132- defaultMarker : {
133- header : '' ,
134- get : ( data ) : string => data . defaultMarker ?? '' ,
135- } ,
136- alias : {
137- header : 'ALIAS' ,
138- get : ( data ) : string => data . alias ?? '' ,
139- } ,
140- username : { header : 'USERNAME' } ,
141- orgId : { header : 'ORG ID' } ,
142- ...( ! skipconnectionstatus ? { connectedStatus : { header : 'CONNECTED STATUS' } } : { } ) ,
146+ this . table ( rows , {
147+ defaultMarker : {
148+ header : '' ,
149+ get : ( data ) : string => data . defaultMarker ?? '' ,
143150 } ,
144- {
145- title : 'Non-scratch orgs' ,
146- }
147- ) ;
151+ alias : {
152+ header : 'ALIAS' ,
153+ get : ( data ) : string => data . alias ?? '' ,
154+ } ,
155+ username : { header : 'USERNAME' } ,
156+ orgId : { header : 'ORG ID' } ,
157+ ...( ! skipconnectionstatus ? { connectedStatus : { header : 'CONNECTED STATUS' } } : { } ) ,
158+ } ) ;
148159 }
160+ this . log ( ) ;
149161 }
150162
151163 private printScratchOrgTable ( scratchOrgs : FullyPopulatedScratchOrgFields [ ] ) : void {
152164 if ( scratchOrgs . length === 0 ) {
153- this . log ( messages . getMessage ( 'noActiveScratchOrgs' ) ) ;
165+ this . info ( messages . getMessage ( 'noActiveScratchOrgs' ) ) ;
154166 } else {
167+ this . info ( this . flags . all ? 'Scratch Orgs' : 'Active Scratch Orgs (use --all to see all)' ) ;
155168 // One or more rows are available.
156169 // we only need a few of the props for our table. Oclif table doesn't like extra props non-string props.
157170 const rows = scratchOrgs
@@ -195,12 +208,13 @@ export class OrgListCommand extends SfCommand<OrgListResult> {
195208 }
196209 : { } ) ,
197210 expirationDate : { header : 'EXPIRATION DATE' } ,
198- } ,
199- {
200- title : 'Scratch orgs' ,
201211 }
212+ // {
213+ // title: 'Scratch orgs',
214+ // }
202215 ) ;
203216 }
217+ this . log ( ) ;
204218 }
205219}
206220
0 commit comments