feat(FN-3328): refactor droid-cli into compatibility shim backed by fusion-

Merged FN-3328: Refactored the droid integration by converting `droid-cli` into a lightweight compatibility shim that delegates to `fusion-plugin-droid-runtime`, reducing droid-cli by ~5,400 lines of code while moving the actual runtime logic into the plugin scaffold. Updated the plugin loader to al

Fusion-Task-Id: FN-3328
This commit is contained in:
Fusion
2026-05-04 17:04:31 -07:00
committed by gsxdsm
parent 6ea1fb01e4
commit 7e1768b1b1
21 changed files with 310 additions and 5700 deletions

View File

@@ -1,22 +1,61 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it, vi, beforeEach } from "vitest";
import { EventEmitter } from "node:events";
import { PassThrough } from "node:stream";
const spawnMock = vi.hoisted(() => vi.fn());
vi.mock("node:child_process", () => ({
spawn: vi.fn(() => {
const proc = new EventEmitter() as any;
proc.stdout = new PassThrough();
proc.stderr = new PassThrough();
queueMicrotask(() => proc.emit("error", Object.assign(new Error("not found"), { code: "ENOENT" })));
return proc;
}),
spawn: spawnMock,
}));
import { probeDroidBinary } from "../probe.js";
describe("probeDroidBinary", () => {
beforeEach(() => {
spawnMock.mockReset();
});
it("returns unavailable when binary is missing", async () => {
spawnMock.mockImplementationOnce(() => {
const proc = new EventEmitter() as any;
proc.stdout = new PassThrough();
proc.stderr = new PassThrough();
queueMicrotask(() => proc.emit("error", Object.assign(new Error("not found"), { code: "ENOENT" })));
return proc;
});
const result = await probeDroidBinary({ timeoutMs: 10 });
expect(result.available).toBe(false);
expect(result.reason).toContain("not found");
});
it("returns available and version on success", async () => {
spawnMock.mockImplementationOnce(() => {
const proc = new EventEmitter() as any;
proc.stdout = new PassThrough();
proc.stderr = new PassThrough();
queueMicrotask(() => {
proc.stdout.write("droid 1.2.3\n");
proc.emit("close", 0);
});
return proc;
});
const result = await probeDroidBinary();
expect(result.available).toBe(true);
expect(result.version).toBe("droid 1.2.3");
});
it("uses custom binary path", async () => {
spawnMock.mockImplementationOnce(() => {
const proc = new EventEmitter() as any;
proc.stdout = new PassThrough();
proc.stderr = new PassThrough();
queueMicrotask(() => proc.emit("close", 1));
return proc;
});
await probeDroidBinary({ binaryPath: "/custom/droid" });
expect(spawnMock).toHaveBeenCalledWith("/custom/droid", ["--version"], expect.anything());
});
});