(pluginId: string)
| 2209 | * @returns The plugin entry or null if not found/cache missing |
| 2210 | */ |
| 2211 | export async function getPluginByIdCacheOnly(pluginId: string): Promise<{ |
| 2212 | entry: PluginMarketplaceEntry |
| 2213 | marketplaceInstallLocation: string |
| 2214 | } | null> { |
| 2215 | const { name: pluginName, marketplace: marketplaceName } = |
| 2216 | parsePluginIdentifier(pluginId) |
| 2217 | if (!pluginName || !marketplaceName) { |
| 2218 | return null |
| 2219 | } |
| 2220 | |
| 2221 | const fs = getFsImplementation() |
| 2222 | const configFile = getKnownMarketplacesFile() |
| 2223 | |
| 2224 | try { |
| 2225 | const content = await fs.readFile(configFile, { encoding: 'utf-8' }) |
| 2226 | const config = jsonParse(content) as KnownMarketplacesConfig |
| 2227 | const marketplaceConfig = config[marketplaceName] |
| 2228 | |
| 2229 | if (!marketplaceConfig) { |
| 2230 | return null |
| 2231 | } |
| 2232 | |
| 2233 | const marketplace = await getMarketplaceCacheOnly(marketplaceName) |
| 2234 | if (!marketplace) { |
| 2235 | return null |
| 2236 | } |
| 2237 | |
| 2238 | const plugin = marketplace.plugins.find(p => p.name === pluginName) |
| 2239 | if (!plugin) { |
| 2240 | return null |
| 2241 | } |
| 2242 | |
| 2243 | return { |
| 2244 | entry: plugin, |
| 2245 | marketplaceInstallLocation: marketplaceConfig.installLocation, |
| 2246 | } |
| 2247 | } catch { |
| 2248 | return null |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | /** |
| 2253 | * Get plugin by ID from a specific marketplace |
no test coverage detected