(
baseUrl: string = DEFAULT_REGISTRY_URL,
options?: { skipCache?: boolean },
)
| 83 | * Returns undefined if the registry is unreachable (offline / 404). |
| 84 | */ |
| 85 | export async function fetchRegistryManifest( |
| 86 | baseUrl: string = DEFAULT_REGISTRY_URL, |
| 87 | options?: { skipCache?: boolean }, |
| 88 | ): Promise<RegistryManifest | undefined> { |
| 89 | const cacheFile = cachePath(baseUrl, "registry"); |
| 90 | if (!options?.skipCache) { |
| 91 | const cached = readCache<RegistryManifest>(cacheFile); |
| 92 | if (cached) return cached; |
| 93 | } |
| 94 | |
| 95 | try { |
| 96 | const manifest = await fetchJson<RegistryManifest>(`${baseUrl}/registry.json`); |
| 97 | writeCache(cacheFile, manifest); |
| 98 | return manifest; |
| 99 | } catch { |
| 100 | return undefined; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Fetch a single item's `registry-item.json` manifest. Cached for 24h. |
no test coverage detected