Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Adds recursive boilerplate discovery to the genomic scaffolder, enabling proper filtering of directories that contain .boilerplate.json files. This solves the issue where non-boilerplate directories (like scripts/) would appear as options when using --dir . to bypass .boilerplates.json.

Key changes:

  • New scanBoilerplatesRecursive function that recursively finds all directories with .boilerplate.json
  • New findBoilerplateByPath function for matching user-provided paths against discovered boilerplates (exact match, then unambiguous basename match)
  • Added scanBoilerplates method to TemplateScaffolder class for convenience
  • Updated resolveFromPath to use recursive scanning as a fallback resolution strategy

With this change, when a user runs pgpm init --dir ., only directories with .boilerplate.json (e.g., default/module, default/workspace) will be available as options.

Review & Testing Checklist for Human

  • Test with pgpm init: Clone pgpm-boilerplates and verify pgpm init --dir . only shows default/module and default/workspace, not scripts/
  • Review basename matching logic in findBoilerplateByPath - returns null for ambiguous matches (e.g., if both default/module and supabase/module exist, module returns null)
  • Performance check: The recursive scan is now called as a fallback in resolveFromPath. For large template repos, this could add latency. Consider if caching is needed.
  • Consider adding unit tests for the new scanning functions before merging

Test Plan

  1. Clone pgpm-boilerplates locally
  2. Run pgpm init --dir . and verify only valid boilerplates appear
  3. Run pgpm init module --dir . and verify it resolves to default/module
  4. Verify normal pgpm init workspace still works (uses .boilerplates.json)

Notes

- Add scanBoilerplatesRecursive function to discover all boilerplates
  in a directory tree by looking for .boilerplate.json files
- Add findBoilerplateByPath for matching fromPath against discovered
  boilerplates (exact match, then unambiguous basename match)
- Add findBoilerplateByType and filterBoilerplatesByType helpers
- Add scanBoilerplates method to TemplateScaffolder class
- Update resolveFromPath to use recursive scan as fallback when
  direct path and .boilerplates.json resolution fail

This enables proper boilerplate discovery when using --dir . to bypass
.boilerplates.json, ensuring directories without .boilerplate.json
(like scripts/) are never shown as options.
@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

@pyramation pyramation merged commit 5467050 into main Dec 27, 2025
36 checks passed
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