Skip to content
Snippets Groups Projects
Unverified Commit 5c386948 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

chore(yarn): improve logging for version detection (#27629)

parent f6fc1284
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,9 @@ export async function getYarnLock(filePath: string): Promise<LockFile> { ...@@ -21,6 +21,9 @@ export async function getYarnLock(filePath: string): Promise<LockFile> {
if (key === '__metadata') { if (key === '__metadata') {
// yarn 2 // yarn 2
lockfileVersion = parseInt(val.cacheKey, 10); lockfileVersion = parseInt(val.cacheKey, 10);
logger.once.debug(
`yarn.lock ${filePath} has __metadata.cacheKey=${lockfileVersion}`,
);
} else { } else {
for (const entry of key.split(', ')) { for (const entry of key.split(', ')) {
try { try {
...@@ -39,8 +42,18 @@ export async function getYarnLock(filePath: string): Promise<LockFile> { ...@@ -39,8 +42,18 @@ export async function getYarnLock(filePath: string): Promise<LockFile> {
} }
} }
} }
const isYarn1 = !('__metadata' in parsed);
if (isYarn1) {
logger.once.debug(
`yarn.lock ${filePath} is has no __metadata so is yarn 1`,
);
} else {
logger.once.debug(
`yarn.lock ${filePath} is has __metadata so is yarn 2+`,
);
}
return { return {
isYarn1: !('__metadata' in parsed), isYarn1,
lockfileVersion, lockfileVersion,
lockedVersions, lockedVersions,
}; };
......
import upath from 'upath'; import upath from 'upath';
import { logger } from '../../../../logger';
import { readLocalFile } from '../../../../util/fs'; import { readLocalFile } from '../../../../util/fs';
import { Lazy } from '../../../../util/lazy'; import { Lazy } from '../../../../util/lazy';
import { PackageJson, PackageJsonSchema } from '../schema'; import { PackageJson, PackageJsonSchema } from '../schema';
...@@ -30,10 +31,18 @@ export function getPackageManagerVersion( ...@@ -30,10 +31,18 @@ export function getPackageManagerVersion(
pkg: PackageJsonSchema, pkg: PackageJsonSchema,
): string | null { ): string | null {
if (pkg.packageManager?.name === name) { if (pkg.packageManager?.name === name) {
return pkg.packageManager.version; const version = pkg.packageManager.version;
logger.debug(
`Found ${name} constraint in package.json packageManager: ${version}`,
);
return version;
} }
if (pkg.engines?.[name]) { if (pkg.engines?.[name]) {
return pkg.engines[name]; const version = pkg.engines[name];
logger.debug(
`Found ${name} constraint in package.json engines: ${version}`,
);
return version;
} }
return null; return null;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment