feat(cli): show Prisma CLI path in version output
/claim #7771 Fixes #7771
Summary
- add the running Prisma CLI package path to
prisma -v/prisma version - resolve the path from the CLI package metadata so the reported location matches the CLI that is actually executing
- add test coverage for both the human-readable output and the JSON output
Why
Issue #7771 asks for a way to tell which Prisma CLI installation is actually running. This helps when prisma resolves to a parent or otherwise unexpected install and the current version output does not reveal that.
Implementation
- compute
prismaCliPathfrompath.dirname(require.resolve('../package.json')) - append a
Prisma CLI Pathrow to the version output table - update the inline snapshot for the version command
- add a JSON regression test asserting the
prisma-cli-pathfield
Verification
pnpm --filter "prisma..." buildpnpm test src/__tests__/commands/Version.test.tspnpm exec eslint packages/cli/src/Version.ts packages/cli/src/__tests__/commands/Version.test.tspnpm exec prettier --check packages/cli/src/Version.ts packages/cli/src/__tests__/commands/Version.test.tsnode packages/cli/build/index.js -vnode packages/cli/build/index.js version --json
This contribution was prepared with AI assistance under human direction and review. I inspected the change, verified the behavior described here, and am responsible for the submission.
No actionable comments were generated in the recent review. ๐
โน๏ธ Recent review info
โ๏ธ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e2f9cfba-fcbe-4702-bc74-1afe9a5ffb0c
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 42f91027828f3581066d01cc7f5d22a3006327d9 and fd3a62443d3fefe2f56cc8e737f63d4ebe98dc4e.
๐ Files selected for processing (2)
packages/cli/src/Version.tspackages/cli/src/__tests__/commands/Version.test.ts
Summary by CodeRabbit
- New Features
- The
versioncommand now displays the Prisma CLI Path in its output, available in both table and JSON formats.
- The
Walkthrough
The version command implementation now resolves and displays the Prisma CLI's installation directory path. The Version.ts module computes this path by resolving the CLI package.json and extracting its directory, then includes it in the version output table and JSON response. Corresponding test cases validate both human-readable and JSON output formats, with snapshot sanitization for stable test runs.
Changes
CLI Path Version Output
| Layer / File(s) | Summary |
|---|---|
CLI path computation and output packages/cli/src/Version.ts |
The path module is imported. A prismaCliPath variable is computed by resolving the CLI package.json and extracting its directory with path.dirname(). A "Prisma CLI Path" row is added to the version output table for display in both CLI and JSON output. |
Version output test updates packages/cli/src/__tests__/commands/Version.test.ts |
The test file imports the path module. The human-readable version output snapshot is extended to include the CLI path line. A new test validates that version --json includes a prisma-cli-path field with the expected directory value. The snapshot sanitizer is updated to replace the CLI path value with a stable normalized value for reliable test assertions. |
๐ฏ 2 (Simple) | โฑ๏ธ ~10 minutes
๐ฅ 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 |
|---|---|---|
| Title check | โ Passed | The title clearly and specifically describes the main change: adding Prisma CLI path to version output. |
| Description check | โ Passed | The description is directly related to the changeset, providing context, implementation details, and verification steps for the CLI path feature. |
| 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. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
โจ Simplify code
- [ ] Create PR with simplified code
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 @coderabbitai help to get the list of available commands and usage tips.
Thanks โ this looks correct end to end: the resolution reuses the existing require('../package.json') pattern, the snapshot alignment matches formatTable's padding, the sanitizer is right, and the JSON test asserting the slugified prisma-cli-path key is a nice touch. No blocking issues from our review; we'll get full CI running on it.