| 118 | function fairSourcePaths(paths: string[], project: ServiceProject, services: ContainerTopology['services']): string[] { |
| 119 | const available = new Map(paths.map(path => [normalizeSourcePath(project.rootPath, path), path])); |
| 120 | const priority = (path: string) => { |
| 121 | const name = path.split('/').at(-1) ?? ''; |
| 122 | if (/(?:impl|client|gateway|transport)\.[^.]+$/i.test(name)) return 0; |
| 123 | return /(?:service|controller|repository)/i.test(name) ? 1 : 2; |
| 124 | }; |
| 125 | const queues = [...services].sort((a, b) => a.id.localeCompare(b.id)).map(service => service.sourcePaths |
| 126 | .flatMap(path => available.has(path) ? [available.get(path)!] : []) |
| 127 | .sort((a, b) => priority(a) - priority(b) || a.localeCompare(b))).filter(queue => queue.length); |