"library.json" import {LIBRARY_CACHE_FILENAME} from '@fuzdev/gro/library_load.js'; Cache filename inside a repo's .gro directory for library_load_from_repo.
10 declarations
"library.json" import {LIBRARY_CACHE_FILENAME} from '@fuzdev/gro/library_load.js'; Cache filename inside a repo's .gro directory for library_load_from_repo.
(repo_dir: string): Promise<string | null> import {library_cache_key} from '@fuzdev/gro/library_load.js'; 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> import {library_cache_read} from '@fuzdev/gro/library_load.js'; Reads and validates the .gro/library.json cache at cache_path.
Returns the cached {library_json, package_json} only when the file exists,
its stored hash matches key, and its version and
svelte_docinfo_version stamps match the current LIBRARY_CACHE_VERSION
and SVELTE_DOCINFO_VERSION. Returns null on every miss - absent, stale
(different hash or stamps), 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?LoggerPromise<LibraryLoadResult | null>
the cached result, or null on any miss
2 import {LIBRARY_CACHE_VERSION} from '@fuzdev/gro/library_load.js'; 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. Upstream analyzer changes need no
bump: each record also stamps SVELTE_DOCINFO_VERSION and self-invalidates
when the installed svelte-docinfo moves.
(cache_path: string, key: string, result: LibraryLoadResult, log?: Logger | undefined): Promise<void> import {library_cache_write} from '@fuzdev/gro/library_load.js'; Writes result to the .gro/library.json cache at cache_path, keyed by
key and stamped with the current LIBRARY_CACHE_VERSION and
SVELTE_DOCINFO_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?LoggerPromise<void>
(repo_dir: string, options?: LibraryLoadOptions | undefined): Promise<LibraryLoadResult> import {library_load_from_repo} from '@fuzdev/gro/library_load.js'; 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.
Refuses to analyze a repo whose tsconfig.json extends $app/tsconfig but
that hasn't been synced (see sveltekit_tsconfig_is_unsynced): its analysis
would read external types as any. The check runs only on a cache miss - a
cache hit is served as written. svelte-docinfo logs to a child of log
labelled with the repo dir's name: its diagnostics as warnings and errors,
its progress at debug level.
repo_dirabsolute path to the repo to analyze
stringoptions?Promise<LibraryLoadResult>
the repo's LibraryLoadResult (library_json + full package_json)
Error - if the repo extends `$app/tsconfig` without
`node_modules/$app/tsconfig.json` - install its dependencies if needed, then
run `gro sync` in itLibraryCache import type {LibraryCache} from '@fuzdev/gro/library_load.js'; 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;
svelte_docinfo_version is the SVELTE_DOCINFO_VERSION that analyzed it.
hashtype string
versiontype number
svelte_docinfo_versiontype string
LibraryLoadOptions import type {LibraryLoadOptions} from '@fuzdev/gro/library_load.js'; log?type Logger
cache?Set to false to bypass the .gro cache (always re-analyze, but still write the result).
type boolean
LibraryLoadResult import type {LibraryLoadResult} from '@fuzdev/gro/library_load.js'; 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
string import {SVELTE_DOCINFO_VERSION} from '@fuzdev/gro/library_load.js'; The installed svelte-docinfo version — read from the same copy that
analyzeFromFiles resolves to. Stamped into each cache record and compared
on read, so caches analyzed by a different svelte-docinfo self-invalidate:
source_json.modules is cached verbatim, and the cache key (the analyzed
repo's commit hash) doesn't move when the *analyzer's* dependency changes
its output shape.