renovate 43.208.0 → 43.208.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/config/validation.js +2 -2
  2. package/dist/config/validation.js.map +1 -1
  3. package/dist/config-validator.js +1 -1
  4. package/dist/config-validator.js.map +1 -1
  5. package/dist/modules/datasource/crate/index.js +3 -3
  6. package/dist/modules/datasource/crate/index.js.map +1 -1
  7. package/dist/modules/datasource/crate/schema.js +2 -2
  8. package/dist/modules/datasource/crate/schema.js.map +1 -1
  9. package/dist/modules/datasource/elm-package/index.js +2 -2
  10. package/dist/modules/datasource/elm-package/index.js.map +1 -1
  11. package/dist/modules/datasource/elm-package/schema.js +2 -2
  12. package/dist/modules/datasource/elm-package/schema.js.map +1 -1
  13. package/dist/modules/datasource/helm/index.js.map +1 -1
  14. package/dist/modules/datasource/helm/schema.js.map +1 -1
  15. package/dist/modules/manager/composer/schema.js.map +1 -1
  16. package/dist/modules/manager/github-actions/community.js +5 -5
  17. package/dist/modules/manager/github-actions/community.js.map +1 -1
  18. package/dist/modules/manager/vendir/extract.js.map +1 -1
  19. package/dist/modules/manager/vendir/schema.js.map +1 -1
  20. package/dist/modules/platform/gitlab/pr-cache.js +2 -2
  21. package/dist/modules/platform/gitlab/pr-cache.js.map +1 -1
  22. package/dist/modules/platform/gitlab/schema.js +10 -10
  23. package/dist/modules/platform/gitlab/schema.js.map +1 -1
  24. package/dist/modules/platform/scm-manager/schema.js +17 -17
  25. package/dist/modules/platform/scm-manager/schema.js.map +1 -1
  26. package/dist/modules/platform/scm-manager/scm-manager-helper.js +7 -7
  27. package/dist/modules/platform/scm-manager/scm-manager-helper.js.map +1 -1
  28. package/dist/util/cache/repository/impl/base.js +2 -2
  29. package/dist/util/cache/repository/impl/base.js.map +1 -1
  30. package/dist/util/cache/repository/schema.js +2 -2
  31. package/dist/util/cache/repository/schema.js.map +1 -1
  32. package/dist/util/emoji.js.map +1 -1
  33. package/dist/workers/repository/process/lookup/index.js +1 -1
  34. package/dist/workers/repository/process/lookup/index.js.map +1 -1
  35. package/dist/workers/repository/process/vulnerabilities.js +2 -2
  36. package/dist/workers/repository/process/vulnerabilities.js.map +1 -1
  37. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { regEx } from "../util/regex.js";
2
2
  import { getConfigFileNames } from "./app-strings.js";
3
3
  import { GlobalConfig } from "./global.js";
4
- import { getRegexPredicate, isRegexMatch, matchRegexOrGlobList } from "../util/string-match.js";
4
+ import { anyMatchRegexOrGlobList, getRegexPredicate, isRegexMatch, matchRegexOrGlobList } from "../util/string-match.js";
5
5
  import { logger } from "../logger/index.js";
6
6
  import { AllManagersListLiteral, CustomManagersListLiteral } from "../manager-list.generated.js";
7
7
  import { AllVersioningsListLiteral } from "../versioning-list.generated.js";
