Skip to content

Conversation

@sanny-io
Copy link
Contributor

@sanny-io sanny-io commented Oct 13, 2025

Fixes #295

Summary by CodeRabbit

  • Bug Fixes

    • Corrected output path resolution in the Prisma CLI plugin to reliably generate schema files when the output is specified relative to the configured project output directory.
    • Ensures directories are created as needed and schema generation succeeds without additional configuration.
  • Tests

    • Added coverage verifying schema generation works when the plugin output is set relative to the project’s output path, preventing regressions in path handling.

@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2025

Walkthrough

Removes the schemaFile parameter from the Prisma CLI plugin’s generate signature and switches output path resolution to use defaultOutputPath when pluginOptions.output is a string. Adds a test verifying generation to a path relative to zenstack.output when output is './schema.prisma'.

Changes

Cohort / File(s) Summary of changes
CLI Prisma plugin implementation
packages/cli/src/plugins/prisma.ts
Removed schemaFile from generate signature; updated output path calculation to use defaultOutputPath for string pluginOptions.output; retained directory creation and file writing behavior.
Prisma plugin tests
packages/cli/test/plugins/prisma-plugin.test.ts
Added test ensuring schema is generated under path relative to zenstack.output when plugin output is './schema.prisma'; asserts existence of relative/schema.prisma.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws, code carrots in a row,
Paths hop to default burrows—off we go!
A schema sprouts where outputs point, just so,
Tests nibble truth, green gardens grow.
Hippity hooray—relative roots now glow! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title succinctly describes the main fix which is ensuring the Prisma plugin respects the global zenstack.output setting, matching the primary change in the diff.
Linked Issues Check ✅ Passed The code changes update the Prisma plugin’s output path resolution to use the global defaultOutputPath and the added test confirms that schema.prisma is generated under the configured zenstack.output, fulfilling the requirements of issue #295.
Out of Scope Changes Check ✅ Passed All modifications are focused on adjusting the Prisma plugin output logic and adding a related test case, which directly align with fixing issue #295 and do not introduce any unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d9f296 and e09b70f.

📒 Files selected for processing (2)
  • packages/cli/src/plugins/prisma.ts (1 hunks)
  • packages/cli/test/plugins/prisma-plugin.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{packages,samples,tests}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place packages only under packages/, samples/, or tests/

Files:

  • packages/cli/test/plugins/prisma-plugin.test.ts
  • packages/cli/src/plugins/prisma.ts
🧬 Code graph analysis (1)
packages/cli/test/plugins/prisma-plugin.test.ts (1)
packages/cli/test/utils.ts (2)
  • createProject (12-18)
  • runCli (20-23)
⏰ 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). (2)
  • GitHub Check: build-test (20.x, sqlite)
  • GitHub Check: build-test (20.x, postgresql)
🔇 Additional comments (3)
packages/cli/src/plugins/prisma.ts (2)

8-8: LGTM! Signature correctly updated.

Removing the schemaFile parameter aligns with the new approach of using defaultOutputPath as the base for output path resolution.


9-15: Run Prisma plugin tests with correct Vitest invocation
The previous test run failed because the vitest binary wasn’t found. In packages/cli, re-execute the Prisma plugin tests via:

npm exec vitest run test/plugins/prisma-plugin.test.ts

or

npx vitest run test/plugins/prisma-plugin.test.ts

to confirm no regressions.

packages/cli/test/plugins/prisma-plugin.test.ts (1)

61-80: LGTM! Test correctly validates the fix.

The test case properly verifies that the prisma plugin respects the global zenstack.output option when a relative plugin output path is specified. The setup, execution, and assertion clearly demonstrate the expected behavior described in issue #295.


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 and usage tips.

Copy link
Member

@ymc9 ymc9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @sanny-io !

@ymc9 ymc9 merged commit d3a5606 into zenstackhq:dev Oct 16, 2025
5 of 6 checks passed
@sanny-io sanny-io deleted the fix/issue-295 branch October 16, 2025 01:26
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