Terminal toolkit for colorful logs, loading effects, tables, steps, and CLI output. All functions write to process.stdout or process.stderr unless noted.
import { logSuccess, runStep, showTable } from "scriptdx";Requires Node.js 18+. See README.md for runnable examples.
Write a line with ANSI styling. color is a key of styles (see below). prefix is the left label; message is optional trailing text.
logSuccess(message) / logInfo(message) / logWarning(message) / logError(message) / logQuestion(message)
Convenience loggers with icons (✔, i, ⚠, ✖, ?).
Print a section header with a green divider line, bright title, and optional subtitle.
Print a topic line with ➤ prefix and surrounding blank lines.
Record of ANSI SGR codes: black, red, green, yellow, blue, purple, cyan, white, darkGray, lightRed, lightGreen, lightYellow, lightBlue, lightPurple, lightCyan, brightWhite, plus reset.
Object of chainable color functions: color.black, color.red, color.green, color.yellow, color.blue, color.magenta, color.cyan, color.white. Each returns a string and exposes .bold for bold variant.
| Function | Equivalent |
|---|---|
success |
logSuccess |
info |
logInfo |
warning |
logWarning |
error |
logError |
debug |
logColor("lightPurple", "●", message) |
true when process.platform === "linux".
true when process.platform === "win32".
Cycle frames | / - \\ on stdout. Default repeat = 2, delayMs = 80. If repeat <= 0, loops until interrupted externally.
Rotate characters of text as a loading line. Defaults: repeat = 2, delayMs = 80.
type MenuItem = {
label: string;
run: () => void | Promise<void>;
};Run the menu item at selectedIndex. Logs a warning if the index is invalid.
Run async task while showing a Braille spinner on stderr. On success: clears line and logSuccess(message); returns true. On failure: logError(message); returns false.
Manual spinner control.
Options: intervalMs (default 80), stream (default process.stderr).
Spinner methods:
start(text?)— begin animationstop(finalLine?)— clear line; optionally writefinalLinewith newline
Aligned columns with fixed width (24 chars per column). Returns multi-line string (does not print).
Box-drawn table with dynamic column widths. Returns multi-line string.
string[] — one row of cell values.
Heuristic check that toolName is non-empty and PATH has directories (does not execute the binary).
Split a Record<string, boolean> into { ok: string[], fail: string[] }.
Render word as large block-letter ASCII art (built-in glyph map). Returns multi-line string.
LoggerColor— keyofstylesColorChain— color function with.boldMenuItemSpinner,SpinnerOptionsTableRowToolValidationResult