mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(scripts): share package-source selection to clear the jscpd clone
The spec duplicated collectEventRelations' source-selection block; extract collectPackageSources and use it from both sides.
This commit is contained in:
@@ -9,7 +9,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { dirname, join } from 'node:path'
|
import { dirname, join } from 'node:path'
|
||||||
import { afterAll, describe, expect, it } from 'vitest'
|
import { afterAll, describe, expect, it } from 'vitest'
|
||||||
import { EventRelationCollector, type PackageSource } from './gen-doc-graphs.ts'
|
import { collectPackageSources, EventRelationCollector } from './gen-doc-graphs.ts'
|
||||||
import { TypeScriptProject } from './ts-project.ts'
|
import { TypeScriptProject } from './ts-project.ts'
|
||||||
|
|
||||||
const FIXTURE: Record<string, string> = {
|
const FIXTURE: Record<string, string> = {
|
||||||
@@ -69,11 +69,7 @@ for (const [rel, content] of Object.entries(FIXTURE)) {
|
|||||||
writeFileSync(join(root, rel), content)
|
writeFileSync(join(root, rel), content)
|
||||||
}
|
}
|
||||||
const project = new TypeScriptProject(root)
|
const project = new TypeScriptProject(root)
|
||||||
const sources = project.sourceFiles().flatMap((sourceFile): PackageSource[] => {
|
const sources = collectPackageSources(project)
|
||||||
const rel = project.relativePath(sourceFile)
|
|
||||||
const match = /^packages\/[^/]+\/([^/]+)\/src\/.+\.ts$/.exec(rel)
|
|
||||||
return match?.[1] ? [{ rel, pkg: match[1], sourceFile }] : []
|
|
||||||
}).sort((left, right) => left.rel.localeCompare(right.rel))
|
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
rmSync(root, { recursive: true, force: true })
|
rmSync(root, { recursive: true, force: true })
|
||||||
|
|||||||
@@ -1050,14 +1050,22 @@ function unionSets<T>(left: ReadonlySet<T>, right: ReadonlySet<T>): Set<T> {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectEventRelations(): Map<string, EventRelation> {
|
/**
|
||||||
const project = new TypeScriptProject(root)
|
* Select the package source files of one project in deterministic order.
|
||||||
const sources = project.sourceFiles().flatMap((sourceFile): PackageSource[] => {
|
* @param project - the loaded repository TypeScript project.
|
||||||
|
* @returns `packages/<group>/<pkg>/src` files tagged with their package name.
|
||||||
|
*/
|
||||||
|
export function collectPackageSources(project: TypeScriptProject): PackageSource[] {
|
||||||
|
return project.sourceFiles().flatMap((sourceFile): PackageSource[] => {
|
||||||
const rel = project.relativePath(sourceFile)
|
const rel = project.relativePath(sourceFile)
|
||||||
const match = /^packages\/[^/]+\/([^/]+)\/src\/.+\.ts$/.exec(rel)
|
const match = /^packages\/[^/]+\/([^/]+)\/src\/.+\.ts$/.exec(rel)
|
||||||
return match?.[1] ? [{ rel, pkg: match[1], sourceFile }] : []
|
return match?.[1] ? [{ rel, pkg: match[1], sourceFile }] : []
|
||||||
}).sort((left, right) => left.rel.localeCompare(right.rel))
|
}).sort((left, right) => left.rel.localeCompare(right.rel))
|
||||||
return new EventRelationCollector(project, sources).collect()
|
}
|
||||||
|
|
||||||
|
function collectEventRelations(): Map<string, EventRelation> {
|
||||||
|
const project = new TypeScriptProject(root)
|
||||||
|
return new EventRelationCollector(project, collectPackageSources(project)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
function relationPackages(map: Map<string, Set<string>>, pkgsByShort: Map<string, Pkg>): string {
|
function relationPackages(map: Map<string, Set<string>>, pkgsByShort: Map<string, Pkg>): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user