"library.json" Cache filename inside a repo's .gro directory for library_load_from_repo.
7 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<LibraryJson | null> Reads and validates the .gro/library.json cache at cache_path.
Returns the cached library_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<LibraryJson | null> the cached library_json, or null on any miss
(cache_path: string, key: string, library_json: LibraryJson, log?: Logger | undefined): Promise<void> Writes library_json to the .gro/library.json cache at cache_path, keyed
by key, 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)
stringlibrary_jsonLibraryJsonlog?Logger | undefinedPromise<void> (repo_dir: string, options?: LibraryLoadOptions | undefined): Promise<LibraryJson> 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. 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<LibraryJson> the repo's LibraryJson
LibraryCache On-disk shape of the .gro/library.json cache file.
The hash is the git-based cache key the library_json was computed at.
hashtype string
library_jsontype LibraryJson
LibraryLoadOptions logtype Logger
cacheSet to false to bypass the .gro cache (always re-analyze, but still write the result).
type boolean