Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / packages/cli/src/lib/logger.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | packages/cli/src/lib/logger.ts |
| Original SHA-256 | 105d8d8566dfc627fc0391a21c31a563d2f6b6e724b94083a6500112bd860fa9 |
| Git blob SHA | b812c0f99e8f872e3b83e208f4ba065d48726f7e |
| Reading-copy SHA-256 | 105d8d8566dfc627fc0391a21c31a563d2f6b6e724b94083a6500112bd860fa9 |
Recovered source transcript
Download complete source text ↓88 lines · 1.8 KB
import * as p from '@clack/prompts'
import pc from 'picocolors'
/**
* Log an informational message.
*/
export function info(message: string): void {
p.log.info(message)
}
/**
* Log a success message.
*/
export function success(message: string): void {
p.log.success(message)
}
/**
* Log a warning message.
*/
export function warn(message: string): void {
p.log.warn(message)
}
/**
* Log an error message.
*/
export function error(message: string): void {
p.log.error(message)
}
/**
* Log a dimmed message for secondary information.
*/
export function dim(message: string): void {
p.log.message(pc.dim(message))
}
/**
* Log a bold heading / step marker.
*/
export function heading(message: string): void {
p.log.step(pc.bold(message))
}
/** Spinner that wraps @clack/prompts spinner with ora-compatible methods. */
export interface Spinner {
/** Start the spinner with optional text override. */
start(text?: string): void
/** Stop the spinner. */
stop(text?: string): void
/** Stop with a green checkmark. */
succeed(text: string): void
/** Stop with a red cross. */
fail(text: string): void
/** Stop with an info icon. */
info(text: string): void
/** Stop with a warning icon. */
warn(text: string): void
}
/**
* Create a spinner with ora-compatible succeed/fail/info/warn methods.
*/
export function spinner(_text?: string): Spinner {
const s = p.spinner()
return {
start(text?: string) {
s.start(text || _text || '')
},
stop(text?: string) {
s.stop(text || '')
},
succeed(text: string) {
s.stop(`${pc.green('✓')} ${text}`)
},
fail(text: string) {
s.stop(`${pc.red('✗')} ${text}`)
},
info(text: string) {
s.stop(`${pc.blue('ℹ')} ${text}`)
},
warn(text: string) {
s.stop(`${pc.yellow('⚠')} ${text}`)
}
}
}