MCPcopy
hub / github.com/npmx-dev/npmx.dev / fetchLatestVersionWithFallback

Function fetchLatestVersionWithFallback

server/utils/npm.ts:23–34  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

21 * @returns Latest version string or null if not found
22 */
23export async function fetchLatestVersionWithFallback(name: string): Promise<string | null> {
24 const version = await fetchLatestVersion(name)
25 if (version) return version
26
27 // Fallback to full packument (also cached)
28 try {
29 const packument = await fetchNpmPackage(name)
30 return packument['dist-tags']?.latest ?? null
31 } catch {
32 return null
33 }
34}
35
36/**
37 * Check if a version constraint explicitly includes a prerelease tag.

Callers 2

[...pkg].get.tsFile · 0.85
[...pkg].get.tsFile · 0.85

Calls 1

fetchLatestVersionFunction · 0.85

Tested by

no test coverage detected