"library.json" Cache filename inside a repo's .gro directory for library_load_from_repo.
9 declarations
"library.json" Cache filename inside a repo's .gro directory for library_load_from_repo.
(repo_dir: string): Promise<string | null> Computes the cache key for a repo at repo_dir: the git HEAD commit hash.
Returns null (uncacheable — analysis still runs, caching is skipped) when
the dir is not a git repo OR when the working tree is dirty. A dirty tree is
deliberately uncacheable: the commit hash doesn't capture uncommitted edits,
so a single -dirty key would serve a stale analysis across successive edits.
Skipping the cache while dirty guarantees fresh metadata; clean commits cache.
repo_dirstringPromise<string | null> (cache_path: string, key: string, log?: Logger | undefined): Promise<LibraryLoadResult | null> Reads and validates the .gro/library.json cache at cache_path.
Returns the cached {library_json, package_json} only when the file exists
and its stored hash matches key. Returns null on every miss - absent,
stale (different hash), or unreadable/corrupt - signalling the caller to
re-analyze.
cache_pathabsolute path to the cache file
stringkeythe expected cache key (a clean git commit hash)
stringlog?Logger | undefinedPromise<LibraryLoadResult | null> the cached result, or null on any miss
1 Format version for the .gro/library.json cache. The cache key is the git
commit hash, which does NOT change when the cached *shape* changes — so bump
this whenever LibraryCache's shape changes (e.g. the LibraryJson /
PkgJson split, then slimming LibraryJson to the raw pkg_json/source_json
pair) to self-invalidate stale caches across the ecosystem rather than serve
old-shaped data at an unchanged commit.
(cache_path: string, key: string, result: LibraryLoadResult, log?: Logger | undefined): Promise<void> Writes result to the .gro/library.json cache at cache_path, keyed by
key and stamped with the current LIBRARY_CACHE_VERSION, creating the
parent directory as needed.
Best effort: caching is optional, so write failures are logged as a warning and swallowed rather than thrown.
cache_pathabsolute path to the cache file
stringkeythe cache key to store (a clean git commit hash)
stringresultthe {library_json, package_json} to cache
log?Logger | undefinedPromise<void> (repo_dir: string, options?: LibraryLoadOptions | undefined): Promise<LibraryLoadResult> Loads a repo's library metadata via svelte-docinfo, with a .gro cache
keyed by git hash.
Analyzes repo_dir with analyzeFromFiles and combines the result with the
repo's package.json into a LibraryJson, returned alongside the full
package.json. Results are cached at <repo_dir>/.gro/library.json keyed by
the current git HEAD, so repeated loads at the same commit skip the
(potentially slow) analysis. A dirty working tree (or a non-git dir) is
uncacheable, so analysis re-runs on every load until the changes are
committed - see library_cache_key.
repo_dirabsolute path to the repo to analyze
stringoptions?LibraryLoadOptions | undefinedPromise<LibraryLoadResult> the repo's LibraryLoadResult (library_json + full package_json)
LibraryCache On-disk shape of the .gro/library.json cache file.
The hash is the git-based cache key the result was computed at; version
is the LIBRARY_CACHE_VERSION it was written under.
hashtype string
versiontype number
LibraryLoadOptions logtype Logger
cacheSet to false to bypass the .gro cache (always re-analyze, but still write the result).
type boolean
LibraryLoadResult Result of loading a repo's library metadata: the curated LibraryJson
(carrying the publish-safe pkg_json) plus the repo's full package.json.
The full package_json is kept alongside — not folded into LibraryJson —
because tooling like fuz_gitops needs dependencies/devDependencies, which
the curated LibraryJson.pkg_json deliberately omits.
library_jsontype LibraryJson
package_jsontype PackageJson