MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveLatestVersion

Function resolveLatestVersion

src/upgrade/index.ts:244–271  ·  view source on GitHub ↗
(repo = REPO, timeoutMs = 12000)

Source from the content-addressed store, hash-verified

242 * be read.
243 */
244export async function resolveLatestVersion(repo = REPO, timeoutMs = 12000): Promise<string> {
245 try {
246 const res = await httpsGet(
247 `https://github.com/${repo}/releases/latest`,
248 { 'User-Agent': 'codegraph-upgrade' },
249 timeoutMs
250 );
251 const loc = res.headers.location;
252 const tag = parseLatestTagFromLocation(Array.isArray(loc) ? loc[0] : loc);
253 if (tag) return normalizeVersion(tag);
254 } catch {
255 /* fall through to API */
256 }
257 try {
258 const res = await httpsGet(
259 `https://api.github.com/repos/${repo}/releases/latest`,
260 { 'User-Agent': 'codegraph-upgrade', Accept: 'application/vnd.github+json' },
261 timeoutMs
262 );
263 const tag = JSON.parse(res.body)?.tag_name;
264 if (typeof tag === 'string' && tag) return normalizeVersion(tag);
265 } catch {
266 /* fall through to error */
267 }
268 throw new Error(
269 'could not resolve the latest version from GitHub. Check your network, or pin a version: `codegraph upgrade <version>`.'
270 );
271}
272
273// ---------------------------------------------------------------------------
274// Orchestrator

Callers 1

resolveDepsFunction · 0.90

Calls 3

httpsGetFunction · 0.85
normalizeVersionFunction · 0.85

Tested by

no test coverage detected