@syncify/ansi
v0.2.2
Published
ANSI Colors, Symbols and TUI related terminal enchancements for Syncify.
Downloads
67
Readme
@syncify/ansi
Terminal utilities for the Syncify CLI Shopify theme development tool. This module provides CLI enhancements, helpers and various other TUI logic which are used in console logging and reporting for Syncify.
Installation
$ pnpm add @syncify/ansi -D
Colors
Terminal colors are exposed and made available using Ansis. There are custom colors and raw access to Ansis
is available.
Standard Colors
Bright Colors
Custom Colors
Symbols
There are various symbols (characters) available as named exports. Symbols in the CLI are color wrapped and injected into strings when composing logs and messaged etc.
Character Helpers
Character are const
exports, they are output in darkGray
by default.
import {
PIP // |
HSH // #
PLS // +
MIN // -
COM // ,
CHK // ✓
BAD // 𐄂
COL // :
ARR // →
CHV // ▸
ARL // ⥂
TLD // ~
DSH // —
} from '@syncify/ansi'
Infix Wrappers
Infix wrappers are const
exports, they are output in darkGray
by default.
import {
LPR // (
RPR // )
LCB // {
RCB // }
LSB // [
RSB // ]
LAN // <
RAN // >
} from '@syncify/ansi'
Tree Characters
Tree characters available on the Tree
named export and are output in darkGray
by default. Characters are also available in red
and yellow
colors.
import { Tree } from '@syncify/ansi';
Tree.open // ┌─
Tree.stub // ├
Tree.dash // ├─
Tree.line // │
Tree.base // └─
Tree.next // \n│
Tree.after // │\n
Tree.wrap // \n│\n
Tree.indent.edge // ├──┬─
Tree.indent.line // │ │
Tree.indent.stub // │ ├
Tree.indent.dash // │ ├─
Tree.indent.base // │ └─
Tree.indent.fall // ├──┐
Tree Create
Log message generator instance which can be used to compose a complex output log.
import { Create } from '@syncify/ansi';
const message = Create();
message.BR;
message.NL;
message.Break();
message.Context();
message.Dash();
message.End();
message.Error();
message.Get();
message.Inline();
message.Insert();
message.Line();
message.Newline();
message.Pop();
message.Remove();
message.Ruler();
message.Top();
message.Trim();
message.Warn();
message.Wrap();
message.toLine();
message.toRaw();
message.toString();
Spinner
Symbol Spinner utility which will persist a terminal animation.
import { spinner } from '@syncify/ansi';
spinner('loading', {
line: true,
action: {},
color: 'pink',
style: 'spinning'
});
spinner.update('');
spinner.stop();
Progress
Progress bar utility is available on the progress
named export. This function returns an instance with methods.
▰▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱ 50%
Usage
import { progress } from '@syncify/ansi';
const loading = progress(25, {
showPercentage: true,
barColor: 'neonGreen',
percentColor: 'whiteBright',
barSize: 40,
clearOnComplete: false
});
loading.increment(1); // Increment progress
loading.decrement(1); // Decrement progress
loading.render() // Render the progress bar, returns string
loading.stop() // Stop progress
loading.percent // Returns loading percentage
Terminal Size
The module also exposes a helper utility for obtaining the developers terminal size and will return some information about the terminal dimensions.
import { tsize } from '@syncify/ansi';
const {
wrap, // number
cols, // number
row // number
} = size();
Contributing
This package is designed for usage within Syncify. Contributions are not accepted unless they pertain to the core Syncify module. If contributions fall into that category, fork the Syncify project.