Skip to content

feat(cli): add Prisma CLI path to version output#29275

Open
quantbitrealmSimon wants to merge 2 commits intoprisma:mainfrom
quantbitrealmSimon:fix/add-prisma-path-to-version
Open

feat(cli): add Prisma CLI path to version output#29275
quantbitrealmSimon wants to merge 2 commits intoprisma:mainfrom
quantbitrealmSimon:fix/add-prisma-path-to-version

Conversation

@quantbitrealmSimon
Copy link
Copy Markdown

@quantbitrealmSimon quantbitrealmSimon commented Feb 28, 2026

Adds the Prisma CLI installation path to the version command output to help debug which installation is being used.

Fixes #7771

Summary by CodeRabbit

  • New Features

    • Version command now shows the Prisma CLI installation path in its output.
  • Tests

    • Updated test snapshots and sanitization logic to include and verify the new CLI path field in version information.

Adds the installation path of the Prisma CLI to the version command output.
This helps users debug issues where multiple Prisma installations exist.

Fixes prisma#7771
@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
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 28, 2026

Walkthrough

Adds a "Prisma CLI Path" field to the prisma -v output by computing and exposing the resolved installation directory of the CLI; updates tests and snapshot sanitization to account for the new field.

Changes

Cohort / File(s) Summary
Version output & CLI path
packages/cli/src/Version.ts
Imports path, computes prismaCliPath as the resolved parent directory of the current file, and adds a "Prisma CLI Path" row to the version output table. Minor row-rendering formatting adjusted to include the new field.
Tests & snapshots
packages/cli/src/__tests__/commands/Version.test.ts
Updated inline snapshot to include the new "Prisma CLI Path" line and added sanitization step replacing that line with sanitized_path.
🚥 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 'feat(cli): add Prisma CLI path to version output' accurately and specifically describes the main change introduced in this PR.
Linked Issues check ✅ Passed The PR successfully implements the main requirement from issue #7771 by adding the Prisma CLI installation path to version command output for better debugging.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the requested feature: Version.ts adds CLI path computation and output, while Version.test.ts updates corresponding snapshots.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 455853d and c5dd13d.

📒 Files selected for processing (2)
  • packages/cli/src/Version.ts
  • packages/cli/src/__tests__/commands/Version.test.ts

- Fix regex bug in Version.test.ts that was appending instead of replacing path
- Use node:path prefix for built-in module import in Version.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5dd13d and 25a3749.

📒 Files selected for processing (2)
  • packages/cli/src/Version.ts
  • packages/cli/src/__tests__/commands/Version.test.ts

Comment on lines +77 to +78
// sanitize Prisma CLI Path
str = str.replace(new RegExp('(Prisma CLI Path\s+:) .*', 'g'), '$1 sanitized_path')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Bug: Missing escape in regex — \s should be \\s.

Inside a regular string passed to new RegExp(), backslashes must be doubled. Currently \s is interpreted as the literal character s (since \s isn't a recognized JS string escape), so the pattern becomes (Prisma CLI Paths+:) which won't match the output with multiple spaces.

All other similar patterns in this file correctly use \\s (see lines 65, 66, 69).

🐛 Proposed fix
   // sanitize Prisma CLI Path
-  str = str.replace(new RegExp('(Prisma CLI Path\s+:) .*', 'g'), '$1 sanitized_path')
+  str = str.replace(new RegExp('(Prisma CLI Path\\s+:) .*', 'g'), '$1 sanitized_path')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// sanitize Prisma CLI Path
str = str.replace(new RegExp('(Prisma CLI Path\s+:) .*', 'g'), '$1 sanitized_path')
// sanitize Prisma CLI Path
str = str.replace(new RegExp('(Prisma CLI Path\\s+:) .*', 'g'), '$1 sanitized_path')

Comment on lines +83 to +84
// Get the Prisma CLI path from the current file location
const prismaCliPath = path.resolve(__dirname, '..')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Remove the comment — it restates the code.

Per coding guidelines, inline comments should explain why, not what or how. The code path.resolve(__dirname, '..') is self-explanatory; the comment adds no new information.

♻️ Suggested change
-    // Get the Prisma CLI path from the current file location
     const prismaCliPath = path.resolve(__dirname, '..')

As per coding guidelines: "Only write inline comments explaining Why (context, background, GitHub issues, decisions), not What or How."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Get the Prisma CLI path from the current file location
const prismaCliPath = path.resolve(__dirname, '..')
const prismaCliPath = path.resolve(__dirname, '..')

Copy link
Copy Markdown
Contributor

@jacek-prisma jacek-prisma left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!
It looks like some of the CLI test snapshots are failing after your changes due to the version.

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.

Output path of current Prisma in -v

4 participants