()
| 20 | import { trackBrowserInstall, trackCommandFailure } from "../telemetry/events.js"; |
| 21 | |
| 22 | async 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(); |
no test coverage detected