mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
wip
This commit is contained in:
parent
65175f3cf3
commit
37e2ba87a7
13 changed files with 134 additions and 0 deletions
50
pre_commit/tools/node.py
Normal file
50
pre_commit/tools/node.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import json
|
||||
|
||||
from pre_commit.prefix import Prefix
|
||||
from pre_commit.request import fetch
|
||||
|
||||
RESOLVABLE = ('latest', 'lts')
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _node_versions() -> dict[str, str]:
|
||||
resp = fetch('https://nodejs.org/download/release/index.json')
|
||||
contents = json.load(resp)
|
||||
|
||||
ret = {'latest': contents[0]['version']}
|
||||
for dct in contents:
|
||||
if dct['lts']:
|
||||
ret['lts'] = dct['version']
|
||||
break
|
||||
else:
|
||||
raise AssertionError('unreachable')
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def resolve(version: str) -> str:
|
||||
return _node_versions()[version]
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _target_platform() -> str:
|
||||
# to support:
|
||||
# linux-arm64, linux-ppc64le, linux-s390x, linux-x64
|
||||
# osx-arm64-tar, osx-x86-tar
|
||||
# win-arm64-zip, win-x64-zip
|
||||
# or fallback to `src` ?
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def install(prefix: Prefix, version: str) -> None:
|
||||
# TODO: download and extract to prefix
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def health_check(prefix: Prefix, version: str) -> str | None:
|
||||
# TODO: previously checked `node --version`
|
||||
# TODO: but maybe just check that the installed os/arch is correct?
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue