( pluginId: string, scope: PersistableScope, installPath: string, metadata: Partial<PluginInstallationEntry>, projectPath?: string, )
| 408 | * @param projectPath - Project path (required for project/local scopes) |
| 409 | */ |
| 410 | export function addPluginInstallation( |
| 411 | pluginId: string, |
| 412 | scope: PersistableScope, |
| 413 | installPath: string, |
| 414 | metadata: Partial<PluginInstallationEntry>, |
| 415 | projectPath?: string, |
| 416 | ): void { |
| 417 | const data = loadInstalledPluginsFromDisk() |
| 418 | |
| 419 | // Get or create array for this plugin |
| 420 | const installations = data.plugins[pluginId] || [] |
| 421 | |
| 422 | // Find existing entry for this scope+projectPath |
| 423 | const existingIndex = installations.findIndex( |
| 424 | entry => entry.scope === scope && entry.projectPath === projectPath, |
| 425 | ) |
| 426 | |
| 427 | const newEntry: PluginInstallationEntry = { |
| 428 | scope, |
| 429 | installPath, |
| 430 | version: metadata.version, |
| 431 | installedAt: metadata.installedAt || new Date().toISOString(), |
| 432 | lastUpdated: new Date().toISOString(), |
| 433 | gitCommitSha: metadata.gitCommitSha, |
| 434 | ...(projectPath && { projectPath }), |
| 435 | } |
| 436 | |
| 437 | if (existingIndex >= 0) { |
| 438 | installations[existingIndex] = newEntry |
| 439 | logForDebugging(`Updated installation for ${pluginId} at scope ${scope}`) |
| 440 | } else { |
| 441 | installations.push(newEntry) |
| 442 | logForDebugging(`Added installation for ${pluginId} at scope ${scope}`) |
| 443 | } |
| 444 | |
| 445 | data.plugins[pluginId] = installations |
| 446 | saveInstalledPluginsV2(data) |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Remove a plugin installation entry from a specific scope. |
nothing calls this directly
no test coverage detected