( marketplaceNames: Set<string>, )
| 159 | * @returns plugin IDs that were actually updated (not already up-to-date) |
| 160 | */ |
| 161 | export async function updatePluginsForMarketplaces( |
| 162 | marketplaceNames: Set<string>, |
| 163 | ): Promise<string[]> { |
| 164 | const installedPlugins = loadInstalledPluginsFromDisk() |
| 165 | const pluginIds = Object.keys(installedPlugins.plugins) |
| 166 | |
| 167 | if (pluginIds.length === 0) { |
| 168 | return [] |
| 169 | } |
| 170 | |
| 171 | const results = await Promise.allSettled( |
| 172 | pluginIds.map(async pluginId => { |
| 173 | const { marketplace } = parsePluginIdentifier(pluginId) |
| 174 | if (!marketplace || !marketplaceNames.has(marketplace.toLowerCase())) { |
| 175 | return null |
| 176 | } |
| 177 | |
| 178 | const allInstallations = installedPlugins.plugins[pluginId] |
| 179 | if (!allInstallations || allInstallations.length === 0) { |
| 180 | return null |
| 181 | } |
| 182 | |
| 183 | const relevantInstallations = allInstallations.filter( |
| 184 | isInstallationRelevantToCurrentProject, |
| 185 | ) |
| 186 | if (relevantInstallations.length === 0) { |
| 187 | return null |
| 188 | } |
| 189 | |
| 190 | return updatePlugin(pluginId, relevantInstallations) |
| 191 | }), |
| 192 | ) |
| 193 | |
| 194 | return results |
| 195 | .filter( |
| 196 | (r): r is PromiseFulfilledResult<string> => |
| 197 | r.status === 'fulfilled' && r.value !== null, |
| 198 | ) |
| 199 | .map(r => r.value) |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Update plugins from marketplaces that have autoUpdate enabled. |
no test coverage detected