* Update a single plugin's installations. * Returns the plugin ID if any installation was updated, null otherwise.
(
pluginId: string,
installations: Array<{ scope: PluginScope; projectPath?: string }>,
)
| 106 | * Returns the plugin ID if any installation was updated, null otherwise. |
| 107 | */ |
| 108 | async function updatePlugin( |
| 109 | pluginId: string, |
| 110 | installations: Array<{ scope: PluginScope; projectPath?: string }>, |
| 111 | ): Promise<string | null> { |
| 112 | let wasUpdated = false |
| 113 | |
| 114 | for (const { scope } of installations) { |
| 115 | try { |
| 116 | const result = await updatePluginOp(pluginId, scope) |
| 117 | |
| 118 | if (result.success && !result.alreadyUpToDate) { |
| 119 | wasUpdated = true |
| 120 | logForDebugging( |
| 121 | `Plugin autoupdate: updated ${pluginId} from ${result.oldVersion} to ${result.newVersion}`, |
| 122 | ) |
| 123 | } else if (!result.alreadyUpToDate) { |
| 124 | logForDebugging( |
| 125 | `Plugin autoupdate: failed to update ${pluginId}: ${result.message}`, |
| 126 | { level: 'warn' }, |
| 127 | ) |
| 128 | } |
| 129 | } catch (error) { |
| 130 | logForDebugging( |
| 131 | `Plugin autoupdate: error updating ${pluginId}: ${errorMessage(error)}`, |
| 132 | { level: 'warn' }, |
| 133 | ) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | return wasUpdated ? pluginId : null |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Update all project-relevant installed plugins from the given marketplaces. |
no test coverage detected