build: order Host and Client compilation faces

This commit is contained in:
imccyu
2026-08-08 03:29:12 +08:00
parent 8158a0e63a
commit 9c3d5725a5
32 changed files with 440 additions and 184 deletions

View File

@@ -118,11 +118,8 @@ function checkBuild(
violations: PackageInvariantViolation[],
): void {
const tsconfigPath = `${owner.dir}/tsconfig.json`
const tsconfig = JSON.parse(readFileSync(resolve(root, tsconfigPath), 'utf8')) as {
references?: Array<{ path?: string }>
}
if (owner.packageName !== '@deepseek-ai/dsh-invariants'
&& !tsconfig.references?.some(reference => reference.path === '../../support/invariants')) {
&& !projectReferencesInvariants(root, owner.dir, tsconfigPath)) {
addViolation(
violations,
tsconfigPath,
@@ -138,6 +135,31 @@ function checkBuild(
}
}
function projectReferencesInvariants(root: string, ownerDir: string, entryPath: string): boolean {
const ownerRoot = resolve(root, ownerDir)
const target = resolve(root, 'packages/support/invariants')
const pending = [resolve(root, entryPath)]
const visited = new Set<string>()
while (pending.length > 0) {
const configPath = pending.pop()
if (configPath === undefined) break
if (visited.has(configPath)) continue
visited.add(configPath)
const config = JSON.parse(readFileSync(configPath, 'utf8')) as {
references?: Array<{ path?: string }>
}
for (const reference of config.references ?? []) {
if (reference.path === undefined) continue
const referenced = resolve(dirname(configPath), reference.path)
if (referenced === target) return true
if (!referenced.startsWith(`${ownerRoot}${sep}`)) continue
const childConfig = referenced.endsWith('.json') ? referenced : resolve(referenced, 'tsconfig.json')
if (existsSync(childConfig)) pending.push(childConfig)
}
}
return false
}
function checkSource(
owner: PackageInvariantOwner,
root: string,