feat(create-gen-app): add TemplateScaffolder orchestrator and prompter pass-through #33
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.
Summary
This PR adds two major features to create-gen-app:
Optional
prompterparameter - Allows callers to pass an existingInquirererinstance toTemplatizer.process()instead of creating a new one internally. This addresses the "two instances on stdin" problem that causes double-echoed keystrokes.TemplateScaffolderorchestrator class - A high-level API that combinesCacheManager,GitCloner, andTemplatizerinto a single, easy-to-use class. This was the "missing top-level API" that downstream tools like pgpm were reimplementing.Ownership semantics for prompter:
prompteris provided: caller retains ownership and must close itprompteris not provided: a new instance is created and closed automatically (existing behavior)New
promptUsersignature:Updates since last revision
inspect()method toTemplateScaffolderthat clones/caches a template and reads its.boilerplate.jsonconfiguration without scaffoldingInspectOptionsandInspectResulttypes exported from scaffolder moduletypefield before deciding how to handle scaffolding (e.g., pgpm can now usepgpm init <anything>and branch based on template type)inspectLocal()andinspectRemote()private methods that mirror the scaffold methods but skip the templatizer stepReview & Testing Checklist for Human
inspect()method correctness: TheinspectLocalandinspectRemotemethods duplicate cache/clone logic fromscaffoldFromLocal/scaffoldFromRemote- verify they stay in sync and both correctly resolve paths via.boilerplates.jsoninspect(): The new method was added without dedicated tests - consider if this is acceptable or if tests should be added before mergeresolveFromPathlogic correctly handles: (1) direct paths, (2).boilerplates.jsondir-based resolution, (3) fallback behaviorTemplateScaffolder.scaffold()correctly passes the prompter through toTemplatizer.process()Test plan:
inspectTemplate()for metadata-driven initpgpm init workspaceandpgpm init moduleend-to-end - verify the template'stypefield is correctly read and the appropriate flow is triggeredNotes
This PR is part of a two-PR solution:
inspect()method, and prompter pass-through to create-gen-appImportant: The constructive PR depends on the
inspect()method added here. A new version of create-gen-app must be published before the constructive PR can build.Link to Devin run: https://app.devin.ai/sessions/48555739db3d4f1b9e9edfa9ea1e559a
Requested by: Dan Lynch (@pyramation)