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