@reliverse/relico 1.1.0 β 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +246 -100
- package/bin/mod.d.ts +364 -0
- package/bin/mod.js +1187 -0
- package/bin/utils.d.ts +4 -0
- package/bin/utils.js +10 -0
- package/package.json +16 -15
- package/bin/main.d.ts +0 -124
- package/bin/main.js +0 -369
package/README.md
CHANGED
|
@@ -1,163 +1,309 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reliverse Relico
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[π Docs](.github/DOCS.md) β’ [π¦ NPM](https://npmjs.com/package/@reliverse/relico) β’ [π GitHub](https://github.com/reliverse/relico)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<a href="https://npmjs.org/package/@reliverse/relico">
|
|
7
|
-
<img src="https://img.shields.io/npm/v/@reliverse/relico.svg" alt="version" />
|
|
8
|
-
</a>
|
|
9
|
-
<a href="https://npmjs.org/package/@reliverse/relico">
|
|
10
|
-
<img src="https://img.shields.io/npm/dm/@reliverse/relico.svg" alt="downloads" />
|
|
11
|
-
</a>
|
|
12
|
-
</p>
|
|
5
|
+
> @reliverse/relico is a themeable, chainable, typed, truecolor-powered terminal styling toolkit β built for humans, not just terminals. It makes your CLI output beautiful, accessible, and expressive β with developer-first ergonomics, smart config, and blazing-fast performance.
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
## π Why Relico?
|
|
8
|
+
|
|
9
|
+
Because terminal styling shouldnβt feel like duct tape. **Relico** brings design-system-level polish to your CLI logs, banners, errors, and output β without battling your runtime, shell, or platform. Terminal styling should be *fun*, not frustrating. Relico makes it feel *right*.
|
|
10
|
+
|
|
11
|
+
- π¨ **80+ built-in colors** β easily customize or override with your own [`HEX`](https://chatgpt.com/share/67fd24cd-e7b0-8008-a815-f33d01f33758) palette
|
|
12
|
+
- π§© **Themeable by default** β end-users can configure themes+typography+colors via `relico.config.ts`, developers via `await initUserConfig({ ... })`
|
|
13
|
+
- π **Smart color detection** β full support for truecolor (16M), 256-color, and fallback modes across environments
|
|
14
|
+
- π¦ **A modern alternative** to `chalk`, `kleur`, `colorette`, `gradient-string`, and legacy console hacks
|
|
15
|
+
- π§ **Typed, chainable, DX-optimized** β with autocompletion, inline docs, and expressive API ergonomics
|
|
16
|
+
- πΏ **Respects your environment** β including `NO_COLOR`, `FORCE_COLOR`, and terminal capabilities
|
|
17
|
+
- β‘ **Blazing-fast & lightweight** β zero bloat, runtime-safe, build-time aware, minimal dependencies
|
|
18
|
+
- π‘οΈ **Cross-platform & runtime-ready** β works everywhere β even when your users' terminals are weird β in Node.js, Bun, Deno, CI, Windows, macOS, Linux, Docker & more
|
|
19
|
+
- π― **Precision-crafted ANSI output** β every color, reset, and style code is finely tuned for contrast, legibility, and glitch-free rendering β even in flaky terminals (as far as Node.js permits)
|
|
20
|
+
- π¦Ύ **Relico isnβt just about color** β itβs about communication β make your CLI users' output more than readable β make it feel *intentional*.
|
|
21
|
+
|
|
22
|
+
<img src="example.png" width="50%" alt="Available Relico colors" />
|
|
15
23
|
|
|
16
24
|
## Installation
|
|
17
25
|
|
|
18
|
-
```
|
|
19
|
-
bun add @reliverse/relico
|
|
26
|
+
```bash
|
|
27
|
+
bun add @reliverse/relico
|
|
28
|
+
# bun β’ pnpm β’ yarn β’ npm
|
|
20
29
|
```
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
**If you're end-user OR developer, create `relico.config.ts` in your root**:
|
|
23
34
|
|
|
24
35
|
```ts
|
|
25
36
|
import { defineConfig } from "@reliverse/relico";
|
|
26
37
|
|
|
27
38
|
export default defineConfig({
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
// Choose the theme: "primary" or "secondary"
|
|
31
|
-
theme: "secondary",
|
|
32
|
-
// Override specific colors
|
|
33
|
-
// Use Intellisense to see the available colors
|
|
39
|
+
colorLevel: 3, // 0 = off, 1 = basic, 2 = 256, 3 = truecolor
|
|
40
|
+
theme: "primary", // or "secondary"
|
|
34
41
|
customColors: {
|
|
42
|
+
// ["primary", "secondary"]:
|
|
35
43
|
blue: ["#5f87ff", "#5f87ff"],
|
|
36
44
|
red: ["#ff5555", "#ff0000"],
|
|
37
45
|
green: ["#00ff00", "#00cc00"],
|
|
38
|
-
// Note: The following text formatting
|
|
39
|
-
// colors can be defined only via ANSI:
|
|
40
|
-
// reset: ["\x1b[0m", "\x1b[0m"],
|
|
41
|
-
// bold: ["\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"],
|
|
42
|
-
// dim: ["\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"],
|
|
43
|
-
// italic: ["\x1b[3m", "\x1b[23m"],
|
|
44
|
-
// underline: ["\x1b[4m", "\x1b[24m"],
|
|
45
|
-
// inverse: ["\x1b[7m", "\x1b[27m"],
|
|
46
|
-
// hidden: ["\x1b[8m", "\x1b[28m"],
|
|
47
|
-
// strikethrough: ["\x1b[9m", "\x1b[29m"],
|
|
48
46
|
},
|
|
49
47
|
});
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
**
|
|
50
|
+
**If you're developer, initialize in your app (optional)**:
|
|
53
51
|
|
|
54
52
|
```ts
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
53
|
+
import { initUserConfig, re } from "@reliverse/relico";
|
|
54
|
+
|
|
55
|
+
// Use this to override Relico's
|
|
56
|
+
// default settings for your app
|
|
57
|
+
// (relico.config.ts takes precedence)
|
|
58
|
+
await initUserConfig({ ... });
|
|
59
|
+
console.log(re.info("Custom config loaded!"));
|
|
62
60
|
```
|
|
63
61
|
|
|
64
|
-
##
|
|
62
|
+
## API Sneak Peek
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- **Multiple Color Levels**: Supports different color levels (none, basic, 256-color, truecolor)
|
|
69
|
-
- **Flexible API**: Multiple ways to apply colors (object syntax, functions, RGB)
|
|
70
|
-
- **Windows Support**: Special color handling for Windows Terminal
|
|
71
|
-
- **Environment Aware**: Respects NO_COLOR and FORCE_COLOR environment variables
|
|
64
|
+
```ts
|
|
65
|
+
import { re, colorize, rgb } from "@reliverse/relico";
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
console.log(re.red("Red!"));
|
|
68
|
+
console.log(re.bold(re.green("Bold green")));
|
|
69
|
+
console.log(colorize("magenta", "Hello!"));
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
console.log(rgb(250, 128, 114)("This is salmon"));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Styles Available
|
|
75
|
+
|
|
76
|
+
### Text Colors
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(re.blue("This is blue text"));
|
|
78
|
+
- `re.red("...")`, `re.blue("...")`, `re.greenBright("...")`, ...
|
|
79
|
+
- `re.gray("...")`, `re.whiteBright("...")`
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
console.log(re.bold(re.green("Bold green text")));
|
|
81
|
+
### Backgrounds
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
console.log(colorize("magenta", "This is magenta text"));
|
|
83
|
+
- `re.bgRed("...")`, `re.bgBlueBright("...")`, ...
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
### Text Effects
|
|
86
|
+
|
|
87
|
+
- `re.bold("...")`, `re.italic("...")`, `re.strikethrough("...")`, ...
|
|
88
|
+
|
|
89
|
+
All styles are **composable**:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// Classic way:
|
|
93
|
+
re.bold(re.bgBlue(re.white("YEP!")));
|
|
94
|
+
// Chained way (recommended):
|
|
95
|
+
const boldRed = chain(re.bold, re.red); // go to "chain() Function Examples" section to learn more
|
|
96
|
+
console.log(boldRed("This text is bold and red"));
|
|
91
97
|
```
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
### Supported Colors, Backgrounds & Modifiers
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
| **Modifiers** | **Base Colors** | **Bright Colors** | **Pastel Colors** | **Extra Colors** | **Grayscale** | **Backgrounds** | **Bright Backgrounds** | **Pastel Backgrounds** | **Extra Backgrounds** |
|
|
102
|
+
|---------------- |------------------ |------------------ |------------------ |------------------|------------------ |-----------------|----------------------- |----------------------- |---------------------- |
|
|
103
|
+
| `reset` | `black` | `blackBright` | `redPastel` | `orange` | `gray10` | `bgBlack` | `bgBlackBright` | `bgRedPastel` | `bgOrange` |
|
|
104
|
+
| `bold` | `red` | `redBright` | `greenPastel` | `pink` | `gray20` | `bgRed` | `bgRedBright` | `bgGreenPastel` | `bgPink` |
|
|
105
|
+
| `dim` | `green` | `greenBright` | `yellowPastel` | `purple` | `gray30` | `bgGreen` | `bgGreenBright` | `bgYellowPastel` | `bgPurple` |
|
|
106
|
+
| `italic` | `yellow` | `yellowBright` | `bluePastel` | `teal` | `gray40` | `bgYellow` | `bgYellowBright` | `bgBluePastel` | `bgTeal` |
|
|
107
|
+
| `underline` | `blue` | `blueBright` | `magentaPastel` | `lime` | `gray50`===`gray` | `bgBlue` | `bgBlueBright` | `bgMagentaPastel` | `bgLime` |
|
|
108
|
+
| `inverse` | `magenta` | `magentaBright` | `cyanPastel` | `brown` | `gray60` | `bgMagenta` | `bgMagentaBright` | `bgCyanPastel` | `bgBrown` |
|
|
109
|
+
| `strikethrough` | `cyan` | `cyanBright` | | `navy` | `gray70` | `bgCyan` | `bgCyanBright` | | `bgNavy` |
|
|
110
|
+
| `hidden` | `white` | `whiteBright` | | `maroon` | `gray80` | `bgWhite` | `bgWhiteBright` | | `bgMaroon` |
|
|
111
|
+
| | `gray`===`gray50` | | | `olive` | `gray90` | | | | `bgOlive` |
|
|
112
|
+
| | | | | `olive` | | | | | `bgSilver` |
|
|
96
113
|
|
|
97
|
-
|
|
98
|
-
- Level 1: Basic color support
|
|
99
|
-
- Level 2: 256 color support
|
|
100
|
-
- Level 3: Truecolor (16 million colors) support
|
|
114
|
+
### Want to Get Only Certain Colors?
|
|
101
115
|
|
|
102
|
-
|
|
116
|
+
```ts
|
|
117
|
+
import type { DefaultColorKeys } from "@reliverse/relico";
|
|
118
|
+
const brandColors: DefaultColorKeys[] = ["magentaBright", "maroon"];
|
|
119
|
+
```
|
|
103
120
|
|
|
104
|
-
|
|
121
|
+
## Color Detection
|
|
122
|
+
|
|
123
|
+
Relico detects your terminalβs capability:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
105
126
|
import { colorSupport } from "@reliverse/relico";
|
|
106
127
|
|
|
107
|
-
console.log(
|
|
108
|
-
console.log(
|
|
109
|
-
console.log("Colors Forced:", colorSupport.isForced);
|
|
110
|
-
console.log("Colors Disabled:", colorSupport.isDisabled);
|
|
128
|
+
console.log(colorSupport.terminalName); // iTerm2, Windows Terminal, etc.
|
|
129
|
+
console.log(colorSupport.level); // 0, 1, 2, or 3
|
|
111
130
|
```
|
|
112
131
|
|
|
113
|
-
|
|
132
|
+
**Supports**:
|
|
114
133
|
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
- **Background Colors**: `bgRed`, `bgGreen`, `bgBlue`, etc.
|
|
118
|
-
- **Text Styles**: `bold`, `dim`, `italic`, `underline`, `inverse`, `hidden`, `strikethrough`
|
|
134
|
+
- `NO_COLOR`
|
|
135
|
+
- `FORCE_COLOR=1` (or 0/2/3)
|
|
119
136
|
|
|
120
|
-
##
|
|
137
|
+
## Advanced Features
|
|
138
|
+
|
|
139
|
+
### Custom RGB + Hex
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { rgb, bgHex, hex } from "@reliverse/relico";
|
|
143
|
+
|
|
144
|
+
console.log(rgb(255, 105, 180)("Hot pink"));
|
|
145
|
+
console.log(bgHex("#1e90ff")("Dodger blue background"));
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Gradients & Rainbow
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { gradient, multiGradient, rainbow } from "@reliverse/relico";
|
|
152
|
+
|
|
153
|
+
console.log(rainbow("π Woohoo!"));
|
|
154
|
+
console.log(gradient("From red to blue", "#ff0000", "#0000ff"));
|
|
155
|
+
```
|
|
121
156
|
|
|
122
|
-
|
|
157
|
+
## `chain()` Function
|
|
158
|
+
|
|
159
|
+
This function allows you to combine multiple color formatters into a single formatter function. This is useful for creating complex styles that apply multiple effects to text.
|
|
160
|
+
|
|
161
|
+
## Basic Usage
|
|
123
162
|
|
|
124
163
|
```typescript
|
|
125
|
-
import {
|
|
164
|
+
import { re, chain } from "@reliverse/relico";
|
|
126
165
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
166
|
+
// Create a custom style that combines bold and red text
|
|
167
|
+
const boldRed = chain(re.bold, re.red);
|
|
168
|
+
console.log(boldRed("This text is bold and red"));
|
|
169
|
+
|
|
170
|
+
// Create a warning style with yellow text on a dark background
|
|
171
|
+
const warning = chain(re.yellow, re.bgBlack);
|
|
172
|
+
console.log(warning("Warning: This operation might take a while"));
|
|
173
|
+
|
|
174
|
+
// Chain three or more styles
|
|
175
|
+
const importantError = chain(re.bold, re.underline, re.red);
|
|
176
|
+
console.log(importantError("CRITICAL ERROR: System failure"));
|
|
134
177
|
```
|
|
135
178
|
|
|
136
|
-
##
|
|
179
|
+
## Creating Theme Combinations
|
|
137
180
|
|
|
138
|
-
|
|
181
|
+
```typescript
|
|
182
|
+
import { re, chain } from "@reliverse/relico";
|
|
183
|
+
|
|
184
|
+
// Create themed message styles
|
|
185
|
+
const successStyle = chain(re.bold, re.green);
|
|
186
|
+
const errorStyle = chain(re.bold, re.red);
|
|
187
|
+
const infoStyle = chain(re.blue, re.italic);
|
|
188
|
+
const warnStyle = chain(re.yellow, re.bold);
|
|
189
|
+
|
|
190
|
+
// Use them in your application
|
|
191
|
+
console.log(successStyle("β Operation completed successfully"));
|
|
192
|
+
console.log(errorStyle("β Failed to connect to server"));
|
|
193
|
+
console.log(infoStyle("βΉ Running in development mode"));
|
|
194
|
+
console.log(warnStyle("β API rate limit approaching"));
|
|
195
|
+
```
|
|
139
196
|
|
|
140
|
-
|
|
141
|
-
- Text styling
|
|
142
|
-
- Background colors
|
|
143
|
-
- RGB colors
|
|
144
|
-
- Color level switching
|
|
145
|
-
- Terminal detection
|
|
197
|
+
## Custom RGB Combinations
|
|
146
198
|
|
|
147
|
-
|
|
199
|
+
```typescript
|
|
200
|
+
import { re, rgb, bgRgb, chain } from "@reliverse/relico";
|
|
201
|
+
|
|
202
|
+
// Create a custom color scheme with RGB values
|
|
203
|
+
const customHeader = chain(
|
|
204
|
+
rgb(255, 105, 180), // Hot pink text
|
|
205
|
+
bgRgb(25, 25, 25) // Dark gray background
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// Create a "danger" style with custom red and bold
|
|
209
|
+
const danger = chain(
|
|
210
|
+
rgb(220, 20, 60), // Crimson text
|
|
211
|
+
re.bold,
|
|
212
|
+
re.underline
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
console.log(customHeader(" SYSTEM STATUS "));
|
|
216
|
+
console.log(danger("Danger: High voltage detected!"));
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Multiline Text Handling
|
|
220
|
+
|
|
221
|
+
The `chain()` function automatically handles multiline text to prevent style leakage:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { re, chain } from "@reliverse/relico";
|
|
225
|
+
|
|
226
|
+
const highlight = chain(re.bgYellow, re.black, re.bold);
|
|
148
227
|
|
|
149
|
-
|
|
228
|
+
const multilineText = `This is line one
|
|
229
|
+
This is line two
|
|
230
|
+
This is line three`;
|
|
231
|
+
|
|
232
|
+
// Each line is properly wrapped with start/end codes
|
|
233
|
+
console.log(highlight(multilineText));
|
|
234
|
+
```
|
|
150
235
|
|
|
151
|
-
|
|
152
|
-
|
|
236
|
+
## Creating a Simple Logger
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import { re, chain } from "@reliverse/relico";
|
|
240
|
+
|
|
241
|
+
// Create logger styles
|
|
242
|
+
const styles = {
|
|
243
|
+
info: chain(re.blue, re.bold),
|
|
244
|
+
success: chain(re.green, re.bold),
|
|
245
|
+
warning: chain(re.yellow, re.bold),
|
|
246
|
+
error: chain(re.red, re.bold),
|
|
247
|
+
debug: chain(re.magenta, re.dim)
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// Simple logger implementation
|
|
251
|
+
const logger = {
|
|
252
|
+
info: (msg) => console.log(styles.info("INFO"), msg),
|
|
253
|
+
success: (msg) => console.log(styles.success("SUCCESS"), msg),
|
|
254
|
+
warning: (msg) => console.log(styles.warning("WARNING"), msg),
|
|
255
|
+
error: (msg) => console.log(styles.error("ERROR"), msg),
|
|
256
|
+
debug: (msg) => console.log(styles.debug("DEBUG"), msg)
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Usage
|
|
260
|
+
logger.info("Application started");
|
|
261
|
+
logger.success("Data loaded successfully");
|
|
262
|
+
logger.warning("Cache expired, refreshing data");
|
|
263
|
+
logger.error("Failed to connect to database");
|
|
264
|
+
logger.debug("Request payload: " + JSON.stringify({id: 123}));
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
This allows you to create powerful, reusable style combinations for your terminal applications.
|
|
268
|
+
|
|
269
|
+
## Local Playground
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
git clone https://github.com/reliverse/relico
|
|
153
273
|
cd relico
|
|
154
274
|
bun i
|
|
275
|
+
bun dev
|
|
155
276
|
```
|
|
156
277
|
|
|
157
|
-
|
|
278
|
+
Check `examples/e-mod.ts` for all the fun.
|
|
279
|
+
|
|
280
|
+
## Use Cases
|
|
281
|
+
|
|
282
|
+
- Beautiful CLI banners & success/error messages
|
|
283
|
+
- Colored logger outputs
|
|
284
|
+
- DX-enhanced terminal tools
|
|
285
|
+
- Custom internal design systems for CLIs
|
|
158
286
|
|
|
159
|
-
|
|
287
|
+
## Related
|
|
288
|
+
|
|
289
|
+
- [`chalk`](https://github.com/chalk/chalk) β the classic
|
|
290
|
+
- [`kleur`](https://github.com/lukeed/kleur) β performance-driven
|
|
291
|
+
- [`colorette`](https://github.com/jorgebucaran/colorette) β super tiny
|
|
292
|
+
|
|
293
|
+
Relico draws inspiration from all β and goes beyond them with modern configs, types, theming, and composability.
|
|
294
|
+
|
|
295
|
+
## π Contributing
|
|
296
|
+
|
|
297
|
+
Weβd love your help! Bug? Feature? Example? PR it!
|
|
298
|
+
Or hop into [Discord](https://discord.gg/Pb8uKbwpsJ) to discuss CLI theming and terminal art π
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
git clone https://github.com/reliverse/relico
|
|
302
|
+
cd relico
|
|
303
|
+
bun i
|
|
304
|
+
```
|
|
160
305
|
|
|
161
306
|
## License
|
|
162
307
|
|
|
163
|
-
|
|
308
|
+
MIT Β© [blefnk Nazar Kornienko](https://github.com/blefnk)
|
|
309
|
+
Part of the [Reliverse](https://github.com/reliverse) ecosystem
|