@@ -708,7 +708,7 @@ async function validateGlobalConfig(key, val, type, warnings, errors, currentPat
708
708
  } else if (key === "cacheTtlOverride") for (const [subKey, subValue] of Object.entries(val)) {
709
709
  const allowsNegative = optionAllowsNegativeIntegers.has(key);
710
710
  warnings.push(...validateNumber(key, subValue, allowsNegative, currentPath, subKey));
711
- if (!packageCacheNamespaces.includes(subKey)) errors.push({
711
+ if (!packageCacheNamespaces.includes(subKey) && !anyMatchRegexOrGlobList(packageCacheNamespaces, [subKey])) errors.push({
712
712
  message: `${currentPath}: namespace \`${subKey}\` does not exist`,
713
713
  topic: "Configuration Error"
714
714
  });
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":["regexOrGlobValidator.check","matchBaseBranchesValidator.check"],"sources":["../../lib/config/validation.ts"],"sourcesContent":["import is, {\n isArray,\n isEmptyString,\n isNonEmptyArray,\n isNonEmptyString,\n isObject,\n isPlainObject,\n isString,\n isUndefined,\n} from '@sindresorhus/is';\nimport type { PlatformId } from '../constants/index.ts';\nimport { logger } from '../logger/index.ts';\nimport {\n AllManagersListLiteral,\n CustomManagersListLiteral,\n} from '../manager-list.generated.ts';\nimport { isCustomManager } from '../modules/manager/custom/index.ts';\nimport type { CustomManager } from '../modules/manager/custom/types.ts';\nimport type { HostRule } from '../types/index.ts';\nimport { packageCacheNamespaces } from '../util/cache/package/namespaces.ts';\nimport { getToolConfig } from '../util/exec/containerbase.ts';\nimport { isConstraintName, isToolName } from '../util/exec/types.ts';\nimport { getExpression } from '../util/jsonata.ts';\nimport { regEx } from '../util/regex.ts';\nimport {\n getRegexPredicate,\n isRegexMatch,\n matchRegexOrGlobList,\n} from '../util/string-match.ts';\nimport * as template from '../util/template/index.ts';\nimport { parseUrl } from '../util/url.ts';\nimport {\n AllVersioningsListLiteral,\n type VersioningName,\n} from '../versioning-list.generated.ts';\nimport {\n hasValidSchedule,\n hasValidTimezone,\n} from '../workers/repository/update/branch/schedule.ts';\nimport { getConfigFileNames } from './app-strings.ts';\nimport { GlobalConfig } from './global.ts';\nimport { migrateConfig } from './migration.ts';\nimport { getOptions } from './options/index.ts';\nimport { resolveConfigPresets } from './presets/index.ts';\nimport { supportedDatasources } from './presets/internal/merge-confidence.preset.ts';\nimport { parsePreset } from './presets/parse.ts';\nimport type {\n AllConfig,\n AllowedParents,\n RenovateConfig,\n RenovateOptions,\n StatusCheckKey,\n ValidationMessage,\n ValidationResult,\n} from './types.ts';\nimport { allowedStatusCheckStrings } from './types.ts';\nimport * as matchBaseBranchesValidator from './validation-helpers/match-base-branches.ts';\nimport * as regexOrGlobValidator from './validation-helpers/regex-glob-matchers.ts';\nimport {\n getParentName,\n isFalseGlobal,\n validateJSONataManagerFields,\n validateNumber,\n validatePlainObject,\n validateRegexManagerFields,\n} from './validation-helpers/utils.ts';\n\nconst options = getOptions();\n\nlet optionsInitialized = false;\nlet optionTypes: Record<string, RenovateOptions['type']>;\nlet optionParents: Record<string, AllowedParents[]>;\nlet optionGlobals: Set<string>;\nlet optionInherits: Set<string>;\nlet optionRegexOrGlob: Set<string>;\nlet optionAllowsNegativeIntegers: Set<string>;\nlet optionSupportsTemplating: Set<string>;\n\nconst managerList: readonly string[] = AllManagersListLiteral;\n\nconst allManagersList: readonly string[] = [\n ...AllManagersListLiteral,\n ...CustomManagersListLiteral,\n];\n\nconst topLevelObjects = [...managerList, 'env'];\n\nconst ignoredNodes = [\n '$schema',\n 'headers',\n 'depType',\n 'npmToken',\n 'packageFile',\n 'forkToken',\n 'repository',\n 'vulnerabilityAlertsOnly',\n 'vulnerabilityAlert',\n 'isVulnerabilityAlert',\n 'vulnerabilityFixVersion', // not intended to be used by end users but may be by Mend apps\n 'copyLocalLibs', // deprecated - functionality is now enabled by default\n 'prBody', // deprecated\n 'minimumConfidence', // undocumented feature flag\n];\nconst tzRe = regEx(/^:timezone\\((.+)\\)$/);\nconst rulesRe = regEx(/p.*Rules\\[\\d+\\]$/);\n\nfunction isIgnored(key: string): boolean {\n return ignoredNodes.includes(key);\n}\n\nfunction getUnsupportedEnabledManagers(enabledManagers: string[]): string[] {\n return enabledManagers.filter(\n (manager) => !allManagersList.includes(manager.replace('custom.', '')),\n );\n}\n\nfunction getDeprecationMessage(option: string): string | undefined {\n const deprecatedOptions: Record<string, string | undefined> = {\n branchName: `Direct editing of branchName is now deprecated. Please edit branchPrefix, additionalBranchPrefix, or branchTopic instead`,\n commitMessage: `Direct editing of commitMessage is now deprecated. Please edit commitMessage's subcomponents instead.`,\n prTitle: `Direct editing of prTitle is now deprecated. Please edit commitMessage subcomponents instead as they will be passed through to prTitle.`,\n };\n if (deprecatedOptions[option]) {\n return deprecatedOptions[option];\n }\n\n const found = options.find((o) => o.name === option);\n if (!found) {\n return undefined;\n }\n\n if (!found.deprecationMsg) {\n return undefined;\n }\n\n return `The '${option}' option is deprecated: ${found.deprecationMsg}`;\n}\n\nfunction isInhertConfigOption(key: string): boolean {\n return optionInherits.has(key);\n}\n\nfunction isRegexOrGlobOption(key: string): boolean {\n return optionRegexOrGlob.has(key);\n}\n\nfunction isGlobalOption(key: string): boolean {\n return optionGlobals.has(key);\n}\n\nfunction initOptions(): void {\n if (optionsInitialized) {\n return;\n }\n\n optionParents = {};\n optionInherits = new Set();\n optionTypes = {};\n optionRegexOrGlob = new Set();\n optionGlobals = new Set();\n optionAllowsNegativeIntegers = new Set();\n optionSupportsTemplating = new Set();\n\n for (const option of options) {\n optionTypes[option.name] = option.type;\n\n if (option.parents) {\n optionParents[option.name] = option.parents;\n }\n\n if (option.inheritConfigSupport) {\n optionInherits.add(option.name);\n }\n\n if (option.patternMatch) {\n optionRegexOrGlob.add(option.name);\n }\n\n if (option.globalOnly) {\n optionGlobals.add(option.name);\n }\n\n if (option.allowNegative) {\n optionAllowsNegativeIntegers.add(option.name);\n }\n\n if (option.supportsTemplating) {\n optionSupportsTemplating.add(option.name);\n }\n }\n\n optionsInitialized = true;\n}\n\nexport async function validateConfig(\n configType: 'global' | 'inherit' | 'repo',\n config: AllConfig,\n isPreset?: boolean,\n parentPath?: string,\n): Promise<ValidationResult> {\n initOptions();\n\n let errors: ValidationMessage[] = [];\n let warnings: ValidationMessage[] = [];\n\n for (const [key, val] of Object.entries(config)) {\n const currentPath = parentPath ? `${parentPath}.${key}` : key;\n /* v8 ignore next 7 -- TODO: add test */\n if (key === '__proto__') {\n errors.push({\n topic: 'Config security error',\n message: '__proto__',\n });\n continue;\n }\n if (\n parentPath &&\n parentPath !== 'onboardingConfig' &&\n topLevelObjects.includes(key)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `The \"${key}\" object can only be configured at the top level of a config but was found inside \"${parentPath}\"`,\n });\n }\n\n if (isGlobalOption(key)) {\n if (configType === 'global') {\n await validateGlobalConfig(\n key,\n val,\n optionTypes[key],\n warnings,\n errors,\n currentPath,\n config,\n );\n continue;\n } else if (\n !isFalseGlobal(key, parentPath) &&\n !(configType === 'inherit' && isInhertConfigOption(key))\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `The \"${key}\" option is a global option reserved only for Renovate's global configuration and cannot be configured within a repository's config file.`,\n });\n continue;\n }\n }\n if (key === 'enabledManagers' && val) {\n const unsupportedManagers = getUnsupportedEnabledManagers(\n val as string[],\n );\n if (isNonEmptyArray(unsupportedManagers)) {\n errors.push({\n topic: 'Configuration Error',\n message: `The following managers configured in enabledManagers are not supported: \"${unsupportedManagers.join(\n ', ',\n )}\"`,\n });\n }\n }\n if (key === 'registryUrls' && !parentPath && isNonEmptyArray(val)) {\n warnings.push({\n topic: 'Configuration Warning',\n message:\n 'Setting `registryUrls` at the top level of your config will apply it to all managers and datasources, which can cause the wrong registry URL to be used for some packages. Use `registryUrls` inside `packageRules` to target specific managers or packages.',\n });\n }\n if (key === 'defaultRegistryUrls' && !parentPath && isNonEmptyArray(val)) {\n warnings.push({\n topic: 'Configuration Warning',\n message:\n 'Setting `defaultRegistryUrls` at the top level of your config will apply it to all managers and datasources, which can cause the wrong registry URL to be used for some packages. Use `defaultRegistryUrls` inside `packageRules` to target specific managers or packages.',\n });\n }\n if (\n !isIgnored(key) && // We need to ignore some reserved keys\n !(is as any).function(val) // Ignore all functions\n ) {\n if (getDeprecationMessage(key)) {\n warnings.push({\n topic: 'Deprecation Warning',\n message: getDeprecationMessage(key)!,\n });\n }\n if (optionSupportsTemplating.has(key) && val) {\n try {\n // TODO: types (#22198)\n template.validate((val as string).toString());\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid template in config path: ${currentPath}`,\n });\n }\n }\n const parentName = getParentName(parentPath);\n if (\n !isPreset &&\n optionParents[key] &&\n !optionParents[key].includes(parentName as AllowedParents)\n ) {\n // TODO: types (#22198)\n const options = optionParents[key]?.toSorted().join(', ');\n const message = `\"${key}\" can't be used in \"${parentName}\". Allowed objects: ${options}.`;\n warnings.push({\n topic: `${parentPath ? `${parentPath}.` : ''}${key}`,\n message,\n });\n }\n\n // v8 ignore else -- intentionally unhandled - if we knew what was to be covered here, we'd add validation\n if (!optionTypes[key]) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid configuration option: ${currentPath}`,\n });\n } else if (key === 'schedule') {\n const [validSchedule, errorMessage] = hasValidSchedule(val as string[]);\n if (!validSchedule) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid ${currentPath}: \\`${errorMessage}\\``,\n });\n }\n } else if (\n [\n 'allowedVersions',\n 'matchCurrentVersion',\n 'matchCurrentValue',\n 'matchNewValue',\n ].includes(key) &&\n isRegexMatch(val)\n ) {\n if (!getRegexPredicate(val)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${val}\\``,\n });\n }\n } else if (key === 'timezone' && val !== null) {\n const [validTimezone, errorMessage] = hasValidTimezone(val as string);\n if (!validTimezone) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${errorMessage}`,\n });\n }\n } else if (val !== null) {\n const type = optionTypes[key];\n if (type === 'boolean') {\n if (val !== true && val !== false) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be boolean. Found: ${JSON.stringify(\n val,\n )} (${typeof val})`,\n });\n }\n } else if (type === 'integer') {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n errors.push(...validateNumber(key, val, allowsNegative, currentPath));\n } else if (type === 'array' && val) {\n if (isArray(val)) {\n for (const [subIndex, subval] of val.entries()) {\n if (isObject(subval)) {\n const subValidation = await validateConfig(\n configType,\n subval as RenovateConfig,\n isPreset,\n `${currentPath}[${subIndex}]`,\n );\n warnings = warnings.concat(subValidation.warnings);\n errors = errors.concat(subValidation.errors);\n }\n }\n if (isRegexOrGlobOption(key)) {\n errors.push(\n ...regexOrGlobValidator.check({\n val,\n currentPath,\n }),\n );\n }\n if (key === 'extends') {\n for (const subval of val) {\n if (isString(subval)) {\n if (configType !== 'global' && subval.startsWith('global:')) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: you cannot extend from \"global:\" presets in a repository config's \"extends\"`,\n });\n }\n\n if (\n parentName === 'packageRules' &&\n subval.startsWith('group:')\n ) {\n warnings.push({\n topic: 'Configuration Warning',\n message: `${currentPath}: you should not extend \"group:\" presets`,\n });\n }\n if (tzRe.test(subval)) {\n const [, timezone] = tzRe.exec(subval)!;\n const [validTimezone, errorMessage] =\n hasValidTimezone(timezone);\n if (!validTimezone) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${errorMessage}`,\n });\n }\n }\n if (!subval.includes('{{')) {\n try {\n parsePreset(subval);\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: preset \"${subval}\" is not valid`,\n });\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: preset value is not a string`,\n });\n }\n }\n }\n\n const selectors = [\n 'matchFileNames',\n 'matchLanguages',\n 'matchCategories',\n 'matchBaseBranches',\n 'matchManagers',\n 'matchDatasources',\n 'matchDepTypes',\n 'matchDepNames',\n 'matchPackageNames',\n 'matchCurrentValue',\n 'matchCurrentVersion',\n 'matchSourceUrls',\n 'matchRegistryUrls',\n 'matchUpdateTypes',\n 'matchConfidence',\n 'matchCurrentAge',\n 'matchRepositories',\n 'matchNewValue',\n 'matchJsonata',\n ];\n if (key === 'packageRules') {\n for (const [subIndex, packageRule] of val.entries()) {\n if (isObject(packageRule)) {\n const { config: resolved } = await resolveConfigPresets(\n packageRule as RenovateConfig,\n config,\n );\n const resolvedRule = migrateConfig({\n packageRules: [resolved],\n }).migratedConfig.packageRules![0];\n warnings.push(\n ...matchBaseBranchesValidator.check({\n resolvedRule,\n currentPath: `${currentPath}[${subIndex}]`,\n baseBranchPatterns: config.baseBranchPatterns!,\n }),\n );\n const selectorLength = Object.keys(resolvedRule).filter(\n (ruleKey) => selectors.includes(ruleKey),\n ).length;\n if (!selectorLength) {\n const message = `${currentPath}[${subIndex}]: Each packageRule must contain at least one match* or exclude* selector. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n errors.push({\n topic: 'Configuration Error',\n message,\n });\n }\n if (selectorLength === Object.keys(resolvedRule).length) {\n const message = `${currentPath}[${subIndex}]: Each packageRule must contain at least one non-match* or non-exclude* field. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n warnings.push({\n topic: 'Configuration Error',\n message,\n });\n }\n // It's too late to apply any of these options once you already have updates determined\n const preLookupOptions = [\n 'allowedVersions',\n 'extractVersion',\n 'followTag',\n 'ignoreDeps',\n 'ignoreUnstable',\n 'rangeStrategy',\n 'registryUrls',\n 'respectLatest',\n 'rollbackPrs',\n 'separateMajorMinor',\n 'separateMinorPatch',\n 'separateMultipleMajor',\n 'separateMultipleMinor',\n 'versioning',\n ] as const;\n if (isNonEmptyArray(resolvedRule.matchUpdateTypes)) {\n for (const option of preLookupOptions) {\n if (resolvedRule[option] !== undefined) {\n const message = `${currentPath}[${subIndex}]: packageRules cannot combine both matchUpdateTypes and ${option}. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n errors.push({\n topic: 'Configuration Error',\n message,\n });\n }\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath} must contain JSON objects`,\n });\n }\n }\n }\n if (key === 'customManagers') {\n const allowedKeys = [\n 'customType',\n 'description',\n 'fileFormat',\n 'managerFilePatterns',\n 'matchStrings',\n 'matchStringsStrategy',\n 'depNameTemplate',\n 'packageNameTemplate',\n 'datasourceTemplate',\n 'versioningTemplate',\n 'registryUrlTemplate',\n 'currentValueTemplate',\n 'extractVersionTemplate',\n 'autoReplaceStringTemplate',\n 'depTypeTemplate',\n ];\n for (const customManager of val as CustomManager[]) {\n if (\n Object.keys(customManager).some(\n (k) => !allowedKeys.includes(k),\n )\n ) {\n const disallowedKeys = Object.keys(customManager).filter(\n (k) => !allowedKeys.includes(k),\n );\n errors.push({\n topic: 'Configuration Error',\n message: `Custom Manager contains disallowed fields: ${disallowedKeys.join(\n ', ',\n )}`,\n });\n } else if (\n isNonEmptyString(customManager.customType) &&\n isCustomManager(customManager.customType)\n ) {\n if (isNonEmptyArray(customManager.managerFilePatterns)) {\n switch (customManager.customType) {\n case 'regex':\n validateRegexManagerFields(\n customManager,\n currentPath,\n errors,\n );\n break;\n case 'jsonata':\n validateJSONataManagerFields(\n customManager,\n currentPath,\n errors,\n );\n break;\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Each Custom Manager must contain a non-empty managerFilePatterns array`,\n });\n }\n } else {\n if (\n isEmptyString(customManager.customType) ||\n isUndefined(customManager.customType)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Each Custom Manager must contain a non-empty customType string`,\n });\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid customType: ${customManager.customType}. Key is not a custom manager`,\n });\n }\n }\n }\n }\n if (['matchPackageNames', 'matchDepNames'].includes(key)) {\n const startPattern = regEx(/!?\\//);\n const endPattern = regEx(/\\/g?i?$/);\n for (const pattern of val as string[]) {\n if (startPattern.test(pattern) && endPattern.test(pattern)) {\n try {\n // regEx isn't aware of our !/ prefix but can handle the suffix\n regEx(pattern.replace(startPattern, '/'));\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${pattern}\\``,\n });\n }\n }\n }\n }\n if (key === 'baseBranchPatterns') {\n for (const baseBranchPattern of val as string[]) {\n if (\n isRegexMatch(baseBranchPattern) &&\n !getRegexPredicate(baseBranchPattern)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${baseBranchPattern}\\``,\n });\n }\n }\n }\n if (\n (selectors.includes(key) ||\n key === 'matchCurrentVersion' ||\n key === 'matchCurrentValue') &&\n // TODO: can be undefined ? #22198\n !rulesRe.test(parentPath!) && // Inside a packageRule\n (isString(parentPath) || !isPreset) // top level in a preset\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${key} should be inside a \\`packageRule\\` only`,\n });\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a list (Array)`,\n });\n }\n } else if (type === 'string') {\n if (!isString(val)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a string`,\n });\n }\n } else if (type === 'object') {\n if (isPlainObject(val)) {\n if (key === 'registryAliases') {\n const res = validatePlainObject(val);\n if (res !== true) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${key}.${res}\\` configuration: value is not a string`,\n });\n }\n } else if (key === 'env') {\n const allowedEnvVars =\n configType === 'global'\n ? (config.allowedEnv ?? [])\n : GlobalConfig.get('allowedEnv');\n for (const [envVarName, envVarValue] of Object.entries(val)) {\n if (!isString(envVarValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid env variable value: \\`${currentPath}.${envVarName}\\` must be a string.`,\n });\n }\n if (!matchRegexOrGlobList(envVarName, allowedEnvVars)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Env variable name \\`${envVarName}\\` is not allowed by this bot's \\`allowedEnv\\`.`,\n });\n }\n }\n } else if (key === 'statusCheckNames') {\n for (const [statusCheckKey, statusCheckValue] of Object.entries(\n val,\n )) {\n if (\n !allowedStatusCheckStrings.includes(\n statusCheckKey as StatusCheckKey,\n )\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${key}.${statusCheckKey}\\` configuration: key is not allowed.`,\n });\n }\n if (\n !(isString(statusCheckValue) || null === statusCheckValue)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${statusCheckKey}\\` configuration: status check is not a string.`,\n });\n continue;\n }\n }\n } else if (key === 'customDatasources') {\n const allowedKeys = [\n 'description',\n 'defaultRegistryUrlTemplate',\n 'format',\n 'transformTemplates',\n ];\n for (const [\n customDatasourceName,\n customDatasourceValue,\n ] of Object.entries(val)) {\n if (!isPlainObject(customDatasourceValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${customDatasourceName}\\` configuration: customDatasource is not an object`,\n });\n continue;\n }\n for (const [subKey, subValue] of Object.entries(\n customDatasourceValue,\n )) {\n if (!allowedKeys.includes(subKey)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: key is not allowed`,\n });\n } else if (subKey === 'transformTemplates') {\n if (!isArray(subValue, isString)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is not an array of string`,\n });\n }\n } else if (subKey === 'description') {\n if (!(isString(subValue) || isArray(subValue, isString))) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is not an array of strings`,\n });\n }\n } else if (!isString(subValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is a string`,\n });\n }\n }\n }\n } else if (key === 'installTools') {\n for (const toolName of Object.keys(val)) {\n if (!isToolName(toolName)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${toolName}\\` configuration: not a valid tool name.`,\n });\n }\n }\n } else if (key === 'constraints') {\n const { get: getVersioning } =\n await import('../modules/versioning/index.ts');\n for (const [k, v] of Object.entries(val)) {\n if (!isString(v)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` should be an object of key-value pairs of constraints and their value`,\n });\n break;\n }\n\n if (!isConstraintName(k)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\`: \\`${k}\\` is not a supported constraint name`,\n });\n } else if (isToolName(k)) {\n // TODO: #31831\n const versioningId = getToolConfig(k).versioning;\n const versioning = getVersioning(versioningId);\n if (!versioning.isValid(v)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}=${v}\\` is not a valid tool version constraint, according to \\`${versioningId}\\` versioning`,\n });\n }\n }\n }\n } else if (key === 'constraintsVersioning') {\n for (const [k, v] of Object.entries(val)) {\n if (!isString(v)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` should be an object of key-value pairs of additional constraint names and their versioning`,\n });\n break;\n }\n\n if (isToolName(k)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` is not a valid additional constraint name, as \\`${k}\\` is a tool name, and \\`constraintsVersioning\\` can only override the versioning for a non-tool constraint`,\n });\n } else if (isConstraintName(k)) {\n const versioningName = v.split(':')[0];\n if (\n !AllVersioningsListLiteral.includes(\n versioningName as VersioningName,\n )\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}=${v}\\`: \\`${v}\\` is not a valid versioning scheme`,\n });\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\`: \\`${k}\\` is not a known additional constraint name`,\n });\n }\n }\n } else {\n const ignoredObjects = options\n .filter((option) => option.freeChoice)\n .map((option) => option.name);\n if (!ignoredObjects.includes(key)) {\n const subValidation = await validateConfig(\n configType,\n val,\n isPreset,\n currentPath,\n );\n warnings = warnings.concat(subValidation.warnings);\n errors = errors.concat(subValidation.errors);\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a json object`,\n });\n }\n } else {\n // v8 ignore next -- intentionally unhandled - if we knew what was to be covered here, we'd add validation\n logger.debug(\n {},\n `Unhandled validation for ${type} at \\`${currentPath}\\``,\n );\n }\n }\n }\n\n if (key === 'hostRules' && isArray(val)) {\n const allowedHeaders =\n configType === 'global'\n ? (config.allowedHeaders ?? [])\n : GlobalConfig.get('allowedHeaders');\n for (const rule of val as HostRule[]) {\n if (isNonEmptyString(rule.matchHost)) {\n if (rule.matchHost.includes('://')) {\n if (parseUrl(rule.matchHost) === null) {\n errors.push({\n topic: 'Configuration Error',\n message: `hostRules matchHost \\`${rule.matchHost}\\` is not a valid URL.`,\n });\n }\n }\n } else if (isEmptyString(rule.matchHost)) {\n errors.push({\n topic: 'Configuration Error',\n message:\n 'Invalid value for hostRules matchHost. It cannot be an empty string.',\n });\n }\n\n if (!rule.headers) {\n continue;\n }\n for (const [header, value] of Object.entries(rule.headers)) {\n if (!isString(value)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid hostRules headers value configuration: header must be a string.`,\n });\n }\n if (!matchRegexOrGlobList(header, allowedHeaders)) {\n errors.push({\n topic: 'Configuration Error',\n message: `hostRules header \\`${header}\\` is not allowed by this bot's \\`allowedHeaders\\`.`,\n });\n }\n }\n }\n }\n\n if (key === 'matchJsonata' && isArray(val, isString)) {\n for (const expression of val) {\n const res = getExpression(expression);\n if (res instanceof Error) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid JSONata expression for ${currentPath}: ${res.message}`,\n });\n }\n }\n }\n }\n\n function sortAll(a: ValidationMessage, b: ValidationMessage): number {\n if (a.topic === b.topic) {\n return a.message > b.message ? 1 : -1;\n }\n return a.topic > b.topic ? 1 : -1;\n }\n\n errors.sort(sortAll);\n warnings.sort(sortAll);\n return { errors, warnings };\n}\n\n/**\n * Basic validation for global config options\n */\nasync function validateGlobalConfig(\n key: string,\n val: unknown,\n type: string,\n warnings: ValidationMessage[],\n errors: ValidationMessage[],\n currentPath: string | undefined,\n config: AllConfig,\n): Promise<void> {\n /* v8 ignore next 5 -- not testable yet */\n if (getDeprecationMessage(key)) {\n warnings.push({\n topic: 'Deprecation Warning',\n message: getDeprecationMessage(key)!,\n });\n }\n\n if (key === 'binarySource' && val === 'docker') {\n warnings.push({\n topic: 'Deprecation Warning',\n message:\n 'Usage of `binarySource=docker` is deprecated, and will be removed in the future. Please migrate to `binarySource=install`. Feedback on the usage of `binarySource=docker` is welcome at https://github.com/renovatebot/renovate/discussions/40742',\n });\n }\n\n if (val !== null) {\n // v8 ignore else -- TODO: add test #40625\n if (type === 'string') {\n if (isString(val)) {\n if (\n key === 'onboardingConfigFileName' &&\n !getPossibleConfigFileNames({\n configFileNames: config.configFileNames,\n platform: config.platform,\n }).includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${getPossibleConfigFileNames(\n {\n configFileNames: config.configFileNames,\n platform: config.platform,\n },\n ).join(', ')}.`,\n });\n } else if (\n key === 'repositoryCache' &&\n !['enabled', 'disabled', 'reset'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['enabled', 'disabled', 'reset'].join(', ')}.`,\n });\n } else if (\n key === 'dryRun' &&\n !['extract', 'lookup', 'full'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['extract', 'lookup', 'full'].join(', ')}.`,\n });\n } else if (\n key === 'binarySource' &&\n !['docker', 'global', 'install', 'hermit'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['docker', 'global', 'install', 'hermit'].join(', ')}.`,\n });\n } else if (\n key === 'requireConfig' &&\n !['required', 'optional', 'ignored'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['required', 'optional', 'ignored'].join(', ')}.`,\n });\n } else if (\n key === 'gitUrl' &&\n !['default', 'ssh', 'endpoint'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['default', 'ssh', 'endpoint'].join(', ')}.`,\n });\n }\n\n if (\n key === 'reportType' &&\n ['s3', 'file'].includes(val) &&\n !isString(config.reportPath)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `reportType '${val}' requires a configured reportPath`,\n });\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a string.`,\n });\n }\n } else if (type === 'integer') {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n warnings.push(...validateNumber(key, val, allowsNegative, currentPath));\n } else if (type === 'boolean') {\n if (val !== true && val !== false) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a boolean. Found: ${JSON.stringify(\n val,\n )} (${typeof val}).`,\n });\n }\n } else if (type === 'array') {\n if (isArray(val)) {\n if (isRegexOrGlobOption(key)) {\n warnings.push(\n ...regexOrGlobValidator.check({\n val,\n currentPath: currentPath!,\n }),\n );\n }\n if (key === 'gitNoVerify') {\n const allowedValues = ['commit', 'push'];\n for (const value of val as string[]) {\n // v8 ignore else -- TODO: add test #40625\n if (!allowedValues.includes(value)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value for \\`${currentPath}\\`. The allowed values are ${allowedValues.join(', ')}.`,\n });\n }\n }\n }\n if (key === 'mergeConfidenceDatasources') {\n const allowedValues = supportedDatasources;\n for (const value of val as string[]) {\n // v8 ignore else -- TODO: add test #40625\n if (!allowedValues.includes(value)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${value}\\` for \\`${currentPath}\\`. The allowed values are ${allowedValues.join(', ')}.`,\n });\n }\n }\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a list (Array).`,\n });\n }\n } else if (type === 'object') {\n if (isPlainObject(val)) {\n if (key === 'onboardingConfig') {\n const subValidation = await validateConfig('repo', val);\n for (const warning of subValidation.warnings.concat(\n subValidation.errors,\n )) {\n warnings.push(warning);\n }\n } else if (key === 'force') {\n const subValidation = await validateConfig('global', val);\n for (const warning of subValidation.warnings.concat(\n subValidation.errors,\n )) {\n warnings.push(warning);\n }\n } else if (key === 'cacheTtlOverride') {\n for (const [subKey, subValue] of Object.entries(val)) {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n warnings.push(\n ...validateNumber(\n key,\n subValue,\n allowsNegative,\n currentPath,\n subKey,\n ),\n );\n\n if (\n !(packageCacheNamespaces as readonly string[]).includes(subKey)\n ) {\n errors.push({\n message: `${currentPath}: namespace \\`${subKey}\\` does not exist`,\n topic: 'Configuration Error',\n });\n }\n }\n } else {\n const res = validatePlainObject(val);\n if (res !== true) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${res}\\` configuration: value must be a string.`,\n });\n }\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a JSON object.`,\n });\n }\n }\n }\n}\n\nfunction getPossibleConfigFileNames({\n configFileNames,\n platform,\n}: {\n configFileNames?: string[];\n platform?: PlatformId;\n}): string[] {\n const filenames = getConfigFileNames(platform);\n if (isNonEmptyArray(configFileNames)) {\n return filenames.concat(configFileNames);\n }\n\n return filenames;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAM,UAAU,WAAW;AAE3B,IAAI,qBAAqB;AACzB,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,cAAiC;AAEvC,MAAM,kBAAqC,CACzC,GAAG,wBACH,GAAG,yBACL;AAEA,MAAM,kBAAkB,CAAC,GAAG,aAAa,KAAK;AAE9C,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,OAAO,MAAM,qBAAqB;AACxC,MAAM,UAAU,MAAM,kBAAkB;AAExC,SAAS,UAAU,KAAsB;CACvC,OAAO,aAAa,SAAS,GAAG;AAClC;AAEA,SAAS,8BAA8B,iBAAqC;CAC1E,OAAO,gBAAgB,QACpB,YAAY,CAAC,gBAAgB,SAAS,QAAQ,QAAQ,WAAW,EAAE,CAAC,CACvE;AACF;AAEA,SAAS,sBAAsB,QAAoC;CACjE,MAAM,oBAAwD;EAC5D,YAAY;EACZ,eAAe;EACf,SAAS;CACX;CACA,IAAI,kBAAkB,SACpB,OAAO,kBAAkB;CAG3B,MAAM,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,MAAM;CACnD,IAAI,CAAC,OACH;CAGF,IAAI,CAAC,MAAM,gBACT;CAGF,OAAO,QA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GACZ,OAAO;GACP,SAAS,0BAA0B,YAAY;EACjD,CAAC;CAAA;AAIT;AAEA,SAAS,2BAA2B,EAClC,iBACA,YAIW;CACX,MAAM,YAAY,mBAAmB,QAAQ;CAC7C,IAAI,gBAAgB,eAAe,GACjC,OAAO,UAAU,OAAO,eAAe;CAGzC,OAAO;AACT"}
1
+ {"version":3,"file":"validation.js","names":["regexOrGlobValidator.check","matchBaseBranchesValidator.check"],"sources":["../../lib/config/validation.ts"],"sourcesContent":["import is, {\n isArray,\n isEmptyString,\n isNonEmptyArray,\n isNonEmptyString,\n isObject,\n isPlainObject,\n isString,\n isUndefined,\n} from '@sindresorhus/is';\nimport type { PlatformId } from '../constants/index.ts';\nimport { logger } from '../logger/index.ts';\nimport {\n AllManagersListLiteral,\n CustomManagersListLiteral,\n} from '../manager-list.generated.ts';\nimport { isCustomManager } from '../modules/manager/custom/index.ts';\nimport type { CustomManager } from '../modules/manager/custom/types.ts';\nimport type { HostRule } from '../types/index.ts';\nimport { packageCacheNamespaces } from '../util/cache/package/namespaces.ts';\nimport { getToolConfig } from '../util/exec/containerbase.ts';\nimport { isConstraintName, isToolName } from '../util/exec/types.ts';\nimport { getExpression } from '../util/jsonata.ts';\nimport { regEx } from '../util/regex.ts';\nimport {\n anyMatchRegexOrGlobList,\n getRegexPredicate,\n isRegexMatch,\n matchRegexOrGlobList,\n} from '../util/string-match.ts';\nimport * as template from '../util/template/index.ts';\nimport { parseUrl } from '../util/url.ts';\nimport {\n AllVersioningsListLiteral,\n type VersioningName,\n} from '../versioning-list.generated.ts';\nimport {\n hasValidSchedule,\n hasValidTimezone,\n} from '../workers/repository/update/branch/schedule.ts';\nimport { getConfigFileNames } from './app-strings.ts';\nimport { GlobalConfig } from './global.ts';\nimport { migrateConfig } from './migration.ts';\nimport { getOptions } from './options/index.ts';\nimport { resolveConfigPresets } from './presets/index.ts';\nimport { supportedDatasources } from './presets/internal/merge-confidence.preset.ts';\nimport { parsePreset } from './presets/parse.ts';\nimport type {\n AllConfig,\n AllowedParents,\n RenovateConfig,\n RenovateOptions,\n StatusCheckKey,\n ValidationMessage,\n ValidationResult,\n} from './types.ts';\nimport { allowedStatusCheckStrings } from './types.ts';\nimport * as matchBaseBranchesValidator from './validation-helpers/match-base-branches.ts';\nimport * as regexOrGlobValidator from './validation-helpers/regex-glob-matchers.ts';\nimport {\n getParentName,\n isFalseGlobal,\n validateJSONataManagerFields,\n validateNumber,\n validatePlainObject,\n validateRegexManagerFields,\n} from './validation-helpers/utils.ts';\n\nconst options = getOptions();\n\nlet optionsInitialized = false;\nlet optionTypes: Record<string, RenovateOptions['type']>;\nlet optionParents: Record<string, AllowedParents[]>;\nlet optionGlobals: Set<string>;\nlet optionInherits: Set<string>;\nlet optionRegexOrGlob: Set<string>;\nlet optionAllowsNegativeIntegers: Set<string>;\nlet optionSupportsTemplating: Set<string>;\n\nconst managerList: readonly string[] = AllManagersListLiteral;\n\nconst allManagersList: readonly string[] = [\n ...AllManagersListLiteral,\n ...CustomManagersListLiteral,\n];\n\nconst topLevelObjects = [...managerList, 'env'];\n\nconst ignoredNodes = [\n '$schema',\n 'headers',\n 'depType',\n 'npmToken',\n 'packageFile',\n 'forkToken',\n 'repository',\n 'vulnerabilityAlertsOnly',\n 'vulnerabilityAlert',\n 'isVulnerabilityAlert',\n 'vulnerabilityFixVersion', // not intended to be used by end users but may be by Mend apps\n 'copyLocalLibs', // deprecated - functionality is now enabled by default\n 'prBody', // deprecated\n 'minimumConfidence', // undocumented feature flag\n];\nconst tzRe = regEx(/^:timezone\\((.+)\\)$/);\nconst rulesRe = regEx(/p.*Rules\\[\\d+\\]$/);\n\nfunction isIgnored(key: string): boolean {\n return ignoredNodes.includes(key);\n}\n\nfunction getUnsupportedEnabledManagers(enabledManagers: string[]): string[] {\n return enabledManagers.filter(\n (manager) => !allManagersList.includes(manager.replace('custom.', '')),\n );\n}\n\nfunction getDeprecationMessage(option: string): string | undefined {\n const deprecatedOptions: Record<string, string | undefined> = {\n branchName: `Direct editing of branchName is now deprecated. Please edit branchPrefix, additionalBranchPrefix, or branchTopic instead`,\n commitMessage: `Direct editing of commitMessage is now deprecated. Please edit commitMessage's subcomponents instead.`,\n prTitle: `Direct editing of prTitle is now deprecated. Please edit commitMessage subcomponents instead as they will be passed through to prTitle.`,\n };\n if (deprecatedOptions[option]) {\n return deprecatedOptions[option];\n }\n\n const found = options.find((o) => o.name === option);\n if (!found) {\n return undefined;\n }\n\n if (!found.deprecationMsg) {\n return undefined;\n }\n\n return `The '${option}' option is deprecated: ${found.deprecationMsg}`;\n}\n\nfunction isInhertConfigOption(key: string): boolean {\n return optionInherits.has(key);\n}\n\nfunction isRegexOrGlobOption(key: string): boolean {\n return optionRegexOrGlob.has(key);\n}\n\nfunction isGlobalOption(key: string): boolean {\n return optionGlobals.has(key);\n}\n\nfunction initOptions(): void {\n if (optionsInitialized) {\n return;\n }\n\n optionParents = {};\n optionInherits = new Set();\n optionTypes = {};\n optionRegexOrGlob = new Set();\n optionGlobals = new Set();\n optionAllowsNegativeIntegers = new Set();\n optionSupportsTemplating = new Set();\n\n for (const option of options) {\n optionTypes[option.name] = option.type;\n\n if (option.parents) {\n optionParents[option.name] = option.parents;\n }\n\n if (option.inheritConfigSupport) {\n optionInherits.add(option.name);\n }\n\n if (option.patternMatch) {\n optionRegexOrGlob.add(option.name);\n }\n\n if (option.globalOnly) {\n optionGlobals.add(option.name);\n }\n\n if (option.allowNegative) {\n optionAllowsNegativeIntegers.add(option.name);\n }\n\n if (option.supportsTemplating) {\n optionSupportsTemplating.add(option.name);\n }\n }\n\n optionsInitialized = true;\n}\n\nexport async function validateConfig(\n configType: 'global' | 'inherit' | 'repo',\n config: AllConfig,\n isPreset?: boolean,\n parentPath?: string,\n): Promise<ValidationResult> {\n initOptions();\n\n let errors: ValidationMessage[] = [];\n let warnings: ValidationMessage[] = [];\n\n for (const [key, val] of Object.entries(config)) {\n const currentPath = parentPath ? `${parentPath}.${key}` : key;\n /* v8 ignore next 7 -- TODO: add test */\n if (key === '__proto__') {\n errors.push({\n topic: 'Config security error',\n message: '__proto__',\n });\n continue;\n }\n if (\n parentPath &&\n parentPath !== 'onboardingConfig' &&\n topLevelObjects.includes(key)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `The \"${key}\" object can only be configured at the top level of a config but was found inside \"${parentPath}\"`,\n });\n }\n\n if (isGlobalOption(key)) {\n if (configType === 'global') {\n await validateGlobalConfig(\n key,\n val,\n optionTypes[key],\n warnings,\n errors,\n currentPath,\n config,\n );\n continue;\n } else if (\n !isFalseGlobal(key, parentPath) &&\n !(configType === 'inherit' && isInhertConfigOption(key))\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `The \"${key}\" option is a global option reserved only for Renovate's global configuration and cannot be configured within a repository's config file.`,\n });\n continue;\n }\n }\n if (key === 'enabledManagers' && val) {\n const unsupportedManagers = getUnsupportedEnabledManagers(\n val as string[],\n );\n if (isNonEmptyArray(unsupportedManagers)) {\n errors.push({\n topic: 'Configuration Error',\n message: `The following managers configured in enabledManagers are not supported: \"${unsupportedManagers.join(\n ', ',\n )}\"`,\n });\n }\n }\n if (key === 'registryUrls' && !parentPath && isNonEmptyArray(val)) {\n warnings.push({\n topic: 'Configuration Warning',\n message:\n 'Setting `registryUrls` at the top level of your config will apply it to all managers and datasources, which can cause the wrong registry URL to be used for some packages. Use `registryUrls` inside `packageRules` to target specific managers or packages.',\n });\n }\n if (key === 'defaultRegistryUrls' && !parentPath && isNonEmptyArray(val)) {\n warnings.push({\n topic: 'Configuration Warning',\n message:\n 'Setting `defaultRegistryUrls` at the top level of your config will apply it to all managers and datasources, which can cause the wrong registry URL to be used for some packages. Use `defaultRegistryUrls` inside `packageRules` to target specific managers or packages.',\n });\n }\n if (\n !isIgnored(key) && // We need to ignore some reserved keys\n !(is as any).function(val) // Ignore all functions\n ) {\n if (getDeprecationMessage(key)) {\n warnings.push({\n topic: 'Deprecation Warning',\n message: getDeprecationMessage(key)!,\n });\n }\n if (optionSupportsTemplating.has(key) && val) {\n try {\n // TODO: types (#22198)\n template.validate((val as string).toString());\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid template in config path: ${currentPath}`,\n });\n }\n }\n const parentName = getParentName(parentPath);\n if (\n !isPreset &&\n optionParents[key] &&\n !optionParents[key].includes(parentName as AllowedParents)\n ) {\n // TODO: types (#22198)\n const options = optionParents[key]?.toSorted().join(', ');\n const message = `\"${key}\" can't be used in \"${parentName}\". Allowed objects: ${options}.`;\n warnings.push({\n topic: `${parentPath ? `${parentPath}.` : ''}${key}`,\n message,\n });\n }\n\n // v8 ignore else -- intentionally unhandled - if we knew what was to be covered here, we'd add validation\n if (!optionTypes[key]) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid configuration option: ${currentPath}`,\n });\n } else if (key === 'schedule') {\n const [validSchedule, errorMessage] = hasValidSchedule(val as string[]);\n if (!validSchedule) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid ${currentPath}: \\`${errorMessage}\\``,\n });\n }\n } else if (\n [\n 'allowedVersions',\n 'matchCurrentVersion',\n 'matchCurrentValue',\n 'matchNewValue',\n ].includes(key) &&\n isRegexMatch(val)\n ) {\n if (!getRegexPredicate(val)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${val}\\``,\n });\n }\n } else if (key === 'timezone' && val !== null) {\n const [validTimezone, errorMessage] = hasValidTimezone(val as string);\n if (!validTimezone) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${errorMessage}`,\n });\n }\n } else if (val !== null) {\n const type = optionTypes[key];\n if (type === 'boolean') {\n if (val !== true && val !== false) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be boolean. Found: ${JSON.stringify(\n val,\n )} (${typeof val})`,\n });\n }\n } else if (type === 'integer') {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n errors.push(...validateNumber(key, val, allowsNegative, currentPath));\n } else if (type === 'array' && val) {\n if (isArray(val)) {\n for (const [subIndex, subval] of val.entries()) {\n if (isObject(subval)) {\n const subValidation = await validateConfig(\n configType,\n subval as RenovateConfig,\n isPreset,\n `${currentPath}[${subIndex}]`,\n );\n warnings = warnings.concat(subValidation.warnings);\n errors = errors.concat(subValidation.errors);\n }\n }\n if (isRegexOrGlobOption(key)) {\n errors.push(\n ...regexOrGlobValidator.check({\n val,\n currentPath,\n }),\n );\n }\n if (key === 'extends') {\n for (const subval of val) {\n if (isString(subval)) {\n if (configType !== 'global' && subval.startsWith('global:')) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: you cannot extend from \"global:\" presets in a repository config's \"extends\"`,\n });\n }\n\n if (\n parentName === 'packageRules' &&\n subval.startsWith('group:')\n ) {\n warnings.push({\n topic: 'Configuration Warning',\n message: `${currentPath}: you should not extend \"group:\" presets`,\n });\n }\n if (tzRe.test(subval)) {\n const [, timezone] = tzRe.exec(subval)!;\n const [validTimezone, errorMessage] =\n hasValidTimezone(timezone);\n if (!validTimezone) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${errorMessage}`,\n });\n }\n }\n if (!subval.includes('{{')) {\n try {\n parsePreset(subval);\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: preset \"${subval}\" is not valid`,\n });\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: preset value is not a string`,\n });\n }\n }\n }\n\n const selectors = [\n 'matchFileNames',\n 'matchLanguages',\n 'matchCategories',\n 'matchBaseBranches',\n 'matchManagers',\n 'matchDatasources',\n 'matchDepTypes',\n 'matchDepNames',\n 'matchPackageNames',\n 'matchCurrentValue',\n 'matchCurrentVersion',\n 'matchSourceUrls',\n 'matchRegistryUrls',\n 'matchUpdateTypes',\n 'matchConfidence',\n 'matchCurrentAge',\n 'matchRepositories',\n 'matchNewValue',\n 'matchJsonata',\n ];\n if (key === 'packageRules') {\n for (const [subIndex, packageRule] of val.entries()) {\n if (isObject(packageRule)) {\n const { config: resolved } = await resolveConfigPresets(\n packageRule as RenovateConfig,\n config,\n );\n const resolvedRule = migrateConfig({\n packageRules: [resolved],\n }).migratedConfig.packageRules![0];\n warnings.push(\n ...matchBaseBranchesValidator.check({\n resolvedRule,\n currentPath: `${currentPath}[${subIndex}]`,\n baseBranchPatterns: config.baseBranchPatterns!,\n }),\n );\n const selectorLength = Object.keys(resolvedRule).filter(\n (ruleKey) => selectors.includes(ruleKey),\n ).length;\n if (!selectorLength) {\n const message = `${currentPath}[${subIndex}]: Each packageRule must contain at least one match* or exclude* selector. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n errors.push({\n topic: 'Configuration Error',\n message,\n });\n }\n if (selectorLength === Object.keys(resolvedRule).length) {\n const message = `${currentPath}[${subIndex}]: Each packageRule must contain at least one non-match* or non-exclude* field. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n warnings.push({\n topic: 'Configuration Error',\n message,\n });\n }\n // It's too late to apply any of these options once you already have updates determined\n const preLookupOptions = [\n 'allowedVersions',\n 'extractVersion',\n 'followTag',\n 'ignoreDeps',\n 'ignoreUnstable',\n 'rangeStrategy',\n 'registryUrls',\n 'respectLatest',\n 'rollbackPrs',\n 'separateMajorMinor',\n 'separateMinorPatch',\n 'separateMultipleMajor',\n 'separateMultipleMinor',\n 'versioning',\n ] as const;\n if (isNonEmptyArray(resolvedRule.matchUpdateTypes)) {\n for (const option of preLookupOptions) {\n if (resolvedRule[option] !== undefined) {\n const message = `${currentPath}[${subIndex}]: packageRules cannot combine both matchUpdateTypes and ${option}. Rule: ${JSON.stringify(\n packageRule,\n )}`;\n errors.push({\n topic: 'Configuration Error',\n message,\n });\n }\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath} must contain JSON objects`,\n });\n }\n }\n }\n if (key === 'customManagers') {\n const allowedKeys = [\n 'customType',\n 'description',\n 'fileFormat',\n 'managerFilePatterns',\n 'matchStrings',\n 'matchStringsStrategy',\n 'depNameTemplate',\n 'packageNameTemplate',\n 'datasourceTemplate',\n 'versioningTemplate',\n 'registryUrlTemplate',\n 'currentValueTemplate',\n 'extractVersionTemplate',\n 'autoReplaceStringTemplate',\n 'depTypeTemplate',\n ];\n for (const customManager of val as CustomManager[]) {\n if (\n Object.keys(customManager).some(\n (k) => !allowedKeys.includes(k),\n )\n ) {\n const disallowedKeys = Object.keys(customManager).filter(\n (k) => !allowedKeys.includes(k),\n );\n errors.push({\n topic: 'Configuration Error',\n message: `Custom Manager contains disallowed fields: ${disallowedKeys.join(\n ', ',\n )}`,\n });\n } else if (\n isNonEmptyString(customManager.customType) &&\n isCustomManager(customManager.customType)\n ) {\n if (isNonEmptyArray(customManager.managerFilePatterns)) {\n switch (customManager.customType) {\n case 'regex':\n validateRegexManagerFields(\n customManager,\n currentPath,\n errors,\n );\n break;\n case 'jsonata':\n validateJSONataManagerFields(\n customManager,\n currentPath,\n errors,\n );\n break;\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Each Custom Manager must contain a non-empty managerFilePatterns array`,\n });\n }\n } else {\n if (\n isEmptyString(customManager.customType) ||\n isUndefined(customManager.customType)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Each Custom Manager must contain a non-empty customType string`,\n });\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid customType: ${customManager.customType}. Key is not a custom manager`,\n });\n }\n }\n }\n }\n if (['matchPackageNames', 'matchDepNames'].includes(key)) {\n const startPattern = regEx(/!?\\//);\n const endPattern = regEx(/\\/g?i?$/);\n for (const pattern of val as string[]) {\n if (startPattern.test(pattern) && endPattern.test(pattern)) {\n try {\n // regEx isn't aware of our !/ prefix but can handle the suffix\n regEx(pattern.replace(startPattern, '/'));\n } catch {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${pattern}\\``,\n });\n }\n }\n }\n }\n if (key === 'baseBranchPatterns') {\n for (const baseBranchPattern of val as string[]) {\n if (\n isRegexMatch(baseBranchPattern) &&\n !getRegexPredicate(baseBranchPattern)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid regExp for ${currentPath}: \\`${baseBranchPattern}\\``,\n });\n }\n }\n }\n if (\n (selectors.includes(key) ||\n key === 'matchCurrentVersion' ||\n key === 'matchCurrentValue') &&\n // TODO: can be undefined ? #22198\n !rulesRe.test(parentPath!) && // Inside a packageRule\n (isString(parentPath) || !isPreset) // top level in a preset\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `${currentPath}: ${key} should be inside a \\`packageRule\\` only`,\n });\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a list (Array)`,\n });\n }\n } else if (type === 'string') {\n if (!isString(val)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a string`,\n });\n }\n } else if (type === 'object') {\n if (isPlainObject(val)) {\n if (key === 'registryAliases') {\n const res = validatePlainObject(val);\n if (res !== true) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${key}.${res}\\` configuration: value is not a string`,\n });\n }\n } else if (key === 'env') {\n const allowedEnvVars =\n configType === 'global'\n ? (config.allowedEnv ?? [])\n : GlobalConfig.get('allowedEnv');\n for (const [envVarName, envVarValue] of Object.entries(val)) {\n if (!isString(envVarValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid env variable value: \\`${currentPath}.${envVarName}\\` must be a string.`,\n });\n }\n if (!matchRegexOrGlobList(envVarName, allowedEnvVars)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Env variable name \\`${envVarName}\\` is not allowed by this bot's \\`allowedEnv\\`.`,\n });\n }\n }\n } else if (key === 'statusCheckNames') {\n for (const [statusCheckKey, statusCheckValue] of Object.entries(\n val,\n )) {\n if (\n !allowedStatusCheckStrings.includes(\n statusCheckKey as StatusCheckKey,\n )\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${key}.${statusCheckKey}\\` configuration: key is not allowed.`,\n });\n }\n if (\n !(isString(statusCheckValue) || null === statusCheckValue)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${statusCheckKey}\\` configuration: status check is not a string.`,\n });\n continue;\n }\n }\n } else if (key === 'customDatasources') {\n const allowedKeys = [\n 'description',\n 'defaultRegistryUrlTemplate',\n 'format',\n 'transformTemplates',\n ];\n for (const [\n customDatasourceName,\n customDatasourceValue,\n ] of Object.entries(val)) {\n if (!isPlainObject(customDatasourceValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${customDatasourceName}\\` configuration: customDatasource is not an object`,\n });\n continue;\n }\n for (const [subKey, subValue] of Object.entries(\n customDatasourceValue,\n )) {\n if (!allowedKeys.includes(subKey)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: key is not allowed`,\n });\n } else if (subKey === 'transformTemplates') {\n if (!isArray(subValue, isString)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is not an array of string`,\n });\n }\n } else if (subKey === 'description') {\n if (!(isString(subValue) || isArray(subValue, isString))) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is not an array of strings`,\n });\n }\n } else if (!isString(subValue)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${subKey}\\` configuration: is a string`,\n });\n }\n }\n }\n } else if (key === 'installTools') {\n for (const toolName of Object.keys(val)) {\n if (!isToolName(toolName)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${toolName}\\` configuration: not a valid tool name.`,\n });\n }\n }\n } else if (key === 'constraints') {\n const { get: getVersioning } =\n await import('../modules/versioning/index.ts');\n for (const [k, v] of Object.entries(val)) {\n if (!isString(v)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` should be an object of key-value pairs of constraints and their value`,\n });\n break;\n }\n\n if (!isConstraintName(k)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\`: \\`${k}\\` is not a supported constraint name`,\n });\n } else if (isToolName(k)) {\n // TODO: #31831\n const versioningId = getToolConfig(k).versioning;\n const versioning = getVersioning(versioningId);\n if (!versioning.isValid(v)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}=${v}\\` is not a valid tool version constraint, according to \\`${versioningId}\\` versioning`,\n });\n }\n }\n }\n } else if (key === 'constraintsVersioning') {\n for (const [k, v] of Object.entries(val)) {\n if (!isString(v)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` should be an object of key-value pairs of additional constraint names and their versioning`,\n });\n break;\n }\n\n if (isToolName(k)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\` is not a valid additional constraint name, as \\`${k}\\` is a tool name, and \\`constraintsVersioning\\` can only override the versioning for a non-tool constraint`,\n });\n } else if (isConstraintName(k)) {\n const versioningName = v.split(':')[0];\n if (\n !AllVersioningsListLiteral.includes(\n versioningName as VersioningName,\n )\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}=${v}\\`: \\`${v}\\` is not a valid versioning scheme`,\n });\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}.${k}\\`: \\`${k}\\` is not a known additional constraint name`,\n });\n }\n }\n } else {\n const ignoredObjects = options\n .filter((option) => option.freeChoice)\n .map((option) => option.name);\n if (!ignoredObjects.includes(key)) {\n const subValidation = await validateConfig(\n configType,\n val,\n isPreset,\n currentPath,\n );\n warnings = warnings.concat(subValidation.warnings);\n errors = errors.concat(subValidation.errors);\n }\n }\n } else {\n errors.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a json object`,\n });\n }\n } else {\n // v8 ignore next -- intentionally unhandled - if we knew what was to be covered here, we'd add validation\n logger.debug(\n {},\n `Unhandled validation for ${type} at \\`${currentPath}\\``,\n );\n }\n }\n }\n\n if (key === 'hostRules' && isArray(val)) {\n const allowedHeaders =\n configType === 'global'\n ? (config.allowedHeaders ?? [])\n : GlobalConfig.get('allowedHeaders');\n for (const rule of val as HostRule[]) {\n if (isNonEmptyString(rule.matchHost)) {\n if (rule.matchHost.includes('://')) {\n if (parseUrl(rule.matchHost) === null) {\n errors.push({\n topic: 'Configuration Error',\n message: `hostRules matchHost \\`${rule.matchHost}\\` is not a valid URL.`,\n });\n }\n }\n } else if (isEmptyString(rule.matchHost)) {\n errors.push({\n topic: 'Configuration Error',\n message:\n 'Invalid value for hostRules matchHost. It cannot be an empty string.',\n });\n }\n\n if (!rule.headers) {\n continue;\n }\n for (const [header, value] of Object.entries(rule.headers)) {\n if (!isString(value)) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid hostRules headers value configuration: header must be a string.`,\n });\n }\n if (!matchRegexOrGlobList(header, allowedHeaders)) {\n errors.push({\n topic: 'Configuration Error',\n message: `hostRules header \\`${header}\\` is not allowed by this bot's \\`allowedHeaders\\`.`,\n });\n }\n }\n }\n }\n\n if (key === 'matchJsonata' && isArray(val, isString)) {\n for (const expression of val) {\n const res = getExpression(expression);\n if (res instanceof Error) {\n errors.push({\n topic: 'Configuration Error',\n message: `Invalid JSONata expression for ${currentPath}: ${res.message}`,\n });\n }\n }\n }\n }\n\n function sortAll(a: ValidationMessage, b: ValidationMessage): number {\n if (a.topic === b.topic) {\n return a.message > b.message ? 1 : -1;\n }\n return a.topic > b.topic ? 1 : -1;\n }\n\n errors.sort(sortAll);\n warnings.sort(sortAll);\n return { errors, warnings };\n}\n\n/**\n * Basic validation for global config options\n */\nasync function validateGlobalConfig(\n key: string,\n val: unknown,\n type: string,\n warnings: ValidationMessage[],\n errors: ValidationMessage[],\n currentPath: string | undefined,\n config: AllConfig,\n): Promise<void> {\n /* v8 ignore next 5 -- not testable yet */\n if (getDeprecationMessage(key)) {\n warnings.push({\n topic: 'Deprecation Warning',\n message: getDeprecationMessage(key)!,\n });\n }\n\n if (key === 'binarySource' && val === 'docker') {\n warnings.push({\n topic: 'Deprecation Warning',\n message:\n 'Usage of `binarySource=docker` is deprecated, and will be removed in the future. Please migrate to `binarySource=install`. Feedback on the usage of `binarySource=docker` is welcome at https://github.com/renovatebot/renovate/discussions/40742',\n });\n }\n\n if (val !== null) {\n // v8 ignore else -- TODO: add test #40625\n if (type === 'string') {\n if (isString(val)) {\n if (\n key === 'onboardingConfigFileName' &&\n !getPossibleConfigFileNames({\n configFileNames: config.configFileNames,\n platform: config.platform,\n }).includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${getPossibleConfigFileNames(\n {\n configFileNames: config.configFileNames,\n platform: config.platform,\n },\n ).join(', ')}.`,\n });\n } else if (\n key === 'repositoryCache' &&\n !['enabled', 'disabled', 'reset'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['enabled', 'disabled', 'reset'].join(', ')}.`,\n });\n } else if (\n key === 'dryRun' &&\n !['extract', 'lookup', 'full'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['extract', 'lookup', 'full'].join(', ')}.`,\n });\n } else if (\n key === 'binarySource' &&\n !['docker', 'global', 'install', 'hermit'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['docker', 'global', 'install', 'hermit'].join(', ')}.`,\n });\n } else if (\n key === 'requireConfig' &&\n !['required', 'optional', 'ignored'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['required', 'optional', 'ignored'].join(', ')}.`,\n });\n } else if (\n key === 'gitUrl' &&\n !['default', 'ssh', 'endpoint'].includes(val)\n ) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${val}\\` for \\`${currentPath}\\`. The allowed values are ${['default', 'ssh', 'endpoint'].join(', ')}.`,\n });\n }\n\n if (\n key === 'reportType' &&\n ['s3', 'file'].includes(val) &&\n !isString(config.reportPath)\n ) {\n errors.push({\n topic: 'Configuration Error',\n message: `reportType '${val}' requires a configured reportPath`,\n });\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a string.`,\n });\n }\n } else if (type === 'integer') {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n warnings.push(...validateNumber(key, val, allowsNegative, currentPath));\n } else if (type === 'boolean') {\n if (val !== true && val !== false) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a boolean. Found: ${JSON.stringify(\n val,\n )} (${typeof val}).`,\n });\n }\n } else if (type === 'array') {\n if (isArray(val)) {\n if (isRegexOrGlobOption(key)) {\n warnings.push(\n ...regexOrGlobValidator.check({\n val,\n currentPath: currentPath!,\n }),\n );\n }\n if (key === 'gitNoVerify') {\n const allowedValues = ['commit', 'push'];\n for (const value of val as string[]) {\n // v8 ignore else -- TODO: add test #40625\n if (!allowedValues.includes(value)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value for \\`${currentPath}\\`. The allowed values are ${allowedValues.join(', ')}.`,\n });\n }\n }\n }\n if (key === 'mergeConfidenceDatasources') {\n const allowedValues = supportedDatasources;\n for (const value of val as string[]) {\n // v8 ignore else -- TODO: add test #40625\n if (!allowedValues.includes(value)) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid value \\`${value}\\` for \\`${currentPath}\\`. The allowed values are ${allowedValues.join(', ')}.`,\n });\n }\n }\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a list (Array).`,\n });\n }\n } else if (type === 'object') {\n if (isPlainObject(val)) {\n if (key === 'onboardingConfig') {\n const subValidation = await validateConfig('repo', val);\n for (const warning of subValidation.warnings.concat(\n subValidation.errors,\n )) {\n warnings.push(warning);\n }\n } else if (key === 'force') {\n const subValidation = await validateConfig('global', val);\n for (const warning of subValidation.warnings.concat(\n subValidation.errors,\n )) {\n warnings.push(warning);\n }\n } else if (key === 'cacheTtlOverride') {\n for (const [subKey, subValue] of Object.entries(val)) {\n const allowsNegative = optionAllowsNegativeIntegers.has(key);\n warnings.push(\n ...validateNumber(\n key,\n subValue,\n allowsNegative,\n currentPath,\n subKey,\n ),\n );\n\n if (\n !(packageCacheNamespaces as readonly string[]).includes(subKey) &&\n !anyMatchRegexOrGlobList(\n packageCacheNamespaces as unknown as string[],\n [subKey],\n )\n ) {\n errors.push({\n message: `${currentPath}: namespace \\`${subKey}\\` does not exist`,\n topic: 'Configuration Error',\n });\n }\n }\n } else {\n const res = validatePlainObject(val);\n if (res !== true) {\n warnings.push({\n topic: 'Configuration Error',\n message: `Invalid \\`${currentPath}.${res}\\` configuration: value must be a string.`,\n });\n }\n }\n } else {\n warnings.push({\n topic: 'Configuration Error',\n message: `Configuration option \\`${currentPath}\\` should be a JSON object.`,\n });\n }\n }\n }\n}\n\nfunction getPossibleConfigFileNames({\n configFileNames,\n platform,\n}: {\n configFileNames?: string[];\n platform?: PlatformId;\n}): string[] {\n const filenames = getConfigFileNames(platform);\n if (isNonEmptyArray(configFileNames)) {\n return filenames.concat(configFileNames);\n }\n\n return filenames;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,UAAU,WAAW;AAE3B,IAAI,qBAAqB;AACzB,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,cAAiC;AAEvC,MAAM,kBAAqC,CACzC,GAAG,wBACH,GAAG,yBACL;AAEA,MAAM,kBAAkB,CAAC,GAAG,aAA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AAQ,SAAS;GAC1B,MAAM,gBAAgB,MAAM,eAAe,UAAU,GAAG;GACxD,KAAK,MAAM,WAAW,cAAc,SAAS,OAC3C,cAAc,MAChB,GACE,SAAS,KAAK,OAAO;EAEzB,OAAO,IAAI,QAAQ,oBACjB,KAAK,MAAM,CAAC,QAAQ,aAAa,OAAO,QAAQ,GAAG,GAAG;GACpD,MAAM,iBAAiB,6BAA6B,IAAI,GAAG;GAC3D,SAAS,KACP,GAAG,eACD,KACA,UACA,gBACA,aACA,MACF,CACF;GAEA,IACE,CAAE,uBAA6C,SAAS,MAAM,KAC9D,CAAC,wBACC,wBACA,CAAC,MAAM,CACT,GAEA,OAAO,KAAK;IACV,SAAS,GAAG,YAAY,gBAAgB,OAAO;IAC/C,OAAO;GACT,CAAC;EAEL;OACK;GACL,MAAM,MAAM,oBAAoB,GAAG;GACnC,IAAI,QAAQ,MACV,SAAS,KAAK;IACZ,OAAO;IACP,SAAS,aAAa,YAAY,GAAG,IAAI;GAC3C,CAAC;EAEL;OAEA,SAAS,KAAK;GACZ,OAAO;GACP,SAAS,0BAA0B,YAAY;EACjD,CAAC;CAAA;AAIT;AAEA,SAAS,2BAA2B,EAClC,iBACA,YAIW;CACX,MAAM,YAAY,mBAAmB,QAAQ;CAC7C,IAAI,gBAAgB,eAAe,GACjC,OAAO,UAAU,OAAO,eAAe;CAGzC,OAAO;AACT"}
@@ -190,7 +190,7 @@ If you have specified global self-hosted configuration (https://docs.renovatebot
190
190
  } catch {}
191
191
  }
192
192
  if (returnVal === 0 && filesValidated) logger.info(`Config validated successfully against ${filesValidated} file(s)`);
193
- else logger.warn(`No files to perform configuration validation against`);
193
+ else if (!filesValidated) logger.warn(`No files to perform configuration validation against`);
194
194
  process.exitCode = returnVal;
195
195
  });
196
196
  await program.parseAsync();
@@ -1 +1 @@
1
- {"version":3,"file":"config-validator.js","names":["getFileConfig"],"sources":["../lib/config-validator.ts"],"sourcesContent":["#!/usr/bin/env node\nimport 'source-map-support/register.js';\nimport './punycode.cjs';\n\nimport { styleText } from 'node:util';\nimport { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { Command, CommanderError } from 'commander';\nimport { dequal } from 'dequal';\nimport { diffLines } from 'diff';\nimport fs from 'fs-extra';\nimport { getConfigFileNames } from './config/app-strings.ts';\nimport { GlobalConfig } from './config/global.ts';\nimport { massageConfig } from './config/massage.ts';\nimport { migrateConfig } from './config/migration.ts';\nimport type { RenovateConfig } from './config/types.ts';\nimport { validateConfig } from './config/validation.ts';\nimport { pkg } from './expose.ts';\nimport { init, logger } from './logger/index.ts';\nimport { getEnv } from './util/env.ts';\nimport { add as addHostRule } from './util/host-rules.ts';\nimport { regEx } from './util/regex.ts';\nimport { getConfig as getFileConfig } from './workers/global/config/parse/file.ts';\nimport { parseConfigs } from './workers/global/config/parse/index.ts';\nimport { getParsedContent } from './workers/global/config/parse/util.ts';\n\nawait init();\n\nconst { pathExists, readFile } = fs;\n\nlet returnVal = 0;\n\n/**\n * Make sure that we've resolved configuration from the different places that Renovate users would expect them to be specified\n *\n * This then allows a `configType=repo` config to i.e. be validated alongside a `config.js` or `env RENOVATE_ALLOWED_COMMANDS=...`\n *\n * Note that we intentionally don't fully initialize Renovate and its modules, as we're not fully running, and it would require a Platform to be configured\n * */\nasync function partiallyGlobalInitialize(): Promise<void> {\n // NOTE that this doesn't allow command-line arguments\n const globalConfig = await parseConfigs(getEnv(), []);\n GlobalConfig.set(globalConfig);\n\n if (globalConfig.hostRules) {\n for (const hostRule of globalConfig.hostRules) {\n addHostRule(hostRule);\n }\n }\n}\n\nasync function validate(\n configType: 'global' | 'repo',\n desc: string,\n config: RenovateConfig,\n strict: boolean,\n isPreset = false,\n): Promise<void> {\n if (config.hostRules) {\n for (const hostRule of config.hostRules) {\n addHostRule(hostRule);\n }\n }\n const { isMigrated, migratedConfig } = migrateConfig(config);\n if (isMigrated) {\n logger.warn(\n {\n oldConfig: config,\n newConfig: migratedConfig,\n },\n 'Config migration necessary',\n );\n const changedObjects = diffLines(\n JSON.stringify(config, null, 2),\n JSON.stringify(migratedConfig, null, 2),\n { ignoreWhitespace: false, newlineIsToken: false },\n );\n const added = styleText('green', '+ ');\n const removed = styleText('red', '- ');\n const msg = changedObjects\n .flatMap((part) => {\n let linePrefix: string;\n if (part.added) {\n linePrefix = added;\n } else if (part.removed) {\n linePrefix = removed;\n } else {\n linePrefix = ' ';\n }\n return part.value\n .split('\\n')\n .filter(isNonEmptyStringAndNotWhitespace)\n .map((line) =>\n line.replace(regEx(/^(?<ws> *)/), `${linePrefix}$<ws>`),\n );\n })\n .join('\\n');\n logger.warn(`Config migration diff:\\n${msg}`);\n if (strict) {\n returnVal = 1;\n }\n }\n const massagedConfig = massageConfig(migratedConfig);\n const res = await validateConfig(configType, massagedConfig, isPreset);\n if (res.errors.length) {\n logger.error(\n { file: desc, errors: res.errors },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n if (res.warnings.length) {\n logger.warn(\n { file: desc, warnings: res.warnings },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n}\n\ninterface PackageJson {\n renovate?: RenovateConfig;\n 'renovate-config'?: Record<string, RenovateConfig>;\n}\n\n(async () => {\n await partiallyGlobalInitialize();\n\n const program = new Command('renovate-config-validator')\n .summary('Validate Renovate configuration files')\n .description(\n `Validate your Renovate configuration (repo config, shared presets or global configuration) files\\n` +\n 'If no [config-files...] are given, renovate-config-validator will look at the default config file locations (https://docs.renovatebot.com/configuration-options/)',\n )\n .addHelpText(\n 'after',\n `\nWhen specifying [config-files...], Renovate will treat them as global self-hosted configuration files. You can disable this behaviour with --no-global\n\nExamples:\n\n $ renovate-config-validator\n $ renovate-config-validator --strict\n $ renovate-config-validator first_config.json\n $ renovate-config-validator --strict config.js\n $ renovate-config-validator --no-global renovate.json5\n $ env RENOVATE_CONFIG_FILE=obscure-name.json renovate-config-validator\n\nGlobal configuration:\n\nIf you have specified global self-hosted configuration (https://docs.renovatebot.com/self-hosted-configuration/) in environment variables or in a \\`config.js\\`, this will be detected:\n\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator\n # if passing the filename, make sure it's not validating as a global config\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator --no-global renovate.json`,\n )\n .argument('[config-files...]')\n .version(pkg.version, '-v, --version')\n .option(\n '--strict',\n 'Fail command if any configuration warnings, errors, or a migration is needed',\n )\n .option(\n '--no-global',\n 'When specifying [config-files], do not treat them as global self-hosted configuration file(s)',\n true,\n )\n // allow us to manage the exit code\n .exitOverride();\n\n program.action(async (files, opts) => {\n const strict = opts.strict ?? false;\n let filesValidated = 0;\n\n if (files.length) {\n let isGlobalConfig = true;\n if (opts.global === false) {\n isGlobalConfig = false;\n }\n const configType = isGlobalConfig ? 'global' : 'repo';\n for (const file of files) {\n try {\n if (!(await pathExists(file))) {\n returnVal = 1;\n logger.error({ file }, 'File does not exist');\n break;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file} as ${configType} config`);\n await validate(configType, file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n\n filesValidated++;\n }\n } else {\n for (const file of getConfigFileNames().filter(\n (name) => name !== 'package.json',\n )) {\n try {\n if (!(await pathExists(file))) {\n continue;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file}`);\n await validate('repo', file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n\n filesValidated++;\n }\n try {\n const pkgJson = JSON.parse(\n await readFile('package.json', 'utf8'),\n ) as PackageJson;\n if (pkgJson.renovate) {\n logger.info(`Validating package.json > renovate`);\n await validate(\n 'repo',\n 'package.json > renovate',\n pkgJson.renovate,\n strict,\n );\n\n filesValidated++;\n }\n if (pkgJson['renovate-config']) {\n logger.info(`Validating package.json > renovate-config`);\n for (const presetConfig of Object.values(\n pkgJson['renovate-config'],\n )) {\n await validate(\n 'repo',\n 'package.json > renovate-config',\n presetConfig,\n strict,\n true,\n );\n\n filesValidated++;\n }\n }\n } catch {\n // ignore\n }\n try {\n const env = getEnv();\n const fileConfig = await getFileConfig(env);\n if (!dequal(fileConfig, {})) {\n const file = env.RENOVATE_CONFIG_FILE ?? 'config.js';\n logger.info(`Validating ${file}`);\n try {\n await validate('global', file, fileConfig, strict);\n } catch (err) {\n logger.error({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n filesValidated++;\n }\n } catch {\n // ignore\n }\n }\n if (returnVal === 0 && filesValidated) {\n logger.info(\n `Config validated successfully against ${filesValidated} file(s)`,\n );\n } else {\n logger.warn(`No files to perform configuration validation against`);\n }\n // Use exitCode (not process.exit) so async log streams can flush\n process.exitCode = returnVal;\n });\n\n await program.parseAsync();\n})().catch((e) => {\n if (e instanceof CommanderError) {\n // Commander throws an error at the end of Action execution i.e. as part of the `help` and `version` commands, and so we don't want to return an error code in this case\n if (\n e.code === 'commander.helpDisplayed' ||\n e.code === 'commander.version'\n ) {\n return;\n }\n }\n\n // oxlint-disable-next-line no-console -- intentional: display critical error on CLI\n console.error(e);\n process.exit(99);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,KAAK;AAEX,MAAM,EAAE,YAAY,aAAa;AAEjC,IAAI,YAAY;;;;;;;;AAShB,eAAe,4BAA2C;CAExD,MAAM,eAAe,MAAM,aAAa,OAAO,GAAG,CAAC,CAAC;CACpD,aAAa,IAAI,YAAY;CAE7B,IAAI,aAAa,WACf,KAAK,MAAM,YAAY,aAAa,WAClC,IAAY,QAAQ;AAG1B;AAEA,eAAe,SACb,YACA,MACA,QACA,QACA,WAAW,OACI;CACf,IAAI,OAAO,WACT,KAAK,MAAM,YAAY,OAAO,WAC5B,IAAY,QAAQ;CAGxB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C;KAChD,MAAM,SACJ,QACA,2BACA,QAAQ,UACR,MACF;KAEA;IACF;IACA,IAAI,QAAQ,oBAAoB;KAC9B,OAAO,KAAK,2CAA2C;KACvD,KAAK,MAAM,gBAAgB,OAAO,OAChC,QAAQ,kBACV,GAAG;MACD,MAAM,SACJ,QACA,kCACA,cACA,QACA,IACF;MAEA;KACF;IACF;GACF,QAAQ,CAER;GACA,IAAI;IACF,MAAM,MAAM,OAAO;IACnB,MAAM,aAAa,MAAMA,UAAc,GAAG;IAC1C,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC,GAAG;KAC3B,MAAM,OAAO,IAAI,wBAAwB;KACzC,OAAO,KAAK,cAAc,MAAM;KAChC,IAAI;MACF,MAAM,SAAS,UAAU,MAAM,YAAY,MAAM;KACnD,SAAS,KAAK;MACZ,OAAO,MAAM;OAAE;OAAM;MAAI,GAAG,mCAAmC;MAC/D,YAAY;KACd;KACA;IACF;GACF,QAAQ,CAER;EACF;EACA,IAAI,cAAc,KAAK,gBACrB,OAAO,KACL,yCAAyC,eAAe,SAC1D;OAEA,OAAO,KAAK,sDAAsD;EAGpE,QAAQ,WAAW;CACrB,CAAC;CAED,MAAM,QAAQ,WAAW;AAC3B,GAAG,EAAE,OAAO,MAAM;CAChB,IAAI,aAAa;MAGb,EAAE,SAAS,6BACX,EAAE,SAAS,qBAEX;CAAA;CAKJ,QAAQ,MAAM,CAAC;CACf,QAAQ,KAAK,EAAE;AACjB,CAAC"}
1
+ {"version":3,"file":"config-validator.js","names":["getFileConfig"],"sources":["../lib/config-validator.ts"],"sourcesContent":["#!/usr/bin/env node\nimport 'source-map-support/register.js';\nimport './punycode.cjs';\n\nimport { styleText } from 'node:util';\nimport { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { Command, CommanderError } from 'commander';\nimport { dequal } from 'dequal';\nimport { diffLines } from 'diff';\nimport fs from 'fs-extra';\nimport { getConfigFileNames } from './config/app-strings.ts';\nimport { GlobalConfig } from './config/global.ts';\nimport { massageConfig } from './config/massage.ts';\nimport { migrateConfig } from './config/migration.ts';\nimport type { RenovateConfig } from './config/types.ts';\nimport { validateConfig } from './config/validation.ts';\nimport { pkg } from './expose.ts';\nimport { init, logger } from './logger/index.ts';\nimport { getEnv } from './util/env.ts';\nimport { add as addHostRule } from './util/host-rules.ts';\nimport { regEx } from './util/regex.ts';\nimport { getConfig as getFileConfig } from './workers/global/config/parse/file.ts';\nimport { parseConfigs } from './workers/global/config/parse/index.ts';\nimport { getParsedContent } from './workers/global/config/parse/util.ts';\n\nawait init();\n\nconst { pathExists, readFile } = fs;\n\nlet returnVal = 0;\n\n/**\n * Make sure that we've resolved configuration from the different places that Renovate users would expect them to be specified\n *\n * This then allows a `configType=repo` config to i.e. be validated alongside a `config.js` or `env RENOVATE_ALLOWED_COMMANDS=...`\n *\n * Note that we intentionally don't fully initialize Renovate and its modules, as we're not fully running, and it would require a Platform to be configured\n * */\nasync function partiallyGlobalInitialize(): Promise<void> {\n // NOTE that this doesn't allow command-line arguments\n const globalConfig = await parseConfigs(getEnv(), []);\n GlobalConfig.set(globalConfig);\n\n if (globalConfig.hostRules) {\n for (const hostRule of globalConfig.hostRules) {\n addHostRule(hostRule);\n }\n }\n}\n\nasync function validate(\n configType: 'global' | 'repo',\n desc: string,\n config: RenovateConfig,\n strict: boolean,\n isPreset = false,\n): Promise<void> {\n if (config.hostRules) {\n for (const hostRule of config.hostRules) {\n addHostRule(hostRule);\n }\n }\n const { isMigrated, migratedConfig } = migrateConfig(config);\n if (isMigrated) {\n logger.warn(\n {\n oldConfig: config,\n newConfig: migratedConfig,\n },\n 'Config migration necessary',\n );\n const changedObjects = diffLines(\n JSON.stringify(config, null, 2),\n JSON.stringify(migratedConfig, null, 2),\n { ignoreWhitespace: false, newlineIsToken: false },\n );\n const added = styleText('green', '+ ');\n const removed = styleText('red', '- ');\n const msg = changedObjects\n .flatMap((part) => {\n let linePrefix: string;\n if (part.added) {\n linePrefix = added;\n } else if (part.removed) {\n linePrefix = removed;\n } else {\n linePrefix = ' ';\n }\n return part.value\n .split('\\n')\n .filter(isNonEmptyStringAndNotWhitespace)\n .map((line) =>\n line.replace(regEx(/^(?<ws> *)/), `${linePrefix}$<ws>`),\n );\n })\n .join('\\n');\n logger.warn(`Config migration diff:\\n${msg}`);\n if (strict) {\n returnVal = 1;\n }\n }\n const massagedConfig = massageConfig(migratedConfig);\n const res = await validateConfig(configType, massagedConfig, isPreset);\n if (res.errors.length) {\n logger.error(\n { file: desc, errors: res.errors },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n if (res.warnings.length) {\n logger.warn(\n { file: desc, warnings: res.warnings },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n}\n\ninterface PackageJson {\n renovate?: RenovateConfig;\n 'renovate-config'?: Record<string, RenovateConfig>;\n}\n\n(async () => {\n await partiallyGlobalInitialize();\n\n const program = new Command('renovate-config-validator')\n .summary('Validate Renovate configuration files')\n .description(\n `Validate your Renovate configuration (repo config, shared presets or global configuration) files\\n` +\n 'If no [config-files...] are given, renovate-config-validator will look at the default config file locations (https://docs.renovatebot.com/configuration-options/)',\n )\n .addHelpText(\n 'after',\n `\nWhen specifying [config-files...], Renovate will treat them as global self-hosted configuration files. You can disable this behaviour with --no-global\n\nExamples:\n\n $ renovate-config-validator\n $ renovate-config-validator --strict\n $ renovate-config-validator first_config.json\n $ renovate-config-validator --strict config.js\n $ renovate-config-validator --no-global renovate.json5\n $ env RENOVATE_CONFIG_FILE=obscure-name.json renovate-config-validator\n\nGlobal configuration:\n\nIf you have specified global self-hosted configuration (https://docs.renovatebot.com/self-hosted-configuration/) in environment variables or in a \\`config.js\\`, this will be detected:\n\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator\n # if passing the filename, make sure it's not validating as a global config\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator --no-global renovate.json`,\n )\n .argument('[config-files...]')\n .version(pkg.version, '-v, --version')\n .option(\n '--strict',\n 'Fail command if any configuration warnings, errors, or a migration is needed',\n )\n .option(\n '--no-global',\n 'When specifying [config-files], do not treat them as global self-hosted configuration file(s)',\n true,\n )\n // allow us to manage the exit code\n .exitOverride();\n\n program.action(async (files, opts) => {\n const strict = opts.strict ?? false;\n let filesValidated = 0;\n\n if (files.length) {\n let isGlobalConfig = true;\n if (opts.global === false) {\n isGlobalConfig = false;\n }\n const configType = isGlobalConfig ? 'global' : 'repo';\n for (const file of files) {\n try {\n if (!(await pathExists(file))) {\n returnVal = 1;\n logger.error({ file }, 'File does not exist');\n break;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file} as ${configType} config`);\n await validate(configType, file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n\n filesValidated++;\n }\n } else {\n for (const file of getConfigFileNames().filter(\n (name) => name !== 'package.json',\n )) {\n try {\n if (!(await pathExists(file))) {\n continue;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file}`);\n await validate('repo', file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n\n filesValidated++;\n }\n try {\n const pkgJson = JSON.parse(\n await readFile('package.json', 'utf8'),\n ) as PackageJson;\n if (pkgJson.renovate) {\n logger.info(`Validating package.json > renovate`);\n await validate(\n 'repo',\n 'package.json > renovate',\n pkgJson.renovate,\n strict,\n );\n\n filesValidated++;\n }\n if (pkgJson['renovate-config']) {\n logger.info(`Validating package.json > renovate-config`);\n for (const presetConfig of Object.values(\n pkgJson['renovate-config'],\n )) {\n await validate(\n 'repo',\n 'package.json > renovate-config',\n presetConfig,\n strict,\n true,\n );\n\n filesValidated++;\n }\n }\n } catch {\n // ignore\n }\n try {\n const env = getEnv();\n const fileConfig = await getFileConfig(env);\n if (!dequal(fileConfig, {})) {\n const file = env.RENOVATE_CONFIG_FILE ?? 'config.js';\n logger.info(`Validating ${file}`);\n try {\n await validate('global', file, fileConfig, strict);\n } catch (err) {\n logger.error({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n filesValidated++;\n }\n } catch {\n // ignore\n }\n }\n if (returnVal === 0 && filesValidated) {\n logger.info(\n `Config validated successfully against ${filesValidated} file(s)`,\n );\n } else if (!filesValidated) {\n logger.warn(`No files to perform configuration validation against`);\n }\n // Use exitCode (not process.exit) so async log streams can flush\n process.exitCode = returnVal;\n });\n\n await program.parseAsync();\n})().catch((e) => {\n if (e instanceof CommanderError) {\n // Commander throws an error at the end of Action execution i.e. as part of the `help` and `version` commands, and so we don't want to return an error code in this case\n if (\n e.code === 'commander.helpDisplayed' ||\n e.code === 'commander.version'\n ) {\n return;\n }\n }\n\n // oxlint-disable-next-line no-console -- intentional: display critical error on CLI\n console.error(e);\n process.exit(99);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,KAAK;AAEX,MAAM,EAAE,YAAY,aAAa;AAEjC,IAAI,YAAY;;;;;;;;AAShB,eAAe,4BAA2C;CAExD,MAAM,eAAe,MAAM,aAAa,OAAO,GAAG,CAAC,CAAC;CACpD,aAAa,IAAI,YAAY;CAE7B,IAAI,aAAa,WACf,KAAK,MAAM,YAAY,aAAa,WAClC,IAAY,QAAQ;AAG1B;AAEA,eAAe,SACb,YACA,MACA,QACA,QACA,WAAW,OACI;CACf,IAAI,OAAO,WACT,KAAK,MAAM,YAAY,OAAO,WAC5B,IAAY,QAAQ;CAGxB,MAAM,EAAE,YAAY,mBAAmB,cAAc,MAAM;CAC3D,IAAI,YAAY;EACd,OAAO,KACL;GACE,WAAW;GACX,WAAW;EACb,GACA,4BACF;EACA,MAAM,iBAAiB,UACrB,KAAK,UAAU,QAAQ,MAAM,CAAC,GAC9B,KAAK,UAAU,gBAAgB,MAAM,CA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ACA,IACF;MAEA;KACF;IACF;GACF,QAAQ,CAER;GACA,IAAI;IACF,MAAM,MAAM,OAAO;IACnB,MAAM,aAAa,MAAMA,UAAc,GAAG;IAC1C,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC,GAAG;KAC3B,MAAM,OAAO,IAAI,wBAAwB;KACzC,OAAO,KAAK,cAAc,MAAM;KAChC,IAAI;MACF,MAAM,SAAS,UAAU,MAAM,YAAY,MAAM;KACnD,SAAS,KAAK;MACZ,OAAO,MAAM;OAAE;OAAM;MAAI,GAAG,mCAAmC;MAC/D,YAAY;KACd;KACA;IACF;GACF,QAAQ,CAER;EACF;EACA,IAAI,cAAc,KAAK,gBACrB,OAAO,KACL,yCAAyC,eAAe,SAC1D;OACK,IAAI,CAAC,gBACV,OAAO,KAAK,sDAAsD;EAGpE,QAAQ,WAAW;CACrB,CAAC;CAED,MAAM,QAAQ,WAAW;AAC3B,GAAG,EAAE,OAAO,MAAM;CAChB,IAAI,aAAa;MAGb,EAAE,SAAS,6BACX,EAAE,SAAS,qBAEX;CAAA;CAKJ,QAAQ,MAAM,CAAC;CACf,QAAQ,KAAK,EAAE;AACjB,CAAC"}
@@ -13,7 +13,7 @@ import { asTimestamp } from "../../../util/timestamp.js";
13
13
  import { Datasource } from "../datasource.js";
14
14
  import { memCacheProvider } from "../../../util/http/cache/memory-http-cache-provider.js";
15
15
  import { createSimpleGit } from "../../../util/git/index.js";
16
- import { RegistryConfigSchema, ReleaseTimestamp } from "./schema.js";
16
+ import { RegistryConfig, ReleaseTimestamp } from "./schema.js";
17
17
  import upath from "upath";
18
18
  //#region lib/modules/datasource/crate/index.ts
19
19
  var CrateDatasource = class CrateDatasource extends Datasource {
@@ -82,7 +82,7 @@ var CrateDatasource = class CrateDatasource extends Datasource {
82
82
  if (cached) return cached;
83
83
  if (info.clonePath) try {
84
84
  const content = await readCacheFile(upath.join(info.clonePath, "config.json"), "utf8");
85
- const parsed = Json.pipe(RegistryConfigSchema).parse(content);
85
+ const parsed = Json.pipe(RegistryConfig).parse(content);
86
86
  set(cacheKey, parsed);
87
87
  return parsed;
88
88
  } catch {
@@ -90,7 +90,7 @@ var CrateDatasource = class CrateDatasource extends Datasource {
90
90
  }
91
91
  else try {
92
92
  const configUrl = joinUrlParts(info.rawUrl, "config.json");
93
- const { body } = await this.http.getJson(configUrl, RegistryConfigSchema);
93
+ const { body } = await this.http.getJson(configUrl, RegistryConfig);
94
94
  set(cacheKey, body);
95
95
  return body;
96
96
  } catch {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["cargoVersioning.id","memCache.get"],"sources":["../../../../lib/modules/datasource/crate/index.ts"],"sourcesContent":["import upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport * as memCache from '../../../util/cache/memory/index.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { privateCacheDir, readCacheFile } from '../../../util/fs/index.ts';\nimport { createSimpleGit } from '../../../util/git/index.ts';\nimport { toSha256 } from '../../../util/hash.ts';\nimport { memCacheProvider } from '../../../util/http/cache/memory-http-cache-provider.ts';\nimport { acquireLock } from '../../../util/mutex.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { Json } from '../../../util/schema-utils/index.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport { joinUrlParts, parseUrl } from '../../../util/url.ts';\nimport * as cargoVersioning from '../../versioning/cargo/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport type {\n GetReleasesConfig,\n PostprocessReleaseConfig,\n PostprocessReleaseResult,\n Release,\n ReleaseResult,\n} from '../types.ts';\nimport { RegistryConfigSchema, ReleaseTimestamp } from './schema.ts';\nimport type {\n CrateMetadata,\n CrateRecord,\n RegistryFlavor,\n RegistryInfo,\n} from './types.ts';\n\ntype CloneResult =\n | {\n err: Error;\n clonePath?: undefined;\n }\n | {\n clonePath: string;\n err?: undefined;\n };\n\nexport class CrateDatasource extends Datasource {\n static readonly id = 'crate';\n\n constructor() {\n super(CrateDatasource.id);\n }\n\n override defaultRegistryUrls = ['sparse+https://index.crates.io/'];\n\n override defaultVersioning = cargoVersioning.id;\n\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `repository` field in the results.';\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timestamp is determined from `pubtime` field from crates.io index if available, or `version.created_at` field from crates.io API otherwise.';\n\n private async _getReleases({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore if -- should never happen */\n if (!registryUrl) {\n logger.warn(\n 'crate datasource: No registryUrl specified, cannot perform getReleases',\n );\n return null;\n }\n\n const registryInfo = await CrateDatasource.fetchRegistryInfo({\n packageName,\n registryUrl,\n });\n if (!registryInfo) {\n logger.debug(`Could not fetch registry info from ${registryUrl}`);\n return null;\n }\n\n const dependencyUrl = CrateDatasource.getDependencyUrl(\n registryInfo,\n packageName,\n );\n\n const payload = await this.fetchCrateRecordsPayload(\n registryInfo,\n packageName,\n );\n const lines = payload\n .split(newlineRegex) // break into lines\n .map((line) => line.trim()) // remove whitespace\n .filter((line) => line.length !== 0) // remove empty lines\n .map((line) => JSON.parse(line) as CrateRecord); // parse\n\n const metadata = await this.getCrateMetadata(registryInfo, packageName);\n\n const result: ReleaseResult = {\n dependencyUrl,\n releases: [],\n };\n\n if (metadata?.homepage) {\n result.homepage = metadata.homepage;\n }\n\n if (metadata?.repository) {\n result.sourceUrl = metadata.repository;\n }\n\n result.releases = lines\n .map((line) => {\n const versionOrig = line.vers;\n const version = versionOrig.replace(/\\+.*$/, '');\n const release: Release = { version };\n\n if (versionOrig !== version) {\n release.versionOrig = versionOrig;\n }\n\n if (line.yanked) {\n release.isDeprecated = true;\n }\n\n if (line.rust_version) {\n release.constraints = { rust: [line.rust_version] };\n }\n\n if (line.pubtime) {\n release.releaseTimestamp = asTimestamp(line.pubtime);\n }\n\n return release;\n })\n .filter((release) => release.version);\n if (!result.releases.length) {\n return null;\n }\n\n return result;\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: `datasource-${CrateDatasource.id}`,\n // TODO: types (#22198)\n key: `${config.registryUrl}/${config.packageName}`,\n cacheable: CrateDatasource.isCratesIo(config.registryUrl),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n /**\n * Fetches the registry's config.json which provides the API base URL\n * and download URL template.\n * See: https://doc.rust-lang.org/cargo/reference/registry-index.html#index-configuration\n */\n private async fetchRegistryConfig(\n info: RegistryInfo,\n ): Promise<RegistryConfigSchema | null> {\n const cacheKey = `crate-datasource/registry-config/${info.rawUrl}`;\n const cached = memCache.get<RegistryConfigSchema>(cacheKey);\n if (cached) {\n return cached;\n }\n\n if (info.clonePath) {\n try {\n const configPath = upath.join(info.clonePath, 'config.json');\n const content = await readCacheFile(configPath, 'utf8');\n const parsed = Json.pipe(RegistryConfigSchema).parse(content);\n memCache.set(cacheKey, parsed);\n return parsed;\n } catch {\n logger.debug(\n { registryUrl: info.rawUrl },\n 'Could not read config.json from cloned registry',\n );\n }\n } else {\n try {\n const configUrl = joinUrlParts(info.rawUrl, 'config.json');\n const { body } = await this.http.getJson(\n configUrl,\n RegistryConfigSchema,\n );\n memCache.set(cacheKey, body);\n return body;\n } catch {\n logger.debug(\n { registryUrl: info.rawUrl },\n 'Could not fetch registry config.json',\n );\n }\n }\n\n return null;\n }\n\n private async _getCrateMetadata(\n info: RegistryInfo,\n packageName: string,\n ): Promise<CrateMetadata | null> {\n const registryConfig = await this.fetchRegistryConfig(info);\n if (!registryConfig?.api) {\n return null;\n }\n\n const apiBaseUrl = joinUrlParts(registryConfig.api, 'api/v1/');\n\n // The `?include=` suffix is required to avoid unnecessary database queries\n // on the crates.io server. This lets us work around the regular request\n // throttling of one request per second.\n const crateUrl = `${apiBaseUrl}crates/${packageName}?include=`;\n\n logger.trace(\n { crateUrl, packageName, registryUrl: info.rawUrl },\n 'downloading crate metadata',\n );\n\n try {\n interface Response {\n crate: CrateMetadata;\n }\n const response = await this.http.getJsonUnchecked<Response>(crateUrl);\n return response.body.crate;\n } catch (err) {\n logger.debug(\n { err, packageName, registryUrl: info.rawUrl },\n 'failed to download crate metadata',\n );\n }\n\n return null;\n }\n\n public getCrateMetadata(\n info: RegistryInfo,\n packageName: string,\n ): Promise<CrateMetadata | null> {\n return withCache(\n {\n namespace: `datasource-${CrateDatasource.id}-metadata`,\n key: `${info.rawUrl}/${packageName}`,\n cacheable: info.flavor === 'crates.io',\n ttlMinutes: 24 * 60, // 24 hours\n },\n () => this._getCrateMetadata(info, packageName),\n );\n }\n\n public async fetchCrateRecordsPayload(\n info: RegistryInfo,\n packageName: string,\n ): Promise<string> {\n if (info.clonePath) {\n const path = upath.join(\n info.clonePath,\n ...CrateDatasource.getIndexSuffix(packageName),\n );\n return readCacheFile(path, 'utf8');\n }\n\n // sparse index\n const packageSuffix = CrateDatasource.getIndexSuffix(\n packageName.toLowerCase(),\n );\n const crateUrl = joinUrlParts(info.rawUrl, ...packageSuffix);\n logger.trace(\n { crateUrl, packageName, registryUrl: info.rawUrl },\n 'fetching crate records from sparse index',\n );\n try {\n return (await this.http.getText(crateUrl)).body;\n } catch (err) {\n this.handleGenericErrors(err);\n }\n }\n\n /**\n * Computes the dependency URL for a crate, given\n * registry information\n */\n private static getDependencyUrl(\n info: RegistryInfo,\n packageName: string,\n ): string {\n switch (info.flavor) {\n case 'crates.io':\n return `https://crates.io/crates/${packageName}`;\n case 'cloudsmith': {\n // input: https://dl.cloudsmith.io/basic/$org/$repo/cargo/index.git\n const tokens = info.url.pathname.split('/');\n const org = tokens[2];\n const repo = tokens[3];\n return `https://cloudsmith.io/~${org}/repos/${repo}/packages/detail/cargo/${packageName}`;\n }\n default:\n return `${info.url}/${packageName}`;\n }\n }\n\n /**\n * Given a Git URL, computes a semi-human-readable name for a folder in which to\n * clone the repository.\n */\n private static cacheDirFromUrl(url: URL): string {\n const proto = url.protocol.replace(regEx(/:$/), '');\n const host = url.hostname;\n const hash = toSha256(url.pathname).substring(0, 7);\n\n return `crate-registry-${proto}-${host}-${hash}`;\n }\n\n private static isSparseRegistry(url: string): boolean {\n const parsed = parseUrl(url);\n if (!parsed) {\n return false;\n }\n return parsed.protocol.startsWith('sparse+');\n }\n\n /**\n * Fetches information about a registry, by url.\n * If no url is given, assumes crates.io.\n * If an url is given, assumes it's a valid Git repository\n * url and clones it to cache.\n */\n private static async fetchRegistryInfo({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<RegistryInfo | null> {\n /* v8 ignore next 3 -- should never happen */\n if (!registryUrl) {\n return null;\n }\n\n const isSparseRegistry = CrateDatasource.isSparseRegistry(registryUrl);\n const registryFetchUrl = isSparseRegistry\n ? registryUrl.replace(/^sparse\\+/, '')\n : registryUrl;\n\n const url = parseUrl(registryFetchUrl);\n if (!url) {\n logger.debug(`Could not parse registry URL ${registryFetchUrl}`);\n return null;\n }\n\n let flavor: RegistryFlavor;\n if (url.hostname === 'index.crates.io') {\n flavor = 'crates.io';\n } else if (url.hostname === 'dl.cloudsmith.io') {\n flavor = 'cloudsmith';\n } else {\n flavor = 'other';\n }\n\n const registry: RegistryInfo = {\n flavor,\n rawUrl: registryFetchUrl,\n url,\n };\n\n if (\n registry.flavor !== 'crates.io' &&\n !GlobalConfig.get('allowCustomCrateRegistries')\n ) {\n logger.warn(\n 'crate datasource: allowCustomCrateRegistries=true is required for registries other than crates.io, bailing out',\n );\n return null;\n }\n if (!isSparseRegistry) {\n const cacheKey = `crate-datasource/registry-clone-path/${registryFetchUrl}`;\n const lockKey = registryFetchUrl;\n\n const executionTimeout = GlobalConfig.get('executionTimeout') * 60 * 1000;\n const gitTimeout = GlobalConfig.get('gitTimeout') || executionTimeout;\n const releaseLock = await acquireLock(\n lockKey,\n 'crate-registry',\n gitTimeout,\n );\n try {\n const cached = memCache.get<CloneResult>(cacheKey);\n\n if (cached?.err) {\n logger.warn(\n { err: cached.err, packageName, registryFetchUrl },\n 'Previous git clone failed, bailing out.',\n );\n return null;\n }\n\n if (cached?.clonePath) {\n registry.clonePath = cached.clonePath;\n return registry;\n }\n\n const clonePath = upath.join(\n privateCacheDir(),\n CrateDatasource.cacheDirFromUrl(url),\n );\n\n const result = await CrateDatasource.clone(\n registryFetchUrl,\n clonePath,\n packageName,\n );\n\n memCache.set(cacheKey, result);\n\n if (result.err) {\n logger.warn(\n { err: result.err, packageName, registryFetchUrl },\n 'Git clone failed, bailing out.',\n );\n return null;\n }\n\n registry.clonePath = result.clonePath;\n } finally {\n releaseLock();\n }\n }\n\n return registry;\n }\n\n private static async clone(\n registryFetchUrl: string,\n clonePath: string,\n packageName: string,\n ): Promise<CloneResult> {\n logger.info(\n { clonePath, registryFetchUrl },\n `Cloning private cargo registry`,\n );\n\n const git = createSimpleGit({\n config: { maxConcurrentProcesses: 1 },\n });\n\n try {\n await git.clone(registryFetchUrl, clonePath, {\n '--depth': 1,\n });\n return { clonePath };\n } catch (err) {\n if (\n err.message.includes(\n 'fatal: dumb http transport does not support shallow capabilities',\n )\n ) {\n logger.info(\n { packageName, registryFetchUrl },\n 'failed to shallow clone git registry, doing full clone',\n );\n try {\n await git.clone(registryFetchUrl, clonePath);\n return { clonePath };\n } catch (err) {\n logger.warn(\n { err, packageName, registryFetchUrl },\n 'failed cloning git registry',\n );\n return { err };\n }\n } else {\n logger.warn(\n { err, packageName, registryFetchUrl },\n 'failed cloning git registry',\n );\n return { err };\n }\n }\n }\n\n private static isCratesIo(registryUrl: string | undefined): boolean {\n if (!registryUrl) {\n return false;\n }\n const normalized = registryUrl.replace(regEx(/^sparse\\+/), '');\n const parsed = parseUrl(normalized);\n return parsed?.hostname === 'index.crates.io';\n }\n\n public static getIndexSuffix(packageName: string): string[] {\n const len = packageName.length;\n\n if (len === 1) {\n return ['1', packageName];\n }\n if (len === 2) {\n return ['2', packageName];\n }\n if (len === 3) {\n return ['3', packageName[0], packageName];\n }\n\n return [packageName.slice(0, 2), packageName.slice(2, 4), packageName];\n }\n\n private async _postprocessRelease(\n { packageName, registryUrl }: PostprocessReleaseConfig,\n release: Release,\n ): Promise<PostprocessReleaseResult> {\n if (release.releaseTimestamp) {\n return release;\n }\n\n // Look up the registry config from cache (populated during getReleases)\n const rawUrl = registryUrl?.replace(/^sparse\\+/, '');\n if (!rawUrl) {\n return release;\n }\n const cacheKey = `crate-datasource/registry-config/${rawUrl}`;\n const config = memCache.get<{ dl: string; api?: string }>(cacheKey);\n if (!config?.api) {\n return release;\n }\n\n const apiBaseUrl = joinUrlParts(config.api, 'api/v1/');\n const url = `${apiBaseUrl}crates/${packageName}/${release.versionOrig ?? release.version}`;\n logger.trace(\n { url, packageName, version: release.version, registryUrl },\n 'fetching crate release timestamp',\n );\n // Getting release timestamp could become unnecessary if the manual backfill of `pubtime` mentioned in\n // https://github.com/rust-lang/cargo/issues/15491 is done for all packages.\n const { body: releaseTimestamp } = await this.http.getJson(\n url,\n { cacheProvider: memCacheProvider },\n ReleaseTimestamp,\n );\n release.releaseTimestamp = releaseTimestamp;\n return release;\n }\n\n override postprocessRelease(\n config: PostprocessReleaseConfig,\n release: Release,\n ): Promise<PostprocessReleaseResult> {\n return withCache(\n {\n namespace: `datasource-crate`,\n key: `postprocessRelease:${config.registryUrl}:${config.packageName}:${release.version}`,\n ttlMinutes: 7 * 24 * 60,\n cacheable: CrateDatasource.isCratesIo(config.registryUrl ?? undefined),\n },\n () => this._postprocessRelease(config, release),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,IAAa,kBAAb,MAAa,wBAAwB,WAAW;CAC9C,OAAgB,KAAK;CAErB,cAAc;EACZ,MAAM,gBAAgB,EAAE;CAC1B;CAEA,sBAA+B,CAAC,iCAAiC;CAEjE,oBAA6BA;CAE7B,mBAAqC;CACrC,gBACE;CAEF,0BAA4C;CAC5C,uBACE;CAEF,MAAc,aAAa,EACzB,aACA,eACmD;;EAEnD,IAAI,CAAC,aAAa;GAChB,OAAO,KACL,wEACF;G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;GAAa,SAAS,QAAQ;GAAS;EAAY,GAC1D,kCACF;EAGA,MAAM,EAAE,MAAM,qBAAqB,MAAM,KAAK,KAAK,QACjD,KACA,EAAE,eAAe,iBAAiB,GAClC,gBACF;EACA,QAAQ,mBAAmB;EAC3B,OAAO;CACT;CAEA,mBACE,QACA,SACmC;EACnC,OAAO,UACL;GACE,WAAW;GACX,KAAK,sBAAsB,OAAO,YAAY,GAAG,OAAO,YAAY,GAAG,QAAQ;GAC/E,YAAY;GACZ,WAAW,gBAAgB,WAAW,OAAO,eAAe,KAAA,CAAS;EACvE,SACM,KAAK,oBAAoB,QAAQ,OAAO,CAChD;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["cargoVersioning.id","memCache.get"],"sources":["../../../../lib/modules/datasource/crate/index.ts"],"sourcesContent":["import upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport * as memCache from '../../../util/cache/memory/index.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { privateCacheDir, readCacheFile } from '../../../util/fs/index.ts';\nimport { createSimpleGit } from '../../../util/git/index.ts';\nimport { toSha256 } from '../../../util/hash.ts';\nimport { memCacheProvider } from '../../../util/http/cache/memory-http-cache-provider.ts';\nimport { acquireLock } from '../../../util/mutex.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { Json } from '../../../util/schema-utils/index.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport { joinUrlParts, parseUrl } from '../../../util/url.ts';\nimport * as cargoVersioning from '../../versioning/cargo/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport type {\n GetReleasesConfig,\n PostprocessReleaseConfig,\n PostprocessReleaseResult,\n Release,\n ReleaseResult,\n} from '../types.ts';\nimport { RegistryConfig, ReleaseTimestamp } from './schema.ts';\nimport type {\n CrateMetadata,\n CrateRecord,\n RegistryFlavor,\n RegistryInfo,\n} from './types.ts';\n\ntype CloneResult =\n | {\n err: Error;\n clonePath?: undefined;\n }\n | {\n clonePath: string;\n err?: undefined;\n };\n\nexport class CrateDatasource extends Datasource {\n static readonly id = 'crate';\n\n constructor() {\n super(CrateDatasource.id);\n }\n\n override defaultRegistryUrls = ['sparse+https://index.crates.io/'];\n\n override defaultVersioning = cargoVersioning.id;\n\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `repository` field in the results.';\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timestamp is determined from `pubtime` field from crates.io index if available, or `version.created_at` field from crates.io API otherwise.';\n\n private async _getReleases({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore if -- should never happen */\n if (!registryUrl) {\n logger.warn(\n 'crate datasource: No registryUrl specified, cannot perform getReleases',\n );\n return null;\n }\n\n const registryInfo = await CrateDatasource.fetchRegistryInfo({\n packageName,\n registryUrl,\n });\n if (!registryInfo) {\n logger.debug(`Could not fetch registry info from ${registryUrl}`);\n return null;\n }\n\n const dependencyUrl = CrateDatasource.getDependencyUrl(\n registryInfo,\n packageName,\n );\n\n const payload = await this.fetchCrateRecordsPayload(\n registryInfo,\n packageName,\n );\n const lines = payload\n .split(newlineRegex) // break into lines\n .map((line) => line.trim()) // remove whitespace\n .filter((line) => line.length !== 0) // remove empty lines\n .map((line) => JSON.parse(line) as CrateRecord); // parse\n\n const metadata = await this.getCrateMetadata(registryInfo, packageName);\n\n const result: ReleaseResult = {\n dependencyUrl,\n releases: [],\n };\n\n if (metadata?.homepage) {\n result.homepage = metadata.homepage;\n }\n\n if (metadata?.repository) {\n result.sourceUrl = metadata.repository;\n }\n\n result.releases = lines\n .map((line) => {\n const versionOrig = line.vers;\n const version = versionOrig.replace(/\\+.*$/, '');\n const release: Release = { version };\n\n if (versionOrig !== version) {\n release.versionOrig = versionOrig;\n }\n\n if (line.yanked) {\n release.isDeprecated = true;\n }\n\n if (line.rust_version) {\n release.constraints = { rust: [line.rust_version] };\n }\n\n if (line.pubtime) {\n release.releaseTimestamp = asTimestamp(line.pubtime);\n }\n\n return release;\n })\n .filter((release) => release.version);\n if (!result.releases.length) {\n return null;\n }\n\n return result;\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: `datasource-${CrateDatasource.id}`,\n // TODO: types (#22198)\n key: `${config.registryUrl}/${config.packageName}`,\n cacheable: CrateDatasource.isCratesIo(config.registryUrl),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n /**\n * Fetches the registry's config.json which provides the API base URL\n * and download URL template.\n * See: https://doc.rust-lang.org/cargo/reference/registry-index.html#index-configuration\n */\n private async fetchRegistryConfig(\n info: RegistryInfo,\n ): Promise<RegistryConfig | null> {\n const cacheKey = `crate-datasource/registry-config/${info.rawUrl}`;\n const cached = memCache.get<RegistryConfig>(cacheKey);\n if (cached) {\n return cached;\n }\n\n if (info.clonePath) {\n try {\n const configPath = upath.join(info.clonePath, 'config.json');\n const content = await readCacheFile(configPath, 'utf8');\n const parsed = Json.pipe(RegistryConfig).parse(content);\n memCache.set(cacheKey, parsed);\n return parsed;\n } catch {\n logger.debug(\n { registryUrl: info.rawUrl },\n 'Could not read config.json from cloned registry',\n );\n }\n } else {\n try {\n const configUrl = joinUrlParts(info.rawUrl, 'config.json');\n const { body } = await this.http.getJson(configUrl, RegistryConfig);\n memCache.set(cacheKey, body);\n return body;\n } catch {\n logger.debug(\n { registryUrl: info.rawUrl },\n 'Could not fetch registry config.json',\n );\n }\n }\n\n return null;\n }\n\n private async _getCrateMetadata(\n info: RegistryInfo,\n packageName: string,\n ): Promise<CrateMetadata | null> {\n const registryConfig = await this.fetchRegistryConfig(info);\n if (!registryConfig?.api) {\n return null;\n }\n\n const apiBaseUrl = joinUrlParts(registryConfig.api, 'api/v1/');\n\n // The `?include=` suffix is required to avoid unnecessary database queries\n // on the crates.io server. This lets us work around the regular request\n // throttling of one request per second.\n const crateUrl = `${apiBaseUrl}crates/${packageName}?include=`;\n\n logger.trace(\n { crateUrl, packageName, registryUrl: info.rawUrl },\n 'downloading crate metadata',\n );\n\n try {\n interface Response {\n crate: CrateMetadata;\n }\n const response = await this.http.getJsonUnchecked<Response>(crateUrl);\n return response.body.crate;\n } catch (err) {\n logger.debug(\n { err, packageName, registryUrl: info.rawUrl },\n 'failed to download crate metadata',\n );\n }\n\n return null;\n }\n\n public getCrateMetadata(\n info: RegistryInfo,\n packageName: string,\n ): Promise<CrateMetadata | null> {\n return withCache(\n {\n namespace: `datasource-${CrateDatasource.id}-metadata`,\n key: `${info.rawUrl}/${packageName}`,\n cacheable: info.flavor === 'crates.io',\n ttlMinutes: 24 * 60, // 24 hours\n },\n () => this._getCrateMetadata(info, packageName),\n );\n }\n\n public async fetchCrateRecordsPayload(\n info: RegistryInfo,\n packageName: string,\n ): Promise<string> {\n if (info.clonePath) {\n const path = upath.join(\n info.clonePath,\n ...CrateDatasource.getIndexSuffix(packageName),\n );\n return readCacheFile(path, 'utf8');\n }\n\n // sparse index\n const packageSuffix = CrateDatasource.getIndexSuffix(\n packageName.toLowerCase(),\n );\n const crateUrl = joinUrlParts(info.rawUrl, ...packageSuffix);\n logger.trace(\n { crateUrl, packageName, registryUrl: info.rawUrl },\n 'fetching crate records from sparse index',\n );\n try {\n return (await this.http.getText(crateUrl)).body;\n } catch (err) {\n this.handleGenericErrors(err);\n }\n }\n\n /**\n * Computes the dependency URL for a crate, given\n * registry information\n */\n private static getDependencyUrl(\n info: RegistryInfo,\n packageName: string,\n ): string {\n switch (info.flavor) {\n case 'crates.io':\n return `https://crates.io/crates/${packageName}`;\n case 'cloudsmith': {\n // input: https://dl.cloudsmith.io/basic/$org/$repo/cargo/index.git\n const tokens = info.url.pathname.split('/');\n const org = tokens[2];\n const repo = tokens[3];\n return `https://cloudsmith.io/~${org}/repos/${repo}/packages/detail/cargo/${packageName}`;\n }\n default:\n return `${info.url}/${packageName}`;\n }\n }\n\n /**\n * Given a Git URL, computes a semi-human-readable name for a folder in which to\n * clone the repository.\n */\n private static cacheDirFromUrl(url: URL): string {\n const proto = url.protocol.replace(regEx(/:$/), '');\n const host = url.hostname;\n const hash = toSha256(url.pathname).substring(0, 7);\n\n return `crate-registry-${proto}-${host}-${hash}`;\n }\n\n private static isSparseRegistry(url: string): boolean {\n const parsed = parseUrl(url);\n if (!parsed) {\n return false;\n }\n return parsed.protocol.startsWith('sparse+');\n }\n\n /**\n * Fetches information about a registry, by url.\n * If no url is given, assumes crates.io.\n * If an url is given, assumes it's a valid Git repository\n * url and clones it to cache.\n */\n private static async fetchRegistryInfo({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<RegistryInfo | null> {\n /* v8 ignore next 3 -- should never happen */\n if (!registryUrl) {\n return null;\n }\n\n const isSparseRegistry = CrateDatasource.isSparseRegistry(registryUrl);\n const registryFetchUrl = isSparseRegistry\n ? registryUrl.replace(/^sparse\\+/, '')\n : registryUrl;\n\n const url = parseUrl(registryFetchUrl);\n if (!url) {\n logger.debug(`Could not parse registry URL ${registryFetchUrl}`);\n return null;\n }\n\n let flavor: RegistryFlavor;\n if (url.hostname === 'index.crates.io') {\n flavor = 'crates.io';\n } else if (url.hostname === 'dl.cloudsmith.io') {\n flavor = 'cloudsmith';\n } else {\n flavor = 'other';\n }\n\n const registry: RegistryInfo = {\n flavor,\n rawUrl: registryFetchUrl,\n url,\n };\n\n if (\n registry.flavor !== 'crates.io' &&\n !GlobalConfig.get('allowCustomCrateRegistries')\n ) {\n logger.warn(\n 'crate datasource: allowCustomCrateRegistries=true is required for registries other than crates.io, bailing out',\n );\n return null;\n }\n if (!isSparseRegistry) {\n const cacheKey = `crate-datasource/registry-clone-path/${registryFetchUrl}`;\n const lockKey = registryFetchUrl;\n\n const executionTimeout = GlobalConfig.get('executionTimeout') * 60 * 1000;\n const gitTimeout = GlobalConfig.get('gitTimeout') || executionTimeout;\n const releaseLock = await acquireLock(\n lockKey,\n 'crate-registry',\n gitTimeout,\n );\n try {\n const cached = memCache.get<CloneResult>(cacheKey);\n\n if (cached?.err) {\n logger.warn(\n { err: cached.err, packageName, registryFetchUrl },\n 'Previous git clone failed, bailing out.',\n );\n return null;\n }\n\n if (cached?.clonePath) {\n registry.clonePath = cached.clonePath;\n return registry;\n }\n\n const clonePath = upath.join(\n privateCacheDir(),\n CrateDatasource.cacheDirFromUrl(url),\n );\n\n const result = await CrateDatasource.clone(\n registryFetchUrl,\n clonePath,\n packageName,\n );\n\n memCache.set(cacheKey, result);\n\n if (result.err) {\n logger.warn(\n { err: result.err, packageName, registryFetchUrl },\n 'Git clone failed, bailing out.',\n );\n return null;\n }\n\n registry.clonePath = result.clonePath;\n } finally {\n releaseLock();\n }\n }\n\n return registry;\n }\n\n private static async clone(\n registryFetchUrl: string,\n clonePath: string,\n packageName: string,\n ): Promise<CloneResult> {\n logger.info(\n { clonePath, registryFetchUrl },\n `Cloning private cargo registry`,\n );\n\n const git = createSimpleGit({\n config: { maxConcurrentProcesses: 1 },\n });\n\n try {\n await git.clone(registryFetchUrl, clonePath, {\n '--depth': 1,\n });\n return { clonePath };\n } catch (err) {\n if (\n err.message.includes(\n 'fatal: dumb http transport does not support shallow capabilities',\n )\n ) {\n logger.info(\n { packageName, registryFetchUrl },\n 'failed to shallow clone git registry, doing full clone',\n );\n try {\n await git.clone(registryFetchUrl, clonePath);\n return { clonePath };\n } catch (err) {\n logger.warn(\n { err, packageName, registryFetchUrl },\n 'failed cloning git registry',\n );\n return { err };\n }\n } else {\n logger.warn(\n { err, packageName, registryFetchUrl },\n 'failed cloning git registry',\n );\n return { err };\n }\n }\n }\n\n private static isCratesIo(registryUrl: string | undefined): boolean {\n if (!registryUrl) {\n return false;\n }\n const normalized = registryUrl.replace(regEx(/^sparse\\+/), '');\n const parsed = parseUrl(normalized);\n return parsed?.hostname === 'index.crates.io';\n }\n\n public static getIndexSuffix(packageName: string): string[] {\n const len = packageName.length;\n\n if (len === 1) {\n return ['1', packageName];\n }\n if (len === 2) {\n return ['2', packageName];\n }\n if (len === 3) {\n return ['3', packageName[0], packageName];\n }\n\n return [packageName.slice(0, 2), packageName.slice(2, 4), packageName];\n }\n\n private async _postprocessRelease(\n { packageName, registryUrl }: PostprocessReleaseConfig,\n release: Release,\n ): Promise<PostprocessReleaseResult> {\n if (release.releaseTimestamp) {\n return release;\n }\n\n // Look up the registry config from cache (populated during getReleases)\n const rawUrl = registryUrl?.replace(/^sparse\\+/, '');\n if (!rawUrl) {\n return release;\n }\n const cacheKey = `crate-datasource/registry-config/${rawUrl}`;\n const config = memCache.get<{ dl: string; api?: string }>(cacheKey);\n if (!config?.api) {\n return release;\n }\n\n const apiBaseUrl = joinUrlParts(config.api, 'api/v1/');\n const url = `${apiBaseUrl}crates/${packageName}/${release.versionOrig ?? release.version}`;\n logger.trace(\n { url, packageName, version: release.version, registryUrl },\n 'fetching crate release timestamp',\n );\n // Getting release timestamp could become unnecessary if the manual backfill of `pubtime` mentioned in\n // https://github.com/rust-lang/cargo/issues/15491 is done for all packages.\n const { body: releaseTimestamp } = await this.http.getJson(\n url,\n { cacheProvider: memCacheProvider },\n ReleaseTimestamp,\n );\n release.releaseTimestamp = releaseTimestamp;\n return release;\n }\n\n override postprocessRelease(\n config: PostprocessReleaseConfig,\n release: Release,\n ): Promise<PostprocessReleaseResult> {\n return withCache(\n {\n namespace: `datasource-crate`,\n key: `postprocessRelease:${config.registryUrl}:${config.packageName}:${release.version}`,\n ttlMinutes: 7 * 24 * 60,\n cacheable: CrateDatasource.isCratesIo(config.registryUrl ?? undefined),\n },\n () => this._postprocessRelease(config, release),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,IAAa,kBAAb,MAAa,wBAAwB,WAAW;CAC9C,OAAgB,KAAK;CAErB,cAAc;EACZ,MAAM,gBAAgB,EAAE;CAC1B;CAEA,sBAA+B,CAAC,iCAAiC;CAEjE,oBAA6BA;CAE7B,mBAAqC;CACrC,gBACE;CAEF,0BAA4C;CAC5C,uBACE;CAEF,MAAc,aAAa,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AAS,YAAY,GAAG,QAAQ,eAAe,QAAQ;EACjF,OAAO,MACL;GAAE;GAAK;GAAa,SAAS,QAAQ;GAAS;EAAY,GAC1D,kCACF;EAGA,MAAM,EAAE,MAAM,qBAAqB,MAAM,KAAK,KAAK,QACjD,KACA,EAAE,eAAe,iBAAiB,GAClC,gBACF;EACA,QAAQ,mBAAmB;EAC3B,OAAO;CACT;CAEA,mBACE,QACA,SACmC;EACnC,OAAO,UACL;GACE,WAAW;GACX,KAAK,sBAAsB,OAAO,YAAY,GAAG,OAAO,YAAY,GAAG,QAAQ;GAC/E,YAAY;GACZ,WAAW,gBAAgB,WAAW,OAAO,eAAe,KAAA,CAAS;EACvE,SACM,KAAK,oBAAoB,QAAQ,OAAO,CAChD;CACF;AACF"}
@@ -1,12 +1,12 @@
1
1
  import { MaybeTimestamp } from "../../../util/timestamp.js";
2
2
  import { z } from "zod/v4";
3
3
  //#region lib/modules/datasource/crate/schema.ts
4
- const RegistryConfigSchema = z.object({
4
+ const RegistryConfig = z.object({
5
5
  dl: z.string(),
6
6
  api: z.string().optional()
7
7
  });
8
8
  const ReleaseTimestamp = z.object({ version: z.object({ created_at: MaybeTimestamp }) }).transform(({ version: { created_at } }) => created_at).nullable().catch(null);
9
9
  //#endregion
10
- export { RegistryConfigSchema, ReleaseTimestamp };
10
+ export { RegistryConfig, ReleaseTimestamp };
11
11
 
12
12
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../../../lib/modules/datasource/crate/schema.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { MaybeTimestamp } from '../../../util/timestamp.ts';\n\nexport const RegistryConfigSchema = z.object({\n dl: z.string(),\n api: z.string().optional(),\n});\nexport type RegistryConfigSchema = z.infer<typeof RegistryConfigSchema>;\n\nexport const ReleaseTimestamp = z\n .object({\n version: z.object({\n created_at: MaybeTimestamp,\n }),\n })\n .transform(({ version: { created_at } }) => created_at)\n .nullable()\n .catch(null);\n"],"mappings":";;;AAGA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,IAAI,EAAE,OAAO;CACb,KAAK,EAAE,OAAO,EAAE,SAAS;AAC3B,CAAC;AAGD,MAAa,mBAAmB,EAC7B,OAAO,EACN,SAAS,EAAE,OAAO,EAChB,YAAY,eACd,CAAC,EACH,CAAC,EACA,WAAW,EAAE,SAAS,EAAE,mBAAmB,UAAU,EACrD,SAAS,EACT,MAAM,IAAI"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../../lib/modules/datasource/crate/schema.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { MaybeTimestamp } from '../../../util/timestamp.ts';\n\nexport const RegistryConfig = z.object({\n dl: z.string(),\n api: z.string().optional(),\n});\nexport type RegistryConfig = z.infer<typeof RegistryConfig>;\n\nexport const ReleaseTimestamp = z\n .object({\n version: z.object({\n created_at: MaybeTimestamp,\n }),\n })\n .transform(({ version: { created_at } }) => created_at)\n .nullable()\n .catch(null);\n"],"mappings":";;;AAGA,MAAa,iBAAiB,EAAE,OAAO;CACrC,IAAI,EAAE,OAAO;CACb,KAAK,EAAE,OAAO,EAAE,SAAS;AAC3B,CAAC;AAGD,MAAa,mBAAmB,EAC7B,OAAO,EACN,SAAS,EAAE,OAAO,EAChB,YAAY,eACd,CAAC,EACH,CAAC,EACA,WAAW,EAAE,SAAS,EAAE,mBAAmB,UAAU,EACrD,SAAS,EACT,MAAM,IAAI"}
@@ -3,7 +3,7 @@ import { joinUrlParts } from "../../../util/url.js";
3
3
  import "../../versioning/elm/index.js";
4
4
  import { withCache } from "../../../util/cache/package/with-cache.js";
5
5
  import { Datasource } from "../datasource.js";
6
- import { ElmPackageReleasesSchema } from "./schema.js";
6
+ import { ElmPackageReleases } from "./schema.js";
7
7
  import { ZodError } from "zod/v4";
8
8
  //#region lib/modules/datasource/elm-package/index.ts
9
9
  var ElmPackageDatasource = class ElmPackageDatasource extends Datasource {
@@ -22,7 +22,7 @@ var ElmPackageDatasource = class ElmPackageDatasource extends Datasource {
22
22
  /* v8 ignore if -- should never happen */
23
23
  if (!registryUrl) return null;
24
24
  const pkgUrl = joinUrlParts(registryUrl, "packages", packageName, "releases.json");
25
- const { val: result, err } = await this.http.getJsonSafe(pkgUrl, ElmPackageReleasesSchema).onError((err) => {
25
+ const { val: result, err } = await this.http.getJsonSafe(pkgUrl, ElmPackageReleases).onError((err) => {
26
26
  logger.debug({
27
27
  url: pkgUrl,
28
28
  datasource: ElmPackageDatasource.id,