prisma icon indicating copy to clipboard operation
prisma copied to clipboard

feat(cli): show Prisma CLI path in version output

Open symbiosis-institute opened this issue 6 months ago โ€ข 3 comments

/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 prismaCliPath from path.dirname(require.resolve('../package.json'))
  • append a Prisma CLI Path row to the version output table
  • update the inline snapshot for the version command
  • add a JSON regression test asserting the prisma-cli-path field

Verification

  • pnpm --filter "prisma..." build
  • pnpm test src/__tests__/commands/Version.test.ts
  • pnpm exec eslint packages/cli/src/Version.ts packages/cli/src/__tests__/commands/Version.test.ts
  • pnpm exec prettier --check packages/cli/src/Version.ts packages/cli/src/__tests__/commands/Version.test.ts
  • node packages/cli/build/index.js -v
  • node 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.

symbiosis-institute avatar May 26 '26 02:05 symbiosis-institute

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 26 '26 02:05 CLAassistant

Review Change Stack

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.ts
  • packages/cli/src/__tests__/commands/Version.test.ts

Summary by CodeRabbit

  • New Features
    • The version command now displays the Prisma CLI Path in its output, available in both table and JSON formats.

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.

โค๏ธ Share

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

coderabbitai[bot] avatar May 26 '26 02:05 coderabbitai[bot]

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.

tensordreams avatar Jun 04 '26 08:06 tensordreams