Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wr/unset alias config #874

Merged
merged 29 commits into from
Jun 29, 2023
Merged

Wr/unset alias config #874

merged 29 commits into from
Jun 29, 2023

Conversation

WillieRuemmele
Copy link
Member

@WillieRuemmele WillieRuemmele commented Jun 26, 2023

What does this PR do?

when Org.delete is called, it will now unset any config values that reference the org (username or alias) and will unset an alias keys that are set to the org's username

What issues does this PR fix or reference?

forcedotcom/cli#2237
inv @W-13644800@
bug @W-13700499@

mshanemc
mshanemc previously approved these changes Jun 27, 2023
@mshanemc
Copy link
Contributor

mshanemc commented Jun 27, 2023

QA: core PR branch yarn-linked into plugin-org, plugins-linked into sf

create scratch org w/ alias, assign it another alias.
org delete scratch (-o username)
This directory does not contain a valid Salesforce DX project

-- I think you're going to need to either use ConfigAggregator for these OR handle there not being a local (project) config

same test as above, but in a project
✅ auth file is deleted
✅ 2 aliases no longer appear in alias list
✅ 2 aliases no longer appear in alias list
✅ sf config list doesn't show it

❌ doesn't delete global configs (probably another thing solved by config=>configAggregator)

@mshanemc
Copy link
Contributor

QA: core PR branch yarn-linked into plugin-org, plugins-linked into sf

create scratch org w/ alias WR3 and set-defualt, assign it 2nd alias WR4.
Also set as global target-org (using second alias)
org delete scratch (-o username)
✅ auth file is deleted
✅ 2 aliases no longer appear in alias list
✅ sf config list doesn't show it

same test as above, but in a project. Delete using -o username
✅ auth file is deleted
✅ 2 aliases no longer appear in alias list
✅ sf config list doesn't show it

same test, Delete using -o alias (alias is the second alias, not the one used for org create)
✅ auth file is deleted
✅ 2 aliases no longer appear in alias list
✅ sf config list doesn't show it

create and delete org with no alias and no config
✅ looks good!

@@ -334,6 +334,13 @@ export class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggregator.Op
return this.config;
}

public async unsetByValue(key: string): Promise<void> {
this.localConfig?.getKeysByValue(key).map((k) => this.localConfig?.unset(k));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern about this is that parallel org deletes (think org list --clean) could possibly muck up the config files because of the well-known concurrency bug.

it would be nice if we only did write() if we knew that config had been modified.

config.unset return true if it does unset the thing, so you could do something like

const globalIsModified = this.globalConfig?.getKeysByValue(key).map((k) => this.globalConfig?.unset(k)).some(Boolean)

mshanemc
mshanemc previously approved these changes Jun 28, 2023
@mshanemc
Copy link
Contributor

QA: retested using tests from above, all still good in project and not in project

@mshanemc mshanemc merged commit ca2c90b into main Jun 29, 2023
@mshanemc mshanemc deleted the wr/unsetAliasConfig branch June 29, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants