renovate/lib/config/validation-helpers/managers.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

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