feat(cli): add Prisma CLI path to version output#29275
feat(cli): add Prisma CLI path to version output#29275quantbitrealmSimon wants to merge 2 commits intoprisma:mainfrom
Conversation
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
|
|
WalkthroughAdds a "Prisma CLI Path" field to the Changes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
- 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
| // sanitize Prisma CLI Path | ||
| str = str.replace(new RegExp('(Prisma CLI Path\s+:) .*', 'g'), '$1 sanitized_path') |
There was a problem hiding this comment.
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.
| // 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') |
| // Get the Prisma CLI path from the current file location | ||
| const prismaCliPath = path.resolve(__dirname, '..') |
There was a problem hiding this comment.
🧹 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.
| // Get the Prisma CLI path from the current file location | |
| const prismaCliPath = path.resolve(__dirname, '..') | |
| const prismaCliPath = path.resolve(__dirname, '..') |
jacek-prisma
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
It looks like some of the CLI test snapshots are failing after your changes due to the version.
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
Tests