0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-17 17:42:10 +00:00
renovatebot_renovate/lib/config/validation-helpers/managers.ts

38 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

import { allManagersList, isKnownManager } from '../../modules/manager';
import type { ValidationMessage } from '../types';
import type { CheckManagerArgs } from './types';
2019-08-23 15:46:31 +02:00
2019-02-20 23:29:38 +02:00
/**
* Only if type condition or context condition violated then errors array will be mutated to store metadata
*/
2019-08-23 15:46:31 +02:00
export function check({
resolvedRule,
currentPath,
}: CheckManagerArgs): ValidationMessage[] {
let managersErrMessage: string | undefined;
if (Array.isArray(resolvedRule.matchManagers)) {
2019-02-20 23:29:38 +02:00
if (
resolvedRule.matchManagers.find(
(confManager) => !isKnownManager(confManager),
2019-02-20 23:29:38 +02:00
)
) {
managersErrMessage = `${currentPath}:
You have included an unsupported manager in a package rule. Your list: ${String(
resolvedRule.matchManagers,
)}.
Supported managers are: (${allManagersList.join(', ')}).`;
2019-02-20 23:29:38 +02:00
}
} else if (typeof resolvedRule.matchManagers !== 'undefined') {
managersErrMessage = `${currentPath}: Managers should be type of List. You have included ${typeof resolvedRule.matchManagers}.`;
}
2019-02-20 23:29:38 +02:00
return managersErrMessage
? [
{
topic: 'Configuration Error',
2019-02-20 23:29:38 +02:00
message: managersErrMessage,
},
]
: [];
2019-08-23 15:46:31 +02:00
}