-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasdf-check-updates.py
executable file
·44 lines (38 loc) · 1.28 KB
/
asdf-check-updates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import os
import subprocess
import typing as t
from module_utils.asdf import Asdf, Version
def check_updates(asdf: Asdf) -> None:
for plugin_name in asdf.list_plugins():
latest_version = max(asdf.list_all_versions(plugin_name))
installed_versions = asdf.list_versions(plugin_name)
if installed_versions == []:
installed_latest_version = None
else:
installed_latest_version = max(asdf.list_versions(plugin_name))
if (
installed_latest_version is None
or installed_latest_version < latest_version
):
print(
f"! {plugin_name} is upgradable to {latest_version} (current is {installed_latest_version})"
)
else:
print(f"{plugin_name} is latest (current is {installed_latest_version})")
if __name__ == "__main__":
if os.path.exists(".tool-versions"):
os.remove(".tool-versions")
asdf = Asdf()
asdf.update()
check_updates(asdf)
subprocess.run(
[
"sh",
"-c",
r"""
locate .tool-versions | grep '/\.tool-versions$' | sort | xargs -I{} sh -c 'echo {} && sort {} | awk '"'"'{print"\t"$0}'"'"' && echo'
""",
],
check=True,
)