Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

MANIFEST.in

Blame
  • validation.ts 20.37 KiB
    import is from '@sindresorhus/is';
    import { getLanguageList, getManagerList } from '../manager';
    import { configRegexPredicate, isConfigRegex, regEx } from '../util/regex';
    import * as template from '../util/template';
    import { hasValidSchedule, hasValidTimezone } from '../workers/branch/schedule';
    import { migrateConfig } from './migration';
    import { getOptions } from './options';
    import { resolveConfigPresets } from './presets';
    import type {
      RenovateConfig,
      RenovateOptions,
      ValidationMessage,
      ValidationResult,
    } from './types';
    import * as managerValidator from './validation-helpers/managers';
    
    const options = getOptions();
    
    let optionTypes: Record<string, RenovateOptions['type']>;
    let optionParents: Record<string, RenovateOptions['parent']>;
    
    const managerList = getManagerList();
    
    const topLevelObjects = getLanguageList().concat(getManagerList());
    
    const ignoredNodes = [
      '$schema',
      'depType',
      'npmToken',
      'packageFile',
      'forkToken',
      'repository',
      'vulnerabilityAlertsOnly',
      'vulnerabilityAlert',
      'isVulnerabilityAlert',
      'copyLocalLibs', // deprecated - functionality is now enabled by default
      'prBody', // deprecated
      'minimumConfidence', // undocumented feature flag
    ];
    const tzRe = regEx(/^:timezone\((.+)\)$/);
    const rulesRe = regEx(/p.*Rules\[\d+\]$/);
    function isManagerPath(parentPath: string): boolean {
      return (
        regEx(/^regexManagers\[[0-9]+]$/).test(parentPath) ||
        managerList.includes(parentPath)
      );
    }
    
    function isIgnored(key: string): boolean {
      return ignoredNodes.includes(key);
    }
    
    function validateAliasObject(val: Record<string, unknown>): true | string {
      for (const [key, value] of Object.entries(val)) {
        if (!is.urlString(value)) {
          return key;
        }
      }
      return true;
    }
    
    function validatePlainObject(val: Record<string, unknown>): true | string {
      for (const [key, value] of Object.entries(val)) {
        if (!is.string(value)) {
          return key;
        }
      }
      return true;
    }