mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
feat(headroom): activate/uninstall extras + fix interpreter detection
- find interpreter next to headroom binary so extras/version read correctly - add on/off toggle to activate [code]/[ml] via proxy restart - add uninstall action + live install log progress + ~1GB confirm modal
This commit is contained in:
@@ -38,23 +38,22 @@ describe("headroom detect", () => {
|
||||
});
|
||||
|
||||
it("prefers the interpreter that actually has headroom-ai installed", () => {
|
||||
// headroom binary lives in a bin dir; the python next to it has headroom-ai.
|
||||
const binPython = "/opt/hr/bin/python3";
|
||||
mocks.execSync.mockImplementation((cmd) => {
|
||||
if (String(cmd).includes("where") || String(cmd).includes("which")) return Buffer.from("C:/Python/Scripts/headroom.exe\n");
|
||||
if (String(cmd).includes("python3 --version")) return Buffer.from("Python 3.13.0\n");
|
||||
if (String(cmd).includes("python --version")) return Buffer.from("Python 3.13.0\n");
|
||||
if (String(cmd).includes("where") || String(cmd).includes("which")) return Buffer.from("/opt/hr/bin/headroom\n");
|
||||
if (String(cmd).includes("--version")) return Buffer.from("Python 3.13.0\n");
|
||||
throw new Error("unexpected execSync");
|
||||
});
|
||||
mocks.execFileSync.mockImplementation((py, args) => {
|
||||
if (py === "python3" && args.join(" ") === "-m pip show headroom-ai") throw new Error("not installed in python3");
|
||||
if (py === "python" && args.join(" ") === "-m pip show headroom-ai") return Buffer.from("Name: headroom-ai\nVersion: 0.26.0\n");
|
||||
if (py === "python" && args.join(" ").startsWith("-m pip list ")) return Buffer.from(JSON.stringify([
|
||||
{ name: "headroom-ai", version: "0.26.0" },
|
||||
{ name: "tree-sitter", version: "0.25.0" },
|
||||
]));
|
||||
if (args.join(" ") === "-m pip show headroom-ai") {
|
||||
if (py === binPython) return Buffer.from("Name: headroom-ai\nVersion: 0.26.0\n");
|
||||
throw new Error(`not installed in ${py}`);
|
||||
}
|
||||
throw new Error(`unexpected execFileSync: ${py} ${args.join(" ")}`);
|
||||
});
|
||||
|
||||
expect(findPython310()).toBe("python");
|
||||
expect(findPython310()).toBe(binPython);
|
||||
});
|
||||
|
||||
it("keeps top-level installed flag true when extras are readable", async () => {
|
||||
|
||||
Reference in New Issue
Block a user