MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / moduleConfigDigest

Function moduleConfigDigest

src/resolution/index.ts:362–378  ·  view source on GitHub ↗

* A digest of what resolution reads from one config file: a go.mod's module * path, a tsconfig / jsconfig's `extends`, `baseUrl` and `paths`, what a Cargo * manifest declares (see `cargoManifestFields`), the include directories a * compile database names. Not of its bytes: a dependency bump, a `s

(abs: string, projectRoot: string)

Source from the content-addressed store, hash-verified

360 * every one.
361 */
362function moduleConfigDigest(abs: string, projectRoot: string): string {
363 const file = path.basename(abs);
364 // A codegraph.json counts for its `webRoot` alone, which places a PHP
365 // include of `$_SERVER['DOCUMENT_ROOT'] . '/x.php'` (#3298). One that sets
366 // none reads as no file, so writing one to `exclude` a folder, or a snapshot
367 // from before it counted, re-opens nothing.
368 if (file === PROJECT_CONFIG_FILENAME) {
369 const webRoot = loadWebRoot(path.dirname(abs));
370 return webRoot === null ? 'absent' : createHash('sha256').update(`webRoot=${webRoot}`).digest('hex').slice(0, 16);
371 }
372 const read = file === 'go.mod' ? loadGoModule(path.dirname(abs))?.modulePath ?? ''
373 : file === 'Cargo.toml' ? cargoManifestDigestText(abs)
374 : file === 'compile_commands.json' ? (readCompileDbIncludeDirs(abs, projectRoot) ?? []).join('\n')
375 : file === 'package.json' ? packageJsonMainOf(abs)
376 : aliasConfigFields(abs) ?? '';
377 return createHash('sha256').update(read).digest('hex').slice(0, 16);
378}
379
380/**
381 * A package.json as an object, read past a byte order mark; null when it is

Callers 1

moduleConfigEntryFunction · 0.85

Calls 8

loadWebRootFunction · 0.90
loadGoModuleFunction · 0.90
readCompileDbIncludeDirsFunction · 0.90
aliasConfigFieldsFunction · 0.90
cargoManifestDigestTextFunction · 0.85
packageJsonMainOfFunction · 0.85
updateMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected