Skip to content

Commit 8a1e3eb

Browse files
committed
refactor: migrer la CLI vers Ui/Cli
1 parent e4ec83a commit 8a1e3eb

17 files changed

Lines changed: 674 additions & 2769 deletions

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ python -m OnlyMod.EngineOnlyMod --engine nuitka -f script.py --dry-run
199199

200200
## Project layout
201201

202-
- `Ui/Cli/` — active ARK CLI entrypoints and command tree.
203-
- `cli/` — shared runtime and headless helper modules kept during the CLI migration.
202+
- `Ui/Cli/` — active ARK CLI entrypoints, runtime helpers, discovery, and command tree.
204203
- `Core/` — main UI logic.
205204
- `Core/IdeLikeGui/` — wiring layer for the IDE-like main GUI.
206205
- `ENGINES/` — built-in engines.

Ui/Cli/app.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
from pathlib import Path
66
from typing import Any
77

8-
from cli.runtime import install_runtime, should_enable_qt
8+
from .runtime import install_runtime, should_enable_qt
99

1010
from .spec_helpers import (
1111
CliSpecError,
12-
build_context_from_ark_config,
13-
build_context_from_lock,
12+
build_context_object_from_ark_config,
13+
build_context_object_from_lock,
1414
build_lock_payload,
1515
cache_rebuild_lock,
1616
compare_lock_payloads,
1717
default_lock_path,
18+
engine_config_from_lock,
1819
init_workspace,
1920
launch_gui,
2021
list_engines_payload,
@@ -62,6 +63,17 @@ def _resolve_version() -> str:
6263
return "unknown"
6364

6465

66+
def _ensure_engine_known(engine_id: str) -> None:
67+
payload = list_engines_payload()
68+
known_ids = {
69+
str(item.get("id") or "").strip()
70+
for item in payload.get("engines", [])
71+
if isinstance(item, dict)
72+
}
73+
if engine_id not in known_ids:
74+
raise CliSpecError(f"build.engine: unknown engine '{engine_id}'")
75+
76+
6577
def _build_impl(
6678
*,
6779
workspace: Path,
@@ -78,19 +90,22 @@ def _build_impl(
7890
config = load_ark_config(workspace)
7991
validated = validate_ark_config(workspace, config)
8092
engine_id = engine_override or str(validated.config["build"]["engine"])
93+
_ensure_engine_known(engine_id)
8194
lock_payload = build_lock_payload(workspace, validated.config, engine_id=engine_id)
8295
lock_paths = write_lock_files(workspace, lock_payload)
96+
context = build_context_object_from_ark_config(validated.config)
8397
result = run_engine_compile(
8498
workspace=workspace,
8599
engine_id=engine_id,
86-
entry_file=str(validated.config["project"]["entry"]),
100+
context=context,
101+
engine_config=engine_config_from_lock(lock_payload),
87102
)
88103
payload = {
89104
"mode": "build",
90105
"engine": engine_id,
91106
"warnings": validated.warnings,
92107
"lock": lock_paths,
93-
"build_context": build_context_from_ark_config(validated.config),
108+
"build_context": context.to_dict(),
94109
"result": result,
95110
}
96111
if as_json:
@@ -120,11 +135,18 @@ def _build_impl(
120135
entry_file = str(((lock_payload.get("project") or {}).get("entry")) or "").strip()
121136
if not engine_id or not entry_file:
122137
raise CliSpecError("Invalid lock file: missing engine.name or project.entry")
138+
entry_path = workspace / Path(entry_file)
139+
if not entry_path.is_file():
140+
raise CliSpecError(
141+
f"Invalid lock file: project.entry '{entry_file}' is missing or obsolete"
142+
)
123143

144+
context = build_context_object_from_lock(lock_payload)
124145
result = run_engine_compile(
125146
workspace=workspace,
126147
engine_id=engine_id,
127-
entry_file=entry_file,
148+
context=context,
149+
engine_config=engine_config_from_lock(lock_payload),
128150
)
129151

130152
comparison = None
@@ -150,7 +172,7 @@ def _build_impl(
150172
"warnings": warnings,
151173
"comparison_ok": comparison,
152174
"comparison_lock": rebuild_cache,
153-
"build_context": build_context_from_lock(lock_payload),
175+
"build_context": context.to_dict(),
154176
"result": result,
155177
}
156178
if as_json:
@@ -374,4 +396,3 @@ def main(argv: list[str] | None = None) -> int:
374396
exc.show()
375397
return int(getattr(exc, "exit_code", 2))
376398
raise
377-

0 commit comments

Comments
 (0)