renovate/lib/workers/repository/extract/index.ts

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-03-06 08:07:55 +00:00
import {
2020-05-01 16:03:48 +00:00
RenovateConfig,
2020-03-06 08:07:55 +00:00
getManagerConfig,
mergeChildConfig,
} from '../../../config';
2020-05-01 16:03:48 +00:00
import { logger } from '../../../logger';
import { getManagerList } from '../../../manager';
import { PackageFile } from '../../../manager/common';
2020-05-01 16:03:48 +00:00
import { getManagerPackageFiles } from './manager-files';
export async function extractAllDependencies(
config: RenovateConfig
): Promise<Record<string, PackageFile[]>> {
const extractions: Record<string, PackageFile[]> = {};
let fileCount = 0;
for (const manager of getManagerList()) {
if (
config.enabledManagers.length &&
!config.enabledManagers.includes(manager)
) {
logger.debug(`${manager} is not in enabledManagers list - skipping`);
continue; // eslint-disable-line
}
const managerConfig = getManagerConfig(config, manager);
2020-03-06 08:07:55 +00:00
let packageFiles = [];
if (manager === 'regex') {
for (const regexManager of config.regexManagers) {
const regexManagerConfig = mergeChildConfig(
managerConfig,
regexManager
);
const customPackageFiles = await getManagerPackageFiles(
regexManagerConfig
);
if (customPackageFiles) {
packageFiles = packageFiles.concat(customPackageFiles);
}
}
} else {
packageFiles = await getManagerPackageFiles(managerConfig);
}
managerConfig.manager = manager;
2018-12-12 10:26:43 +00:00
if (packageFiles && packageFiles.length) {
fileCount += packageFiles.length;
logger.debug(`Found ${manager} package files`);
extractions[manager] = packageFiles;
}
}
2018-05-31 11:03:36 +00:00
logger.debug(`Found ${fileCount} package file(s)`);
return extractions;
}