mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-10-01 00:29:51 +00:00
## Summary - add `latest-known` as an explicit version selector - resolve it locally to the newest version in the bundled checksum table - preserve existing default and `latest` behavior - document custom-manifest checksum semantics and update published bundles ## Testing - `npm ci --ignore-scripts` - `npm run all` (99 tests passed) Closes #919 Refs: pi-session 019fed0e-6019-7504-911b-bd9955cbbd49
24 lines
658 B
TypeScript
24 lines
658 B
TypeScript
import * as semver from "semver";
|
|
import { KNOWN_CHECKSUMS } from "./known-checksums";
|
|
|
|
const VERSION_IN_CHECKSUM_KEY_PATTERN =
|
|
/-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)$/;
|
|
|
|
export function getLatestKnownVersion(): string {
|
|
const versions = new Set<string>();
|
|
|
|
for (const key of Object.keys(KNOWN_CHECKSUMS)) {
|
|
const version = key.match(VERSION_IN_CHECKSUM_KEY_PATTERN)?.[1];
|
|
if (version !== undefined) {
|
|
versions.add(version);
|
|
}
|
|
}
|
|
|
|
const latestVersion = [...versions].sort(semver.rcompare)[0];
|
|
if (!latestVersion) {
|
|
throw new Error("Could not determine latest known version from checksums.");
|
|
}
|
|
|
|
return latestVersion;
|
|
}
|