Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 25, 2025

Summary

Refactors @pgpmjs/core to use the new TemplateScaffolder class from [email protected], eliminating code duplication between the two packages. This also fixes the "two-instance Inquirerer problem" that caused double-echoed keystrokes when running pgpm init workspace.

Key changes:

  • Update create-gen-app to ^0.7.0
  • Delete boilerplate-scanner.ts and boilerplate-types.ts (now provided by create-gen-app)
  • Rewrite template-scaffold.ts to delegate to TemplateScaffolder instead of manually composing CacheManager/GitCloner/Templatizer
  • Pass prompter through to scaffoldTemplate() to fix double-echo keystrokes
  • scaffoldTemplate() remains the public API from @pgpmjs/core

The template-scaffold.ts file went from ~236 lines to ~100 lines.

Updates since last revision

API Simplification: Replaced type, dir, and templatePath parameters with a single fromPath parameter:

  • Removed: type: TemplateKind parameter and TemplateKind type
  • Removed: dir parameter (was unused in CLI)
  • Removed: templatePath parameter (merged into fromPath)
  • Added: fromPath: string as the single path selector

The .boilerplates.json resolution is now handled entirely by TemplateScaffolder, so callers just specify 'workspace' or 'module' and it resolves to 'default/workspace' or 'default/module' automatically.

Before:

scaffoldTemplate({ type: 'workspace', templatePath: 'default/workspace', ... })

After:

scaffoldTemplate({ fromPath: 'workspace', ... })

Review & Testing Checklist for Human

  • Breaking API change: scaffoldTemplate() now requires fromPath instead of type - verify no external consumers are affected
  • Path resolution: Verify that fromPath: 'workspace' correctly resolves to default/workspace via .boilerplates.json
  • End-to-end test: Run pgpm init workspace interactively and verify:
    • Arrow keys work correctly (no double movement)
    • Text input doesn't echo twice
    • Workspace is created successfully
  • End-to-end test: Run pgpm init module inside a workspace and verify it still works
  • Custom template path: Test pgpm init workspace --templatePath supabase/workspace to verify custom paths still work

Notes

This PR depends on [email protected] which was published from dev-utils#33.

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

- Update create-gen-app to ^0.7.0
- Refactor template-scaffold.ts to use TemplateScaffolder class
- Delete boilerplate-scanner.ts and boilerplate-types.ts (now in create-gen-app)
- Remove duplicate readBoilerplateConfig/readBoilerplatesConfig functions
- Pass prompter through scaffoldTemplate to fix two-instance problem
- Update workspace.ts to pass prompter instead of calling close()

This eliminates code duplication between pgpm/core and create-gen-app.
The TemplateScaffolder class now handles all the boilerplate config reading
and path resolution logic.
@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

- Add InitWorkspaceOptions interface for workspace initialization
- Add static initWorkspace() method to PgpmPackage class
- Update CLI workspace.ts to use PgpmPackage.initWorkspace()
- Remove scaffoldTemplate from public exports (now internal)
- Keep constants (DEFAULT_TEMPLATE_REPO, etc.) exported for CLI use
- Replace scaffoldTemplate() calls with PgpmPackage.initWorkspace()
- Update module test to use PgpmPackage.initModule() (requires workspace)
- Tests now use the public API instead of internal scaffoldTemplate function
… of type/dir/templatePath

- Remove TemplateKind type and type parameter
- Remove dir parameter (unused in CLI)
- Remove templatePath parameter (merged into fromPath)
- Add fromPath as the single path selector
- Update CLI workspace.ts to use fromPath
- Update PgpmPackage.initModule to use fromPath
- Update tests to use fromPath

The .boilerplates.json resolution is handled by TemplateScaffolder internally,
so callers just need to specify 'workspace' or 'module' and it resolves to
'default/workspace' or 'default/module' automatically.
@devin-ai-integration devin-ai-integration bot changed the title refactor(core): use TemplateScaffolder from create-gen-app refactor(core): use TemplateScaffolder and simplify scaffoldTemplate API Dec 25, 2025
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