MCPcopy
hub / github.com/monkeytypegame/monkeytype / fetchLatestVersion

Function fetchLatestVersion

frontend/src/ts/utils/version.ts:21–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21export async function fetchLatestVersion(): Promise<{
22 text: string;
23 isNew: boolean;
24} | null> {
25 if (isDevEnvironment()) return null;
26
27 const { data: currentVersion, error } = await tryCatch(
28 getLatestReleaseFromGitHub(),
29 );
30
31 if (error) {
32 const msg = createErrorMessage(
33 error,
34 "Failed to fetch version number from GitHub",
35 );
36 console.error(msg);
37 return null;
38 }
39
40 const memoryVersion = memoryLS.get();
41 const isNew = memoryVersion === "" ? false : memoryVersion !== currentVersion;
42
43 if (isNew || memoryVersion === "") {
44 memoryLS.set(currentVersion);
45 purgeCaches();
46 }
47
48 return {
49 text: currentVersion,
50 isNew,
51 };
52}

Callers 1

index.tsFile · 0.90

Calls 7

isDevEnvironmentFunction · 0.90
tryCatchFunction · 0.90
createErrorMessageFunction · 0.90
purgeCachesFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected