renovate/lib/workers/repository/process/deprecated.js
Rhys Arkins 7c0a17e9d0 feat: group together deprecation warnings
Previously, deprecation warnings were done as part of dependency lookups, which were run concurrently. This meant the chance of duplicate issues was high, due to race conditions. Instead, raising the issues is done once all package are looked up, to ensure only one issue per manager/dependency. It also means we can list all of the affected package files, in case of a monorepo.

Closes #2224, Closes #2225
2018-07-05 14:23:28 +02:00

45 lines
1.8 KiB
JavaScript

module.exports = {
raiseDeprecationWarnings,
};
async function raiseDeprecationWarnings(config, packageFiles) {
if (!config.raiseDeprecationWarnings) {
return;
}
const deprecatedPackages = {};
for (const [manager, files] of Object.entries(packageFiles)) {
for (const packageFile of files) {
for (const dep of packageFile.deps) {
const { deprecationMessage } = dep;
if (deprecationMessage) {
deprecatedPackages[dep.depName] = deprecatedPackages[dep.depName] || {
deprecationMessage,
depPackageFiles: [],
};
deprecatedPackages[dep.depName].depPackageFiles.push(
packageFile.packageFile
);
}
}
}
logger.debug({ deprecatedPackages });
for (const [depName, val] of Object.entries(deprecatedPackages)) {
const { deprecationMessage, depPackageFiles } = val;
logger.info(
{
depName,
deprecationMessage,
packageFiles: depPackageFiles,
},
'npm dependency is deprecated'
);
const issueTitle = `Dependency deprecation warning: ${depName} (${manager})`;
let issueBody = deprecationMessage;
issueBody += `\n\nPlease take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using \`${depName}\` as-is, please add it to your [ignoreDeps](https://renovatebot.com/docs/configuration-options/#ignoredeps) array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.`;
issueBody += `\n\nAffected package file(s): ${depPackageFiles
.map(f => '`' + f + '`')
.join(', ')}`;
await platform.ensureIssue(issueTitle, issueBody);
}
}
}