adding support for .tool-versions by avaines · Pull Request #33 · pnpm/setup · GitHub
Skip to content

adding support for .tool-versions - #33

Closed
avaines wants to merge 1 commit into
pnpm:mainfrom
avaines:addingToolVersionsSupport
Closed

avaines wants to merge 1 commit into
pnpm:mainfrom
avaines:addingToolVersionsSupport

Conversation

@avaines

@avaines avaines commented Aug 14, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added support for reading the pnpm version from a plain file or .tool-versions.
    • The explicit version setting takes precedence when both options are provided.
    • Added guidance for configuring file-based pnpm versions.
  • Bug Fixes

    • Improved errors and warnings for missing, invalid, or conflicting version configuration.
  • Tests

    • Added automated coverage for version-file parsing, validation, and error handling.
    • Added test and type-check validation to pull request checks.

@qodo-code-review

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 20ccb9fb-b12c-40f0-bfd5-6f94ead7126b

📥 Commits

Reviewing files that changed from the base of the PR and between 84cb39b and f67b432.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (9)
  • .github/workflows/pr-check.yaml
  • .github/workflows/test.yaml
  • README.md
  • action.yml
  • package.json
  • src/inputs/index.ts
  • src/install-pnpm/run.ts
  • src/version-file.ts
  • tests/version-file.test.ts

📝 Walkthrough

Walkthrough

The action adds a version-file input for plain files and .tool-versions. It parses and validates file-based pnpm versions, prioritizes explicit version, updates documentation, adds tests and type checking, and verifies .tool-versions in CI.

Changes

Version-file support

Layer / File(s) Summary
Version-file parsing and input contract
src/inputs/index.ts, src/version-file.ts
The input model accepts version-file. New helpers parse plain files and the pnpm entry in .tool-versions, with errors for missing or invalid versions.
Version resolution and validation
src/install-pnpm/run.ts
The installer resolves file paths from GITHUB_WORKSPACE, prioritizes version, reports the source of mismatches, and includes version-file in missing-version guidance.
Documentation, scripts, and workflow validation
action.yml, README.md, package.json, tests/version-file.test.ts, .github/workflows/test.yaml, .github/workflows/pr-check.yaml
Metadata and documentation describe version-file. Scripts run tests and type checking. Tests and workflows validate plain-file and .tool-versions handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant getInputs
  participant runSelfInstaller
  participant getPnpmVersionFromFile
  participant GITHUB_WORKSPACE

  Workflow->>getInputs: provide version-file
  getInputs->>runSelfInstaller: pass versionFile
  runSelfInstaller->>GITHUB_WORKSPACE: resolve file path
  runSelfInstaller->>getPnpmVersionFromFile: read version file
  getPnpmVersionFromFile-->>runSelfInstaller: return pnpm version
  runSelfInstaller-->>Workflow: validate and use version
Loading

Poem

I’m a rabbit with a version-file tune,
Parsing pnpm beneath the moon.
.tool-versions hops into view,
Tests and type checks join the queue.
Explicit versions lead the way—
CI confirms the setup today.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@avaines
avaines marked this pull request as draft August 14, 2026 15:39
@avaines avaines closed this Aug 14, 2026
@avaines
avaines deleted the addingToolVersionsSupport branch August 14, 2026 15:39
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The compatible range/packageManager conflict should be fixed before merging because it breaks a documented version-file configuration.

The new version-file path accepts ranges and dist-tags but compares them textually against an exact packageManager version, causing compatible configurations to fail before resolution.

Files Needing Attention: src/install-pnpm/run.ts, src/version-file.ts

Reviews (1): Last reviewed commit: "adding support for .tool-versions" | Re-trigger Greptile

Comment thread src/install-pnpm/run.ts
if (version) {
if (packageManagerVersion && packageManagerVersion !== version) {
if (requestedVersion) {
if (packageManagerVersion && packageManagerVersion !== requestedVersion) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Compatible version specs conflict

When a plain version file contains a range or dist-tag compatible with the exact packageManager version, this raw string comparison treats the two specifications as conflicting and aborts setup instead of resolving and installing pnpm.

Comment thread src/version-file.ts
Comment on lines +5 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Parser comments narrate behavior

This JSDoc restates the parser branches and accepted values, duplicating behavior that must then remain synchronized with the implementation and tests. The added workflow comment follows the same pattern even though its job name and steps already communicate its purpose.

Context Used: Comments and docs in code are suspicious. Is test ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant