mise-helper 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: mise-helper
3
+ Version: 0.0.1
@@ -0,0 +1,69 @@
1
+ import json
2
+ import subprocess
3
+ import sys
4
+
5
+
6
+ def get_dependencies():
7
+ result = subprocess.run(["mise", "tasks", "graph", "--json"], capture_output=True)
8
+ if result.stderr:
9
+ raise RuntimeError
10
+ graph_json = json.loads(result.stdout)
11
+ project_dict = {project["id"]: project for project in graph_json["projects"]}
12
+ dependencies = {}
13
+ for project in project_dict.values():
14
+ project_path = f"//{project["root"]}"
15
+ if project_path == "//.":
16
+ project_path = "//"
17
+ project_depends = [
18
+ f"//{project_dict[dependency]["root"]}"
19
+ for dependency in project["dependencies"]
20
+ ]
21
+ dependencies[project_path] = project_depends
22
+
23
+ result = subprocess.run(
24
+ ["mise", "tasks", "ls", "--all", "--json"], capture_output=True
25
+ )
26
+ if result.stderr:
27
+ raise RuntimeError
28
+ tasks_json = json.loads(result.stdout)
29
+ for task in tasks_json:
30
+ task_names = task["aliases"] + [task["name"]]
31
+ task_name = [name for name in task_names if name.startswith("//")][0]
32
+ project_path = task_name.split(":")[0]
33
+
34
+ if project_path not in dependencies:
35
+ dependencies[project_path] = []
36
+ for dependency in task["depends"]:
37
+ if "/" not in dependency:
38
+ continue
39
+ dependency_project_path = dependency.split(":")[0]
40
+ if dependency_project_path.startswith("."):
41
+ dependency_project_path = project_path + dependency_project_path[1:]
42
+ if dependency_project_path not in dependencies[project_path]:
43
+ dependencies[project_path].append(dependency_project_path)
44
+
45
+ return dependencies
46
+
47
+
48
+ def get_dependency_list(project_path):
49
+ dependencies = get_dependencies()
50
+ dependency_list = []
51
+
52
+ def add_project_dependencies(path):
53
+ for dependency in dependencies[path]:
54
+ if dependency in dependency_list:
55
+ continue
56
+ dependency_list.append(dependency)
57
+ if dependency == project_path:
58
+ continue
59
+ add_project_dependencies(dependency)
60
+
61
+ add_project_dependencies(project_path)
62
+ return dependency_list
63
+
64
+
65
+ if __name__ == "__main__":
66
+ if len(sys.argv) == 1:
67
+ print(json.dumps(get_dependencies()))
68
+ else:
69
+ print(json.dumps(get_dependency_list(sys.argv[1])))
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: mise-helper
3
+ Version: 0.0.1
@@ -0,0 +1,6 @@
1
+ mise.py
2
+ pyproject.toml
3
+ mise_helper.egg-info/PKG-INFO
4
+ mise_helper.egg-info/SOURCES.txt
5
+ mise_helper.egg-info/dependency_links.txt
6
+ mise_helper.egg-info/top_level.txt
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "mise-helper"
3
+ dynamic = ["version"]
4
+
5
+ [build-system]
6
+ requires = ["git-semantic-version", "setuptools >= 64.0"]
7
+
8
+ [tool.setuptools]
9
+ py-modules = ["mise"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+