@reliverse/relinka 1.2.0 → 1.2.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 +37 -41
- package/dist-npm/components/core/core.d.ts +2 -0
- package/dist-npm/components/core/core.js +2 -0
- package/dist-npm/{utils/constants.d.ts → components/levels/levels.d.ts} +1 -1
- package/dist-npm/components/{prompts/create.d.ts → modes/basic.d.ts} +3 -3
- package/dist-npm/components/{instance → modes}/basic.js +4 -4
- package/dist-npm/components/{instance → modes}/browser.d.ts +2 -2
- package/dist-npm/components/modes/browser.js +12 -0
- package/dist-npm/components/modes/shared.d.ts +5 -0
- package/dist-npm/components/modes/shared.js +2 -0
- package/dist-npm/components/{prompts → relinka}/relinka.d.ts +2 -4
- package/dist-npm/components/{prompts → relinka}/relinka.js +1 -7
- package/dist-npm/components/{instance/reporter → reporters}/basic.d.ts +1 -1
- package/dist-npm/components/{instance/reporter → reporters}/basic.js +2 -2
- package/dist-npm/components/{instance/reporter → reporters}/browser.d.ts +1 -1
- package/dist-npm/components/{instance/reporter → reporters}/fancy.d.ts +3 -3
- package/dist-npm/components/{instance/reporter → reporters}/fancy.js +5 -7
- package/dist-npm/main.d.ts +8 -1
- package/dist-npm/main.js +34 -1
- package/dist-npm/types/mod.d.ts +42 -0
- package/dist-npm/utils/color.js +4 -1
- package/dist-npm/utils/mod.d.ts +3 -0
- package/dist-npm/utils/mod.js +9 -0
- package/package.json +1 -1
- package/dist-npm/components/anykey/index.d.ts +0 -7
- package/dist-npm/components/anykey/index.js +0 -61
- package/dist-npm/components/block/block.d.ts +0 -10
- package/dist-npm/components/block/block.js +0 -52
- package/dist-npm/components/checkbox/index.d.ts +0 -3
- package/dist-npm/components/checkbox/index.js +0 -217
- package/dist-npm/components/confirm/confirm-main.d.ts +0 -3
- package/dist-npm/components/confirm/confirm-main.js +0 -98
- package/dist-npm/components/confirm/confirm-three.d.ts +0 -13
- package/dist-npm/components/confirm/confirm-three.js +0 -26
- package/dist-npm/components/confirm/index.d.ts +0 -2
- package/dist-npm/components/confirm/index.js +0 -41
- package/dist-npm/components/core/Separator.d.ts +0 -6
- package/dist-npm/components/core/Separator.js +0 -18
- package/dist-npm/components/core/create-prompt.d.ts +0 -4
- package/dist-npm/components/core/create-prompt.js +0 -107
- package/dist-npm/components/core/errors.d.ts +0 -20
- package/dist-npm/components/core/errors.js +0 -21
- package/dist-npm/components/core/hook-engine.d.ts +0 -23
- package/dist-npm/components/core/hook-engine.js +0 -109
- package/dist-npm/components/core/index.d.ts +0 -13
- package/dist-npm/components/core/index.js +0 -12
- package/dist-npm/components/core/key.d.ts +0 -10
- package/dist-npm/components/core/key.js +0 -16
- package/dist-npm/components/core/lines.d.ts +0 -14
- package/dist-npm/components/core/lines.js +0 -52
- package/dist-npm/components/core/make-theme.d.ts +0 -3
- package/dist-npm/components/core/make-theme.js +0 -28
- package/dist-npm/components/core/position.d.ts +0 -12
- package/dist-npm/components/core/position.js +0 -29
- package/dist-npm/components/core/promise-polyfill.d.ts +0 -7
- package/dist-npm/components/core/promise-polyfill.js +0 -13
- package/dist-npm/components/core/screen-manager.d.ts +0 -14
- package/dist-npm/components/core/screen-manager.js +0 -67
- package/dist-npm/components/core/theme.d.ts +0 -21
- package/dist-npm/components/core/theme.js +0 -24
- package/dist-npm/components/core/use-effect.d.ts +0 -2
- package/dist-npm/components/core/use-effect.js +0 -11
- package/dist-npm/components/core/use-keypress.d.ts +0 -3
- package/dist-npm/components/core/use-keypress.js +0 -21
- package/dist-npm/components/core/use-memo.d.ts +0 -1
- package/dist-npm/components/core/use-memo.js +0 -12
- package/dist-npm/components/core/use-pagination.d.ts +0 -11
- package/dist-npm/components/core/use-pagination.js +0 -34
- package/dist-npm/components/core/use-prefix.d.ts +0 -5
- package/dist-npm/components/core/use-prefix.js +0 -42
- package/dist-npm/components/core/use-ref.d.ts +0 -6
- package/dist-npm/components/core/use-ref.js +0 -4
- package/dist-npm/components/core/use-state.d.ts +0 -4
- package/dist-npm/components/core/use-state.js +0 -17
- package/dist-npm/components/core/useKeyPress.d.ts +0 -4
- package/dist-npm/components/core/useKeyPress.js +0 -16
- package/dist-npm/components/core/usePromptState.d.ts +0 -6
- package/dist-npm/components/core/usePromptState.js +0 -10
- package/dist-npm/components/core/utils.d.ts +0 -2
- package/dist-npm/components/core/utils.js +0 -11
- package/dist-npm/components/date/date.d.ts +0 -6
- package/dist-npm/components/date/date.js +0 -210
- package/dist-npm/components/editor/index.d.ts +0 -2
- package/dist-npm/components/editor/index.js +0 -78
- package/dist-npm/components/expand/index.d.ts +0 -3
- package/dist-npm/components/expand/index.js +0 -119
- package/dist-npm/components/figures/index.d.ts +0 -465
- package/dist-npm/components/figures/index.js +0 -299
- package/dist-npm/components/input/index.d.ts +0 -2
- package/dist-npm/components/input/index.js +0 -66
- package/dist-npm/components/input/text-main.d.ts +0 -3
- package/dist-npm/components/input/text-main.js +0 -103
- package/dist-npm/components/input/text.d.ts +0 -11
- package/dist-npm/components/input/text.js +0 -26
- package/dist-npm/components/instance/basic.d.ts +0 -8
- package/dist-npm/components/instance/browser.js +0 -18
- package/dist-npm/components/instance/shared.d.ts +0 -6
- package/dist-npm/components/instance/shared.js +0 -2
- package/dist-npm/components/mono/mono.d.ts +0 -5
- package/dist-npm/components/mono/mono.js +0 -64
- package/dist-npm/components/mono/monoTwo.d.ts +0 -30
- package/dist-npm/components/mono/monoTwo.js +0 -37
- package/dist-npm/components/multiselect/group-multiselect.d.ts +0 -23
- package/dist-npm/components/multiselect/group-multiselect.js +0 -58
- package/dist-npm/components/multiselect/multi-select-two.d.ts +0 -3
- package/dist-npm/components/multiselect/multi-select-two.js +0 -111
- package/dist-npm/components/multiselect/multi-select.d.ts +0 -21
- package/dist-npm/components/multiselect/multi-select.js +0 -45
- package/dist-npm/components/multiselect/multiselect-main.d.ts +0 -18
- package/dist-npm/components/multiselect/multiselect-main.js +0 -166
- package/dist-npm/components/multiselect/num-multi-select.d.ts +0 -3
- package/dist-npm/components/multiselect/num-multi-select.js +0 -111
- package/dist-npm/components/multiselect/num-multiselect-main.d.ts +0 -6
- package/dist-npm/components/multiselect/num-multiselect-main.js +0 -28
- package/dist-npm/components/next-steps/next-steps.d.ts +0 -2
- package/dist-npm/components/next-steps/next-steps.js +0 -24
- package/dist-npm/components/number/index.d.ts +0 -2
- package/dist-npm/components/number/index.js +0 -100
- package/dist-npm/components/number/number-main.d.ts +0 -3
- package/dist-npm/components/number/number-main.js +0 -95
- package/dist-npm/components/password/index.d.ts +0 -2
- package/dist-npm/components/password/index.js +0 -59
- package/dist-npm/components/password/password-main.d.ts +0 -3
- package/dist-npm/components/password/password-main.js +0 -119
- package/dist-npm/components/password/password-three.d.ts +0 -13
- package/dist-npm/components/password/password-three.js +0 -28
- package/dist-npm/components/progressbar/ProgressBar.d.ts +0 -22
- package/dist-npm/components/progressbar/ProgressBar.js +0 -53
- package/dist-npm/components/progressbar/helper.d.ts +0 -6
- package/dist-npm/components/progressbar/helper.js +0 -38
- package/dist-npm/components/progressbar/index.d.ts +0 -2
- package/dist-npm/components/progressbar/index.js +0 -1
- package/dist-npm/components/prompts/create.js +0 -35
- package/dist-npm/components/prompts/index.d.ts +0 -49
- package/dist-npm/components/prompts/index.js +0 -46
- package/dist-npm/components/prompts/prompt.d.ts +0 -36
- package/dist-npm/components/prompts/prompt.js +0 -232
- package/dist-npm/components/prompts/promptTwo.d.ts +0 -92
- package/dist-npm/components/prompts/promptTwo.js +0 -653
- package/dist-npm/components/range/range.d.ts +0 -62
- package/dist-npm/components/range/range.js +0 -270
- package/dist-npm/components/rawlist/index.d.ts +0 -3
- package/dist-npm/components/rawlist/index.js +0 -104
- package/dist-npm/components/results/results.d.ts +0 -10
- package/dist-npm/components/results/results.js +0 -34
- package/dist-npm/components/search/index.d.ts +0 -3
- package/dist-npm/components/search/index.js +0 -186
- package/dist-npm/components/select/index.d.ts +0 -3
- package/dist-npm/components/select/index.js +0 -176
- package/dist-npm/components/select/num-select-main.d.ts +0 -8
- package/dist-npm/components/select/num-select-main.js +0 -30
- package/dist-npm/components/select/num-select.d.ts +0 -5
- package/dist-npm/components/select/num-select.js +0 -125
- package/dist-npm/components/select/select-key.d.ts +0 -15
- package/dist-npm/components/select/select-key.js +0 -26
- package/dist-npm/components/select/select-main.d.ts +0 -19
- package/dist-npm/components/select/select-main.js +0 -151
- package/dist-npm/components/select/select-three.d.ts +0 -18
- package/dist-npm/components/select/select-three.js +0 -35
- package/dist-npm/components/select/select-two.d.ts +0 -2
- package/dist-npm/components/select/select-two.js +0 -98
- package/dist-npm/components/spinner/index.d.ts +0 -15
- package/dist-npm/components/spinner/index.js +0 -110
- package/dist-npm/components/st-end/end.d.ts +0 -2
- package/dist-npm/components/st-end/end.js +0 -35
- package/dist-npm/components/st-end/start.d.ts +0 -2
- package/dist-npm/components/st-end/start.js +0 -32
- package/dist-npm/components/toggle/index.d.ts +0 -13
- package/dist-npm/components/toggle/index.js +0 -121
- package/dist-npm/components/visual/animate/animate.d.ts +0 -13
- package/dist-npm/components/visual/animate/animate.js +0 -55
- package/dist-npm/components/visual/ascii-art/ascii-art.d.ts +0 -6
- package/dist-npm/components/visual/ascii-art/ascii-art.js +0 -12
- package/dist-npm/testing/index.d.ts +0 -18
- package/dist-npm/testing/index.js +0 -64
- package/dist-npm/types/general.d.ts +0 -134
- package/dist-npm/types/index.d.ts +0 -2
- package/dist-npm/types/index.js +0 -2
- package/dist-npm/types/keypress.d.ts +0 -52
- package/dist-npm/types/keypress.js +0 -37
- package/dist-npm/types/readline.d.ts +0 -30
- package/dist-npm/types/readline.js +0 -0
- package/dist-npm/types/relinka.d.ts +0 -30
- package/dist-npm/types/relinka.js +0 -0
- package/dist-npm/types/utils.d.ts +0 -17
- package/dist-npm/types/utils.js +0 -0
- package/dist-npm/utils/colorize.d.ts +0 -2
- package/dist-npm/utils/colorize.js +0 -130
- package/dist-npm/utils/component.d.ts +0 -101
- package/dist-npm/utils/component.js +0 -630
- package/dist-npm/utils/core.d.ts +0 -2
- package/dist-npm/utils/core.js +0 -2
- package/dist-npm/utils/decoder.d.ts +0 -14
- package/dist-npm/utils/decoder.js +0 -281
- package/dist-npm/utils/errors.d.ts +0 -1
- package/dist-npm/utils/errors.js +0 -15
- package/dist-npm/utils/keypress.d.ts +0 -7
- package/dist-npm/utils/keypress.js +0 -327
- package/dist-npm/utils/mapping.d.ts +0 -4
- package/dist-npm/utils/mapping.js +0 -49
- package/dist-npm/utils/messages.d.ts +0 -17
- package/dist-npm/utils/messages.js +0 -213
- package/dist-npm/utils/platforms.d.ts +0 -1
- package/dist-npm/utils/platforms.js +0 -22
- package/dist-npm/utils/prompt-tmp.d.ts +0 -13
- package/dist-npm/utils/prompt-tmp.js +0 -254
- package/dist-npm/utils/prompt-two.d.ts +0 -13
- package/dist-npm/utils/prompt-two.js +0 -254
- package/dist-npm/utils/readline.d.ts +0 -2
- package/dist-npm/utils/readline.js +0 -9
- package/dist-npm/utils/skeleton.d.ts +0 -7
- package/dist-npm/utils/skeleton.js +0 -145
- package/dist-npm/utils/terminal.d.ts +0 -5
- package/dist-npm/utils/terminal.js +0 -33
- package/dist-npm/utils/types.d.ts +0 -0
- package/dist-npm/utils/types.js +0 -0
- package/dist-npm/utils/utils.d.ts +0 -3
- package/dist-npm/utils/utils.js +0 -9
- package/dist-npm/utils/variants.d.ts +0 -9
- package/dist-npm/utils/variants.js +0 -49
- /package/dist-npm/{utils/constants.js → components/levels/levels.js} +0 -0
- /package/dist-npm/components/{instance/reporter → reporters}/browser.js +0 -0
- /package/dist-npm/types/{general.js → mod.js} +0 -0
package/README.md
CHANGED
|
@@ -24,16 +24,24 @@
|
|
|
24
24
|
|
|
25
25
|
@reliverse/relinka is a powerful logger for your terminal.
|
|
26
26
|
|
|
27
|
-
@reliverse/relinka is a full-featured alternative to winston, unjs
|
|
27
|
+
@reliverse/relinka is a full-featured alternative to winston, unjs relinka, pino, bristol, node-bunyan, and similar libraries.
|
|
28
|
+
|
|
29
|
+
Used by [@reliverse/prompts](https://github.com/reliverse/prompts#readme) and [@reliverse/cli](https://github.com/blefnk/reliverse#readme).
|
|
28
30
|
|
|
29
31
|
## Installation
|
|
30
32
|
|
|
31
33
|
Install with your preferred package manager:
|
|
32
34
|
|
|
33
35
|
```sh
|
|
34
|
-
bun add @reliverse/relinka # Replace 'bun' with npm, pnpm, or yarn if desired (deno and jsr support coming soon)
|
|
36
|
+
bun add @reliverse/relinka # Replace 'bun' with npm, pnpm, or yarn if desired (deno and full jsr support coming soon)
|
|
35
37
|
```
|
|
36
38
|
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
> **Warning:** The @reliverse/relinka README.md was based on the @reliverse/prompts README.md. Some of the information may be not related to the current library. And will be updated soon.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
37
45
|
## Screenshot
|
|
38
46
|
|
|
39
47
|
[](./example.png)
|
|
@@ -80,7 +88,7 @@ Run `bun dev` to launch the [examples/run-example.ts](./examples/run-example.ts)
|
|
|
80
88
|
2. **[2-mono-example.ts](./examples/2-mono-example.ts)**: A quiz game example inspired by Fireship's [video](https://youtube.com/watch?v=_oHByo8tiEY). It demonstrates the dynamic capabilities of @reliverse/relinka by using a prompt() that includes all prompt components, so you don't need to import each component separately.
|
|
81
89
|
3. **[3-basic-example.ts](./examples/3-basic-example.ts)**: A simple example highlighting the core functionalities of @reliverse/relinka. The entire implementation is contained within a single file for easy understanding.
|
|
82
90
|
|
|
83
|
-
##
|
|
91
|
+
## Logger Library Comparison
|
|
84
92
|
|
|
85
93
|
> **Note:** This table contains approximate and placeholder values. More detailed assessments will be provided as libraries continue to evolve.
|
|
86
94
|
|
|
@@ -91,41 +99,30 @@ Run `bun dev` to launch the [examples/run-example.ts](./examples/run-example.ts)
|
|
|
91
99
|
- 🔵: Partially supported
|
|
92
100
|
- 🔴: Not supported
|
|
93
101
|
|
|
94
|
-
| **Feature** | **@reliverse/relinka** | **@
|
|
95
|
-
|
|
|
96
|
-
| **Full Node.js Modules Support** | 🟢 Native ES module package |
|
|
97
|
-
| **Works both in node, bun, and deno environments** | 🔵 node+bun (deno support is coming soon) |
|
|
98
|
-
| **Codebase typesafety with intellisense** | 🔵 |
|
|
99
|
-
| **Runtime typesafety with schema validation** |
|
|
100
|
-
| **Usage Examples** | 🟢 |
|
|
101
|
-
| **
|
|
102
|
-
| **
|
|
103
|
-
| **
|
|
104
|
-
| **
|
|
105
|
-
| **
|
|
106
|
-
| **
|
|
107
|
-
| **
|
|
108
|
-
| **
|
|
109
|
-
| **
|
|
110
|
-
| **
|
|
111
|
-
| **
|
|
112
|
-
| **
|
|
113
|
-
| **
|
|
114
|
-
| **
|
|
115
|
-
| **
|
|
116
|
-
| **
|
|
117
|
-
| **
|
|
118
|
-
| **General DX** | 🔵 Clean and understandable TypeScript code | 🟡 | 🟡 | 🟡 | 🔴 JS-only | 🔴 JS-only | 🟡 | 🟡 |
|
|
119
|
-
| **DX: Classes** | 🟢 Minimal number of classes as possible | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
120
|
-
| **Documentation** | 🔵 | 🟡 | 🟡 | 🟡 | 🔵 | 🟢 | 🟡 | 🟡 |
|
|
121
|
-
| **Designed With UX/DX in Mind** | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
122
|
-
| **Fast and lightweight argument parser** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
123
|
-
| **Smart value parsing with typecast** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
124
|
-
| **Boolean shortcuts and unknown flag handling** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
125
|
-
| **Nested sub-commands** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
126
|
-
| **Lazy and Async commands** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
127
|
-
| **Pluggable and composable API** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
128
|
-
| **Auto generated usage and help** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟢 | 🟡 |
|
|
102
|
+
| **Feature** | **@reliverse/relinka** | **@unjs/consola** | **@klaudiosinani/signale** | **pino** | **@TomFrost/Bristol** | **@trentm/node-bunyan** | **winston** | **log4js-node** |
|
|
103
|
+
| -----------------------------------------------------------|----------------------------------------------------|------------------------|-----------------------------|---------------------|------------------------|---------------------------|------------------------|--------------------|
|
|
104
|
+
| **Full Node.js Modules Support** | 🟢 Native ES module package | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
105
|
+
| **Works both in node, bun, and deno environments** | 🔵 node+bun (deno support is coming soon) | 🔵 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
106
|
+
| **Codebase typesafety with intellisense** | 🔵 | 🔵 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
107
|
+
| **Runtime typesafety with schema validation** | 🔵 | 🔵 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
108
|
+
| **Usage Examples** | 🟢 | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
109
|
+
| **Prompts Components** | 🟢 Can be enabled using @reliverse/prompts library | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
110
|
+
| **Customization** | 🟢 Colors, typography, variants, borders, and more | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
111
|
+
| **Custom Validation** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
112
|
+
| **Error Handling** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
113
|
+
| **Ease of Setup** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
114
|
+
| **Crash Resilience** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
115
|
+
| **General DX** | 🔵 Clean and understandable TypeScript code | 🔵 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
116
|
+
| **DX: Classes** | 🟢 Minimal number of classes as possible | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
117
|
+
| **Documentation** | 🔵 | 🔵 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
118
|
+
| **Designed With UX/DX in Mind** | 🟢 | 🟢 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
119
|
+
| **Fast and lightweight argument parser** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
120
|
+
| **Smart value parsing with typecast** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
121
|
+
| **Boolean shortcuts and unknown flag handling** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
122
|
+
| **Nested sub-commands** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
123
|
+
| **Lazy and Async commands** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
124
|
+
| **Pluggable and composable API** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
125
|
+
| **Auto generated usage and help** | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 | 🟡 |
|
|
129
126
|
|
|
130
127
|
**Related Links**: [ESM/CJS](https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm), ["Pure ESM package"](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), [Clean code](https://github.com/ryanmcdermott/clean-code-javascript#readme), ["UX patterns for CLI tools"](https://lucasfcosta.com/2022/06/01/ux-patterns-cli-tools.html), [DX (Developer Experience)](https://github.blog/enterprise-software/collaboration/developer-experience-what-is-it-and-why-should-you-care), [TypeBox](https://github.com/sinclairzx81/typebox#readme), ["ANSI Escape Sequences"](https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b)
|
|
131
128
|
|
|
@@ -159,14 +156,13 @@ const username = await textPrompt({
|
|
|
159
156
|
|
|
160
157
|
## Learn More
|
|
161
158
|
|
|
162
|
-
- [Temporary Relinka Docs](.github/DOCS.md)
|
|
163
159
|
- [Reliverse Docs](https://docs.reliverse.org)
|
|
164
160
|
|
|
165
161
|
## Special Thanks
|
|
166
162
|
|
|
167
|
-
This project wouldn’t exist without the amazing work of the huge number of contributors to the list of projects below. Many of the @reliverse/relinka
|
|
163
|
+
This project wouldn’t exist without the amazing work of the huge number of contributors to the list of projects below. Many of the @reliverse/relinka features are based on the incredible work of:
|
|
168
164
|
|
|
169
|
-
[@
|
|
165
|
+
[@reliverse/prompts](https://github.com/reliverse/prompts#readme) | [@unjs/consola](https://github.com/unjs/consola#readme)
|
|
170
166
|
|
|
171
167
|
## License
|
|
172
168
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LogObject } from "
|
|
1
|
+
import type { LogObject } from "../../types/mod.js";
|
|
2
2
|
export type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
3
3
|
export declare const LogLevels: Record<LogType, number>;
|
|
4
4
|
export type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export * from "
|
|
1
|
+
import type { RelinkaInstance } from "../../components/relinka/relinka.js";
|
|
2
|
+
import type { RelinkaOptions } from "../../types/mod.js";
|
|
3
|
+
export * from "./shared.js";
|
|
4
4
|
export declare function createRelinka(options?: Partial<RelinkaOptions & {
|
|
5
5
|
fancy: boolean;
|
|
6
6
|
}>): RelinkaInstance;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRelinka as _createRelinka } from "../../components/
|
|
3
|
-
import {
|
|
4
|
-
export * from "
|
|
1
|
+
import { LogLevels } from "../../components/levels/levels.js";
|
|
2
|
+
import { createRelinka as _createRelinka } from "../../components/relinka/relinka.js";
|
|
3
|
+
import { BasicReporter } from "../../components/reporters/basic.js";
|
|
4
|
+
export * from "./shared.js";
|
|
5
5
|
export function createRelinka(options = {}) {
|
|
6
6
|
let level = LogLevels.info;
|
|
7
7
|
if (process.env.RELINKA_LEVEL) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RelinkaOptions } from "../../types/
|
|
2
|
-
export * from "
|
|
1
|
+
import type { RelinkaOptions } from "../../types/mod.js";
|
|
2
|
+
export * from "./shared.js";
|
|
3
3
|
export declare function createRelinka(options?: Partial<RelinkaOptions>): any;
|
|
4
4
|
export declare const relinka: any;
|
|
5
5
|
export default relinka;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BrowserReporter } from "../../components/reporters/browser.js";
|
|
2
|
+
import { createRelinka as _createRelinka } from "../../components/relinka/relinka.js";
|
|
3
|
+
export * from "./shared.js";
|
|
4
|
+
export function createRelinka(options = {}) {
|
|
5
|
+
const relinka2 = _createRelinka({
|
|
6
|
+
reporters: options.reporters || [new BrowserReporter({})],
|
|
7
|
+
...options
|
|
8
|
+
});
|
|
9
|
+
return relinka2;
|
|
10
|
+
}
|
|
11
|
+
export const relinka = createRelinka();
|
|
12
|
+
export default relinka;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { LogLevels, LogTypes } from "../../components/levels/levels.js";
|
|
2
|
+
export { Relinka } from "../../components/relinka/relinka.js";
|
|
3
|
+
export type * from "../../types/mod.js";
|
|
4
|
+
export type { RelinkaInstance } from "../../components/relinka/relinka.js";
|
|
5
|
+
export type { LogLevel, LogType } from "../../components/levels/levels.js";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { RelinkaReporter, InputLogObject, LogObject, RelinkaOptions } from "../../types/
|
|
3
|
-
import type { LogType } from "../../utils/constants.js";
|
|
1
|
+
import type { LogType } from "../../components/levels/levels.js";
|
|
2
|
+
import type { RelinkaReporter, InputLogObject, LogObject, RelinkaOptions } from "../../types/mod.js";
|
|
4
3
|
export declare class Relinka {
|
|
5
4
|
options: RelinkaOptions;
|
|
6
5
|
_lastLog: {
|
|
@@ -14,7 +13,6 @@ export declare class Relinka {
|
|
|
14
13
|
constructor(options?: Partial<RelinkaOptions>);
|
|
15
14
|
get level(): any;
|
|
16
15
|
set level(level: any);
|
|
17
|
-
prompt<T extends PromptOptions>(message: string, opts?: T): any;
|
|
18
16
|
create(options: Partial<RelinkaOptions>): RelinkaInstance;
|
|
19
17
|
withDefaults(defaults: InputLogObject): RelinkaInstance;
|
|
20
18
|
withTag(tag: string): RelinkaInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import { LogTypes } from "../../
|
|
2
|
+
import { LogTypes } from "../../components/levels/levels.js";
|
|
3
3
|
import { isLogObj } from "../../utils/log.js";
|
|
4
4
|
let paused = false;
|
|
5
5
|
const queue = [];
|
|
@@ -53,12 +53,6 @@ export class Relinka {
|
|
|
53
53
|
this.options.types,
|
|
54
54
|
this.options.level
|
|
55
55
|
);
|
|
56
|
-
}
|
|
57
|
-
prompt(message, opts) {
|
|
58
|
-
if (!this.options.prompt) {
|
|
59
|
-
throw new Error("prompt is not supported!");
|
|
60
|
-
}
|
|
61
|
-
return this.options.prompt(message, opts);
|
|
62
56
|
}
|
|
63
57
|
create(options) {
|
|
64
58
|
const instance = new Relinka({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LogObject, RelinkaReporter, FormatOptions, RelinkaOptions } from "
|
|
1
|
+
import type { LogObject, RelinkaReporter, FormatOptions, RelinkaOptions } from "../../types/mod.js";
|
|
2
2
|
export declare class BasicReporter implements RelinkaReporter {
|
|
3
3
|
formatStack(stack: string, opts: FormatOptions): string;
|
|
4
4
|
formatArgs(args: any[], opts: FormatOptions): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatWithOptions } from "node:util";
|
|
2
|
-
import { parseStack } from "
|
|
3
|
-
import { writeStream } from "
|
|
2
|
+
import { parseStack } from "../../utils/error.js";
|
|
3
|
+
import { writeStream } from "../../utils/stream.js";
|
|
4
4
|
const bracket = (x) => x ? `[${x}]` : "";
|
|
5
5
|
export class BasicReporter {
|
|
6
6
|
formatStack(stack, opts) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import { BasicReporter } from "
|
|
1
|
+
import type { LogLevel, LogType } from "../../components/levels/levels.js";
|
|
2
|
+
import type { FormatOptions, LogObject } from "../../types/mod.js";
|
|
3
|
+
import { BasicReporter } from "../../components/reporters/basic.js";
|
|
4
4
|
export declare const TYPE_COLOR_MAP: Partial<Record<LogType, string>>;
|
|
5
5
|
export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevel, string>>;
|
|
6
6
|
export declare class FancyReporter extends BasicReporter {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import isUnicodeSupported from "is-unicode-supported";
|
|
2
2
|
import _stringWidth from "string-width";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { BasicReporter } from "../../components/reporters/basic.js";
|
|
4
|
+
import { box } from "../../utils/box.js";
|
|
5
|
+
import { colors } from "../../utils/color.js";
|
|
6
|
+
import { parseStack } from "../../utils/error.js";
|
|
7
|
+
import { stripAnsi } from "../../utils/string.js";
|
|
8
8
|
export const TYPE_COLOR_MAP = {
|
|
9
9
|
info: "cyan",
|
|
10
10
|
fail: "red",
|
|
@@ -38,7 +38,6 @@ function stringWidth(str) {
|
|
|
38
38
|
return _stringWidth(str);
|
|
39
39
|
}
|
|
40
40
|
export class FancyReporter extends BasicReporter {
|
|
41
|
-
// @ts-expect-error TODO: fix ts
|
|
42
41
|
formatStack(stack) {
|
|
43
42
|
return "\n" + parseStack(stack).map(
|
|
44
43
|
(line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
|
|
@@ -54,7 +53,6 @@ export class FancyReporter extends BasicReporter {
|
|
|
54
53
|
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
55
54
|
return _type ? getColor(typeColor)(_type) : "";
|
|
56
55
|
}
|
|
57
|
-
// @ts-expect-error TODO: fix ts
|
|
58
56
|
formatLogObj(logObj, opts) {
|
|
59
57
|
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
|
|
60
58
|
"\n"
|
package/dist-npm/main.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RelinkaInstance } from "./components/relinka/relinka.js";
|
|
2
|
+
import type { RelinkaOptions } from "./types/mod.js";
|
|
3
|
+
export * from "./components/modes/shared.js";
|
|
4
|
+
export declare function createRelinka(options?: Partial<RelinkaOptions & {
|
|
5
|
+
fancy: boolean;
|
|
6
|
+
}>): RelinkaInstance;
|
|
7
|
+
export declare const relinka: RelinkaInstance;
|
|
8
|
+
export default relinka;
|
package/dist-npm/main.js
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { isDebug, isTest, isCI } from "std-env";
|
|
2
|
+
import { LogLevels } from "./components/levels/levels.js";
|
|
3
|
+
import { createRelinka as _createRelinka } from "./components/relinka/relinka.js";
|
|
4
|
+
import { BasicReporter } from "./components/reporters/basic.js";
|
|
5
|
+
import { FancyReporter } from "./components/reporters/fancy.js";
|
|
6
|
+
export * from "./components/modes/shared.js";
|
|
7
|
+
export function createRelinka(options = {}) {
|
|
8
|
+
let level = _getDefaultLogLevel();
|
|
9
|
+
if (process.env.RELINKA_LEVEL) {
|
|
10
|
+
level = Number.parseInt(process.env.RELINKA_LEVEL) ?? level;
|
|
11
|
+
}
|
|
12
|
+
const relinka2 = _createRelinka({
|
|
13
|
+
level,
|
|
14
|
+
defaults: { level },
|
|
15
|
+
stdout: process.stdout,
|
|
16
|
+
stderr: process.stderr,
|
|
17
|
+
reporters: options.reporters || [
|
|
18
|
+
options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()
|
|
19
|
+
],
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
return relinka2;
|
|
23
|
+
}
|
|
24
|
+
function _getDefaultLogLevel() {
|
|
25
|
+
if (isDebug) {
|
|
26
|
+
return LogLevels.debug;
|
|
27
|
+
}
|
|
28
|
+
if (isTest) {
|
|
29
|
+
return LogLevels.warn;
|
|
30
|
+
}
|
|
31
|
+
return LogLevels.info;
|
|
32
|
+
}
|
|
33
|
+
export const relinka = createRelinka();
|
|
34
|
+
export default relinka;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { LogLevel, LogType } from "../components/levels/levels.js";
|
|
2
|
+
export type RelinkaOptions = {
|
|
3
|
+
reporters: RelinkaReporter[];
|
|
4
|
+
types: Record<LogType, InputLogObject>;
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
defaults: InputLogObject;
|
|
7
|
+
throttle: number;
|
|
8
|
+
throttleMin: number;
|
|
9
|
+
stdout?: NodeJS.WriteStream;
|
|
10
|
+
stderr?: NodeJS.WriteStream;
|
|
11
|
+
mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
|
|
12
|
+
formatOptions: FormatOptions;
|
|
13
|
+
};
|
|
14
|
+
export type FormatOptions = {
|
|
15
|
+
columns?: number;
|
|
16
|
+
date?: boolean;
|
|
17
|
+
colors?: boolean;
|
|
18
|
+
compact?: boolean | number;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type InputLogObject = {
|
|
22
|
+
level?: LogLevel;
|
|
23
|
+
tag?: string;
|
|
24
|
+
type?: LogType;
|
|
25
|
+
message?: string;
|
|
26
|
+
additional?: string | string[];
|
|
27
|
+
args?: any[];
|
|
28
|
+
date?: Date;
|
|
29
|
+
};
|
|
30
|
+
export type LogObject = {
|
|
31
|
+
level: LogLevel;
|
|
32
|
+
type: LogType;
|
|
33
|
+
tag: string;
|
|
34
|
+
args: any[];
|
|
35
|
+
date: Date;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
} & InputLogObject;
|
|
38
|
+
export type RelinkaReporter = {
|
|
39
|
+
log: (logObj: LogObject, ctx: {
|
|
40
|
+
options: RelinkaOptions;
|
|
41
|
+
}) => void;
|
|
42
|
+
};
|
package/dist-npm/utils/color.js
CHANGED
|
@@ -8,7 +8,10 @@ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
|
8
8
|
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
9
9
|
const isWindows = platform === "win32";
|
|
10
10
|
const isDumbTerminal = env.TERM === "dumb";
|
|
11
|
-
const isCompatibleTerminal =
|
|
11
|
+
const isCompatibleTerminal = (
|
|
12
|
+
|
|
13
|
+
tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal
|
|
14
|
+
);
|
|
12
15
|
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
13
16
|
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
14
17
|
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import logUpdate from "log-update";
|
|
2
|
-
import { fmt } from "../../utils/messages.js";
|
|
3
|
-
import { restoreCursor } from "../../utils/terminal.js";
|
|
4
|
-
const DEFAULT_MESSAGE = "Press any key to continue...";
|
|
5
|
-
const CTRL_C_CODE = 3;
|
|
6
|
-
export async function anykeyPrompt(message = DEFAULT_MESSAGE, options = {}) {
|
|
7
|
-
const { ctrlC = 1, preserveLog = false, hideMessage = false } = options;
|
|
8
|
-
if (message) {
|
|
9
|
-
message = fmt({
|
|
10
|
-
type: "M_GENERAL",
|
|
11
|
-
title: message,
|
|
12
|
-
titleColor: "dim",
|
|
13
|
-
dontRemoveBar: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (message && !hideMessage) {
|
|
17
|
-
logUpdate(message);
|
|
18
|
-
}
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
const cleanup = () => {
|
|
21
|
-
process.stdin.removeListener("data", handler);
|
|
22
|
-
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
23
|
-
process.stdin.setRawMode(false);
|
|
24
|
-
}
|
|
25
|
-
process.stdin.pause();
|
|
26
|
-
restoreCursor();
|
|
27
|
-
};
|
|
28
|
-
const handleCtrlC = () => {
|
|
29
|
-
cleanup();
|
|
30
|
-
if (ctrlC === "reject") {
|
|
31
|
-
reject(new Error("User pressed CTRL+C"));
|
|
32
|
-
} else if (ctrlC === false) {
|
|
33
|
-
resolve();
|
|
34
|
-
} else if (typeof ctrlC === "number") {
|
|
35
|
-
process.exit(ctrlC);
|
|
36
|
-
} else {
|
|
37
|
-
throw new TypeError("Invalid ctrlC option");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const handler = (buffer) => {
|
|
41
|
-
cleanup();
|
|
42
|
-
if (message && !preserveLog) {
|
|
43
|
-
logUpdate.clear();
|
|
44
|
-
} else {
|
|
45
|
-
logUpdate.done();
|
|
46
|
-
process.stdout.write("\n");
|
|
47
|
-
}
|
|
48
|
-
const [firstByte] = buffer;
|
|
49
|
-
if (firstByte === CTRL_C_CODE) {
|
|
50
|
-
handleCtrlC();
|
|
51
|
-
} else {
|
|
52
|
-
resolve();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
process.stdin.resume();
|
|
56
|
-
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
57
|
-
process.stdin.setRawMode(true);
|
|
58
|
-
}
|
|
59
|
-
process.stdin.once("data", handler);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default function block({ input, output, overwrite, hideCursor, }?: {
|
|
2
|
-
input?: (NodeJS.ReadStream & {
|
|
3
|
-
fd: 0;
|
|
4
|
-
}) | undefined;
|
|
5
|
-
output?: (NodeJS.WriteStream & {
|
|
6
|
-
fd: 1;
|
|
7
|
-
}) | undefined;
|
|
8
|
-
overwrite?: boolean | undefined;
|
|
9
|
-
hideCursor?: boolean | undefined;
|
|
10
|
-
}): () => void;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { stdin, stdout } from "node:process";
|
|
2
|
-
import * as readline from "node:readline";
|
|
3
|
-
import { removeCursor, restoreCursor } from "../../utils/terminal.js";
|
|
4
|
-
const isWindows = globalThis.process.platform.startsWith("win");
|
|
5
|
-
export default function block({
|
|
6
|
-
input = stdin,
|
|
7
|
-
output = stdout,
|
|
8
|
-
overwrite = true,
|
|
9
|
-
hideCursor = true
|
|
10
|
-
} = {}) {
|
|
11
|
-
const rl = readline.createInterface({
|
|
12
|
-
input,
|
|
13
|
-
output,
|
|
14
|
-
prompt: "",
|
|
15
|
-
tabSize: 1
|
|
16
|
-
});
|
|
17
|
-
readline.emitKeypressEvents(input, rl);
|
|
18
|
-
if (input.isTTY) {
|
|
19
|
-
input.setRawMode(true);
|
|
20
|
-
}
|
|
21
|
-
const clear = (data, { name }) => {
|
|
22
|
-
const str = String(data);
|
|
23
|
-
if (str === "") {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
if (!overwrite) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const dx = name === "return" ? 0 : -1;
|
|
30
|
-
const dy = name === "return" ? -1 : 0;
|
|
31
|
-
readline.moveCursor(output, dx, dy, () => {
|
|
32
|
-
readline.clearLine(output, 1, () => {
|
|
33
|
-
input.once("keypress", clear);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
if (hideCursor) {
|
|
38
|
-
removeCursor();
|
|
39
|
-
}
|
|
40
|
-
input.once("keypress", clear);
|
|
41
|
-
return () => {
|
|
42
|
-
input.off("keypress", clear);
|
|
43
|
-
if (hideCursor) {
|
|
44
|
-
restoreCursor();
|
|
45
|
-
}
|
|
46
|
-
if (input.isTTY && !isWindows) {
|
|
47
|
-
input.setRawMode(false);
|
|
48
|
-
}
|
|
49
|
-
rl.terminal = false;
|
|
50
|
-
rl.close();
|
|
51
|
-
};
|
|
52
|
-
}
|