Skip to content

Commit b8df82d

Browse files
authored
Merge pull request #267 from salesforcecli/mdonnalley/state-aggregator
feat: use StateAggregator
2 parents 779b2cb + b91b6ed commit b8df82d

File tree

3 files changed

+643
-589
lines changed

3 files changed

+643
-589
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/core": "^1.7.0",
9-
"@salesforce/core": "^3.15.5",
9+
"@salesforce/core": "^3.19.4",
1010
"@salesforce/kit": "^1.5.41",
1111
"@salesforce/sf-plugins-core": "^1.12.3",
1212
"@salesforce/source-deploy-retrieve": "^5.13.1",

src/utils/metadataDeployer.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Duration } from '@salesforce/kit';
1111
import {
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

Comments
 (0)