()
| 2294 | * @returns Promise that resolves when all refresh attempts complete |
| 2295 | */ |
| 2296 | export async function refreshAllMarketplaces(): Promise<void> { |
| 2297 | const config = await loadKnownMarketplacesConfig() |
| 2298 | |
| 2299 | for (const [name, entry] of Object.entries(config)) { |
| 2300 | // Seed-managed marketplaces are controlled by the seed image — refreshing |
| 2301 | // them is pointless (registerSeedMarketplaces overwrites on next startup). |
| 2302 | if (seedDirFor(entry.installLocation)) { |
| 2303 | logForDebugging( |
| 2304 | `Skipping seed-managed marketplace '${name}' in bulk refresh`, |
| 2305 | ) |
| 2306 | continue |
| 2307 | } |
| 2308 | // settings-sourced marketplaces have no upstream — see refreshMarketplace. |
| 2309 | if (entry.source.source === 'settings') { |
| 2310 | continue |
| 2311 | } |
| 2312 | // inc-5046: same GCS intercept as refreshMarketplace() — bulk update |
| 2313 | // hits this path on `claude plugin marketplace update` (no name arg). |
| 2314 | if (name === OFFICIAL_MARKETPLACE_NAME) { |
| 2315 | const sha = await fetchOfficialMarketplaceFromGcs( |
| 2316 | entry.installLocation, |
| 2317 | getMarketplacesCacheDir(), |
| 2318 | ) |
| 2319 | if (sha !== null) { |
| 2320 | config[name]!.lastUpdated = new Date().toISOString() |
| 2321 | continue |
| 2322 | } |
| 2323 | if ( |
| 2324 | !getFeatureValue_CACHED_MAY_BE_STALE( |
| 2325 | 'tengu_plugin_official_mkt_git_fallback', |
| 2326 | true, |
| 2327 | ) |
| 2328 | ) { |
| 2329 | logForDebugging( |
| 2330 | `Skipping official marketplace bulk refresh: GCS failed, git fallback disabled`, |
| 2331 | ) |
| 2332 | continue |
| 2333 | } |
| 2334 | // fall through to git |
| 2335 | } |
| 2336 | try { |
| 2337 | const { cachePath } = await loadAndCacheMarketplace(entry.source) |
| 2338 | config[name]!.lastUpdated = new Date().toISOString() |
| 2339 | config[name]!.installLocation = cachePath |
| 2340 | } catch (error) { |
| 2341 | logForDebugging( |
| 2342 | `Failed to refresh marketplace ${name}: ${errorMessage(error)}`, |
| 2343 | { |
| 2344 | level: 'error', |
| 2345 | }, |
| 2346 | ) |
| 2347 | } |
| 2348 | } |
| 2349 | |
| 2350 | await saveKnownMarketplacesConfig(config) |
| 2351 | } |
| 2352 | |
| 2353 | /** |
no test coverage detected