diff --git a/lib/workers/repository/process/extract-update.ts b/lib/workers/repository/process/extract-update.ts index 1e11ffcd760c6654e83635e049f3306e3b4c2a26..cd65c1cc1d95aebe09d487674c804927e8d36131 100644 --- a/lib/workers/repository/process/extract-update.ts +++ b/lib/workers/repository/process/extract-update.ts @@ -1,3 +1,4 @@ +import { hrtime } from 'process'; import { logger } from '../../../logger'; import { writeUpdates, WriteUpdateResult } from './write'; import { sortBranches } from './sort'; @@ -15,9 +16,42 @@ export type ExtractResult = { packageFiles: Record<string, PackageFile[]>; }; +// istanbul ignore next +function extractStats(packageFiles: Record<string, PackageFile[]>): any { + if (!packageFiles) { + return {}; + } + const stats = { + managers: {}, + total: { + fileCount: 0, + depCount: 0, + }, + }; + for (const [manager, managerPackageFiles] of Object.entries(packageFiles)) { + const fileCount = managerPackageFiles.length; + let depCount = 0; + for (const file of managerPackageFiles) { + depCount += file.deps.length; + } + stats.managers[manager] = { + fileCount, + depCount, + }; + stats.total.fileCount += fileCount; + stats.total.depCount += depCount; + } + return stats; +} + export async function extract(config: RenovateConfig): Promise<ExtractResult> { logger.debug('extractAndUpdate()'); + const startTime = hrtime(); const packageFiles = await extractAllDependencies(config); + const duration = hrtime(startTime); + const seconds = Math.round(duration[0] + duration[1] / 1e9); + const stats = extractStats(packageFiles); + logger.info({ stats, seconds }, `Dependency extraction complete`); logger.trace({ config: packageFiles }, 'packageFiles'); await fetchUpdates(config, packageFiles); logger.debug({ config: packageFiles }, 'packageFiles with updates'); diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts index 9fd2ad93eb98404a60c6afd360d432e2f3195103..914d33ff7f3fc543632594a1a5e1a8b0062a6e83 100644 --- a/lib/workers/repository/process/fetch.ts +++ b/lib/workers/repository/process/fetch.ts @@ -115,25 +115,6 @@ export async function fetchUpdates( packageFiles: Record<string, PackageFile[]> ): Promise<void> { const managers = Object.keys(packageFiles); - const stats = { - managers: {}, - fileCount: 0, - depCount: 0, - }; - for (const [manager, managerPackageFiles] of Object.entries(packageFiles)) { - const fileCount = managerPackageFiles.length; - let depCount = 0; - for (const file of managerPackageFiles) { - depCount += file.deps.length; - } - stats.managers[manager] = { - fileCount, - depCount, - }; - stats.fileCount += fileCount; - stats.depCount += depCount; - } - logger.info({ stats }, `Extraction statistics`); const startTime = hrtime(); const allManagerJobs = managers.map((manager) => fetchManagerUpdates(config, packageFiles, manager)