@maz-ui/node 4.0.0-beta.8 → 4.0.0
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 +2 -1
- package/dist/index.mjs +4 -156
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -99,7 +99,8 @@ catch (error) {
|
|
|
99
99
|
### Custom Logger Integration
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
|
-
import {
|
|
102
|
+
import type { Logger } from '@maz-ui/node'
|
|
103
|
+
import { execPromise, logger } from '@maz-ui/node'
|
|
103
104
|
|
|
104
105
|
// Create custom logger with additional functionality
|
|
105
106
|
const customLogger: Logger = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,158 +1,6 @@
|
|
|
1
1
|
import { exec } from 'node:child_process';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
function e(t) {
|
|
5
|
-
return t instanceof Error ? t.message : typeof t == "string" ? t : t && typeof t == "object" && "message" in t ? String(t.message) : t ? String(t) : "An unexpected error occurred";
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
env = {},
|
|
10
|
-
argv = [],
|
|
11
|
-
platform = "",
|
|
12
|
-
} = typeof process === "undefined" ? {} : process;
|
|
13
|
-
|
|
14
|
-
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
15
|
-
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
16
|
-
const isWindows = platform === "win32";
|
|
17
|
-
const isDumbTerminal = env.TERM === "dumb";
|
|
18
|
-
|
|
19
|
-
const isCompatibleTerminal =
|
|
20
|
-
tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
21
|
-
|
|
22
|
-
const isCI =
|
|
23
|
-
"CI" in env &&
|
|
24
|
-
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
25
|
-
|
|
26
|
-
const isColorSupported =
|
|
27
|
-
!isDisabled &&
|
|
28
|
-
(isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI);
|
|
29
|
-
|
|
30
|
-
const replaceClose = (
|
|
31
|
-
index,
|
|
32
|
-
string,
|
|
33
|
-
close,
|
|
34
|
-
replace,
|
|
35
|
-
head = string.substring(0, index) + replace,
|
|
36
|
-
tail = string.substring(index + close.length),
|
|
37
|
-
next = tail.indexOf(close)
|
|
38
|
-
) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
39
|
-
|
|
40
|
-
const clearBleed = (index, string, open, close, replace) =>
|
|
41
|
-
index < 0
|
|
42
|
-
? open + string + close
|
|
43
|
-
: open + replaceClose(index, string, close, replace) + close;
|
|
44
|
-
|
|
45
|
-
const filterEmpty =
|
|
46
|
-
(open, close, replace = open, at = open.length + 1) =>
|
|
47
|
-
(string) =>
|
|
48
|
-
string || !(string === "" || string === undefined)
|
|
49
|
-
? clearBleed(
|
|
50
|
-
("" + string).indexOf(close, at),
|
|
51
|
-
string,
|
|
52
|
-
open,
|
|
53
|
-
close,
|
|
54
|
-
replace
|
|
55
|
-
)
|
|
56
|
-
: "";
|
|
57
|
-
|
|
58
|
-
const init = (open, close, replace) =>
|
|
59
|
-
filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
60
|
-
|
|
61
|
-
const colors = {
|
|
62
|
-
reset: init(0, 0),
|
|
63
|
-
bold: init(1, 22, "\x1b[22m\x1b[1m"),
|
|
64
|
-
dim: init(2, 22, "\x1b[22m\x1b[2m"),
|
|
65
|
-
italic: init(3, 23),
|
|
66
|
-
underline: init(4, 24),
|
|
67
|
-
inverse: init(7, 27),
|
|
68
|
-
hidden: init(8, 28),
|
|
69
|
-
strikethrough: init(9, 29),
|
|
70
|
-
black: init(30, 39),
|
|
71
|
-
red: init(31, 39),
|
|
72
|
-
green: init(32, 39),
|
|
73
|
-
yellow: init(33, 39),
|
|
74
|
-
blue: init(34, 39),
|
|
75
|
-
magenta: init(35, 39),
|
|
76
|
-
cyan: init(36, 39),
|
|
77
|
-
white: init(37, 39),
|
|
78
|
-
gray: init(90, 39),
|
|
79
|
-
bgBlack: init(40, 49),
|
|
80
|
-
bgRed: init(41, 49),
|
|
81
|
-
bgGreen: init(42, 49),
|
|
82
|
-
bgYellow: init(43, 49),
|
|
83
|
-
bgBlue: init(44, 49),
|
|
84
|
-
bgMagenta: init(45, 49),
|
|
85
|
-
bgCyan: init(46, 49),
|
|
86
|
-
bgWhite: init(47, 49),
|
|
87
|
-
blackBright: init(90, 39),
|
|
88
|
-
redBright: init(91, 39),
|
|
89
|
-
greenBright: init(92, 39),
|
|
90
|
-
yellowBright: init(93, 39),
|
|
91
|
-
blueBright: init(94, 39),
|
|
92
|
-
magentaBright: init(95, 39),
|
|
93
|
-
cyanBright: init(96, 39),
|
|
94
|
-
whiteBright: init(97, 39),
|
|
95
|
-
bgBlackBright: init(100, 49),
|
|
96
|
-
bgRedBright: init(101, 49),
|
|
97
|
-
bgGreenBright: init(102, 49),
|
|
98
|
-
bgYellowBright: init(103, 49),
|
|
99
|
-
bgBlueBright: init(104, 49),
|
|
100
|
-
bgMagentaBright: init(105, 49),
|
|
101
|
-
bgCyanBright: init(106, 49),
|
|
102
|
-
bgWhiteBright: init(107, 49),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const createColors = ({ useColor = isColorSupported } = {}) =>
|
|
106
|
-
useColor
|
|
107
|
-
? colors
|
|
108
|
-
: Object.keys(colors).reduce(
|
|
109
|
-
(colors, key) => ({ ...colors, [key]: String }),
|
|
110
|
-
{}
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const {
|
|
114
|
-
reset,
|
|
115
|
-
bold,
|
|
116
|
-
dim,
|
|
117
|
-
italic,
|
|
118
|
-
underline,
|
|
119
|
-
inverse,
|
|
120
|
-
hidden,
|
|
121
|
-
strikethrough,
|
|
122
|
-
black,
|
|
123
|
-
red,
|
|
124
|
-
green,
|
|
125
|
-
yellow,
|
|
126
|
-
blue,
|
|
127
|
-
magenta,
|
|
128
|
-
cyan,
|
|
129
|
-
white,
|
|
130
|
-
gray,
|
|
131
|
-
bgBlack,
|
|
132
|
-
bgRed,
|
|
133
|
-
bgGreen,
|
|
134
|
-
bgYellow,
|
|
135
|
-
bgBlue,
|
|
136
|
-
bgMagenta,
|
|
137
|
-
bgCyan,
|
|
138
|
-
bgWhite,
|
|
139
|
-
blackBright,
|
|
140
|
-
redBright,
|
|
141
|
-
greenBright,
|
|
142
|
-
yellowBright,
|
|
143
|
-
blueBright,
|
|
144
|
-
magentaBright,
|
|
145
|
-
cyanBright,
|
|
146
|
-
whiteBright,
|
|
147
|
-
bgBlackBright,
|
|
148
|
-
bgRedBright,
|
|
149
|
-
bgGreenBright,
|
|
150
|
-
bgYellowBright,
|
|
151
|
-
bgBlueBright,
|
|
152
|
-
bgMagentaBright,
|
|
153
|
-
bgCyanBright,
|
|
154
|
-
bgWhiteBright,
|
|
155
|
-
} = createColors();
|
|
2
|
+
import { getErrorMessage } from '@maz-ui/utils/helpers/getErrorMessage';
|
|
3
|
+
import { yellow, red, green, blueBright } from 'colorette';
|
|
156
4
|
|
|
157
5
|
const log = console.log;
|
|
158
6
|
const logger = {
|
|
@@ -162,11 +10,11 @@ const logger = {
|
|
|
162
10
|
log: (...message) => log(...message),
|
|
163
11
|
success: (...message) => log(...message.map((m) => green(m))),
|
|
164
12
|
error: (message, error) => {
|
|
165
|
-
const errorMessage = error ?
|
|
13
|
+
const errorMessage = error ? getErrorMessage(error) : "";
|
|
166
14
|
log(red(message), errorMessage ? red(errorMessage) : "");
|
|
167
15
|
},
|
|
168
16
|
warn: (message, error) => {
|
|
169
|
-
const errorMessage = error ?
|
|
17
|
+
const errorMessage = error ? getErrorMessage(error) : "";
|
|
170
18
|
log(yellow(message), errorMessage ? yellow(errorMessage) : "");
|
|
171
19
|
}
|
|
172
20
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0
|
|
5
|
-
"packageManager": "pnpm@10.13.1",
|
|
4
|
+
"version": "4.0.0",
|
|
6
5
|
"description": "Node utilities for Maz-UI library",
|
|
7
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
8
7
|
"license": "MIT",
|
|
@@ -43,20 +42,22 @@
|
|
|
43
42
|
"build": "unbuild",
|
|
44
43
|
"dev": "unbuild --stub",
|
|
45
44
|
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
46
|
-
"lint": "eslint .",
|
|
47
|
-
"lint:fix": "
|
|
45
|
+
"lint": "cross-env NODE_ENV=production eslint .",
|
|
46
|
+
"lint:fix": "pnpm lint --fix",
|
|
48
47
|
"pre-commit": "lint-staged"
|
|
49
48
|
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@maz-ui/utils": "4.0.0",
|
|
51
|
+
"colorette": "^2.0.20"
|
|
52
|
+
},
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^5.8.3",
|
|
54
|
-
"unbuild": "^3.5.0"
|
|
54
|
+
"typescript": "^5.9.2",
|
|
55
|
+
"unbuild": "^3.6.0"
|
|
55
56
|
},
|
|
56
57
|
"lint-staged": {
|
|
57
|
-
"*.{js,jsx,ts,tsx,mjs,mts,cjs,md}": [
|
|
58
|
+
"*.{js,jsx,ts,tsx,mjs,mts,cjs,md,yml,json}": [
|
|
58
59
|
"eslint --fix"
|
|
59
60
|
]
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "b2e03a043ad3334ed5ce456c7f0e67c728c09524"
|
|
62
63
|
}
|