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

Function performPluginUpdate

src/services/plugins/pluginOperations.ts:897–1089  ·  view source on GitHub ↗

* Perform the actual plugin update: fetch source, calculate version, copy to cache, update disk. * This is the core update execution extracted from updatePluginOp.

({
  pluginId,
  pluginName,
  entry,
  marketplaceInstallLocation,
  installation,
  scope,
  projectPath,
}: {
  pluginId: string
  pluginName: string
  entry: PluginMarketplaceEntry
  marketplaceInstallLocation: string
  installation: { version?: string; installPath: string }
  scope: PluginScope
  projectPath: string | undefined
})

Source from the content-addressed store, hash-verified

895 * This is the core update execution extracted from updatePluginOp.
896 */
897async function performPluginUpdate({
898 pluginId,
899 pluginName,
900 entry,
901 marketplaceInstallLocation,
902 installation,
903 scope,
904 projectPath,
905}: {
906 pluginId: string
907 pluginName: string
908 entry: PluginMarketplaceEntry
909 marketplaceInstallLocation: string
910 installation: { version?: string; installPath: string }
911 scope: PluginScope
912 projectPath: string | undefined
913}): Promise<PluginUpdateResult> {
914 const fs = getFsImplementation()
915 const oldVersion = installation.version
916
917 let sourcePath: string
918 let newVersion: string
919 let shouldCleanupSource = false
920 let gitCommitSha: string | undefined
921
922 // Handle remote vs local plugins
923 if (typeof entry.source !== 'string') {
924 // Remote plugin: download to temp directory first
925 const cacheResult = await cachePlugin(entry.source, {
926 manifest: { name: entry.name },
927 })
928 sourcePath = cacheResult.path
929 shouldCleanupSource = true
930 gitCommitSha = cacheResult.gitCommitSha
931
932 // Calculate version from downloaded plugin. For git-subdir sources,
933 // cachePlugin captured the commit SHA before discarding the ephemeral
934 // clone (the extracted subdir has no .git, so the installPath-based
935 // fallback in calculatePluginVersion can't recover it).
936 newVersion = await calculatePluginVersion(
937 pluginId,
938 entry.source,
939 cacheResult.manifest,
940 cacheResult.path,
941 entry.version,
942 cacheResult.gitCommitSha,
943 )
944 } else {
945 // Local plugin: use path from marketplace
946 // Stat directly — handle ENOENT inline rather than pre-checking existence
947 let marketplaceStats
948 try {
949 marketplaceStats = await fs.stat(marketplaceInstallLocation)
950 } catch (e: unknown) {
951 if (isENOENT(e)) {
952 return {
953 success: false,
954 message: `Marketplace directory not found at ${marketplaceInstallLocation}`,

Callers 1

updatePluginOpFunction · 0.85

Calls 11

getFsImplementationFunction · 0.85
cachePluginFunction · 0.85
calculatePluginVersionFunction · 0.85
isENOENTFunction · 0.85
loadPluginManifestFunction · 0.85
getVersionedCachePathFunction · 0.85
getVersionedZipCachePathFunction · 0.85

Tested by

no test coverage detected