import { getEnvConfig , createDefaultConfig } from "backfill-config" ; import { Logger , makeLogger } from "backfill-logger" ; import { CacheOptions } from "../types/CacheOptions" ; import { RemoteFallbackCacheProvider } from "./RemoteFallbackCacheProvider" ; export function getCacheConfig ( cwd , cacheOptions ) { const defaultCacheConfig = createDefaultConfig ( cwd ) ; defaultCacheConfig . cacheStorageConfig . provider = "local" ; const logger = makeLogger ( "warn" ) ; const envConfig = getEnvConfig ( logger ) ; const configWithEnvOverrides = { ... defaultCacheConfig , ... cacheOptions , ... envConfig , writeRemoteCache : cacheOptions . writeRemoteCache || ! ! process . env . LAGE_WRITE_REMOTE_CACHE } ; const configWithFallback = { ... configWithEnvOverrides , cacheStorageConfig : { ... configWithEnvOverrides . cacheStorageConfig , provider : ( logger , cwd ) => new RemoteFallbackCacheProvider ( configWithEnvOverrides , logger , cwd ) , name : "remote-fallback-provider" } , } ; return configWithFallback ; }