mesh-build-node: place every mesh package a module names at its latest release (H-A-267)

A trunk build put only the SDK into a module's node_modules; any other
@novox/mesh-* package its package.json names was left out of the install
and only a group or a member's build brought it, so the forge module's
build failed with "Cannot find module" for its contracts package. Each
such package is now placed at the latest release the registry holds, as
the SDK is; a group's packed package or a member's build still takes
precedence.

Builds: design 47 H H-A-267
This commit is contained in:
2026-11-21 15:35:26 +01:00
parent efc8c52e68
commit 83802dc4a6
4 changed files with 121 additions and 60 deletions
@@ -97,9 +97,17 @@ func TestAModuleNamingOnlyTheSdkAndTypesInstallsNothing(t *testing.T) {
}
// 47/G A-72: a module naming another @novox/mesh-* package beside the SDK has no package beyond the SDK, so it installs
// nothing and is not refused for want of a lock.
// nothing and is not refused for want of a lock. 47/H H-A-267 (ADR 0573 §2): a fetch with no group and no members' builds
// places that package at the latest release the registry holds, as it places the SDK, whatever the module's lock names.
func TestAMeshPackageIsNotBeyondTheSdk(t *testing.T) {
m, f := fetchMachine(t, typeScriptModule(`{"dependencies":{"@novox/mesh-sdk":"^0.1.6","@novox/mesh-tools":"^0.1.6"}}`), nil)
const contracts = "@novox/mesh-delivery-contracts-git"
files := typeScriptModule(`{"dependencies":{"@novox/mesh-sdk":"^0.1.6","` + contracts + `":"^0.1.2"}}`)
files["modules/m/package-lock.json"] = `{"lockfileVersion":3,"packages":{"node_modules/` + contracts + `":{"version":"0.1.2","integrity":"sha512-old"}}}`
m, f := fetchMachine(t, files, nil)
fakeRegistryOf(t, m, map[string]map[string][]byte{
sdkPackage: {"0.1.15": tgzOf(t, sdkPackage, "0.1.15")},
contracts: {"0.1.2": tgzOf(t, contracts, "0.1.2"), "0.1.4": tgzOf(t, contracts, "0.1.4"), "0.1.5-feat.1": tgzOf(t, contracts, "0.1.5-feat.1")},
})
out, err := m.fetch(context.Background(), fetchArgs)
if err != nil {
t.Fatal(err)
@@ -108,6 +116,14 @@ func TestAMeshPackageIsNotBeyondTheSdk(t *testing.T) {
if len(npmCalls(f)) != 0 || len(r.Installed) != 0 || len(r.Refused) != 0 {
t.Errorf("result = %+v, npm calls %d, want nothing installed and nothing refused", r, len(npmCalls(f)))
}
dir := filepath.Join(m.Work, r.Workspace, "tree", "modules", "m")
got, err := readPackageJSON(filepath.Join(dir, "node_modules", filepath.FromSlash(contracts)))
if err != nil || got.Version != "0.1.4" {
t.Errorf("%s placed %q (%v), want the latest release 0.1.4", contracts, got.Version, err)
}
if v := placedSDK(dir); v != "0.1.15" || r.SDK["modules/m"] != "0.1.15" {
t.Errorf("the SDK placed %q, answered %q, want the latest release 0.1.15", v, r.SDK["modules/m"])
}
}
// 1489/AC2: a module naming lodash with a lock gets npm ci --omit=dev --ignore-scripts (fake runner), its install put