()
| 33 | } |
| 34 | |
| 35 | export 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 | } |
no test coverage detected