MCPcopy Create free account
hub / github.com/WJX20/claude-code / updatePluginOp

Function updatePluginOp

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

Source from the content-addressed store, hash-verified

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