Skip to content

contract emit survives a relative project root; init scaffolds definePrismaConfig - #30064

Merged
wmadden merged 1 commit into
mainfrom
claude/contract-emit-and-init-fixes
Aug 18, 2026
Merged

wmadden merged 1 commit into
mainfrom
claude/contract-emit-and-init-fixes

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Two of the three defects reported against the consolidated 8.0.0-rc.5 stack:

  • contract emit crashed after writing artifacts when the project root was relative: validateContractDeps() built createRequire()'s argument from the root verbatim, and createRequire requires an absolute path (The argument 'filename' must be … or absolute path string. Received './src/prisma/package.json'). The root is resolved first now, with a regression test on a relative root.
  • init scaffolded the deprecated defineConfig: templates and quick-references now import definePrismaConfig, the name engine 0.2.0 gives the config marker. Snapshots updated — the diff is purely the rename. All 1422 CLI package tests pass.

Deliberately not done: dropping dotenv from the scaffold. The report asked for it, but engine 0.2.0's config loader explicitly disables .env reading (dotenv: false in its c12 options), and init scaffolds a .env that the config reads through process.env — removing the import 'dotenv/config' line today would break the scaffold's own flow. If the intent is for the engine (or CLI startup) to load .env itself, that's an engine change to make first; flagging for a decision rather than guessing.

The third reported defect — @prisma/[email protected] requiring [email protected] — is composer-repo work and follows separately.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved project initialization templates with the correct Prisma configuration format.
    • Relative project paths are now handled correctly during dependency validation.
  • Tests

    • Added coverage confirming dependency validation works with relative project roots.

…PrismaConfig

validateContractDeps() handed createRequire() a path built from the
project root verbatim, and createRequire requires an absolute path —
so `contract emit` wrote its artifacts and then crashed whenever the
project root arrived relative ('./src/prisma/package.json'). The root
is resolved first now, with a test on a relative root.

The init templates import definePrismaConfig, the name engine 0.2.0
gives the config marker; the deprecated defineConfig alias still works
for existing files, but new scaffolds should not start deprecated.
Snapshots move with the templates.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner August 18, 2026 12:55
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: cc9d8945-6a99-4359-941d-5faf5772ab68

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4bbfe and 0a0d4ec.

⛔ Files ignored due to path filters (1)
  • packages/1-framework/3-tooling/cli/test/commands/init/__snapshots__/templates.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • packages/1-framework/3-tooling/cli/src/commands/init/templates/code-templates.ts
  • packages/1-framework/3-tooling/cli/src/commands/init/templates/quick-reference-mongo.md
  • packages/1-framework/3-tooling/cli/src/commands/init/templates/quick-reference-postgres.md
  • packages/1-framework/3-tooling/cli/src/utils/validate-contract-deps.ts
  • packages/1-framework/3-tooling/cli/test/utils/validate-contract-deps.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The CLI configuration templates now use definePrismaConfig. Contract dependency validation resolves relative project roots before calling createRequire, with test coverage for relative paths.

Changes

CLI tooling updates

