// CLI spinner utility export class Spinner { private frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; private interval: NodeJS.Timeout | undefined; private frameIndex = 0; private message: string; private isSpinning = false; constructor(message: string = 'Loading...') { this.message = message; } start(): this { if (this.isSpinning) return this; this.isSpinning = true; this.frameIndex = 0; // Hide cursor process.stdout.write('\x1B[?25l'); this.interval = setInterval(() => { process.stdout.write(`\r${this.frames[this.frameIndex]} ${this.message}`); this.frameIndex = (this.frameIndex + 1) % this.frames.length; }, 80); return this; } stop(finalMessage?: string): void { if (!this.isSpinning) return; this.isSpinning = false; if (this.interval) { clearInterval(this.interval); this.interval = undefined; } // Clear line and show cursor process.stdout.write('\r\x1B[K\x1B[?25h'); if (finalMessage) { console.log(finalMessage); } } succeed(message?: string): void { this.stop(`✅ ${message || this.message}`); } fail(message?: string): void { this.stop(`❌ ${message || this.message}`); } updateMessage(message: string): void { this.message = message; } }