@reliverse/relinka 1.1.4 → 1.1.6

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.
Files changed (118) hide show
  1. package/dist-npm/components/anykey/index.js +77 -57
  2. package/dist-npm/components/block/block.js +61 -48
  3. package/dist-npm/components/checkbox/index.js +211 -178
  4. package/dist-npm/components/confirm/confirm-main.js +122 -86
  5. package/dist-npm/components/confirm/confirm-three.js +27 -24
  6. package/dist-npm/components/confirm/index.js +45 -36
  7. package/dist-npm/components/core/Separator.js +17 -15
  8. package/dist-npm/components/core/create-prompt.js +124 -101
  9. package/dist-npm/components/core/errors.js +15 -19
  10. package/dist-npm/components/core/hook-engine.js +120 -91
  11. package/dist-npm/components/core/index.js +12 -12
  12. package/dist-npm/components/core/key.js +6 -16
  13. package/dist-npm/components/core/lines.js +54 -45
  14. package/dist-npm/components/core/make-theme.js +30 -21
  15. package/dist-npm/components/core/position.js +23 -27
  16. package/dist-npm/components/core/promise-polyfill.js +14 -11
  17. package/dist-npm/components/core/screen-manager.js +74 -59
  18. package/dist-npm/components/core/theme.js +32 -22
  19. package/dist-npm/components/core/use-effect.js +15 -9
  20. package/dist-npm/components/core/use-keypress.js +23 -19
  21. package/dist-npm/components/core/use-memo.js +16 -10
  22. package/dist-npm/components/core/use-pagination.js +32 -33
  23. package/dist-npm/components/core/use-prefix.js +38 -40
  24. package/dist-npm/components/core/use-ref.js +5 -2
  25. package/dist-npm/components/core/use-state.js +23 -15
  26. package/dist-npm/components/core/useKeyPress.js +17 -14
  27. package/dist-npm/components/core/usePromptState.js +14 -8
  28. package/dist-npm/components/core/utils.js +16 -7
  29. package/dist-npm/components/date/date.js +204 -168
  30. package/dist-npm/components/editor/index.js +92 -71
  31. package/dist-npm/components/expand/index.js +124 -96
  32. package/dist-npm/components/figures/index.js +294 -283
  33. package/dist-npm/components/input/index.js +87 -61
  34. package/dist-npm/components/input/text-main.js +124 -86
  35. package/dist-npm/components/input/text.js +28 -24
  36. package/dist-npm/components/instance/basic.js +25 -17
  37. package/dist-npm/components/instance/browser.js +18 -14
  38. package/dist-npm/components/instance/reporter/basic.js +65 -46
  39. package/dist-npm/components/instance/reporter/browser.js +47 -44
  40. package/dist-npm/components/instance/reporter/fancy.js +96 -83
  41. package/dist-npm/components/instance/shared.js +2 -2
  42. package/dist-npm/components/mono/mono.js +62 -52
  43. package/dist-npm/components/mono/monoTwo.js +49 -35
  44. package/dist-npm/components/multiselect/group-multiselect.js +71 -55
  45. package/dist-npm/components/multiselect/multi-select-two.js +130 -98
  46. package/dist-npm/components/multiselect/multi-select.js +49 -43
  47. package/dist-npm/components/multiselect/multiselect-main.js +146 -120
  48. package/dist-npm/components/multiselect/num-multi-select.js +130 -98
  49. package/dist-npm/components/multiselect/num-multiselect-main.js +35 -24
  50. package/dist-npm/components/next-steps/next-steps.js +25 -24
  51. package/dist-npm/components/number/index.js +112 -78
  52. package/dist-npm/components/number/number-main.js +2 -96
  53. package/dist-npm/components/password/index.js +73 -54
  54. package/dist-npm/components/password/password-main.js +2 -120
  55. package/dist-npm/components/password/password-three.js +30 -26
  56. package/dist-npm/components/progressbar/ProgressBar.js +64 -45
  57. package/dist-npm/components/progressbar/helper.js +40 -33
  58. package/dist-npm/components/progressbar/index.js +1 -1
  59. package/dist-npm/components/prompts/create.js +44 -29
  60. package/dist-npm/components/prompts/index.js +45 -45
  61. package/dist-npm/components/prompts/prompt.js +260 -211
  62. package/dist-npm/components/prompts/promptTwo.js +605 -561
  63. package/dist-npm/components/prompts/relinka.js +295 -237
  64. package/dist-npm/components/range/range.js +294 -247
  65. package/dist-npm/components/rawlist/index.js +107 -87
  66. package/dist-npm/components/results/results.js +37 -31
  67. package/dist-npm/components/search/index.js +193 -148
  68. package/dist-npm/components/select/index.js +186 -148
  69. package/dist-npm/components/select/num-select-main.js +27 -27
  70. package/dist-npm/components/select/num-select.js +5 -125
  71. package/dist-npm/components/select/select-key.js +25 -24
  72. package/dist-npm/components/select/select-main.js +133 -109
  73. package/dist-npm/components/select/select-three.js +36 -32
  74. package/dist-npm/components/select/select-two.js +87 -95
  75. package/dist-npm/components/spinner/index.js +136 -107
  76. package/dist-npm/components/st-end/end.d.ts +1 -1
  77. package/dist-npm/components/st-end/end.js +26 -35
  78. package/dist-npm/components/st-end/start.d.ts +1 -1
  79. package/dist-npm/components/st-end/start.js +15 -30
  80. package/dist-npm/components/toggle/index.js +137 -113
  81. package/dist-npm/components/visual/animate/animate.js +10 -53
  82. package/dist-npm/components/visual/ascii-art/ascii-art.js +1 -12
  83. package/dist-npm/mod.js +2 -1
  84. package/dist-npm/testing/index.js +83 -58
  85. package/dist-npm/types/general.d.ts +2 -1
  86. package/dist-npm/types/general.js +1 -0
  87. package/dist-npm/types/index.js +3 -2
  88. package/dist-npm/types/keypress.js +36 -35
  89. package/dist-npm/types/readline.js +1 -0
  90. package/dist-npm/types/relinka.js +1 -0
  91. package/dist-npm/types/utils.js +1 -0
  92. package/dist-npm/utils/box.js +137 -135
  93. package/dist-npm/utils/color.js +74 -65
  94. package/dist-npm/utils/colorize.js +156 -124
  95. package/dist-npm/utils/component.js +657 -532
  96. package/dist-npm/utils/constants.js +63 -64
  97. package/dist-npm/utils/core.js +3 -2
  98. package/dist-npm/utils/decoder.js +223 -244
  99. package/dist-npm/utils/error.js +9 -4
  100. package/dist-npm/utils/errors.js +4 -14
  101. package/dist-npm/utils/format.js +24 -19
  102. package/dist-npm/utils/keypress.js +414 -316
  103. package/dist-npm/utils/log.js +15 -11
  104. package/dist-npm/utils/mapping.js +52 -45
  105. package/dist-npm/utils/messages.js +183 -183
  106. package/dist-npm/utils/platforms.js +20 -16
  107. package/dist-npm/utils/prompt-tmp.js +286 -235
  108. package/dist-npm/utils/prompt-two.js +286 -235
  109. package/dist-npm/utils/readline.js +7 -5
  110. package/dist-npm/utils/skeleton.js +170 -130
  111. package/dist-npm/utils/stream.js +2 -2
  112. package/dist-npm/utils/string.js +58 -44
  113. package/dist-npm/utils/terminal.js +34 -23
  114. package/dist-npm/utils/tree.js +41 -30
  115. package/dist-npm/utils/types.js +1 -0
  116. package/dist-npm/utils/utils.js +8 -8
  117. package/dist-npm/utils/variants.js +44 -36
  118. package/package.json +20 -28
