MCPcopy Create free account
hub / github.com/Noumena-Network/code / updatePluginOp

Function updatePluginOp

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

Source from the content-addressed store, hash-verified

830 * @returns Result indicating success/failure with version info
831 */
832export 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,

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