mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 08:36:26 +00:00
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
const { getNpmLock } = require('./npm');
|
|
const { getYarnLock } = require('./yarn');
|
|
|
|
module.exports = {
|
|
getLockedVersions,
|
|
};
|
|
|
|
async function getLockedVersions(packageFiles) {
|
|
const lockFileCache = {};
|
|
logger.debug('Finding locked versions');
|
|
for (const packageFile of packageFiles) {
|
|
const { yarnLock, npmLock, pnpmShrinkwrap } = packageFile;
|
|
if (yarnLock) {
|
|
logger.trace('Found yarnLock');
|
|
if (!lockFileCache[yarnLock]) {
|
|
logger.debug('Retrieving/parsing ' + yarnLock);
|
|
lockFileCache[yarnLock] = await getYarnLock(yarnLock);
|
|
}
|
|
for (const dep of packageFile.deps) {
|
|
dep.lockedVersion =
|
|
lockFileCache[yarnLock][`${dep.depName}@${dep.currentVersion}`];
|
|
}
|
|
} else if (npmLock) {
|
|
logger.debug({ npmLock }, 'npm lockfile');
|
|
if (!lockFileCache[npmLock]) {
|
|
logger.debug('Retrieving/parsing ' + npmLock);
|
|
lockFileCache[npmLock] = await getNpmLock(npmLock);
|
|
}
|
|
for (const dep of packageFile.deps) {
|
|
dep.lockedVersion = lockFileCache[npmLock][dep.depName];
|
|
}
|
|
} else if (pnpmShrinkwrap) {
|
|
logger.info('TODO: implement shrinkwrap.yaml parsing of lockVersion');
|
|
}
|
|
}
|
|
}
|