MCPcopy Create free account
hub / github.com/ShipSecAI/studio / performVersionCheck

Function performVersionCheck

backend/src/version-check.ts:44–79  ·  view source on GitHub ↗
(
  overrides: Partial<VersionCheckMetadata> = {},
)

Source from the content-addressed store, hash-verified

42}
43
44export async function performVersionCheck(
45 overrides: Partial<VersionCheckMetadata> = {},
46): Promise<VersionCheckResult> {
47 const metadata: VersionCheckMetadata = {
48 version: overrides.version ?? DEFAULT_VERSION,
49 platform: overrides.platform ?? process.platform,
50 arch: overrides.arch ?? process.arch,
51 };
52
53 const url = new URL('/api/version/check', ensureTrailingSlash(DEFAULT_BASE_URL));
54 url.searchParams.set('app', 'studio');
55 url.searchParams.set('version', metadata.version);
56 if (metadata.platform) url.searchParams.set('platform', metadata.platform);
57 if (metadata.arch) url.searchParams.set('arch', metadata.arch);
58
59 const controller = new AbortController();
60 const timeout = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT_MS);
61
62 try {
63 const response = await fetch(url.toString(), { signal: controller.signal });
64 if (!response.ok) {
65 const body = await safeBody(response);
66 throw new Error(
67 `Version check failed with status ${response.status}${body ? `: ${body}` : ''}`,
68 );
69 }
70 const payload = (await response.json()) as VersionCheckResponse;
71 return {
72 outcome: evaluateOutcome(payload),
73 response: payload,
74 requestedVersion: metadata.version,
75 };
76 } finally {
77 clearTimeout(timeout);
78 }
79}
80
81function evaluateOutcome(response: VersionCheckResponse): VersionCheckOutcome {
82 if (!response.is_supported) {

Callers 2

enforceVersionCheckFunction · 0.90
mainFunction · 0.90

Calls 5

ensureTrailingSlashFunction · 0.85
fetchFunction · 0.85
safeBodyFunction · 0.85
evaluateOutcomeFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected