@salesforce/core 2.35.2 → 2.35.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/org.js +26 -28
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.35.3](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v2.35.3) (2022-02-23)
6
+
7
+ ### Bug Fixes
8
+
9
+ - always try to clean up aliases and configs ([cd0adc4](https://github.com/forcedotcom/sfdx-core/commit/cd0adc456978f27fc2d44cbcb61632925edcccd9))
10
+
5
11
  ### [2.35.2](https://github.com/forcedotcom/sfdx-core/compare/v2.35.1...v2.35.2) (2022-02-16)
6
12
 
7
13
  ### Bug Fixes
package/lib/org.js CHANGED
@@ -644,35 +644,33 @@ class Org extends kit_1.AsyncCreatable {
644
644
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
645
645
  async removeUsers(throwWhenRemoveFails) {
646
646
  this.logger.debug(`Removing users associate with org: ${this.getOrgId()}`);
647
- const config = await this.retrieveOrgUsersConfig();
647
+ const [config, authInfos, aliases] = await Promise.all([
648
+ this.retrieveOrgUsersConfig(),
649
+ this.readUserAuthFiles(),
650
+ aliases_1.Aliases.create(aliases_1.Aliases.getDefaultOptions()),
651
+ ]);
648
652
  this.logger.debug(`using path for org users: ${config.getPath()}`);
649
- if (await config.exists()) {
650
- const authInfos = await this.readUserAuthFiles();
651
- const aliases = await aliases_1.Aliases.create(aliases_1.Aliases.getDefaultOptions());
652
- this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
653
- for (const auth of authInfos) {
654
- const username = auth.getFields().username;
655
- const aliasKeys = (username && aliases.getKeysByValue(username)) || [];
656
- aliases.unsetAll(aliasKeys);
657
- let orgForUser;
658
- if (username === this.getUsername()) {
659
- orgForUser = this;
660
- }
661
- else {
662
- const info = await authInfo_1.AuthInfo.create({ username });
663
- const connection = await connection_1.Connection.create({ authInfo: info });
664
- orgForUser = await Org.create({ connection });
665
- }
666
- const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
667
- const configInfo = orgForUser.configAggregator.getInfo(orgType);
668
- if ((configInfo.value === username || aliasKeys.includes(configInfo.value)) &&
669
- (configInfo.isGlobal() || configInfo.isLocal())) {
670
- await config_1.Config.update(configInfo.isGlobal(), orgType, undefined);
671
- }
672
- await orgForUser.removeAuth();
673
- }
674
- await aliases.write();
675
- }
653
+ this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
654
+ await Promise.all(authInfos
655
+ .map((auth) => auth.getFields().username)
656
+ .map(async (username) => {
657
+ const aliasKeys = (username && aliases.getKeysByValue(username)) || [];
658
+ aliases.unsetAll(aliasKeys);
659
+ const orgForUser = username === this.getUsername()
660
+ ? this
661
+ : await Org.create({
662
+ connection: await connection_1.Connection.create({ authInfo: await authInfo_1.AuthInfo.create({ username }) }),
663
+ });
664
+ const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
665
+ const configInfo = orgForUser.configAggregator.getInfo(orgType);
666
+ const needsConfigUpdate = (configInfo.isGlobal() || configInfo.isLocal()) &&
667
+ (configInfo.value === username || aliasKeys.includes(configInfo.value));
668
+ return [
669
+ orgForUser.removeAuth(),
670
+ needsConfigUpdate ? config_1.Config.update(configInfo.isGlobal(), orgType, undefined) : undefined,
671
+ ].filter(Boolean);
672
+ }));
673
+ await aliases.write();
676
674
  }
677
675
  /**
678
676
  * Remove an associate sandbox config.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "2.35.2",
3
+ "version": "2.35.3",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",