feat: added recursive package resolution

This commit is contained in:
Jordan ⌨️ 2023-05-29 17:36:24 +02:00
parent 1c5e369926
commit 2fd545f313

View file

@ -9,6 +9,7 @@ from typing import Callable, cast
from cutekit import context, shell, const, vt100, builder, graph, project from cutekit import context, shell, const, vt100, builder, graph, project
from cutekit.args import Args from cutekit.args import Args
from cutekit.model import Extern
from cutekit.context import contextFor from cutekit.context import contextFor
Callback = Callable[[Args], None] Callback = Callable[[Args], None]
@ -210,14 +211,8 @@ def graphCmd(args: Args):
cmds += [Cmd("g", "graph", "Show dependency graph", graphCmd)] cmds += [Cmd("g", "graph", "Show dependency graph", graphCmd)]
def installCmd(args: Args): def grabExtern(extern: dict[str, Extern]):
project.chdir() for extSpec, ext in extern.items():
pj = context.loadProject(".")
for extSpec in pj.extern:
ext = pj.extern[extSpec]
extPath = os.path.join(const.EXTERN_DIR, extSpec) extPath = os.path.join(const.EXTERN_DIR, extSpec)
if os.path.exists(extPath): if os.path.exists(extPath):
@ -228,6 +223,16 @@ def installCmd(args: Args):
shell.popen("git", "clone", "--depth", "1", "--branch", shell.popen("git", "clone", "--depth", "1", "--branch",
ext.tag, ext.git, extPath) ext.tag, ext.git, extPath)
if os.path.exists(os.path.join(extPath, "project.json")):
grabExtern(context.loadProject(extPath).extern)
def installCmd(args: Args):
project.chdir()
pj = context.loadProject(".")
grabExtern(pj.extern)
cmds += [Cmd("i", "install", "Install all the external packages", installCmd)] cmds += [Cmd("i", "install", "Install all the external packages", installCmd)]