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

Function getLatestVersion

src/utils/autoUpdater.ts:329–354  ·  view source on GitHub ↗
(
  channel: ReleaseChannel,
)

Source from the content-addressed store, hash-verified

327}
328
329export async function getLatestVersion(
330 channel: ReleaseChannel,
331): Promise<string | null> {
332 const npmTag = channel === 'stable' ? 'stable' : 'latest'
333
334 // Run from home directory to avoid reading project-level .npmrc
335 // which could be maliciously crafted to redirect to an attacker's registry
336 const result = await execFileNoThrowWithCwd(
337 'npm',
338 ['view', `${MACRO.PACKAGE_URL}@${npmTag}`, 'version', '--prefer-online'],
339 { abortSignal: AbortSignal.timeout(5000), cwd: homedir() },
340 )
341 if (result.code !== 0) {
342 logForDebugging(`npm view failed with code ${result.code}`)
343 if (result.stderr) {
344 logForDebugging(`npm stderr: ${result.stderr.trim()}`)
345 } else {
346 logForDebugging('npm stderr: (empty)')
347 }
348 if (result.stdout) {
349 logForDebugging(`npm stdout: ${result.stdout.trim()}`)
350 }
351 return null
352 }
353 return result.stdout.trim()
354}
355
356export type NpmDistTags = {
357 latest: string | null

Callers 2

AutoUpdaterFunction · 0.50
updateFunction · 0.50

Calls 2

execFileNoThrowWithCwdFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected