MCPcopy Index your code
hub / github.com/codeaashu/claude-code / migrateV1ToV2

Function migrateV1ToV2

src/utils/plugins/installedPluginsManager.ts:284–305  ·  view source on GitHub ↗

* Migrate V1 data to V2 format. * All V1 plugins are migrated to 'user' scope since V1 had no scope concept.

(v1Data: InstalledPluginsFileV1)

Source from the content-addressed store, hash-verified

282 * All V1 plugins are migrated to 'user' scope since V1 had no scope concept.
283 */
284function 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.

Callers 3

loadInstalledPluginsV2Function · 0.85

Calls 2

getVersionedCachePathFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected