Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 25, 2025

Summary

Adds a --boilerplate flag to pgpm init that scans the template repository for available boilerplates and presents an autocomplete selection prompt to the user, instead of defaulting to 'module'.

When running pgpm init --boilerplate without a positional argument:

  1. The CLI clones/caches the template repository (using optional fromPath in inspectTemplate)
  2. Scans the boilerplates directory using resolveBoilerplateBaseDir and scanBoilerplates
  3. Presents an autocomplete selection prompt with all available boilerplate names
  4. Uses the selected boilerplate as the fromPath

The --boilerplate flow is now separated into a dedicated handleBoilerplateInit function for cleaner code organization.

--dir Override Behavior

When --dir is specified, it now bypasses .boilerplates.json resolution entirely:

  • Uses the new useBoilerplatesConfig: false option from create-gen-app to explicitly disable .boilerplates.json fallback
  • Boilerplate scanning uses resolvedTemplatePath directly instead of reading .boilerplates.json
  • If .boilerplates.json is missing or has no dir property, defaults to repo root (.)

Error Handling

  • If no boilerplates are found, throws an error with the checked directory path
  • In non-interactive mode (CI/--no-tty), throws an error if no positional <fromPath> is provided

Updates since last revision

  • Refactored to use useBoilerplatesConfig API: Replaced brittle post-hoc string comparison validation with the new useBoilerplatesConfig option from create-gen-app. When --dir is specified, passes useBoilerplatesConfig: false to bypass .boilerplates.json resolution at the source.
  • Bumped create-gen-app dependency to ^0.9.0: This version includes the new useBoilerplatesConfig option.
  • Simplified both inspectTemplate and scaffoldTemplate by removing the validation logic that checked if create-gen-app fell back to .boilerplates.json.

Review & Testing Checklist for Human

  • ⚠️ BLOCKING: Merge and publish create-gen-app first: This PR requires create-gen-app@^0.9.0 with the useBoilerplatesConfig option. See companion PR: feat(create-gen-app): add useBoilerplatesConfig option to control .boilerplates.json resolution dev-utils#36
  • Test --dir bypass: Run pgpm init module --dir supabase and verify it does NOT fall back to .boilerplates.json (should error if supabase/module doesn't exist)
  • Test boilerplate selection: Run pgpm init --boilerplate and verify autocomplete prompt appears with available boilerplates
  • Test --boilerplate with --dir: Run pgpm init --boilerplate --dir supabase and verify it scans the supabase/ directory, not default/
  • Test non-interactive mode: Run with CI=true pgpm init --boilerplate and verify it throws an actionable error message

Recommended test plan:

cd /path/to/workspace

# Test autocomplete selection
pgpm init --boilerplate
# Should see autocomplete prompt with available boilerplates

# Test --dir bypass (should error if path doesn't exist)
pgpm init module --dir nonexistent
# Should throw error about directory not found, NOT fall back to .boilerplates.json

# Test --boilerplate with --dir
pgpm init --boilerplate --dir supabase
# Should scan supabase/ directory for boilerplates

# Test error handling
CI=true pgpm init --boilerplate
# Should throw error about non-interactive mode

Notes

Dependency: This PR depends on constructive-io/dev-utils#36 being merged and create-gen-app@0.9.0 being published first. CI will fail until then.

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

When using 'pgpm init --boilerplate' without a fromPath argument, the CLI
now scans the template repository for available boilerplates and presents
a selection prompt to the user. This removes the hardcoded default of
'module' and allows users to choose from all available boilerplate options.
@devin-ai-integration
Copy link
Contributor

🤖 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

- Make fromPath optional in InspectTemplateOptions to avoid dummy values
- Update effectiveFromPath calculation to handle undefined fromPath
- Separate --boilerplate path into dedicated handleBoilerplateInit function
- Throw error when no boilerplates found instead of falling back to 'module'
- Add noTty check to throw error in non-interactive mode without fromPath
- When --dir is specified, bypass .boilerplates.json and use dir directly
- Add validation to throw error if create-gen-app falls back to .boilerplates.json
- Update --boilerplate scanning to respect --dir (use resolvedTemplatePath)
- Fix scaffoldTemplate to use result.fromPath instead of resolvedFromPath
Replace brittle post-hoc validation with the new useBoilerplatesConfig option:
- When dir is specified, pass useBoilerplatesConfig: false to bypass .boilerplates.json
- When dir is not specified, use default behavior (useBoilerplatesConfig: true)
- Remove the string comparison validation that was checking if create-gen-app fell back

This simplifies both inspectTemplate and scaffoldTemplate functions by moving
the resolution policy control into create-gen-app where it belongs.

BREAKING: Requires create-gen-app ^0.9.0 with useBoilerplatesConfig support
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