MCPcopy Create free account
hub / github.com/freecodexyz/free-code / addPluginInstallation

Function addPluginInstallation

src/utils/plugins/installedPluginsManager.ts:406–443  ·  view source on GitHub ↗
(
  pluginId: string,
  scope: PersistableScope,
  installPath: string,
  metadata: Partial<PluginInstallationEntry>,
  projectPath?: string,
)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

logForDebuggingFunction · 0.85
saveInstalledPluginsV2Function · 0.85

Tested by

no test coverage detected