Layer / File(s) Summary
Update generated configuration templates
packages/1-framework/3-tooling/cli/src/commands/init/templates/*
Generated and reference configurations now import and call definePrismaConfig from @prisma/cli-engine.
Resolve relative project roots
packages/1-framework/3-tooling/cli/src/utils/validate-contract-deps.ts, packages/1-framework/3-tooling/cli/test/utils/validate-contract-deps.test.ts
Contract dependency validation resolves projectRoot against package.json before calling createRequire. Tests cover relative project-root input.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 0a0d4

The PR fixes relative-root contract emission and updates init scaffolds to use definePrismaConfig without changing the existing dotenv flow; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: wmadden

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both main changes: relative project root handling and definePrismaConfig in init scaffolds.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/contract-emit-and-init-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@wmadden-electric

Copy link
Copy Markdown
Contributor Author

Ruling from Will (2026-08-18): the engine will never load .env — env loading is against the framework's principles, and the engine's dotenv: false is deliberate and permanent. That closes the open question in this PR's body the other way than it suggested: the scaffold keeps import 'dotenv/config' and the dotenv dependency, because that line is the only thing that makes the scaffolded .env reach process.env. The report's third item (stop adding dotenv) is declined as stated; if create-prisma wants scaffolds without dotenv, the scaffold has to stop using a .env file altogether, which is a product decision for the init flow, not an engine change.

@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30064

@prisma/orm-extension-middleware-cache

npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30064

@prisma/orm-extension-paradedb

npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30064

@prisma/orm-extension-pgvector

npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30064

@prisma/orm-extension-postgis

npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30064

@prisma/orm-extension-supabase

npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30064

@prisma/orm-family-mongo

npm i https://pkg.pr.new/@prisma/orm-family-mongo@30064

@prisma/orm-family-sql

npm i https://pkg.pr.new/@prisma/orm-family-sql@30064

@prisma/orm-framework

npm i https://pkg.pr.new/@prisma/orm-framework@30064

@prisma/orm-mongo

npm i https://pkg.pr.new/@prisma/orm-mongo@30064

@prisma/orm-postgres

npm i https://pkg.pr.new/@prisma/orm-postgres@30064

@prisma/orm-sqlite

npm i https://pkg.pr.new/@prisma/orm-sqlite@30064

@prisma/orm-target-mongo

npm i https://pkg.pr.new/@prisma/orm-target-mongo@30064

@prisma/orm-target-postgres

npm i https://pkg.pr.new/@prisma/orm-target-postgres@30064

@prisma/orm-target-sqlite

npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30064

@prisma/orm-toolchain

npm i https://pkg.pr.new/@prisma/orm-toolchain@30064

commit: 0a0d4ec

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 172.72 KB (0%)
postgres / emit 149.89 KB (0%)
mongo / no-emit 101.15 KB (0%)
mongo / emit 91.01 KB (0%)
cf-worker / no-emit 197.16 KB (0%)
cf-worker / emit 171.8 KB (0%)

@wmadden
wmadden added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 3586a98 Aug 18, 2026
16 of 17 checks passed
@wmadden
wmadden deleted the claude/contract-emit-and-init-fixes branch August 18, 2026 13:28
Shgit29 pushed a commit to Shgit29/prisma that referenced this pull request Aug 18, 2026
…ma#30065)

Follow-up to prisma#30064: the init-journey harness pinned the scaffolded
project's `@prisma/cli-engine` at 0.0.9 — an engine from before the
`definePrismaConfig` rename — so all 20 journey emit/plan steps fail on
main right now (`(0, _cliEngine.definePrismaConfig) is not a function`).
The pin moves to 0.2.0, what the workspace pins. All 32 journey tests
pass locally with the full workspace built.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Updated the scaffolded CLI engine development dependency to version
0.2.0.
* Clarified the required `definePrismaConfig` export in generated
project documentation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden pushed a commit that referenced this pull request Aug 18, 2026
Releases the consolidated-stack fixes as `[email protected]`: the
config hard-cut (#30058), `contract emit` surviving a relative project
root, and init scaffolding `definePrismaConfig` (#30064).
`composer-prisma-cloud` re-releases against this next, then
`[email protected]` pins the pair.

Beyond the version sweep: regenerated contract fixtures; release notes
at `docs/releases/v8.0.0-rc.4.md` leading with #30058's config
migration; two new upgrade-skill entries covering the contract-artifact
restamp (users re-emit once, extension authors regenerate fixtures —
cases #30058's entries don't reach); and a cherry-pick of #30068 so this
PR's CI runs the fixed `check:upgrade-coverage` (deduplicates on merge).
Both release checks pass locally. Merging publishes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added upgrade guidance for regenerating contract artifacts when moving
to v8.0.0-rc.4.

- **Bug Fixes**
  - Fixed handling of relative project roots during contract generation.
  - Updated initialization scaffolding.
- Removed deprecated configuration fallbacks and the legacy
`prisma-next` binary.
- Added guidance for migrating to `prisma.config.ts` with
`definePrismaConfig`.

- **Documentation**
  - Published v8.0.0-rc.4 release notes and upgrade instructions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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.

3 participants