Skip to content

Conversation

@puzzler7
Copy link
Collaborator

Currently, we only install the latest pnpm version, which fails if the user has specified a pnpm version under packageManager in their package.json. This PR changes that to attempt to parse the version out of the package.json before defaulting to latest.

The pnpm/action-setup action does have logic for parsing the version out of the package.json, but we cannot provide both an version and a version in the package.json, or it will fail (source link).

Tested manually, both with and without the packageManager field.

shell: bash
run: |
if [ -e package.json ] && command -v jq >/dev/null; then
PNPM_VERSION=$(jq -r '.packageManager|split("@")[1]' package.json || echo "")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Splitting because the format in package.json is pnpm@version-num and we just need the version number.

@puzzler7 puzzler7 requested review from TylerJang27, det and jennygzma May 16, 2024 00:24
Copy link
Contributor

@TylerJang27 TylerJang27 left a comment

Choose a reason for hiding this comment

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

LGTM. Would be nice to at a trunk tools install jq dependency at some point for this

@puzzler7 puzzler7 merged commit f6c5f1b into main May 16, 2024
@puzzler7 puzzler7 deleted the maverick/trunk-11473-install-correct-pnpm-version-in-trunk-action branch May 16, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants