fix: --flags-dir works on 3rd party plugins @W-21178947@#1553
Merged
Conversation
soridalac
approved these changes
Mar 9, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-dirflag that supplies a directory containing files denoting all of the other flag values. i.e., instead ofsf hello --flag1 a --flag2 b .... --flag50 beep, you could put all of those flags in a file and dosf 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-dirdoesn'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.