Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build-utils] log pnpm lockfile selection #11591

Merged
merged 6 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-zoos-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vercel/build-utils": patch
---

[build-utils] pnpm lockfile testing and fixing
14 changes: 13 additions & 1 deletion packages/build-utils/src/fs/run-user-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ export function getEnvForPackageManager({

type DetectedPnpmVersion =
| 'not found'
| 'pnpm 6'
| 'pnpm 7'
| 'pnpm 8'
| 'pnpm 9'
Expand All @@ -608,7 +609,9 @@ function detectPnpmVersion(
return 'corepack_enabled';
case lockfileVersion === undefined:
return 'not found';
case lockfileVersion === 5.3 || lockfileVersion === 5.4:
case lockfileVersion === 5.3:
return 'pnpm 6';
case lockfileVersion === 5.4:
return 'pnpm 7';
case lockfileVersion === 6.0 || lockfileVersion === 6.1:
return 'pnpm 8';
Expand Down Expand Up @@ -703,6 +706,7 @@ export function getPathOverrideForPackageManager({
detectedLockfile: 'pnpm-lock.yaml',
detectedPackageManager: 'pnpm 9',
};
case 'pnpm 6':
default:
return no_override;
}
Expand Down Expand Up @@ -764,6 +768,14 @@ export function getPathForPackageManager({
env,
});

debug(
`Detected ${
overrides.detectedPackageManager
} with lockfileVersion ${lockfileVersion} (${typeof lockfileVersion}): ${
overrides.path
}`
);

const alreadyInPath = (newPath: string) => {
const oldPath = env.PATH ?? '';
return oldPath.split(path.delimiter).includes(newPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ describe('Test `getPathOverrideForPackageManager()`', () => {
path: undefined,
},
},
{
name: 'should not set path if pnpm 6 is detected',
args: {
cliType: 'pnpm',
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
lockfileVersion: 5.3, // detects as pnpm@6, which is the default
env: {
FOO: 'bar',
PATH: 'foo',
},
},
want: {
detectedLockfile: undefined,
detectedPackageManager: undefined,
path: undefined,
},
},
{
name: 'should set path if pnpm 7+ is detected',
args: {
Expand Down
72 changes: 59 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading