feat: game/engine split refactor + skybox
This commit is contained in:
parent
581e5892b0
commit
eeedcb8e48
34 changed files with 610 additions and 218 deletions
32
tests/layering.test.ts
Normal file
32
tests/layering.test.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
|
||||
// The engine is the reusable, content-agnostic layer: it must import nothing from
|
||||
// game (content) or app (browser glue). game -> engine and app -> game -> engine are
|
||||
// fine; the reverse is the violation. This freezes the Stage-3 seam so a stray import
|
||||
// can't quietly re-couple the layers.
|
||||
function tsFiles(dir: string): string[] {
|
||||
const out: string[] = []
|
||||
for (const name of readdirSync(dir)) {
|
||||
const p = join(dir, name)
|
||||
if (statSync(p).isDirectory()) {
|
||||
out.push(...tsFiles(p))
|
||||
} else if (p.endsWith(".ts")) {
|
||||
out.push(p)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test("engine imports nothing from game or app", () => {
|
||||
const engineDir = new URL("../engine", import.meta.url).pathname
|
||||
const offenders = tsFiles(engineDir).filter((f) => /from\s+["'][^"']*\/(?:game|app)\//.test(readFileSync(f, "utf8")))
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
|
||||
test("game imports nothing from app", () => {
|
||||
const gameDir = new URL("../game", import.meta.url).pathname
|
||||
const offenders = tsFiles(gameDir).filter((f) => /from\s+["'][^"']*\/app\//.test(readFileSync(f, "utf8")))
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue