library_load.ts

Declarations
#

7 declarations

view source

LIBRARY_CACHE_FILENAME
#

library_cache_key
#

library_load.ts view source

(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_dir

type string

returns

Promise<string | null>

library_cache_read
#

library_load.ts view source

(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_path

absolute path to the cache file

type string

key

the expected cache key (a clean git commit hash)

type string

log?

type Logger | undefined
optional

returns

Promise<LibraryJson | null>

the cached library_json, or null on any miss

library_cache_write
#

library_load.ts view source

(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_path

absolute path to the cache file

type string

key

the cache key to store (a clean git commit hash)

type string

library_json

type LibraryJson

log?

type Logger | undefined
optional

returns

Promise<void>

library_load_from_repo
#

library_load.ts view source

(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_dir

absolute path to the repo to analyze

type string

options?

type LibraryLoadOptions | undefined
optional

returns

Promise<LibraryJson>

the repo's LibraryJson

LibraryCache
#

library_load.ts view source

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.

hash

type string

library_json

type LibraryJson

LibraryLoadOptions
#

library_load.ts view source

LibraryLoadOptions

log

type Logger

cache

Set to false to bypass the .gro cache (always re-analyze, but still write the result).

type boolean

Depends on
#

Imported by
#