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> {
if (key === '__metadata') {
// yarn 2
lockfileVersion = parseInt(val.cacheKey, 10);
logger.once.debug(
`yarn.lock ${filePath} has __metadata.cacheKey=${lockfileVersion}`,
);
} else {
for (const entry of key.split(', ')) {
try {
......@@ -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 {
isYarn1: !('__metadata' in parsed),
isYarn1,
lockfileVersion,
lockedVersions,
};
......
import upath from 'upath';
import { logger } from '../../../../logger';
import { readLocalFile } from '../../../../util/fs';
import { Lazy } from '../../../../util/lazy';
import { PackageJson, PackageJsonSchema } from '../schema';
......@@ -30,10 +31,18 @@ export function getPackageManagerVersion(
pkg: PackageJsonSchema,
): string | null {
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]) {
return pkg.engines[name];
const version = pkg.engines[name];
logger.debug(
`Found ${name} constraint in package.json engines: ${version}`,
);
return version;
}
return null;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment