( plugin: string, scope: PluginScope, )
| 827 | * @returns Result indicating success/failure with version info |
| 828 | */ |
| 829 | export async function updatePluginOp( |
| 830 | plugin: string, |
| 831 | scope: PluginScope, |
| 832 | ): Promise<PluginUpdateResult> { |
| 833 | // Parse the plugin identifier to get the full plugin ID |
| 834 | const { name: pluginName, marketplace: marketplaceName } = |
| 835 | parsePluginIdentifier(plugin) |
| 836 | const pluginId = marketplaceName ? `${pluginName}@${marketplaceName}` : plugin |
| 837 | |
| 838 | // Get plugin info from marketplace |
| 839 | const pluginInfo = await getPluginById(plugin) |
| 840 | if (!pluginInfo) { |
| 841 | return { |
| 842 | success: false, |
| 843 | message: `Plugin "${pluginName}" not found`, |
| 844 | pluginId, |
| 845 | scope, |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | const { entry, marketplaceInstallLocation } = pluginInfo |
| 850 | |
| 851 | // Get installations from disk |
| 852 | const diskData = loadInstalledPluginsFromDisk() |
| 853 | const installations = diskData.plugins[pluginId] |
| 854 | |
| 855 | if (!installations || installations.length === 0) { |
| 856 | return { |
| 857 | success: false, |
| 858 | message: `Plugin "${pluginName}" is not installed`, |
| 859 | pluginId, |
| 860 | scope, |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | // Determine projectPath based on scope |
| 865 | const projectPath = getProjectPathForScope(scope) |
| 866 | |
| 867 | // Find the installation for this scope |
| 868 | const installation = installations.find( |
| 869 | inst => inst.scope === scope && inst.projectPath === projectPath, |
| 870 | ) |
| 871 | if (!installation) { |
| 872 | const scopeDesc = projectPath ? `${scope} (${projectPath})` : scope |
| 873 | return { |
| 874 | success: false, |
| 875 | message: `Plugin "${pluginName}" is not installed at scope ${scopeDesc}`, |
| 876 | pluginId, |
| 877 | scope, |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | return performPluginUpdate({ |
| 882 | pluginId, |
| 883 | pluginName, |
| 884 | entry, |
| 885 | marketplaceInstallLocation, |
| 886 | installation, |
no test coverage detected