"build.json" import {BUILD_CACHE_METADATA_FILENAME} from '@fuzdev/gro/build_cache.js'; 12 declarations
"build.json" import {BUILD_CACHE_METADATA_FILENAME} from '@fuzdev/gro/build_cache.js'; "1" import {BUILD_CACHE_VERSION} from '@fuzdev/gro/build_cache.js'; value + type
{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; } import {BuildCacheMetadata} from '@fuzdev/gro/build_cache.js'; Metadata stored in .gro/ directory to track build cache validity. Schema validates structure at load time to catch corrupted cache files.
versiontype string
git_committype string | null
build_cache_config_hashtype string
timestamptype string
outputstype BuildOutputEntry[]
value + type
{ path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; } import {BuildOutputEntry} from '@fuzdev/gro/build_cache.js'; Metadata about a single build output file. Includes cryptographic hash for validation plus filesystem stats for debugging and optimization.
pathtype string
hashtype string
sizetype number
mtimetype number
ctimetype number
modetype number
(build_dirs: string[]): Promise<{ path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]> import {collect_build_outputs} from '@fuzdev/gro/build_cache.js'; Collects information about all files in build output directories. Returns an array of entries with path, hash, size, mtime, ctime, and mode.
Files are hashed in parallel for performance. For very large builds (10k+ files), this may take several seconds but ensures complete cache validation.
build_dirsarray of output directories to scan (e.g., ['build', 'dist', 'dist_server'])
string[]Promise<BuildOutputEntry[]>
(config: GroConfig, log: Logger, git_commit?: string | null | undefined): Promise<{ git_commit: string | null; build_cache_config_hash: string; }> import {compute_build_cache_key} from '@fuzdev/gro/build_cache.js'; Computes the cache key components for a build. This determines whether a cached build can be reused.
configGro config (build_cache_config_hash is already computed during config load)
logLogger
Loggergit_commit?optional pre-computed git commit hash (optimization to avoid re-reading)
string | nullPromise<{ git_commit: string | null; build_cache_config_hash: string; }>
(config: GroConfig, log: Logger, git_commit?: string | null | undefined, build_dirs?: string[] | undefined): Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { ...; }[]; }> import {create_build_cache_metadata} from '@fuzdev/gro/build_cache.js'; Creates build cache metadata after a successful build. Automatically discovers all build output directories (build/, dist/, dist_*).
configGro config
logLogger
Loggergit_commit?optional pre-computed git commit hash (optimization)
string | nullbuild_dirs?optional pre-discovered build directories (optimization to avoid redundant filesystem scans)
string[]Promise<BuildCacheMetadata>
(): Promise<string[]> import {discover_build_output_dirs} from '@fuzdev/gro/build_cache.js'; Discovers all build output directories in the current working directory. Returns an array of directory names that exist: build/, dist/, dist_*
Promise<string[]>
(config: GroConfig, log: Logger, git_commit?: string | null | undefined): Promise<boolean> import {is_build_cache_valid} from '@fuzdev/gro/build_cache.js'; Main function to check if the build cache is valid. Returns true if the cached build can be used, false if a fresh build is needed.
configGro config
logLogger
Loggergit_commit?optional pre-computed git commit hash (optimization)
string | nullPromise<boolean>
(): Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; } | null> import {load_build_cache_metadata} from '@fuzdev/gro/build_cache.js'; Loads build cache metadata from .gro/ directory. Invalid or corrupted cache files are automatically deleted.
Promise<BuildCacheMetadata | null>
(metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }, log?: Logger | undefined): Promise<...> import {save_build_cache_metadata} from '@fuzdev/gro/build_cache.js'; Saves build cache metadata to .gro/ directory. Errors are logged but don't fail the build (cache is optional).
metadatalog?LoggerPromise<void>
(metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; timestamp: string; outputs: { path: string; hash: string; size: number; mtime: number; ctime: number; mode: number; }[]; }): Promise<...> import {validate_build_cache} from '@fuzdev/gro/build_cache.js'; Validates that a cached build is still valid by checking stats and hashing outputs. Uses size as a fast negative check before expensive hashing. This is comprehensive validation to catch manual tampering or corruption.
metadataPromise<boolean>