Files
orca/config/scripts/node-resolution/ancestor-modules/store-ancestor-node-modules.mjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

41 lines
1.5 KiB
JavaScript

import { existsSync, realpathSync } from 'node:fs'
import { basename, dirname, join } from 'node:path'
import { isSharedPackageDir } from '../../native-build/node-addons/native-build-entry.cjs'
// Find ancestor node_modules above global-store links root: upward Node resolution can inject undeclared dependencies and hide isolation bugs.
export function nodeModulesAboveStore(slotPackageDir, exists = existsSync) {
let storeRoot = slotPackageDir
while (basename(storeRoot) !== 'links') {
const parent = dirname(storeRoot)
if (parent === storeRoot) {
return []
}
storeRoot = parent
}
const found = []
for (let dir = dirname(storeRoot); ; dir = dirname(dir)) {
if (exists(join(dir, 'node_modules'))) {
found.push(join(dir, 'node_modules'))
}
if (dirname(dir) === dir) {
return found
}
}
}
/** Warns, never fails: the install itself is fine, only undeclared-dependency checks are blinded. */
export function warnAboutNodeModulesAboveSharedStore(projectDir, probePackage = 'zod') {
const linked = join(projectDir, 'node_modules', probePackage)
if (!existsSync(linked) || !isSharedPackageDir(linked, projectDir)) {
return []
}
const found = nodeModulesAboveStore(realpathSync(linked))
for (const dir of found) {
console.warn(
`[gvs] ${dir} sits above the shared pnpm store, so packages there resolve dependencies ` +
'they never declared and undeclared-dependency bugs stay hidden. Move or remove it.'
)
}
return found
}