MCPcopy
hub / github.com/codeaashu/claude-code / updatePluginOp

Function updatePluginOp

src/services/plugins/pluginOperations.ts:829–890  ·  view source on GitHub ↗
(
  plugin: string,
  scope: PluginScope,
)

Source from the content-addressed store, hash-verified

827 * @returns Result indicating success/failure with version info
828 */
829export 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,

Callers 3

updatePluginFunction · 0.85
handleSingleOperationFunction · 0.85
updatePluginCliFunction · 0.85

Calls 5

parsePluginIdentifierFunction · 0.85
getPluginByIdFunction · 0.85
getProjectPathForScopeFunction · 0.85
performPluginUpdateFunction · 0.85

Tested by

no test coverage detected