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

Function installOrUpdateClaudePackage

src/utils/localInstaller.ts:113–154  ·  view source on GitHub ↗
(
  channel: ReleaseChannel,
  specificVersion?: string | null,
)

Source from the content-addressed store, hash-verified

111 * @param specificVersion - Optional specific version to install (overrides channel)
112 */
113export async function installOrUpdateClaudePackage(
114 channel: ReleaseChannel,
115 specificVersion?: string | null,
116): Promise<'in_progress' | 'success' | 'install_failed'> {
117 try {
118 // First ensure the environment is set up
119 if (!(await ensureLocalPackageEnvironment())) {
120 return 'install_failed'
121 }
122
123 // Use specific version if provided, otherwise use channel tag
124 const versionSpec = specificVersion
125 ? specificVersion
126 : channel === 'stable'
127 ? 'stable'
128 : 'latest'
129 const result = await execFileNoThrowWithCwd(
130 'npm',
131 ['install', `${MACRO.PACKAGE_URL}@${versionSpec}`],
132 { cwd: getLocalInstallDir(), maxBuffer: 1000000 },
133 )
134
135 if (result.code !== 0) {
136 const error = new Error(
137 `Failed to install NCode CLI package: ${result.stderr}`,
138 )
139 logError(error)
140 return result.code === 190 ? 'in_progress' : 'install_failed'
141 }
142
143 // Set installMethod to 'local' to prevent npm permission warnings
144 saveGlobalConfig(current => ({
145 ...current,
146 installMethod: 'local',
147 }))
148
149 return 'success'
150 } catch (error) {
151 logError(error)
152 return 'install_failed'
153 }
154}
155
156/**
157 * Check if local installation exists.

Callers 2

AutoUpdaterFunction · 0.85
updateFunction · 0.85

Calls 5

execFileNoThrowWithCwdFunction · 0.85
getLocalInstallDirFunction · 0.85
logErrorFunction · 0.70
saveGlobalConfigFunction · 0.70

Tested by

no test coverage detected