Skip to content

Conversation

@pyramation
Copy link
Contributor

feat: add optionsFrom resolver support for dynamic options

Summary

Adds a new optionsFrom property to inquirerer questions that allows resolving options dynamically from a resolver, similar to how defaultFrom and setFrom work for default values.

Changes:

  • inquirerer: Added optionsFrom?: string to BaseQuestion type and implemented resolveOptionsFrom() method that populates question.options from a resolver
  • create-gen-app: Registers a licenses resolver that returns listSupportedLicenses(), enabling boilerplate templates to use "optionsFrom": "licenses" for dynamic license options

This enables boilerplate templates like:

{
  "name": "license",
  "type": "list",
  "optionsFrom": "licenses"
}

Review & Testing Checklist for Human

  • Verify the resolveOptionsFrom() implementation correctly handles edge cases (resolver returns non-array, resolver throws, etc.)
  • Check that registering the resolver at module load time in create-gen-app/src/index.ts is acceptable (runs on import)
  • Note: No dedicated unit tests were added for optionsFrom - consider if this is acceptable or if tests should be added
  • Test plan: Update pgpm-boilerplates workspace template to use "optionsFrom": "licenses" instead of hardcoded options, then run pgpm init workspace to verify CLOSED license appears in the list

Notes

  • The type cast (question as any).options = resolved bypasses TypeScript checking - this follows the same pattern used in resolveDynamicDefaults
  • The resolver silently does nothing if the resolved value is not an array (defensive behavior)

Link to Devin run: https://app.devin.ai/sessions/fed966add0284ae0b88295cb40116e7b
Requested by: Dan Lynch (@pyramation)

devin-ai-integration bot and others added 2 commits December 21, 2025 07:33
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 <[email protected]>
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 <[email protected]>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

2 participants