(pluginId: string)
| 2186 | * @returns The plugin entry or null if not found/cache missing |
| 2187 | */ |
| 2188 | export async function getPluginByIdCacheOnly(pluginId: string): Promise<{ |
| 2189 | entry: PluginMarketplaceEntry |
| 2190 | marketplaceInstallLocation: string |
| 2191 | } | null> { |
| 2192 | const { name: pluginName, marketplace: marketplaceName } = |
| 2193 | parsePluginIdentifier(pluginId) |
| 2194 | if (!pluginName || !marketplaceName) { |
| 2195 | return null |
| 2196 | } |
| 2197 | |
| 2198 | const fs = getFsImplementation() |
| 2199 | const configFile = getKnownMarketplacesFile() |
| 2200 | |
| 2201 | try { |
| 2202 | const content = await fs.readFile(configFile, { encoding: 'utf-8' }) |
| 2203 | const config = jsonParse(content) as KnownMarketplacesConfig |
| 2204 | const marketplaceConfig = config[marketplaceName] |
| 2205 | |
| 2206 | if (!marketplaceConfig) { |
| 2207 | return null |
| 2208 | } |
| 2209 | |
| 2210 | const marketplace = await getMarketplaceCacheOnly(marketplaceName) |
| 2211 | if (!marketplace) { |
| 2212 | return null |
| 2213 | } |
| 2214 | |
| 2215 | const plugin = marketplace.plugins.find(p => p.name === pluginName) |
| 2216 | if (!plugin) { |
| 2217 | return null |
| 2218 | } |
| 2219 | |
| 2220 | return { |
| 2221 | entry: plugin, |
| 2222 | marketplaceInstallLocation: marketplaceConfig.installLocation, |
| 2223 | } |
| 2224 | } catch { |
| 2225 | return null |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | /** |
| 2230 | * Get plugin by ID from a specific marketplace |
no test coverage detected