Skip to content

W-18988586 feat: support paths for ConfigAggregator #1211

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

Merged
merged 5 commits into from
Jul 9, 2025

Conversation

mshanemc
Copy link
Contributor

@mshanemc mshanemc commented Jul 9, 2025

What does this PR do?

ConfigAggregator is a singleton
instead of caching 1 ConfigAggregator instance, it has one per sfdx project
to help with multiple project and VSCode when the user changes projects and the singleton has to be destroyed and recreated.

What issues does this PR fix or reference?

@W-18988586@

@mshanemc mshanemc requested a review from a team as a code owner July 9, 2025 13:24
@@ -116,16 +116,27 @@ export class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggregator.Op

// Use typing from AsyncOptionalCreatable to support extending ConfigAggregator.
// We really don't want ConfigAggregator extended but typescript doesn't support a final.
public static async create<T extends ConfigAggregator>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this makes the types cleaner inside the method, but is kinda ugly
explanation: because this could be subclassed, the original let anything that extends AsyncOptionalCreatable use it.

we can have a tighter condition , where if we know the thing is really a ConfigAggregator (or its subclasses) the types can be more specific.

I'd also be happy to let create only work with ConfigAggregator but I don't understand heavy-OOP to know the implications. There are a few extends ConfigAggregator I saw in the wild on github so I wanted to be careful with the public API.

ConfigAggregator.instance = new this();
(ConfigAggregator.instance as ConfigAggregator).loadPropertiesSync();
private static getInstance(projectPath = process.cwd()): ConfigAggregator {
if (!ConfigAggregator.instances.has(projectPath)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this has the potential to be sketchy, even before this PR.

because getValue is sync, we can't do the real create here. So I think it's going to have a ConfigAggregator missing the options.configMeta stuff?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed - but I think that's why the jsdoc points out that you should call reload after

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try explaining better:

getValue calls getInstance.

so if you say getValue and pass it something that you'd expect to be loaded from custom configMeta, it's not.

Because there's no way to pass options in via getValue like you would if you were using async create.

@mdonnalley
Copy link
Contributor

mdonnalley commented Jul 9, 2025

QA:

🟢 sf config set org-isv-debugger-sid=foobar => successfully sets encrypts
🟢 sf config list
🟢 sf config get org-isv-debugger-sid

🟡 It's not scoping the ConfigAggregator to the project - or am I misunderstanding the intent of the PR?

Here's the script

import { ConfigAggregator } from "@salesforce/core";

const configAgg1 = await ConfigAggregator.create();
console.log(`Config Aggregator 1: ${process.cwd()}`);
console.log(configAgg1.getConfig());

const configAgg2 = await ConfigAggregator.create({projectPath: "~/repos/VivekMChawla/afdx-test/"});
console.log(`Config Aggregator 2: ~/repos/VivekMChawla/afdx-test/`);
console.log(configAgg2.getConfig());

org-isv-debugger-sid is set locally in the dreamhouse-lwc repo but it's showing up in the ConfigAgg that's scoped to afdx-test. Also the target-org should be different for each project

Screenshot 2025-07-09 at 9 49 13 AM

mdonnalley
mdonnalley previously approved these changes Jul 9, 2025
@mshanemc mshanemc merged commit 2483c0b into main Jul 9, 2025
15 of 71 checks passed
@mshanemc mshanemc deleted the sm/paths-in-config-aggregator branch July 9, 2025 19:56
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