2020-05-03 14:15:22 +00:00
|
|
|
import is from '@sindresorhus/is';
|
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';
|
2019-12-12 03:38:40 +00:00
|
|
|
import { PackageFile } from '../../../manager/common';
|
2020-05-03 15:03:23 +00:00
|
|
|
import { getMatchingFiles } from './file-match';
|
2020-05-01 16:03:48 +00:00
|
|
|
import { getManagerPackageFiles } from './manager-files';
|
2018-05-09 06:03:59 +00:00
|
|
|
|
2019-12-12 03:38:40 +00:00
|
|
|
export async function extractAllDependencies(
|
|
|
|
config: RenovateConfig
|
|
|
|
): Promise<Record<string, PackageFile[]>> {
|
2020-05-03 14:15:22 +00:00
|
|
|
let managerList = getManagerList();
|
|
|
|
if (is.nonEmptyArray(config.enabledManagers)) {
|
|
|
|
logger.debug('Applying enabledManagers filtering');
|
|
|
|
managerList = managerList.filter((manager) =>
|
|
|
|
config.enabledManagers.includes(manager)
|
|
|
|
);
|
|
|
|
}
|
2020-05-03 15:03:23 +00:00
|
|
|
const extractList: RenovateConfig[] = [];
|
2020-05-03 14:15:22 +00:00
|
|
|
for (const manager of managerList) {
|
2018-05-09 06:03:59 +00:00
|
|
|
const managerConfig = getManagerConfig(config, manager);
|
2020-05-03 15:03:23 +00:00
|
|
|
managerConfig.manager = manager;
|
2020-03-06 08:07:55 +00:00
|
|
|
if (manager === 'regex') {
|
|
|
|
for (const regexManager of config.regexManagers) {
|
|
|
|
const regexManagerConfig = mergeChildConfig(
|
|
|
|
managerConfig,
|
|
|
|
regexManager
|
|
|
|
);
|
2020-05-03 15:03:23 +00:00
|
|
|
regexManagerConfig.fileList = await getMatchingFiles(
|
2020-03-06 08:07:55 +00:00
|
|
|
regexManagerConfig
|
|
|
|
);
|
2020-05-03 15:03:23 +00:00
|
|
|
if (regexManagerConfig.fileList.length) {
|
|
|
|
extractList.push(regexManagerConfig);
|
2020-03-06 08:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2020-05-03 15:03:23 +00:00
|
|
|
managerConfig.fileList = await getMatchingFiles(managerConfig);
|
|
|
|
if (managerConfig.fileList.length) {
|
|
|
|
extractList.push(managerConfig);
|
|
|
|
}
|
2020-03-06 08:07:55 +00:00
|
|
|
}
|
2020-05-03 15:03:23 +00:00
|
|
|
}
|
2020-05-03 15:27:35 +00:00
|
|
|
const extractResults = [];
|
2020-05-03 15:03:23 +00:00
|
|
|
for (const managerConfig of extractList) {
|
|
|
|
const { manager } = managerConfig;
|
|
|
|
const packageFiles = await getManagerPackageFiles(managerConfig);
|
2020-05-03 15:27:35 +00:00
|
|
|
extractResults.push({ manager, packageFiles });
|
|
|
|
}
|
|
|
|
const extractions: Record<string, PackageFile[]> = {};
|
|
|
|
let fileCount = 0;
|
|
|
|
for (const { manager, packageFiles } of extractResults) {
|
2018-12-12 10:26:43 +00:00
|
|
|
if (packageFiles && packageFiles.length) {
|
2018-05-09 06:03:59 +00:00
|
|
|
fileCount += packageFiles.length;
|
2020-02-24 07:43:01 +00:00
|
|
|
logger.debug(`Found ${manager} package files`);
|
2020-05-03 15:03:23 +00:00
|
|
|
extractions[manager] = (extractions[manager] || []).concat(packageFiles);
|
2018-05-09 06:03:59 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-31 11:03:36 +00:00
|
|
|
logger.debug(`Found ${fileCount} package file(s)`);
|
2018-05-09 06:03:59 +00:00
|
|
|
return extractions;
|
|
|
|
}
|