Thanks to visit codestin.com
Credit goes to gro.fuz.dev

library_load.ts

Declarations
#

9 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<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_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<LibraryLoadResult | null>

the cached result, or null on any miss

LIBRARY_CACHE_VERSION
#

library_load.ts view source

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.

library_cache_write
#

library_load.ts view source

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

absolute path to the cache file

type string

key

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

type string

result

the {library_json, package_json} to cache

log?

type Logger | undefined
optional

returns

Promise<void>

library_load_from_repo
#

library_load.ts view source

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

absolute path to the repo to analyze

type string

options?

type LibraryLoadOptions | undefined
optional

returns

Promise<LibraryLoadResult>

the repo's LibraryLoadResult (library_json + full package_json)

LibraryCache
#

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

LibraryLoadResult
#

library_load.ts view source

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_json

type LibraryJson

package_json

type PackageJson

Depends on
#

Imported by
#