Skip to content

fix: --flags-dir works on 3rd party plugins @W-21178947@#1553

Merged
soridalac merged 1 commit intomainfrom
d/W-21178947-b
Mar 9, 2026
Merged

fix: --flags-dir works on 3rd party plugins @W-21178947@#1553
soridalac merged 1 commit intomainfrom
d/W-21178947-b

Conversation

@jfeingold35
Copy link
Copy Markdown
Contributor

RECREATION OF #1549 , which got mangled by a git rebase.

This fixes SF CLI Issue #3493.

In theory, SF CLI commands are supposed to support a --flags-dir flag that supplies a directory containing files denoting all of the other flag values. i.e., instead of sf hello --flag1 a --flag2 b .... --flag50 beep, you could put all of those flags in a file and do sf hello --flags-dir myflags. This feature works as designed for first-party plugins. However, when a third-party plugin is using the same version of @oclif/core as the CLI on which it's running, --flags-dir doesn't work.

The problem was that the results of the preparse hook (which handles --flags-dir) were being compared to a cached version of the plugin, as seen here. The cache was only being populated with that value when the config loaded, as seen here, and since the versions of OCLIF were the same, that reloading wasn't occurring for the Command-level plugin. It worked for first-party plugins because they import OCLIF from the same location as the CLI and thus use the same cache directly instead of using a different cache populated with overlapping values.

The fix is to simply reload the config all the time instead of only when the versions mismatch. This was an optimization that was necessary once upon a time, but is no longer necessary because of how plugin instantiation has been optimized elsewhere.

@soridalac
Copy link
Copy Markdown
Contributor

QA notes:
Link core to plugins: run hello --flags-dir mascots
✅ : results with both names instead of default value.
Screenshot 2026-03-09 at 2 28 03 PM

@soridalac soridalac merged commit 9da9748 into main Mar 9, 2026
88 checks passed
@soridalac soridalac deleted the d/W-21178947-b branch March 9, 2026 21:33
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.

Using --flags-dir on (third-party) sf plugins does not work

2 participants