MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runEnsure

Function runEnsure

packages/cli/src/commands/browser.ts:22–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20import { trackBrowserInstall, trackCommandFailure } from "../telemetry/events.js";
21
22async function runEnsure(): Promise<void> {
23 clack.intro(c.bold("hyperframes browser ensure"));
24
25 // ARM64 Linux: Chrome headless shell is not available.
26 // Try to find system Chromium first, then attempt auto-install via apt.
27 if (isLinuxArm()) {
28 const s = clack.spinner();
29 s.start("Linux ARM64 detected — looking for system Chromium...");
30 const existing = await findBrowser();
31 if (existing) {
32 s.stop(c.success("System Chromium found"));
33 console.log();
34 console.log(` ${c.dim("Source:")} ${c.bold(existing.source)}`);
35 console.log(` ${c.dim("Path:")} ${c.bold(existing.executablePath)}`);
36 console.log();
37 clack.outro(c.success("Ready to render."));
38 return;
39 }
40
41 s.stop(c.warn("No Chromium found — attempting auto-install via apt-get..."));
42 console.log();
43
44 // Delegate to ensureBrowser which handles the full ARM64 install flow.
45 try {
46 const result = await ensureBrowser();
47 console.log();
48 console.log(` ${c.dim("Source:")} ${c.bold(result.source)}`);
49 console.log(` ${c.dim("Path:")} ${c.bold(result.executablePath)}`);
50 console.log();
51 clack.outro(c.success("Chromium ready. You can now render on ARM64."));
52 } catch (err) {
53 // The ARM64 auto-install failed: the browser is NOT ready, so this is a
54 // real failure (exit 1), not a success. Report it and stop swallowing.
55 trackCommandFailure("browser", err);
56 clack.log.error(err instanceof Error ? err.message : String(err));
57 clack.outro(c.warn("Manual setup required (see instructions above)."));
58 process.exit(1);
59 }
60 return;
61 }
62
63 const s = clack.spinner();
64 s.start("Looking for an existing browser...");
65
66 const existing = await findBrowser();
67 if (existing) {
68 s.stop(c.success("Browser found"));
69 console.log();
70 console.log(` ${c.dim("Source:")} ${c.bold(existing.source)}`);
71 console.log(` ${c.dim("Path:")} ${c.bold(existing.executablePath)}`);
72 console.log();
73 clack.outro(c.success("Ready to render."));
74 return;
75 }
76
77 s.stop("No browser found — downloading");
78
79 const downloadSpinner = clack.spinner();

Callers 1

runFunction · 0.85

Calls 10

isLinuxArmFunction · 0.85
findBrowserFunction · 0.85
ensureBrowserFunction · 0.85
trackCommandFailureFunction · 0.85
trackBrowserInstallFunction · 0.85
warnMethod · 0.80
errorMethod · 0.80
formatBytesFunction · 0.50
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected