| 32 | |
| 33 | |
| 34 | def latest_lts_version() -> str: |
| 35 | with urllib.request.urlopen(NODE_INDEX_URL) as response: # noqa: S310 |
| 36 | releases = json.load(response) |
| 37 | # The index is ordered newest-first; each release's "lts" field is false for |
| 38 | # non-LTS lines and the LTS codename otherwise. The first truthy one is the |
| 39 | # latest LTS release, e.g. {"version": "v24.16.0", "lts": "Krypton"}. |
| 40 | for release in releases: |
| 41 | if release.get("lts"): |
| 42 | return str(release["version"]).lstrip("v") |
| 43 | raise SystemExit("No LTS release found in the Node.js release index") |
| 44 | |
| 45 | |
| 46 | def main() -> None: |