()
| 489 | // Note that a plugin can be fetched but not installed, so that's why we |
| 490 | // still need a separate listInstalledPluginVersions. |
| 491 | listFetchedPluginVersions() { |
| 492 | const fetchJsonPath = files.pathJoin(this.pluginsDir, 'fetch.json'); |
| 493 | |
| 494 | if (!files.exists(fetchJsonPath)) { |
| 495 | return {}; |
| 496 | } |
| 497 | |
| 498 | const fetchedPluginsMetadata = JSON.parse(files.readFile( |
| 499 | fetchJsonPath, 'utf8')); |
| 500 | return _.object(_.map(fetchedPluginsMetadata, (metadata, name) => { |
| 501 | const source = metadata.source; |
| 502 | |
| 503 | const idWithVersion = source.id ? source.id : name; |
| 504 | const scoped = idWithVersion[0] === '@'; |
| 505 | const id = `${scoped ? '@' : ''}${idWithVersion.split('@')[scoped ? 1 : 0]}`; |
| 506 | let version; |
| 507 | if (source.type === 'registry') { |
| 508 | version = idWithVersion.split('@')[scoped ? 2 : 1]; |
| 509 | } else if (source.type === 'git') { |
| 510 | version = `${source.url}${'ref' in source ? `#${source.ref}` : ''}`; |
| 511 | } else if (source.type === 'local') { |
| 512 | version = `file://${source.path}`; |
| 513 | } |
| 514 | return [name, { id, version }]; |
| 515 | })); |
| 516 | } |
| 517 | |
| 518 | // Construct a target suitable for 'cordova plugin add' from an id and |
| 519 | // version, converting or resolving a URL or path where needed. |
no test coverage detected