@@ -1,59 +1,78 @@
1
- import ansiEscapes from "ansi-escapes";
1
+ import ansiEscapes from 'ansi-escapes';
2
2
  import {
3
- createPrompt,
4
- useState,
5
- useKeypress,
6
- usePrefix,
7
- isEnterKey,
8
- makeTheme
9
- } from "../../components/core/index.js";
3
+ createPrompt,
4
+ useState,
5
+ useKeypress,
6
+ usePrefix,
7
+ isEnterKey,
8
+ makeTheme,
9
+ } from '../../components/core/index.js';
10
+
11
+ const isString = (a) => typeof a === 'string';
12
+
10
13
  export default createPrompt((config, done) => {
11
- const { validate = () => true } = config;
12
- const theme = makeTheme(config.theme);
13
- const [status, setStatus] = useState("idle");
14
- const [errorMsg, setError] = useState();
15
- const [value, setValue] = useState("");
16
- const prefix = usePrefix({ status, theme });
17
- useKeypress(async (key, rl) => {
18
- if (status !== "idle") {
19
- return;
14
+ const {validate = () => true} = config;
15
+ const theme = makeTheme(config.theme);
16
+ const [status, setStatus] = useState('idle');
17
+ const [errorMsg, setError] = useState();
18
+ const [value, setValue] = useState('');
19
+ const prefix = usePrefix({
20
+ status,
21
+ theme,
22
+ });
23
+
24
+ useKeypress(async (key, rl) => {
25
+ if (status !== 'idle') {
26
+ return;
27
+ }
28
+
29
+ if (isEnterKey(key)) {
30
+ const answer = value;
31
+ setStatus('loading');
32
+ const isValid = await validate(answer);
33
+
34
+ if (isValid) {
35
+ setValue(answer);
36
+ setStatus('done');
37
+ done(answer);
38
+ } else {
39
+ rl.write(value);
40
+ setError(isValid || 'You must provide a valid value');
41
+ setStatus('idle');
42
+ }
43
+ } else {
44
+ setValue(rl.line);
45
+ setError(void 0);
46
+ }
47
+ });
48
+ const message = theme.style.message(config.message, status);
49
+ let formattedValue = '';
50
+ let helpTip;
51
+
52
+ if (config.mask) {
53
+ const maskChar = isString(config.mask) ? config.mask : '*';
54
+ formattedValue = maskChar.repeat(value.length);
55
+ } else if (status !== 'done') {
56
+ helpTip = `${theme.style.help('[input is masked]')}${ansiEscapes.cursorHide}`;
20
57
  }
21
- if (isEnterKey(key)) {
22
- const answer = value;
23
- setStatus("loading");
24
- const isValid = await validate(answer);
25
- if (isValid === true) {
26
- setValue(answer);
27
- setStatus("done");
28
- done(answer);
29
- } else {
30
- rl.write(value);
31
- setError(isValid || "You must provide a valid value");
32
- setStatus("idle");
33
- }
34
- } else {
35
- setValue(rl.line);
36
- setError(void 0);
58
+
59
+
60
+ if (status === 'done') {
61
+ formattedValue = theme.style.answer(formattedValue);
37
62
  }
38
- });
39
- const message = theme.style.message(config.message, status);
40
- let formattedValue = "";
41
- let helpTip;
42
- if (config.mask) {
43
- const maskChar = typeof config.mask === "string" ? config.mask : "*";
44
- formattedValue = maskChar.repeat(value.length);
45
- } else if (status !== "done") {
46
- helpTip = `${theme.style.help("[input is masked]")}${ansiEscapes.cursorHide}`;
47
- }
48
- if (status === "done") {
49
- formattedValue = theme.style.answer(formattedValue);
50
- }
51
- let error = "";
52
- if (errorMsg) {
53
- error = theme.style.error(errorMsg);
54
- }
55
- return [
56
- [prefix, message, config.mask ? formattedValue : helpTip].join(" "),
57
- error
58
- ];
63
+
64
+ let error = '';
65
+
66
+ if (errorMsg) {
67
+ error = theme.style.error(errorMsg);
68
+ }
69
+
70
+ return [
71
+ [
72
+ prefix,
73
+ message,
74
+ config.mask ? formattedValue : helpTip,
75
+ ].join(' '),
76
+ error,
77
+ ];
59
78
  });
@@ -1,120 +1,2 @@
1
- import { Value } from "@sinclair/typebox/value";
2
- import { bar, fmt } from "../../utils/messages.js";
3
- import {
4
- countLines,
5
- deleteLastLines
6
- } from "../../utils/terminal.js";
7
- export async function passwordPrompt(options) {
8
- const {
9
- title,
10
- hint,
11
- validate,
12
- schema,
13
- defaultValue,
14
- titleColor = "cyanBright",
15
- answerColor = "none",
16
- titleTypography = "bold",
17
- titleVariant,
18
- content,
19
- contentColor,
20
- contentTypography,
21
- contentVariant,
22
- borderColor = "viceGradient",
23
- variantOptions
24
- } = options;
25
- let linesToDelete = 0;
26
- let errorMessage = "";
27
- while (true) {
28
- const question = fmt({
29
- type: errorMessage !== "" ? "M_ERROR" : "M_GENERAL",
30
- title: `${title}${defaultValue ? ` [Default: ****]` : ""}`,
31
- titleColor,
32
- titleTypography,
33
- titleVariant,
34
- content,
35
- contentColor,
36
- contentTypography,
37
- contentVariant,
38
- borderColor,
39
- hint,
40
- variantOptions,
41
- errorMessage
42
- });
43
- const questionLines = countLines(question);
44
- if (linesToDelete > 0) {
45
- deleteLastLines(linesToDelete);
46
- }
47
- process.stdout.write(question);
48
- const password = await readPassword(borderColor);
49
- linesToDelete = questionLines + 1;
50
- const formattedBar = bar({ borderColor });
51
- if (!password.trim() && defaultValue !== void 0) {
52
- deleteLastLines(2);
53
- process.stdout.write(`${formattedBar} ****`);
54
- console.log(`
55
- ${formattedBar}`);
56
- return defaultValue;
57
- }
58
- let isValid = true;
59
- errorMessage = "";
60
- if (schema) {
61
- isValid = Value.Check(schema, password);
62
- if (!isValid) {
63
- const errors = [...Value.Errors(schema, password)];
64
- if (errors.length > 0) {
65
- errorMessage = errors[0]?.message ?? "Invalid input.";
66
- } else {
67
- errorMessage = "Invalid input.";
68
- }
69
- }
70
- }
71
- if (validate && isValid) {
72
- const validation = await validate(password);
73
- if (validation !== true) {
74
- isValid = false;
75
- errorMessage = typeof validation === "string" ? validation : "Invalid input.";
76
- }
77
- }
78
- if (isValid) {
79
- process.stdout.write("\n");
80
- return password;
81
- } else {
82
- }
83
- }
84
- }
85
- function readPassword(borderColor) {
86
- return new Promise((resolve, reject) => {
87
- const stdin = process.stdin;
88
- let password = "";
89
- const formattedBar = bar({ borderColor });
90
- stdin.setRawMode(true);
91
- stdin.resume();
92
- stdin.setEncoding("utf8");
93
- const onData = function(char) {
94
- char = char.toString();
95
- if (char === "\n" || char === "\r" || char === "") {
96
- stdin.setRawMode(false);
97
- stdin.pause();
98
- stdin.removeListener("data", onData);
99
- process.stdout.write(`
100
- ${formattedBar}`);
101
- resolve(password.trim());
102
- } else if (char === "") {
103
- stdin.setRawMode(false);
104
- stdin.pause();
105
- stdin.removeListener("data", onData);
106
- reject(new Error("User aborted."));
107
- } else if (char === "\x7F" ||
108
- char === "\b" || char === "\x7F" || char === "\b") {
109
- if (password.length > 0) {
110
- password = password.slice(0, -1);
111
- process.stdout.write("\b \b");
112
- }
113
- } else {
114
- password += char;
115
- process.stdout.write("*");
116
- }
117
- };
118
- stdin.on("data", onData);
119
- });
120
- }
1
+ export function passwordPrompt() {
2
+ while (true) {}}
@@ -1,28 +1,32 @@
1
- import color from "picocolors";
2
- import Prompt from "../../components/prompts/prompt.js";
1
+ import color from 'picocolors';
2
+ import Prompt from '../../components/prompts/prompt.js';
3
+
3
4
  export default class PasswordPrompt extends Prompt {
4
- valueWithCursor = "";
5
- _mask = "\u2022";
6
- get cursor() {
7
- return this._cursor;
8
- }
9
- get masked() {
10
- return this.value.replaceAll(/./g, this._mask);
11
- }
12
- constructor({ mask, ...opts }) {
13
- super(opts);
14
- this._mask = mask ?? "\u2022";
15
- this.on("finalize", () => {
16
- this.valueWithCursor = this.masked;
17
- });
18
- this.on("value", () => {
19
- if (this.cursor >= this.value.length) {
20
- this.valueWithCursor = `${this.masked}${color.inverse(color.hidden("_"))}`;
21
- } else {
22
- const s1 = this.masked.slice(0, this.cursor);
23
- const s2 = this.masked.slice(this.cursor);
24
- this.valueWithCursor = `${s1}${color.inverse(s2[0])}${s2.slice(1)}`;
25
- }
26
- });
27
- }
5
+ valueWithCursor = '';
6
+ _mask = '\u2022';
7
+ get cursor() {
8
+ return this._cursor;
9
+ }
10
+
11
+ get masked() {
12
+ return this.value.replaceAll(/./g, this._mask);
13
+ }
14
+
15
+ constructor({mask, ...opts}) {
16
+ super(opts);
17
+ this._mask = mask ?? '\u2022';
18
+ this.on('finalize', () => {
19
+ this.valueWithCursor = this.masked;
20
+ });
21
+ this.on('value', () => {
22
+ if (this.cursor >= this.value.length) {
23
+ this.valueWithCursor = `${this.masked}${color.inverse(color.hidden('_'))}`;
24
+ } else {
25
+ const s1 = this.masked.slice(0, this.cursor);
26
+ const s2 = this.masked.slice(this.cursor);
27
+
28
+ this.valueWithCursor = `${s1}${color.inverse(s2[0])}${s2.slice(1)}`;
29
+ }
30
+ });
31
+ }
28
32
  }
@@ -1,53 +1,72 @@
1
- import { green, greenBright, red } from "picocolors";
1
+ import {
2
+ green,
3
+ greenBright,
4
+ red,
5
+ } from 'picocolors';
6
+ import process from 'node:process';
7
+
2
8
  export class ProgressBar {
3
- total;
4
- current;
5
- width;
6
- completeChar;
7
- incompleteChar;
8
- startTime;
9
- format;
10
- colorize;
11
- constructor(options) {
12
- if (options.total <= 0) {
13
- throw new Error("Total must be a positive number");
9
+ total;
10
+ current;
11
+ width;
12
+ completeChar;
13
+ incompleteChar;
14
+ startTime;
15
+ format;
16
+ colorize;
17
+ constructor(options) {
18
+ if (options.total <= 0) {
19
+ throw Error('Total must be a positive number');
20
+ }
21
+
22
+ this.total = options.total;
23
+ this.current = 0;
24
+ this.width = options.width || 40;
25
+ this.completeChar = options.completeChar || '\u2588';
26
+ this.incompleteChar = options.incompleteChar || '\u2591';
27
+ this.startTime = Date.now();
28
+ this.format = options.format || 'Progress: [:bar] :percent% | Elapsed: :elapsed s';
29
+ this.colorize = options.colorize || false;
14
30
  }
15
- this.total = options.total;
16
- this.current = 0;
17
- this.width = options.width || 40;
18
- this.completeChar = options.completeChar || "\u2588";
19
- this.incompleteChar = options.incompleteChar || "\u2591";
20
- this.startTime = Date.now();
21
- this.format = options.format || "Progress: [:bar] :percent% | Elapsed: :elapsed s";
22
- this.colorize = options.colorize || false;
23
- }
31
+
24
32
  update(value) {
25
- const newValue = Math.min(value, this.total);
26
- if (newValue !== this.current) {
27
- this.current = newValue;
28
- this.render();
33
+ const newValue = Math.min(value, this.total);
34
+
35
+ if (newValue !== this.current) {
36
+ this.current = newValue;
37
+ this.render();
38
+ }
29
39
  }
30
- }
40
+
31
41
  increment(amount = 1) {
32
- this.update(this.current + amount);
33
- }
34
- render() {
35
- const percent = this.current / this.total;
36
- const filledLength = Math.round(this.width * percent);
37
- const emptyLength = this.width - filledLength;
38
- let bar = this.completeChar.repeat(filledLength) + this.incompleteChar.repeat(emptyLength);
39
- if (this.colorize) {
40
- bar = green(this.completeChar.repeat(filledLength)) + red(this.incompleteChar.repeat(emptyLength));
42
+ this.update(this.current + amount);
41
43
  }
42
- const percentage = (percent * 100).toFixed(2);
43
- const elapsed = ((Date.now() - this.startTime) / 1e3).toFixed(2);
44
- const eta = percent > 0 ? ((Date.now() - this.startTime) / percent / 1e3).toFixed(2) : "N/A";
45
- const output = this.format.replace(":bar", bar).replace(":percent", percentage).replace(":elapsed", elapsed).replace(":eta", eta);
46
- process.stdout.clearLine(0);
47
- process.stdout.cursorTo(0);
48
- process.stdout.write(greenBright("\u25C6") + " " + output);
49
- if (this.current >= this.total) {
50
- process.stdout.write("\n");
44
+
45
+ render() {
46
+ const percent = this.current / this.total;
47
+ const filledLength = Math.round(this.width * percent);
48
+ const emptyLength = this.width - filledLength;
49
+ let bar = this.completeChar.repeat(filledLength) + this.incompleteChar.repeat(emptyLength);
50
+
51
+ if (this.colorize) {
52
+ bar = green(this.completeChar.repeat(filledLength)) + red(this.incompleteChar.repeat(emptyLength));
53
+ }
54
+
55
+ const percentage = (percent * 100).toFixed(2);
56
+ const elapsed = ((Date.now() - this.startTime) / 1e3).toFixed(2);
57
+ const eta = percent > 0 ? ((Date.now() - this.startTime) / percent / 1e3).toFixed(2) : 'N/A';
58
+ const output = this
59
+ .format
60
+ .replace(':bar', bar)
61
+ .replace(':percent', percentage)
62
+ .replace(':elapsed', elapsed)
63
+ .replace(':eta', eta);
64
+
65
+ process.stdout.clearLine(0);
66
+ process.stdout.cursorTo(0);
67
+ process.stdout.write(greenBright('\u25C6') + ' ' + output);
68
+ if (this.current >= this.total) {
69
+ process.stdout.write('\n');
70
+ }
51
71
  }
52
- }
53
72
  }
@@ -1,38 +1,45 @@
1
- import { msg } from "../../utils/messages.js";
2
- import { ProgressBar } from "./ProgressBar.js";
1
+ import {msg} from '../../utils/messages.js';
2
+ import {ProgressBar} from './ProgressBar.js';
3
+
3
4
  export async function progressbar(options) {
4
- const {
5
- total,
6
- increment = 1,
7
- desiredTotalTime = 3e3,
8
- ...progressBarOptions
9
- } = options;
10
- if (increment <= 0) {
11
- throw new Error("Increment must be a positive number");
12
- }
13
- const iterations = Math.ceil(total / increment) + 1;
14
- const delay = desiredTotalTime / iterations;
15
- const progressBar = new ProgressBar({
16
- total,
17
- ...progressBarOptions
18
- });
19
- try {
20
- for (let i = 0; i <= total; i += increment) {
21
- progressBar.update(i);
22
- await sleep(delay);
5
+ const {
6
+ total,
7
+ increment = 1,
8
+ desiredTotalTime = 3e3,
9
+ ...progressBarOptions
10
+ } = options;
11
+
12
+ if (increment <= 0) {
13
+ throw Error('Increment must be a positive number');
23
14
  }
24
- if (total % increment !== 0) {
25
- progressBar.update(total);
26
- }
27
- } catch (error) {
28
- console.error("Progress bar encountered an error:", error);
29
- }
30
- msg({
31
- type: "M_MIDDLE",
32
- title: "",
33
- borderColor: "viceGradient"
34
- });
15
+
16
+ const iterations = Math.ceil(total / increment) + 1;
17
+ const delay = desiredTotalTime / iterations;
18
+
19
+ const progressBar = new ProgressBar({
20
+ total,
21
+ ...progressBarOptions,
22
+ });
23
+
24
+ try {
25
+ for (let i = 0; i <= total; i += increment) {
26
+ progressBar.update(i);
27
+ await sleep(delay);
28
+ }
29
+
30
+ if (total % increment) {
31
+ progressBar.update(total);
32
+ }
33
+ } catch(error) {}
34
+
35
+
36
+ msg({
37
+ type: 'M_MIDDLE',
38
+ title: '',
39
+ borderColor: 'viceGradient',
40
+ });
35
41
  }
42
+
36
43
  function sleep(ms) {
37
- return new Promise((resolve) => setTimeout(resolve, ms));
44
+ return new Promise((resolve) => setTimeout(resolve, ms));
38
45
  }
@@ -1 +1 @@
1
- export { progressbar } from "./helper.js";
1
+ export {progressbar} from './helper.js';
@@ -1,35 +1,50 @@
1
- import { isDebug, isTest, isCI } from "std-env";
2
- import { LogLevels } from "../../utils/constants.js";
3
- import { BasicReporter } from "../instance/reporter/basic.js";
4
- import { FancyReporter } from "../instance/reporter/fancy.js";
5
- import { createRelinka as _createRelinka } from "./relinka.js";
6
- export * from "../instance/shared.js";
1
+ import {
2
+ isDebug,
3
+ isTest,
4
+ isCI,
5
+ } from 'std-env';
6
+ import process from 'node:process';
7
+ import {LogLevels} from '../../utils/constants.js';
8
+ import {BasicReporter} from '../instance/reporter/basic.js';
9
+ import {FancyReporter} from '../instance/reporter/fancy.js';
10
+ import {createRelinka as _createRelinka} from './relinka.js';
11
+
12
+ export * from '../instance/shared.js';
7
13
  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
- prompt: (...args) => import("../../components/mono/monoTwo.js").then((m) => m.prompt(...args)),
18
- reporters: options.reporters || [
19
- options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()
20
- ],
21
- ...options
22
- });
23
- return relinka2;
14
+ let level = _getDefaultLogLevel();
15
+
16
+ if (process.env.RELINKA_LEVEL) {
17
+ level = Number.parseInt(process.env.RELINKA_LEVEL) ?? level;
18
+ }
19
+
20
+ const relinka2 = _createRelinka({
21
+ level,
22
+ defaults: {
23
+ level,
24
+ },
25
+ stdout: process.stdout,
26
+ stderr: process.stderr,
27
+ prompt: (...args) => import('../../components/mono/monoTwo.js').then((m) => m.prompt(...args)),
28
+ reporters: options.reporters || [
29
+ options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter(),
30
+ ],
31
+ ...options,
32
+ });
33
+
34
+ return relinka2;
24
35
  }
36
+
25
37
  function _getDefaultLogLevel() {
26
- if (isDebug) {
27
- return LogLevels.debug;
28
- }
29
- if (isTest) {
30
- return LogLevels.warn;
31
- }
32
- return LogLevels.info;
38
+ if (isDebug) {
39
+ return LogLevels.debug;
40
+ }
41
+
42
+ if (isTest) {
43
+ return LogLevels.warn;
44
+ }
45
+
46
+ return LogLevels.info;
33
47
  }
48
+
34
49
  export const relinka = createRelinka();
35
50
  export default relinka;