(pluginId: string)
| 2236 | * @returns The plugin entry or null if not found |
| 2237 | */ |
| 2238 | export async function getPluginById(pluginId: string): Promise<{ |
| 2239 | entry: PluginMarketplaceEntry |
| 2240 | marketplaceInstallLocation: string |
| 2241 | } | null> { |
| 2242 | // Try cache-only first (fast path) |
| 2243 | const cached = await getPluginByIdCacheOnly(pluginId) |
| 2244 | if (cached) { |
| 2245 | return cached |
| 2246 | } |
| 2247 | |
| 2248 | // Cache miss - try fetching from source |
| 2249 | const { name: pluginName, marketplace: marketplaceName } = |
| 2250 | parsePluginIdentifier(pluginId) |
| 2251 | if (!pluginName || !marketplaceName) { |
| 2252 | return null |
| 2253 | } |
| 2254 | |
| 2255 | try { |
| 2256 | const config = await loadKnownMarketplacesConfig() |
| 2257 | const marketplaceConfig = config[marketplaceName] |
| 2258 | if (!marketplaceConfig) { |
| 2259 | return null |
| 2260 | } |
| 2261 | |
| 2262 | const marketplace = await getMarketplace(marketplaceName) |
| 2263 | const plugin = marketplace.plugins.find(p => p.name === pluginName) |
| 2264 | |
| 2265 | if (!plugin) { |
| 2266 | return null |
| 2267 | } |
| 2268 | |
| 2269 | return { |
| 2270 | entry: plugin, |
| 2271 | marketplaceInstallLocation: marketplaceConfig.installLocation, |
| 2272 | } |
| 2273 | } catch (error) { |
| 2274 | logForDebugging( |
| 2275 | `Could not find plugin ${pluginId}: ${errorMessage(error)}`, |
| 2276 | { level: 'debug' }, |
| 2277 | ) |
| 2278 | return null |
| 2279 | } |
| 2280 | } |
| 2281 | |
| 2282 | /** |
| 2283 | * Refresh all marketplace caches |
no test coverage detected