Skip to content

fix: Gracefully handle missing .env in prisma.config.mts files#676

Merged
kingston merged 2 commits into
mainfrom
kingston/eng-902-allow-env-file-to-be-missing-when-running-pnpm-install-due
Oct 14, 2025
Merged

fix: Gracefully handle missing .env in prisma.config.mts files#676
kingston merged 2 commits into
mainfrom
kingston/eng-902-allow-env-file-to-be-missing-when-running-pnpm-install-due

Conversation

@kingston

@kingston kingston commented Oct 14, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • Prisma configuration now gracefully handles missing .env files, avoiding errors when running generation commands in environments without env files.
    • Example projects updated to avoid errors when .env is absent.
  • Documentation

    • Clarified guidance on where to make code changes (avoid modifying generators directly).
    • Expanded instructions for template metadata management with clearer steps and examples.
  • Chores

    • Updated development permissions configuration.
    • Added a patch-level release entry.

@changeset-bot

changeset-bot Bot commented Oct 14, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6edf837

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

This PR includes changesets to release 18 packages
Name Type
@baseplate-dev/fastify-generators Patch
@baseplate-dev/project-builder-server Patch
@baseplate-dev/plugin-auth Patch
@baseplate-dev/plugin-queue Patch
@baseplate-dev/plugin-storage Patch
@baseplate-dev/project-builder-cli Patch
@baseplate-dev/project-builder-common Patch
@baseplate-dev/project-builder-test Patch
@baseplate-dev/project-builder-web Patch
@baseplate-dev/create-project Patch
@baseplate-dev/code-morph Patch
@baseplate-dev/core-generators Patch
@baseplate-dev/project-builder-lib Patch
@baseplate-dev/react-generators Patch
@baseplate-dev/sync 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

@vercel

vercel Bot commented Oct 14, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
baseplate-project-builder-web Ready Ready Preview Comment Oct 14, 2025 7:11am

@coderabbitai

coderabbitai Bot commented Oct 14, 2025

Copy link
Copy Markdown

Walkthrough

Adds a conditional .env loading check to Prisma config files in examples and the generator template using existsSync before loadEnvFile(). Updates AGENTS.md guidance and template metadata instructions. Introduces a permissions allowlist in .claude/settings.json. Adds a changeset recording a patch for the fastify-generators package.

Changes

Cohort / File(s) Summary of changes
Prisma env loading guard
examples/blog-with-auth/packages/backend/prisma.config.mts, examples/todo-with-auth0/packages/backend/prisma.config.mts, packages/fastify-generators/src/generators/prisma/prisma/templates/package/prisma.config.mts
Import existsSync from node:fs and guard loadEnvFile() with if (existsSync('.env')) so .env is only loaded when present.
Docs updates
AGENTS.md
Clarifies not to modify generator files directly; simplifies developer instructions; expands Template Metadata Management guidance and MCP action examples.
Tooling permissions
.claude/settings.json
Adds top-level permissions.allow list with specific Bash(...) and mcp__... entries.
Release metadata
.changeset/graceful-env-file-loading.md
Adds a patch-level changeset for the fastify-generators package describing conditional .env loading behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant CLI as Prisma CLI
    participant CFG as prisma.config.mts
    participant FS as File System
    participant Env as loadEnvFile()

    Dev->>CLI: run `pnpm prisma generate`
    CLI->>CFG: load prisma config
    CFG->>FS: existsSync(".env")
    alt .env present
        CFG->>Env: loadEnvFile()
        note right of Env: environment variables loaded
    else .env absent
        note right of CFG: skip env loading
    end
    CFG-->>CLI: continue
    CLI-->>Dev: generation completes
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title precisely captures the core change of adding a guard in prisma.config.mts to gracefully handle missing .env files, which is the main focus of the modifications across example projects and generator templates. It is concise, specific, and closely matches the updates without introducing unrelated details. The wording clearly indicates that this is a fix and identifies the relevant files. Overall, it communicates the purpose of the pull request effectively.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kingston/eng-902-allow-env-file-to-be-missing-when-running-pnpm-install-due

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 983ffd9 and 6edf837.

📒 Files selected for processing (1)
  • .changeset/graceful-env-file-loading.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/graceful-env-file-loading.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test E2E

Comment @coderabbitai help to get the list of available commands and usage tips.

@kingston kingston merged commit e68624e into main Oct 14, 2025
16 checks passed
@kingston kingston deleted the kingston/eng-902-allow-env-file-to-be-missing-when-running-pnpm-install-due branch October 14, 2025 08:06
@github-actions github-actions Bot mentioned this pull request Oct 14, 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.

1 participant