Skip to content

Conversation

@kingston
Copy link
Collaborator

@kingston kingston commented Jul 9, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a CLI command to regenerate template files from existing configurations without running extraction, with an option to skip cleaning output directories.
    • Added a migration script and supporting commands for updating template metadata formats.
  • Refactor

    • Simplified and unified template metadata handling across the platform, consolidating template definitions and removing legacy mapping logic.
    • Standardized template configuration files to use concise template identifiers and explicit source file references.
    • Streamlined internal metadata file naming and structure for improved clarity and maintainability.
  • Bug Fixes

    • Improved error handling and validation for template generation and metadata processing.
  • Chores

    • Updated test suites and documentation to align with new metadata and configuration formats.
    • Cleaned up and reorganized project scripts for template extraction and generation.

End-users will experience more consistent template management, easier manual template regeneration, and improved reliability in code generation workflows.

@vercel
Copy link

vercel bot commented Jul 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baseplate-project-builder-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2025 6:34pm

@changeset-bot
Copy link

changeset-bot bot commented Jul 9, 2025

🦋 Changeset detected

Latest commit: f6d29ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@baseplate-dev/sync Patch
@baseplate-dev/core-generators Patch
@baseplate-dev/project-builder-server Patch
@baseplate-dev/project-builder-cli Patch
@baseplate-dev/fastify-generators Patch
@baseplate-dev/project-builder-common Patch
@baseplate-dev/project-builder-lib Patch
@baseplate-dev/project-builder-test Patch
@baseplate-dev/react-generators Patch
@baseplate-dev/plugin-auth Patch
@baseplate-dev/plugin-storage Patch
@baseplate-dev/project-builder-web Patch
@baseplate-dev/code-morph Patch
@baseplate-dev/create-project Patch
@baseplate-dev/tools Patch
@baseplate-dev/ui-components Patch
@baseplate-dev/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change refactors the template metadata system by consolidating template definitions to be keyed by template names in extractor.json files, removing file ID mapping, and introducing a new .templates-info.json format for tracking template instances. All extractors, renderers, and related tests are updated to use the new metadata structure. A new CLI command enables template file regeneration from existing configurations, and a migration script is provided for existing projects.

Changes

Files/Paths Change Summary
.changeset/*, package.json, packages/project-builder-cli/package.json Updated scripts: removed extract:templates, added templates:extract, templates:generate, and migration script.
packages/core-generators/src/generators/*/extractor.json, packages/fastify-generators/src/generators/*/extractor.json, packages/react-generators/src/generators/*/extractor.json, plugins/plugin-auth/src/*/extractor.json, plugins/plugin-storage/src/*/extractor.json All template keys changed from file paths to template names; removed name fields; added sourceFile property to each template entry; some entries swapped or regrouped for clarity.
packages/core-generators/src/renderers/*, packages/react-generators/src/generators/*/*.generator.ts Refactored to use new template metadata keyed by template name and new templateInfo structure; updated file writing and metadata passing logic.
packages/sync/src/templates/constants.ts Added TEMPLATES_INFO_FILENAME constant for new metadata file.
packages/sync/src/templates/extractor/configs/* Updated schemas and config lookup: replaced name with sourceFile, templates now keyed by name; removed file ID map logic; added methods for template config retrieval by name.
packages/sync/src/templates/extractor/runner/*, packages/sync/src/templates/extractor/run-template-file-extractors.ts Refactored extractor interfaces/types to distinguish template metadata and instance data; updated method signatures and logic to new structure; removed file ID map usage; added generateTemplateFiles function for generation-only flow.
packages/sync/src/templates/extractor/utils/* Updated utility functions and tests to handle new template keying and metadata format; adjusted merging, cleanup, and config indexing logic.
packages/sync/src/templates/metadata/* Introduced new Zod schemas/types for .templates-info.json; replaced all "template metadata" handling with "template info" (read/write/validation); updated file grouping and writing logic; updated tests.
packages/project-builder-cli/src/commands/templates.ts Added new CLI subcommand templates generate <directory> <app> with --skip-clean option; handler invokes new generation logic.
packages/project-builder-server/src/template-extractor/run-template-extractor.ts Added exported function generateTemplateFilesForProject to generate template files from configs; updated extractor runner to remove file ID map usage.
packages/project-builder-server/src/sync/generate-for-directory.ts Switched to writing .templates-info.json using new function.
packages/project-builder-server/src/sync/index.ts Added export for sync-metadata-controller.js.
packages/core-generators/src/renderers/typescript/extractor/*, packages/core-generators/src/renderers/text/*, packages/core-generators/src/renderers/raw/* Unified and simplified metadata schemas/types; updated function signatures and logic to use template names and new metadata structure; updated all usages accordingly.
packages/core-generators/src/renderers/extractor/utils/deduplicate-templates.ts Updated deduplication logic to use new metadata property names.
packages/core-generators/src/renderers/text/utils.ts Simplified variable extraction to use direct string mapping.
packages/core-generators/src/renderers/typescript/extractor/build-ts-project-export-map.ts Changed function signature and logic to work with new template output path mapping.
packages/sync/src/output/generator-task-output.ts Renamed all references from templateMetadata to templateInfo; updated types and comments.
Tests: *.unit.test.ts Updated all tests to use new template keying, metadata structure, and file naming; removed/added tests as needed to match new logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ProjectBuilderServer
    participant Sync
    participant FileSystem

    User->>CLI: templates generate <directory> <app> [--skip-clean]
    CLI->>ProjectBuilderServer: generateTemplateFilesForProject(directory, app, plugins, logger, options)
    ProjectBuilderServer->>Sync: generateTemplateFiles(templateExtractors, appDir, generatorPackageMap, logger, options)
    Sync->>FileSystem: Read extractor.json (keyed by template name)
    Sync->>FileSystem: Write generated template files
    Sync->>FileSystem: Write .templates-info.json
    Sync->>CLI: Generation complete
Loading

Possibly related PRs

  • halfdomelabs/baseplate#589: Introduces a Template Renderers plugin that generates simplified template rendering APIs, aligning with the move to template-name-based metadata and the new system for template definitions.
  • halfdomelabs/baseplate#496: Adds a reverse generation engine for TypeScript templates, directly modifying the TypeScript template extractor and related metadata handling, which are also refactored in this PR.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kingston kingston merged commit 059edf7 into main Jul 9, 2025
8 of 9 checks passed
@kingston kingston deleted the kingston/eng-774-simplify-template-metadata-system branch July 9, 2025 18:38
@github-actions github-actions bot mentioned this pull request Jul 9, 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