( enabledPlugins: string[], )
| 214 | * @returns Array of missing plugin IDs |
| 215 | */ |
| 216 | export async function findMissingPlugins( |
| 217 | enabledPlugins: string[], |
| 218 | ): Promise<string[]> { |
| 219 | try { |
| 220 | const installedPlugins = await getInstalledPlugins() |
| 221 | |
| 222 | // Filter to not-installed synchronously, then look up all in parallel. |
| 223 | // Results are collected in original enabledPlugins order. |
| 224 | const notInstalled = enabledPlugins.filter( |
| 225 | id => !installedPlugins.includes(id), |
| 226 | ) |
| 227 | const lookups = await Promise.all( |
| 228 | notInstalled.map(async pluginId => { |
| 229 | try { |
| 230 | const plugin = await getPluginById(pluginId) |
| 231 | return { pluginId, found: plugin !== null && plugin !== undefined } |
| 232 | } catch (error) { |
| 233 | logForDebugging( |
| 234 | `Failed to check plugin ${pluginId} in marketplace: ${error}`, |
| 235 | ) |
| 236 | // Plugin doesn't exist in any marketplace, will be handled as an error |
| 237 | return { pluginId, found: false } |
| 238 | } |
| 239 | }), |
| 240 | ) |
| 241 | const missing = lookups |
| 242 | .filter(({ found }) => found) |
| 243 | .map(({ pluginId }) => pluginId) |
| 244 | |
| 245 | return missing |
| 246 | } catch (error) { |
| 247 | logError(error) |
| 248 | return [] |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Result of plugin installation attempt |
nothing calls this directly
no test coverage detected