From fa00f3ffa21c172ea467fcd0e8f9342077b4e3c0 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 13 Sep 2026 17:43:55 +0200 Subject: [PATCH] Fix cultnet-ts test build for out-of-package contract location REC-032 commit 1 follow-up, found during required verification: moving the CultNet schemas out of packages/cultnet-ts/contracts into CultLib/contracts/cultnet broke npm test for cultnet-ts. tsconfig.test.json compiled with rootDir "." (to cover both src/ and test/ as siblings), and TypeScript's resolveJsonModule copy-into-output behavior only mirrors files that fall within the declared rootDir. The old contracts/ folder was a sibling of src/ (inside rootDir), so it got copied into dist-test/contracts and the "../contracts/x" import resolved. The new contracts/cultnet is two directories above the package, outside any possible rootDir short of the repo root, so nothing got copied and the "../../../contracts/cultnet/x" import 404'd at runtime under dist-test (the production "dist" build was unaffected, since dist/ and src/ sit at the same depth under the package). Fix: widen tsconfig.test.json's rootDir to the CultLib repo root so resolveJsonModule can find and copy contracts/cultnet into dist-test, update the "test"/"test:interop" npm scripts for the resulting deeper dist-test/packages/cultnet-ts/... output path, and correct the two __dirname-relative computations in test/interop/cultnet-interop.test.ts and test/runtime-presence-health.test.ts that assumed the old shallower depth. Also fixes packages/cultmesh-ts/test/cultmesh.test.ts, which still looked up the shard-catalog builtins by their old bare cultnet.shard_catalog_{request,response}.v0 schemaId; CultNetSchemaCatalog keys by $id, which D1 changed to the CultLib contracts URL, so the lookup returned undefined. REC-032, decision D1. Co-Authored-By: Claude Sonnet 5 --- packages/cultmesh-ts/test/cultmesh.test.ts | 8 ++++++-- packages/cultnet-ts/package.json | 4 ++-- packages/cultnet-ts/test/interop/cultnet-interop.test.ts | 2 +- packages/cultnet-ts/test/runtime-presence-health.test.ts | 2 +- packages/cultnet-ts/tsconfig.test.json | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cultmesh-ts/test/cultmesh.test.ts b/packages/cultmesh-ts/test/cultmesh.test.ts index 77bd635c..3954c697 100644 --- a/packages/cultmesh-ts/test/cultmesh.test.ts +++ b/packages/cultmesh-ts/test/cultmesh.test.ts @@ -2500,11 +2500,15 @@ test("CultMesh TS branded facade exposes schema and shard catalogs", () => { const builtIns = CultMesh.createBuiltInSchemaCatalog(); assert.equal( - builtIns.get("cultnet.shard_catalog_request.v0")?.schemaVersion, + builtIns.get( + "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.shard-catalog-request.schema.json", + )?.schemaVersion, "cultnet.shard_catalog_request.v0", ); assert.equal( - builtIns.get("cultnet.shard_catalog_response.v0")?.kind, + builtIns.get( + "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.shard-catalog-response.schema.json", + )?.kind, "wire_message", ); assert.equal( diff --git a/packages/cultnet-ts/package.json b/packages/cultnet-ts/package.json index 82baeba0..0b101282 100644 --- a/packages/cultnet-ts/package.json +++ b/packages/cultnet-ts/package.json @@ -23,8 +23,8 @@ "contracts:generate": "node tools/generate-swarm-contracts.mjs", "build": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json", "typecheck": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json --pretty false", - "test": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test dist-test/test/*.test.js", - "test:interop": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test --test-force-exit dist-test/test/interop/*.test.js" + "test": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test dist-test/packages/cultnet-ts/test/*.test.js", + "test:interop": "node tools/generate-swarm-contracts.mjs && node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test --test-force-exit dist-test/packages/cultnet-ts/test/interop/*.test.js" }, "keywords": [ "messagepack", diff --git a/packages/cultnet-ts/test/interop/cultnet-interop.test.ts b/packages/cultnet-ts/test/interop/cultnet-interop.test.ts index 51bea1ff..07fb268b 100644 --- a/packages/cultnet-ts/test/interop/cultnet-interop.test.ts +++ b/packages/cultnet-ts/test/interop/cultnet-interop.test.ts @@ -21,7 +21,7 @@ const execFileAsync = promisify(execFile); const cargoCommand = process.env.CARGO ?? (process.platform === "win32" ? join(homedir(), ".cargo", "bin", "cargo.exe") : "cargo"); const dotnetCommand = process.env.DOTNET ?? (process.platform === "win32" ? join("C:", "Program Files", "dotnet", "dotnet.exe") : "dotnet"); const pythonCommand = process.env.PYTHON ?? resolvePythonCommand(); -const cultNetTsRoot = resolve(__dirname, "../../.."); +const cultNetTsRoot = resolve(__dirname, "../../../../.."); const cultLibRoot = findAncestor(cultNetTsRoot, "CultLib.sln") ?? resolve(cultNetTsRoot, "..", "CultLib"); const cultcachePyRoot = resolve(cultLibRoot, "packages", "cultcache-py"); const cultcachePySrc = ["cultcache-py", "cultnet-py", "cultmesh-py"] diff --git a/packages/cultnet-ts/test/runtime-presence-health.test.ts b/packages/cultnet-ts/test/runtime-presence-health.test.ts index fa21aeaa..2ceedde3 100644 --- a/packages/cultnet-ts/test/runtime-presence-health.test.ts +++ b/packages/cultnet-ts/test/runtime-presence-health.test.ts @@ -26,7 +26,7 @@ import { // are generated output and must have exactly one home. const VECTORS = JSON.parse( readFileSync( - join(__dirname, "..", "..", "test", "fixtures", "runtime-presence-vectors.json"), + join(__dirname, "..", "..", "..", "..", "test", "fixtures", "runtime-presence-vectors.json"), "utf8", ), ) as { proof: string; signed: string }; diff --git a/packages/cultnet-ts/tsconfig.test.json b/packages/cultnet-ts/tsconfig.test.json index a73b52c0..fc47617c 100644 --- a/packages/cultnet-ts/tsconfig.test.json +++ b/packages/cultnet-ts/tsconfig.test.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "rootDir": ".", + "rootDir": "../..", "outDir": "dist-test", "declaration": false, "declarationMap": false