prisma icon indicating copy to clipboard operation
prisma copied to clipboard

Show Prisma CLI path in version output

Open oathis opened this issue 6 months ago โ€ข 3 comments

Summary

  • add the resolved Prisma CLI script path to prisma -v / prisma version output
  • sanitize the path in the existing version command snapshot

Tests

  • npx prettier --check packages/cli/src/Version.ts packages/cli/src/__tests__/commands/Version.test.ts
  • git diff --check

Note: I attempted corepack pnpm --filter prisma test -- Version.test.ts, but this local Windows checkout could not build/link workspace packages such as @prisma/engines after install. The changed snapshot covers the intended output shape.

Fixes #7771

@algora-pbc /claim #7771

oathis avatar May 30 '26 21:05 oathis

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 30 '26 21: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: 88ce86c6-5794-455e-a9b2-987ac31966da

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 42f91027828f3581066d01cc7f5d22a3006327d9 and 3c2629fd5b5e62cf4096509fad61df0efb860396.

๐Ÿ“’ Files selected for processing (2)
  • packages/cli/src/Version.ts
  • packages/cli/src/__tests__/commands/Version.test.ts

Summary by CodeRabbit

  • New Features
    • The prisma version command now displays the path to the Prisma CLI executable, showing the location of the CLI binary on your system.

Walkthrough

This PR adds a "Prisma CLI path" field to the prisma -v version output, displaying the resolved absolute path of the executing Prisma CLI binary or "Unknown" if unavailable. Implementation and test snapshot are updated together.

Changes

CLI Path Output

Layer / File(s) Summary
CLI path output implementation
packages/cli/src/Version.ts
Imports Node's path module and adds a "Prisma CLI path" row to the version table, resolving process.argv[1] via path.resolve() with "Unknown" fallback.
Test snapshot and sanitization
packages/cli/src/__tests__/commands/Version.test.ts
Version test snapshot is updated to include the new "Prisma CLI path" line, and cleanSnapshot is extended to replace the path value with PRISMA_CLI_PATH placeholder for stable test runs.

Estimated code review effort

๐ŸŽฏ 1 (Trivial) | โฑ๏ธ ~2 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 concisely describes the main change: adding the Prisma CLI path to version output.
Description check โœ… Passed The description is related to the changeset, explaining the addition of CLI path to version output and snapshot sanitization.
Linked Issues check โœ… Passed The PR successfully implements the requirement from issue #7771 by adding the resolved Prisma CLI script path to the prisma -v output.
Out of Scope Changes check โœ… Passed All changes are directly related to the linked issue #7771: adding CLI path reporting to version output and updating test snapshots accordingly.

โœ๏ธ 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 30 '26 21:05 coderabbitai[bot]

Thanks for the focused change โ€” the integration point (the rows array) and the sanitizer are right.

Blocking: the hand-written snapshot line is misaligned by one space. formatTable pads each label to the longest one (Default Engines Hash, 20 chars), so Prisma CLI path (15 chars) gets exactly 5 trailing spaces + : โ€” 6 spaces before the colon; the snapshot line has 7. Since your sanitizer preserves the real padding, the snapshot can never match and the test fails. The fix is to actually run the test and let Jest write the snapshot rather than hand-editing it (the PR notes the local environment couldn't build โ€” that's the missing step).

Also worth considering: path.resolve(process.argv[1]) points at the bin shim; fs.realpathSync would surface the actual install location.


We're triaging a large number of overlapping PRs for this issue. If we don't hear back within the next few days, we'll close this PR to keep the queue manageable.

tensordreams avatar Jun 04 '26 08:06 tensordreams