2022-12-16 21:20:35 +05:30
|
|
|
import { getManagerConfig, mergeChildConfig } from '../../../config';
|
2023-09-13 11:16:48 +05:45
|
|
|
import type { RenovateConfig } from '../../../config/types';
|
2023-11-08 18:58:26 +05:45
|
|
|
import { getEnabledManagersList } from '../../../modules/manager';
|
2023-08-15 22:57:54 +05:45
|
|
|
import { isCustomManager } from '../../../modules/manager/custom';
|
2023-09-13 11:16:48 +05:45
|
|
|
import type { RegexManagerTemplates } from '../../../modules/manager/custom/regex/types';
|
|
|
|
import type { CustomExtractConfig } from '../../../modules/manager/custom/types';
|
2024-12-13 01:42:59 +05:30
|
|
|
import { validMatchFields } from '../../../modules/manager/custom/utils';
|
2022-12-16 21:20:35 +05:30
|
|
|
import type { WorkerExtractConfig } from '../../types';
|
|
|
|
|
|
|
|
export interface FingerprintExtractConfig {
|
|
|
|
managerList: Set<string>;
|
|
|
|
managers: WorkerExtractConfig[];
|
|
|
|
}
|
|
|
|
|
2023-09-24 14:40:56 +05:45
|
|
|
// checks for regex manager fields
|
|
|
|
function getCustomManagerFields(
|
2023-11-07 12:50:29 -03:00
|
|
|
config: WorkerExtractConfig,
|
2022-12-16 21:20:35 +05:30
|
|
|
): CustomExtractConfig {
|
|
|
|
const regexFields = {} as CustomExtractConfig;
|
|
|
|
for (const field of validMatchFields.map(
|
2023-11-07 12:50:29 -03:00
|
|
|
(f) => `${f}Template` as keyof RegexManagerTemplates,
|
2022-12-16 21:20:35 +05:30
|
|
|
)) {
|
|
|
|
if (config[field]) {
|
|
|
|
regexFields[field] = config[field];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
autoReplaceStringTemplate: config.autoReplaceStringTemplate,
|
|
|
|
matchStrings: config.matchStrings,
|
|
|
|
matchStringsStrategy: config.matchStringsStrategy,
|
|
|
|
...regexFields,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilteredManagerConfig(
|
2023-11-07 12:50:29 -03:00
|
|
|
config: WorkerExtractConfig,
|
2022-12-16 21:20:35 +05:30
|
|
|
): WorkerExtractConfig {
|
|
|
|
return {
|
2023-09-24 14:40:56 +05:45
|
|
|
...(isCustomManager(config.manager) && getCustomManagerFields(config)),
|
2022-12-16 21:20:35 +05:30
|
|
|
manager: config.manager,
|
2025-05-04 14:00:24 +05:30
|
|
|
managerFilePatterns: config.managerFilePatterns,
|
2022-12-16 21:20:35 +05:30
|
|
|
npmrc: config.npmrc,
|
|
|
|
npmrcMerge: config.npmrcMerge,
|
|
|
|
enabled: config.enabled,
|
|
|
|
ignorePaths: config.ignorePaths ?? [],
|
|
|
|
includePaths: config.includePaths ?? [],
|
|
|
|
skipInstalls: config.skipInstalls,
|
|
|
|
registryAliases: config.registryAliases,
|
|
|
|
fileList: [],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function generateFingerprintConfig(
|
2023-11-07 12:50:29 -03:00
|
|
|
config: RenovateConfig,
|
2022-12-16 21:20:35 +05:30
|
|
|
): FingerprintExtractConfig {
|
|
|
|
const managerExtractConfigs: WorkerExtractConfig[] = [];
|
2023-11-08 18:58:26 +05:45
|
|
|
const managerList = new Set(getEnabledManagersList(config.enabledManagers));
|
2022-12-16 21:20:35 +05:30
|
|
|
|
|
|
|
for (const manager of managerList) {
|
|
|
|
const managerConfig = getManagerConfig(config, manager);
|
2023-08-15 22:57:54 +05:45
|
|
|
if (isCustomManager(manager)) {
|
2023-09-24 14:40:56 +05:45
|
|
|
const filteredCustomManagers = (config.customManagers ?? []).filter(
|
2023-11-07 12:50:29 -03:00
|
|
|
(mgr) => mgr.customType === manager,
|
2023-08-22 19:46:03 +05:45
|
|
|
);
|
|
|
|
for (const customManager of filteredCustomManagers) {
|
2022-12-16 21:20:35 +05:30
|
|
|
managerExtractConfigs.push({
|
2023-08-22 19:46:03 +05:45
|
|
|
...mergeChildConfig(managerConfig, customManager),
|
2022-12-16 21:20:35 +05:30
|
|
|
fileList: [],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
managerExtractConfigs.push({ ...managerConfig, fileList: [] });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
managerList,
|
|
|
|
managers: managerExtractConfigs.map(getFilteredManagerConfig),
|
|
|
|
};
|
|
|
|
}
|