MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / getLatestVersion

Function getLatestVersion

packages/cli/src/utils/version-utils.ts:35–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33}
34
35export async function getLatestVersion() {
36 const fetchResult = await fetch(`https://registry.npmjs.org/@zenstackhq/cli/${VERSION_CHECK_TAG}`, {
37 headers: { accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' },
38 signal: AbortSignal.timeout(CHECK_VERSION_TIMEOUT),
39 });
40
41 if (fetchResult.ok) {
42 const data: any = await fetchResult.json();
43 const latestVersion = data?.version;
44 if (typeof latestVersion === 'string' && semver.valid(latestVersion)) {
45 return latestVersion;
46 }
47 }
48
49 throw new Error('invalid npm registry response');
50}

Callers 1

checkNewVersionFunction · 0.85

Calls 1

fetchFunction · 0.85

Tested by

no test coverage detected