()
| 2317 | * @returns Promise that resolves when all refresh attempts complete |
| 2318 | */ |
| 2319 | export async function refreshAllMarketplaces(): Promise<void> { |
| 2320 | const config = await loadKnownMarketplacesConfig() |
| 2321 | |
| 2322 | for (const [name, entry] of Object.entries(config)) { |
| 2323 | // Seed-managed marketplaces are controlled by the seed image — refreshing |
| 2324 | // them is pointless (registerSeedMarketplaces overwrites on next startup). |
| 2325 | if (seedDirFor(entry.installLocation)) { |
| 2326 | logForDebugging( |
| 2327 | `Skipping seed-managed marketplace '${name}' in bulk refresh`, |
| 2328 | ) |
| 2329 | continue |
| 2330 | } |
| 2331 | // settings-sourced marketplaces have no upstream — see refreshMarketplace. |
| 2332 | if (entry.source.source === 'settings') { |
| 2333 | continue |
| 2334 | } |
| 2335 | // inc-5046: same GCS intercept as refreshMarketplace() — bulk update |
| 2336 | // hits this path on `ncode plugin marketplace update` (no name arg). |
| 2337 | if (name === OFFICIAL_MARKETPLACE_NAME) { |
| 2338 | const sha = await fetchOfficialMarketplaceFromGcs( |
| 2339 | entry.installLocation, |
| 2340 | getMarketplacesCacheDir(), |
| 2341 | ) |
| 2342 | if (sha !== null) { |
| 2343 | config[name]!.lastUpdated = new Date().toISOString() |
| 2344 | continue |
| 2345 | } |
| 2346 | if (!isOfficialMarketplaceGitFallbackEnabled()) { |
| 2347 | logForDebugging( |
| 2348 | `Skipping official marketplace bulk refresh: GCS failed, git fallback disabled`, |
| 2349 | ) |
| 2350 | continue |
| 2351 | } |
| 2352 | // fall through to git |
| 2353 | } |
| 2354 | try { |
| 2355 | const { cachePath } = await loadAndCacheMarketplace(entry.source) |
| 2356 | config[name]!.lastUpdated = new Date().toISOString() |
| 2357 | config[name]!.installLocation = cachePath |
| 2358 | } catch (error) { |
| 2359 | logForDebugging( |
| 2360 | `Failed to refresh marketplace ${name}: ${errorMessage(error)}`, |
| 2361 | { |
| 2362 | level: 'error', |
| 2363 | }, |
| 2364 | ) |
| 2365 | } |
| 2366 | } |
| 2367 | |
| 2368 | await saveKnownMarketplacesConfig(config) |
| 2369 | } |
| 2370 | |
| 2371 | /** |
| 2372 | * Refresh a single marketplace cache |
no test coverage detected