feat: add optionsFrom resolver support for dynamic options #27
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)