* The circular imports inside the chosen root (see findFileCycles). * * A component longer than MAX_CYCLE_LENGTH is reported truncated rather * than printed — a 200-file knot is a fact about the repository, not a list * anybody reads.
(
pairs: ReadonlyArray<{ source: string; target: string }>,
moduleOfFile: Map<string, string>
)
| 811 | * anybody reads. |
| 812 | */ |
| 813 | function fileCycles( |
| 814 | pairs: ReadonlyArray<{ source: string; target: string }>, |
| 815 | moduleOfFile: Map<string, string> |
| 816 | ): WireMapPayload['cycles'] { |
| 817 | const cycles = findFileCycles( |
| 818 | pairs.filter((pair) => moduleOfFile.has(pair.source) && moduleOfFile.has(pair.target)) |
| 819 | ); |
| 820 | |
| 821 | const items = cycles.slice(0, MAX_FILE_CYCLES).map((files) => ({ |
| 822 | size: files.length, |
| 823 | files: files.slice(0, MAX_CYCLE_LENGTH), |
| 824 | modules: [...new Set(files.map((file) => moduleOfFile.get(file) ?? file))].sort(), |
| 825 | })); |
| 826 | return { |
| 827 | total: cycles.length, |
| 828 | shown: items.length, |
| 829 | truncated: cycles.length > items.length, |
| 830 | items, |
| 831 | }; |
| 832 | } |
| 833 | |
| 834 | /** |
| 835 | * The roots the selector offers: the repository root plus every top-level |
no test coverage detected