import ora, { Ora } from 'ora'; export const createSpinner = (text: string): Ora => { return ora({ text, color: 'yellow' }); }; export const runWithSpinner = async (text: string, fn: () => Promise): Promise => { const spinner = createSpinner(text); spinner.start(); try { const result = await fn(); spinner.succeed(); return result; } catch (error) { // Surface the first line of the error alongside the failed spinner so the user sees // the immediate cause inline with the step that failed. The full error detail is still // printed by the top-level error handler in index.ts. const firstLine = error instanceof Error ? error.message.split('\n')[0] : undefined; spinner.fail(firstLine); throw error; } };