renovate/lib/workers/repository/error-config.js
Rhys Arkins f0cd0cb8b8
feat: raise config action issue if failing to look up locked dependency (#1704)
If an npm dependency can’t be found, and the package.json has a lock file, then Renovate will encounter lock file errors every time *any* dependency in that package.json has an update. Instead of raising PRs with an error, we instead now stop raising PRs and instead raise a config warning issue. Users can “dismiss” this by setting config option `updateLockFiles` to false.

Closes #1697
2018-03-22 11:55:58 +01:00

30 lines
1.2 KiB
JavaScript

module.exports = {
raiseConfigWarningIssue,
};
async function raiseConfigWarningIssue(config, error) {
logger.debug('raiseConfigWarningIssue()');
let body = `There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.\n\n`;
if (error.configFile) {
body += `File: \`${error.configFile}\`\n`;
}
body += `Error type: ${error.validationError}\n`;
if (error.validationMessage) {
body += `Message: ${error.validationMessage}\n`;
}
const pr = await platform.getBranchPr('renovate/configure');
if (pr && pr.state && pr.state.startsWith('open')) {
logger.info('Updating onboarding PR with config error notice');
body = `## Action Required: Fix Renovate Configuration\n\n${body}`;
body += `\n\nOnce you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration.`;
await platform.updatePr(pr.number, 'Configure Renovate', body);
} else {
const res = await platform.ensureIssue(
'Action Required: Fix Renovate Configuration',
body
);
if (res === 'created') {
logger.warn({ configError: error, res }, 'Config Warning');
}
}
}