Skip to content

lightgun-poc / lib/cli / CliDeps

Interface: CliDeps

Defined in: lib/cli.ts:33

Everything the CLI touches that a test wants to replace.

Properties

adb?

optional adb?: (port, run) => object

Defined in: lib/cli.ts:38

Runs adb reverse so the phone's localhost:<port> reaches this PC. The mapping dies on cable replug / adb restart — start:adb re-runs it each time. Failure is reported, never thrown; the server starts anyway.

The port is validated and adb is invoked with an argument array (no shell), so nothing that arrives via the CLI can smuggle extra commands in.

Parameters

port

number

run?

AdbRun = runAdb

Returns

object

detail

detail: string

ok

ok: boolean


appDir?

optional appDir?: string

Defined in: lib/cli.ts:46

Directory holding the running program — where the SEA's buttons.json lives.


buildEditor?

optional buildEditor?: (d) => void

Defined in: lib/cli.ts:56

Editor auto-build for serve; tests inject a noop so npm never runs.

Builds the editor when stale, logging what happened. NEVER throws: the server must start regardless of the editor's build health.

Parameters

d

EditorBuildDeps

Returns

void


env?

optional env?: Record<string, string | undefined>

Defined in: lib/cli.ts:40


error?

optional error?: (line) => void

Defined in: lib/cli.ts:36

Parameters

line

string

Returns

void


exec?

optional exec?: (cmd) => string

Defined in: lib/cli.ts:37

Parameters

cmd

string

Returns

string


getAsset?

optional getAsset?: (key) => ArrayBuffer

Defined in: lib/cli.ts:44

sea.getRawAsset, only consulted when isSea.

Parameters

key

string

Returns

ArrayBuffer


isSea?

optional isSea?: boolean

Defined in: lib/cli.ts:42

True inside the single executable: assets are embedded, not on disk.


loadFfi?

optional loadFfi?: () => Promise<Ffi>

Defined in: lib/cli.ts:50

FFI loader for monitors; tests inject one so no real user32 is called.

Returns

Promise<Ffi>


loadNative?

optional loadNative?: () => Promise<LibNut>

Defined in: lib/cli.ts:48

Native addon loader for check; tests inject one so no real device is touched.

Returns

Promise<LibNut>


log?

optional log?: (line) => void

Defined in: lib/cli.ts:35

Parameters

line

string

Returns

void


onShutdown?

optional onShutdown?: (fn) => void

Defined in: lib/cli.ts:54

Registers teardown; tests inject one to avoid real signal handlers.

Parameters

fn

() => void

Returns

void


platform?

optional platform?: string

Defined in: lib/cli.ts:39


start?

optional start?: (opts) => Promise<RunningServer>

Defined in: lib/cli.ts:34

Boots the whole PC side: static file serving, WebSocket intake, aim the 2ms newest-wins cursor loop, button execution and jitter stats.

Parameters

opts?

ServerOptions = {}

Returns

Promise<RunningServer>


tunnel?

optional tunnel?: (port, d) => Promise<Tunnel>

Defined in: lib/cli.ts:52

Public-tunnel starter; tests inject one so no agent is ever spawned.

Brings up (or adopts) an ngrok endpoint for port.

The URL comes from the agent's documented local API rather than by scraping its log lines, and an agent that is already running is reused instead of fought with — the free plan allows one session, so spawning a second one just fails.

Parameters

port

number

d?

NgrokDeps = {}

Returns

Promise<Tunnel>

Throws

When the binary is missing, the agent dies, or no endpoint appears before timeoutMs. Callers are expected to keep serving anyway: a tunnel is a convenience, and the USB and LAN flows are unaffected by its absence.

Released under the MIT License.