feat: add optionsFrom resolver support for dynamic options#27
Closed
pyramation wants to merge 2 commits intomainfrom
Closed
feat: add optionsFrom resolver support for dynamic options#27pyramation wants to merge 2 commits intomainfrom
pyramation wants to merge 2 commits intomainfrom
Conversation
Adds a new 'optionsFrom' property to questions that allows resolving
options dynamically from a resolver, similar to how 'defaultFrom' and
'setFrom' work for default values.
This enables boilerplate templates to use dynamic option lists like:
{
"name": "license",
"type": "list",
"optionsFrom": "licenses"
}
The resolver should return an array of strings or OptionValue objects.
Co-Authored-By: Dan Lynch <pyramation@gmail.com>
Registers a 'licenses' resolver that returns the list of supported licenses from listSupportedLicenses(). This allows boilerplate templates to use 'optionsFrom: licenses' to dynamically populate license options. Also updates the test mock to include registerDefaultResolver. Co-Authored-By: Dan Lynch <pyramation@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
3 tasks
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.
feat: add optionsFrom resolver support for dynamic options
Summary
Adds a new
optionsFromproperty to inquirerer questions that allows resolving options dynamically from a resolver, similar to howdefaultFromandsetFromwork for default values.Changes:
optionsFrom?: stringtoBaseQuestiontype and implementedresolveOptionsFrom()method that populatesquestion.optionsfrom a resolverlicensesresolver that returnslistSupportedLicenses(), enabling boilerplate templates to use"optionsFrom": "licenses"for dynamic license optionsThis enables boilerplate templates like:
{ "name": "license", "type": "list", "optionsFrom": "licenses" }Review & Testing Checklist for Human
resolveOptionsFrom()implementation correctly handles edge cases (resolver returns non-array, resolver throws, etc.)create-gen-app/src/index.tsis acceptable (runs on import)optionsFrom- consider if this is acceptable or if tests should be added"optionsFrom": "licenses"instead of hardcoded options, then runpgpm init workspaceto verify CLOSED license appears in the listNotes
(question as any).options = resolvedbypasses TypeScript checking - this follows the same pattern used inresolveDynamicDefaultsLink to Devin run: https://app.devin.ai/sessions/fed966add0284ae0b88295cb40116e7b
Requested by: Dan Lynch (@pyramation)