UNPKG

typescript-runtime-schemas

Version:

A TypeScript schema generation tool that extracts Zod schemas from TypeScript source files with runtime validation support. Generate validation schemas directly from your existing TypeScript types with support for computed types and constraint-based valid

63 lines 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProgressIndicator = void 0; exports.handleError = handleError; exports.logInfo = logInfo; /** * Handle CLI errors with consistent formatting */ function handleError(error, context) { if (process.argv.includes('--verbose')) { console.error(`❌ ${context}:`); console.error(error); } else { const message = error instanceof Error ? error.message : String(error); console.error(`❌ ${context}: ${message}`); } process.exit(1); } /** * Log information unless quiet mode is enabled */ function logInfo(message) { if (!process.argv.includes('--quiet')) { console.error(message); } } /** * Create a spinner-like progress indicator */ class ProgressIndicator { constructor() { this.interval = null; this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; this.currentFrame = 0; } start(message) { if (process.argv.includes('--quiet')) { return; } process.stderr.write(`${this.frames[0]} ${message}`); this.interval = setInterval(() => { this.currentFrame = (this.currentFrame + 1) % this.frames.length; process.stderr.write(`\r${this.frames[this.currentFrame]} ${message}`); }, 100); } stop(finalMessage) { if (this.interval) { clearInterval(this.interval); this.interval = null; } if (!process.argv.includes('--quiet')) { if (finalMessage) { process.stderr.write(`\r✅ ${finalMessage}\n`); } else { process.stderr.write('\r'); } } } } exports.ProgressIndicator = ProgressIndicator; //# sourceMappingURL=utils.js.map