* Migrate V1 data to V2 format. * All V1 plugins are migrated to 'user' scope since V1 had no scope concept.
(v1Data: InstalledPluginsFileV1)
| 282 | * All V1 plugins are migrated to 'user' scope since V1 had no scope concept. |
| 283 | */ |
| 284 | function migrateV1ToV2(v1Data: InstalledPluginsFileV1): InstalledPluginsFileV2 { |
| 285 | const v2Plugins: InstalledPluginsMapV2 = {} |
| 286 | |
| 287 | for (const [pluginId, plugin] of Object.entries(v1Data.plugins)) { |
| 288 | // V2 format uses versioned cache path: ~/.claude/plugins/cache/{marketplace}/{plugin}/{version} |
| 289 | // Compute it from pluginId and version instead of using the V1 installPath |
| 290 | const versionedCachePath = getVersionedCachePath(pluginId, plugin.version) |
| 291 | |
| 292 | v2Plugins[pluginId] = [ |
| 293 | { |
| 294 | scope: 'user', // Default all existing installs to user scope |
| 295 | installPath: versionedCachePath, |
| 296 | version: plugin.version, |
| 297 | installedAt: plugin.installedAt, |
| 298 | lastUpdated: plugin.lastUpdated, |
| 299 | gitCommitSha: plugin.gitCommitSha, |
| 300 | }, |
| 301 | ] |
| 302 | } |
| 303 | |
| 304 | return { version: 2, plugins: v2Plugins } |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Load installed plugins in V2 format. |
no test coverage detected