@@ -11,7 +11,7 @@ import { Duration } from '@salesforce/kit';
1111import {
1212 AuthInfo ,
1313 ConfigAggregator ,
14- GlobalInfo ,
14+ StateAggregator ,
1515 Messages ,
1616 NamedPackageDir ,
1717 OrgAuthorization ,
@@ -145,8 +145,9 @@ export class MetadataDeployer extends Deployer {
145145
146146 public async promptForUsername ( ) : Promise < string > {
147147 const aliasOrUsername = ConfigAggregator . getValue ( OrgConfigProperties . TARGET_ORG ) ?. value as string ;
148- const globalInfo = await GlobalInfo . getInstance ( ) ;
149- const allAliases = globalInfo . aliases . getAll ( ) ;
148+ const stateAggregator = await StateAggregator . getInstance ( ) ;
149+ await stateAggregator . orgs . readAll ( ) ;
150+ const allAliases = stateAggregator . aliases . getAll ( ) ;
150151 let targetOrgAuth : OrgAuthorization ;
151152 // make sure the "target-org" can be used in this deploy
152153 if ( aliasOrUsername ) {
@@ -168,18 +169,21 @@ export class MetadataDeployer extends Deployer {
168169 throw messages . createError ( 'error.UserTerminatedDeployForExpiredOrg' ) ;
169170 }
170171 } else {
171- return globalInfo . aliases . resolveUsername ( aliasOrUsername ) ;
172+ return stateAggregator . aliases . resolveUsername ( aliasOrUsername ) ;
172173 }
173174 }
174175 }
176+
175177 if ( ! aliasOrUsername || targetOrgAuth ?. isExpired ) {
176- const authorizations = (
178+ const promises = (
177179 await AuthInfo . listAllAuthorizations ( ( orgAuth ) => ! orgAuth . error && orgAuth . isExpired !== true )
178- ) . map ( ( orgAuth ) => {
179- const org = globalInfo . orgs . get ( orgAuth . username ) ;
180- const timestamp = org . timestamp ? new Date ( org . timestamp as string ) : new Date ( ) ;
180+ ) . map ( async ( orgAuth ) => {
181+ const stat = await stateAggregator . orgs . stat ( orgAuth . username ) ;
182+ const timestamp = stat ? new Date ( stat . mtimeMs ) : new Date ( ) ;
181183 return { ...orgAuth , timestamp } as OrgAuthWithTimestamp ;
182184 } ) ;
185+
186+ const authorizations = await Promise . all ( promises ) ;
183187 if ( authorizations . length > 0 ) {
184188 const newestAuths = authorizations . sort ( compareOrgs ) ;
185189 const options = newestAuths . map ( ( auth ) => ( {
0 commit comments