(
source: ImpactSource,
root: string,
options: ImpactReadOptions,
)
| 142 | |
| 143 | /** The whole assessment, from the four readings. */ |
| 144 | export async function readImpact( |
| 145 | source: ImpactSource, |
| 146 | root: string, |
| 147 | options: ImpactReadOptions, |
| 148 | ): Promise<ImpactReading> { |
| 149 | const opts: ProviderQueryOptions = { |
| 150 | ...(options.projectName === undefined ? {} : { projectName: options.projectName }), |
| 151 | ...(options.generation === undefined ? {} : { generation: options.generation }), |
| 152 | }; |
| 153 | const cap = options.testCap ?? IMPACT_TEST_LOOKUP_CAP; |
| 154 | |
| 155 | const change = await source.changeImpact(root, options.sinceRef, opts); |
| 156 | const overview = await source.architectureOverview(root, opts); |
| 157 | |
| 158 | const scan = await scanRoutes(overview.files, options.readSource); |
| 159 | const architecture: ArchitectureOverviewDto = { |
| 160 | ...overview, |
| 161 | routes: mergeRoutes(scan.routes, overview.routes), |
| 162 | }; |
| 163 | |
| 164 | const qualifiedNames = [ |
| 165 | ...new Set( |
| 166 | change.symbols |
| 167 | .filter((symbol) => symbol.changeKind !== 'module') |
| 168 | .map((symbol) => symbol.qualifiedName) |
| 169 | .filter((name): name is string => name !== undefined), |
| 170 | ), |
| 171 | ]; |
| 172 | const complexity = qualifiedNames.length === 0 |
| 173 | ? [] |
| 174 | : await source.getComplexity(root, qualifiedNames, opts).catch(() => []); |
| 175 | |
| 176 | const tests = await testLookup(source, root, change.symbols, cap, opts); |
| 177 | |
| 178 | return { |
| 179 | model: mapChangeImpact(change, architecture, buildComplexityLookup(complexity, architecture), tests), |
| 180 | routeNote: scan.scanned === 0 && scan.cappedAt === undefined |
| 181 | ? '' |
| 182 | : impactRouteScanNote(scan.scanned, scan.cappedAt, scan.truncatedFiles), |
| 183 | change, |
| 184 | }; |
| 185 | } |
no test coverage detected