@storm-software/tsdown 0.36.59 → 0.36.66
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 +1 -1
- package/dist/build.cjs +3 -3
- package/dist/build.js +2 -2
- package/dist/{chunk-CEXNXG7S.cjs → chunk-7L7BKTGQ.cjs} +756 -121
- package/dist/{chunk-44GBTB3B.js → chunk-AQ4RJKTQ.js} +659 -24
- package/dist/chunk-IAKUT4HI.js +326 -0
- package/dist/chunk-IO7MJMVE.cjs +326 -0
- package/dist/clean.cjs +2 -2
- package/dist/clean.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-7DJJEEQO.js +0 -895
- package/dist/chunk-VGKKFBSD.cjs +0 -895
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// ../config-tools/src/types.ts
|
|
2
|
+
var LogLevel = {
|
|
3
|
+
SILENT: 0,
|
|
4
|
+
FATAL: 10,
|
|
5
|
+
ERROR: 20,
|
|
6
|
+
WARN: 30,
|
|
7
|
+
SUCCESS: 35,
|
|
8
|
+
INFO: 40,
|
|
9
|
+
DEBUG: 60,
|
|
10
|
+
TRACE: 70,
|
|
11
|
+
ALL: 100
|
|
12
|
+
};
|
|
13
|
+
var LogLevelLabel = {
|
|
14
|
+
SILENT: "silent",
|
|
15
|
+
FATAL: "fatal",
|
|
16
|
+
ERROR: "error",
|
|
17
|
+
WARN: "warn",
|
|
18
|
+
SUCCESS: "success",
|
|
19
|
+
INFO: "info",
|
|
20
|
+
DEBUG: "debug",
|
|
21
|
+
TRACE: "trace",
|
|
22
|
+
ALL: "all"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// ../config-tools/src/utilities/colors.ts
|
|
26
|
+
var DEFAULT_COLOR_CONFIG = {
|
|
27
|
+
light: {
|
|
28
|
+
background: "#fafafa",
|
|
29
|
+
foreground: "#1d1e22",
|
|
30
|
+
brand: "#1fb2a6",
|
|
31
|
+
alternate: "#db2777",
|
|
32
|
+
help: "#5C4EE5",
|
|
33
|
+
success: "#087f5b",
|
|
34
|
+
info: "#0550ae",
|
|
35
|
+
warning: "#e3b341",
|
|
36
|
+
danger: "#D8314A",
|
|
37
|
+
fatal: "#51070f",
|
|
38
|
+
link: "#3fa6ff",
|
|
39
|
+
positive: "#22c55e",
|
|
40
|
+
negative: "#dc2626",
|
|
41
|
+
gradient: ["#1fb2a6", "#db2777", "#5C4EE5"]
|
|
42
|
+
},
|
|
43
|
+
dark: {
|
|
44
|
+
background: "#1d1e22",
|
|
45
|
+
foreground: "#cbd5e1",
|
|
46
|
+
brand: "#2dd4bf",
|
|
47
|
+
alternate: "#db2777",
|
|
48
|
+
help: "#818cf8",
|
|
49
|
+
success: "#10b981",
|
|
50
|
+
info: "#58a6ff",
|
|
51
|
+
warning: "#f3d371",
|
|
52
|
+
danger: "#D8314A",
|
|
53
|
+
fatal: "#a40e26",
|
|
54
|
+
link: "#3fa6ff",
|
|
55
|
+
positive: "#22c55e",
|
|
56
|
+
negative: "#dc2626",
|
|
57
|
+
gradient: ["#1fb2a6", "#db2777", "#818cf8"]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ../config-tools/src/logger/chalk.ts
|
|
62
|
+
import chalk from "chalk";
|
|
63
|
+
var chalkDefault = {
|
|
64
|
+
hex: (_) => (message) => message,
|
|
65
|
+
bgHex: (_) => ({
|
|
66
|
+
whiteBright: (message) => message,
|
|
67
|
+
white: (message) => message
|
|
68
|
+
}),
|
|
69
|
+
white: (message) => message,
|
|
70
|
+
whiteBright: (message) => message,
|
|
71
|
+
gray: (message) => message,
|
|
72
|
+
bold: {
|
|
73
|
+
hex: (_) => (message) => message,
|
|
74
|
+
bgHex: (_) => ({
|
|
75
|
+
whiteBright: (message) => message,
|
|
76
|
+
white: (message) => message
|
|
77
|
+
}),
|
|
78
|
+
whiteBright: (message) => message,
|
|
79
|
+
white: (message) => message
|
|
80
|
+
},
|
|
81
|
+
dim: {
|
|
82
|
+
hex: (_) => (message) => message,
|
|
83
|
+
gray: (message) => message
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var getChalk = () => {
|
|
87
|
+
let _chalk = chalk;
|
|
88
|
+
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) {
|
|
89
|
+
_chalk = chalkDefault;
|
|
90
|
+
}
|
|
91
|
+
return _chalk;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ../config-tools/src/logger/is-unicode-supported.ts
|
|
95
|
+
function isUnicodeSupported() {
|
|
96
|
+
if (process.platform !== "win32") {
|
|
97
|
+
return process.env.TERM !== "linux";
|
|
98
|
+
}
|
|
99
|
+
return Boolean(process.env.WT_SESSION) || // Windows Terminal
|
|
100
|
+
Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
|
|
101
|
+
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
|
|
102
|
+
process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ../config-tools/src/logger/console-icons.ts
|
|
106
|
+
var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
|
|
107
|
+
var CONSOLE_ICONS = {
|
|
108
|
+
[LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
|
|
109
|
+
[LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
|
|
110
|
+
[LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
|
|
111
|
+
[LogLevelLabel.INFO]: useIcon("\u2139", "i"),
|
|
112
|
+
[LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
|
|
113
|
+
[LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
|
|
114
|
+
[LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
|
|
115
|
+
[LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ../config-tools/src/logger/format-timestamp.ts
|
|
119
|
+
var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
|
|
120
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// ../config-tools/src/logger/get-log-level.ts
|
|
124
|
+
var getLogLevel = (label) => {
|
|
125
|
+
switch (label) {
|
|
126
|
+
case "all":
|
|
127
|
+
return LogLevel.ALL;
|
|
128
|
+
case "trace":
|
|
129
|
+
return LogLevel.TRACE;
|
|
130
|
+
case "debug":
|
|
131
|
+
return LogLevel.DEBUG;
|
|
132
|
+
case "info":
|
|
133
|
+
return LogLevel.INFO;
|
|
134
|
+
case "warn":
|
|
135
|
+
return LogLevel.WARN;
|
|
136
|
+
case "error":
|
|
137
|
+
return LogLevel.ERROR;
|
|
138
|
+
case "fatal":
|
|
139
|
+
return LogLevel.FATAL;
|
|
140
|
+
case "silent":
|
|
141
|
+
return LogLevel.SILENT;
|
|
142
|
+
default:
|
|
143
|
+
return LogLevel.INFO;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
|
|
147
|
+
if (logLevel >= LogLevel.ALL) {
|
|
148
|
+
return LogLevelLabel.ALL;
|
|
149
|
+
}
|
|
150
|
+
if (logLevel >= LogLevel.TRACE) {
|
|
151
|
+
return LogLevelLabel.TRACE;
|
|
152
|
+
}
|
|
153
|
+
if (logLevel >= LogLevel.DEBUG) {
|
|
154
|
+
return LogLevelLabel.DEBUG;
|
|
155
|
+
}
|
|
156
|
+
if (logLevel >= LogLevel.INFO) {
|
|
157
|
+
return LogLevelLabel.INFO;
|
|
158
|
+
}
|
|
159
|
+
if (logLevel >= LogLevel.WARN) {
|
|
160
|
+
return LogLevelLabel.WARN;
|
|
161
|
+
}
|
|
162
|
+
if (logLevel >= LogLevel.ERROR) {
|
|
163
|
+
return LogLevelLabel.ERROR;
|
|
164
|
+
}
|
|
165
|
+
if (logLevel >= LogLevel.FATAL) {
|
|
166
|
+
return LogLevelLabel.FATAL;
|
|
167
|
+
}
|
|
168
|
+
if (logLevel <= LogLevel.SILENT) {
|
|
169
|
+
return LogLevelLabel.SILENT;
|
|
170
|
+
}
|
|
171
|
+
return LogLevelLabel.INFO;
|
|
172
|
+
};
|
|
173
|
+
var isVerbose = (label = LogLevelLabel.SILENT) => {
|
|
174
|
+
const logLevel = typeof label === "string" ? getLogLevel(label) : label;
|
|
175
|
+
return logLevel >= LogLevel.DEBUG;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// ../config-tools/src/logger/console.ts
|
|
179
|
+
var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
180
|
+
const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
|
|
181
|
+
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
182
|
+
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
183
|
+
return (_) => {
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
187
|
+
return (message) => {
|
|
188
|
+
console.error(
|
|
189
|
+
`
|
|
190
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? DEFAULT_COLOR_CONFIG.dark.fatal)(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
191
|
+
`
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
196
|
+
return (message) => {
|
|
197
|
+
console.error(
|
|
198
|
+
`
|
|
199
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? DEFAULT_COLOR_CONFIG.dark.danger)(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
200
|
+
`
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
205
|
+
return (message) => {
|
|
206
|
+
console.warn(
|
|
207
|
+
`
|
|
208
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? DEFAULT_COLOR_CONFIG.dark.warning)(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
214
|
+
return (message) => {
|
|
215
|
+
console.info(
|
|
216
|
+
`
|
|
217
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? DEFAULT_COLOR_CONFIG.dark.success)(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
218
|
+
`
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
223
|
+
return (message) => {
|
|
224
|
+
console.info(
|
|
225
|
+
`
|
|
226
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
227
|
+
`
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
232
|
+
return (message) => {
|
|
233
|
+
console.debug(
|
|
234
|
+
`
|
|
235
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
236
|
+
`
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
241
|
+
return (message) => {
|
|
242
|
+
console.debug(
|
|
243
|
+
`
|
|
244
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
245
|
+
`
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return (message) => {
|
|
250
|
+
console.log(
|
|
251
|
+
`
|
|
252
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CONFIG.dark.brand)(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
253
|
+
`
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
|
|
258
|
+
var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
|
|
259
|
+
var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
|
|
260
|
+
var writeDebug = (message, config) => getLogFn(LogLevel.DEBUG, config)(message);
|
|
261
|
+
var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
|
|
262
|
+
var getStopwatch = (name) => {
|
|
263
|
+
const start = process.hrtime();
|
|
264
|
+
return () => {
|
|
265
|
+
const end = process.hrtime(start);
|
|
266
|
+
console.info(
|
|
267
|
+
`
|
|
268
|
+
> \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
|
|
269
|
+
end[0] * 1e3 + end[1] / 1e6
|
|
270
|
+
)}ms to complete
|
|
271
|
+
`
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
var MAX_DEPTH = 4;
|
|
276
|
+
var formatLogMessage = (message, options = {}, depth = 0) => {
|
|
277
|
+
if (depth > MAX_DEPTH) {
|
|
278
|
+
return "<max depth>";
|
|
279
|
+
}
|
|
280
|
+
const prefix = options.prefix ?? "-";
|
|
281
|
+
const skip = options.skip ?? [];
|
|
282
|
+
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
|
|
283
|
+
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
|
|
284
|
+
${Object.keys(message).filter((key) => !skip.includes(key)).map(
|
|
285
|
+
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
|
|
286
|
+
message[key],
|
|
287
|
+
{ prefix: `${prefix}-`, skip },
|
|
288
|
+
depth + 1
|
|
289
|
+
) : message[key]}`
|
|
290
|
+
).join("\n")}` : message;
|
|
291
|
+
};
|
|
292
|
+
var _isFunction = (value) => {
|
|
293
|
+
try {
|
|
294
|
+
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
|
|
295
|
+
} catch {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/clean.ts
|
|
301
|
+
import { rm } from "node:fs/promises";
|
|
302
|
+
async function clean(name = "TSDown", directory, config) {
|
|
303
|
+
writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
304
|
+
const stopwatch = getStopwatch(`${name} output clean`);
|
|
305
|
+
await cleanDirectories(name, directory, config);
|
|
306
|
+
stopwatch();
|
|
307
|
+
}
|
|
308
|
+
async function cleanDirectories(name = "TSDown", directory, config) {
|
|
309
|
+
await rm(directory, { recursive: true, force: true });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export {
|
|
313
|
+
LogLevel,
|
|
314
|
+
getLogLevel,
|
|
315
|
+
getLogLevelLabel,
|
|
316
|
+
isVerbose,
|
|
317
|
+
writeFatal,
|
|
318
|
+
writeWarning,
|
|
319
|
+
writeSuccess,
|
|
320
|
+
writeDebug,
|
|
321
|
+
writeTrace,
|
|
322
|
+
getStopwatch,
|
|
323
|
+
formatLogMessage,
|
|
324
|
+
clean,
|
|
325
|
+
cleanDirectories
|
|
326
|
+
};
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ../config-tools/src/types.ts
|
|
2
|
+
var LogLevel = {
|
|
3
|
+
SILENT: 0,
|
|
4
|
+
FATAL: 10,
|
|
5
|
+
ERROR: 20,
|
|
6
|
+
WARN: 30,
|
|
7
|
+
SUCCESS: 35,
|
|
8
|
+
INFO: 40,
|
|
9
|
+
DEBUG: 60,
|
|
10
|
+
TRACE: 70,
|
|
11
|
+
ALL: 100
|
|
12
|
+
};
|
|
13
|
+
var LogLevelLabel = {
|
|
14
|
+
SILENT: "silent",
|
|
15
|
+
FATAL: "fatal",
|
|
16
|
+
ERROR: "error",
|
|
17
|
+
WARN: "warn",
|
|
18
|
+
SUCCESS: "success",
|
|
19
|
+
INFO: "info",
|
|
20
|
+
DEBUG: "debug",
|
|
21
|
+
TRACE: "trace",
|
|
22
|
+
ALL: "all"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// ../config-tools/src/utilities/colors.ts
|
|
26
|
+
var DEFAULT_COLOR_CONFIG = {
|
|
27
|
+
light: {
|
|
28
|
+
background: "#fafafa",
|
|
29
|
+
foreground: "#1d1e22",
|
|
30
|
+
brand: "#1fb2a6",
|
|
31
|
+
alternate: "#db2777",
|
|
32
|
+
help: "#5C4EE5",
|
|
33
|
+
success: "#087f5b",
|
|
34
|
+
info: "#0550ae",
|
|
35
|
+
warning: "#e3b341",
|
|
36
|
+
danger: "#D8314A",
|
|
37
|
+
fatal: "#51070f",
|
|
38
|
+
link: "#3fa6ff",
|
|
39
|
+
positive: "#22c55e",
|
|
40
|
+
negative: "#dc2626",
|
|
41
|
+
gradient: ["#1fb2a6", "#db2777", "#5C4EE5"]
|
|
42
|
+
},
|
|
43
|
+
dark: {
|
|
44
|
+
background: "#1d1e22",
|
|
45
|
+
foreground: "#cbd5e1",
|
|
46
|
+
brand: "#2dd4bf",
|
|
47
|
+
alternate: "#db2777",
|
|
48
|
+
help: "#818cf8",
|
|
49
|
+
success: "#10b981",
|
|
50
|
+
info: "#58a6ff",
|
|
51
|
+
warning: "#f3d371",
|
|
52
|
+
danger: "#D8314A",
|
|
53
|
+
fatal: "#a40e26",
|
|
54
|
+
link: "#3fa6ff",
|
|
55
|
+
positive: "#22c55e",
|
|
56
|
+
negative: "#dc2626",
|
|
57
|
+
gradient: ["#1fb2a6", "#db2777", "#818cf8"]
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ../config-tools/src/logger/chalk.ts
|
|
62
|
+
var _chalk2 = require('chalk'); var _chalk3 = _interopRequireDefault(_chalk2);
|
|
63
|
+
var chalkDefault = {
|
|
64
|
+
hex: (_) => (message) => message,
|
|
65
|
+
bgHex: (_) => ({
|
|
66
|
+
whiteBright: (message) => message,
|
|
67
|
+
white: (message) => message
|
|
68
|
+
}),
|
|
69
|
+
white: (message) => message,
|
|
70
|
+
whiteBright: (message) => message,
|
|
71
|
+
gray: (message) => message,
|
|
72
|
+
bold: {
|
|
73
|
+
hex: (_) => (message) => message,
|
|
74
|
+
bgHex: (_) => ({
|
|
75
|
+
whiteBright: (message) => message,
|
|
76
|
+
white: (message) => message
|
|
77
|
+
}),
|
|
78
|
+
whiteBright: (message) => message,
|
|
79
|
+
white: (message) => message
|
|
80
|
+
},
|
|
81
|
+
dim: {
|
|
82
|
+
hex: (_) => (message) => message,
|
|
83
|
+
gray: (message) => message
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var getChalk = () => {
|
|
87
|
+
let _chalk = _chalk3.default;
|
|
88
|
+
if (!_optionalChain([_chalk, 'optionalAccess', _2 => _2.hex]) || !_optionalChain([_chalk, 'optionalAccess', _3 => _3.bold, 'optionalAccess', _4 => _4.hex]) || !_optionalChain([_chalk, 'optionalAccess', _5 => _5.bgHex]) || !_optionalChain([_chalk, 'optionalAccess', _6 => _6.whiteBright]) || !_optionalChain([_chalk, 'optionalAccess', _7 => _7.white])) {
|
|
89
|
+
_chalk = chalkDefault;
|
|
90
|
+
}
|
|
91
|
+
return _chalk;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ../config-tools/src/logger/is-unicode-supported.ts
|
|
95
|
+
function isUnicodeSupported() {
|
|
96
|
+
if (process.platform !== "win32") {
|
|
97
|
+
return process.env.TERM !== "linux";
|
|
98
|
+
}
|
|
99
|
+
return Boolean(process.env.WT_SESSION) || // Windows Terminal
|
|
100
|
+
Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
|
|
101
|
+
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
|
|
102
|
+
process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ../config-tools/src/logger/console-icons.ts
|
|
106
|
+
var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
|
|
107
|
+
var CONSOLE_ICONS = {
|
|
108
|
+
[LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
|
|
109
|
+
[LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
|
|
110
|
+
[LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
|
|
111
|
+
[LogLevelLabel.INFO]: useIcon("\u2139", "i"),
|
|
112
|
+
[LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
|
|
113
|
+
[LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
|
|
114
|
+
[LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
|
|
115
|
+
[LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ../config-tools/src/logger/format-timestamp.ts
|
|
119
|
+
var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
|
|
120
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// ../config-tools/src/logger/get-log-level.ts
|
|
124
|
+
var getLogLevel = (label) => {
|
|
125
|
+
switch (label) {
|
|
126
|
+
case "all":
|
|
127
|
+
return LogLevel.ALL;
|
|
128
|
+
case "trace":
|
|
129
|
+
return LogLevel.TRACE;
|
|
130
|
+
case "debug":
|
|
131
|
+
return LogLevel.DEBUG;
|
|
132
|
+
case "info":
|
|
133
|
+
return LogLevel.INFO;
|
|
134
|
+
case "warn":
|
|
135
|
+
return LogLevel.WARN;
|
|
136
|
+
case "error":
|
|
137
|
+
return LogLevel.ERROR;
|
|
138
|
+
case "fatal":
|
|
139
|
+
return LogLevel.FATAL;
|
|
140
|
+
case "silent":
|
|
141
|
+
return LogLevel.SILENT;
|
|
142
|
+
default:
|
|
143
|
+
return LogLevel.INFO;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
|
|
147
|
+
if (logLevel >= LogLevel.ALL) {
|
|
148
|
+
return LogLevelLabel.ALL;
|
|
149
|
+
}
|
|
150
|
+
if (logLevel >= LogLevel.TRACE) {
|
|
151
|
+
return LogLevelLabel.TRACE;
|
|
152
|
+
}
|
|
153
|
+
if (logLevel >= LogLevel.DEBUG) {
|
|
154
|
+
return LogLevelLabel.DEBUG;
|
|
155
|
+
}
|
|
156
|
+
if (logLevel >= LogLevel.INFO) {
|
|
157
|
+
return LogLevelLabel.INFO;
|
|
158
|
+
}
|
|
159
|
+
if (logLevel >= LogLevel.WARN) {
|
|
160
|
+
return LogLevelLabel.WARN;
|
|
161
|
+
}
|
|
162
|
+
if (logLevel >= LogLevel.ERROR) {
|
|
163
|
+
return LogLevelLabel.ERROR;
|
|
164
|
+
}
|
|
165
|
+
if (logLevel >= LogLevel.FATAL) {
|
|
166
|
+
return LogLevelLabel.FATAL;
|
|
167
|
+
}
|
|
168
|
+
if (logLevel <= LogLevel.SILENT) {
|
|
169
|
+
return LogLevelLabel.SILENT;
|
|
170
|
+
}
|
|
171
|
+
return LogLevelLabel.INFO;
|
|
172
|
+
};
|
|
173
|
+
var isVerbose = (label = LogLevelLabel.SILENT) => {
|
|
174
|
+
const logLevel = typeof label === "string" ? getLogLevel(label) : label;
|
|
175
|
+
return logLevel >= LogLevel.DEBUG;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// ../config-tools/src/logger/console.ts
|
|
179
|
+
var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
180
|
+
const colors = !_optionalChain([config, 'access', _8 => _8.colors, 'optionalAccess', _9 => _9.dark]) && !_optionalChain([config, 'access', _10 => _10.colors, 'optionalAccess', _11 => _11["base"]]) && !_optionalChain([config, 'access', _12 => _12.colors, 'optionalAccess', _13 => _13["base"], 'optionalAccess', _14 => _14.dark]) ? DEFAULT_COLOR_CONFIG : _optionalChain([config, 'access', _15 => _15.colors, 'optionalAccess', _16 => _16.dark]) && typeof config.colors.dark === "string" ? config.colors : _optionalChain([config, 'access', _17 => _17.colors, 'optionalAccess', _18 => _18["base"], 'optionalAccess', _19 => _19.dark]) && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : _optionalChain([config, 'access', _20 => _20.colors, 'optionalAccess', _21 => _21["base"]]) ? _optionalChain([config, 'access', _22 => _22.colors, 'optionalAccess', _23 => _23["base"]]) : DEFAULT_COLOR_CONFIG;
|
|
181
|
+
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
182
|
+
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
183
|
+
return (_) => {
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
187
|
+
return (message) => {
|
|
188
|
+
console.error(
|
|
189
|
+
`
|
|
190
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.fatal, () => ( DEFAULT_COLOR_CONFIG.dark.fatal)))(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
191
|
+
`
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
196
|
+
return (message) => {
|
|
197
|
+
console.error(
|
|
198
|
+
`
|
|
199
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.danger, () => ( DEFAULT_COLOR_CONFIG.dark.danger)))(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
200
|
+
`
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
205
|
+
return (message) => {
|
|
206
|
+
console.warn(
|
|
207
|
+
`
|
|
208
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.warning, () => ( DEFAULT_COLOR_CONFIG.dark.warning)))(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
214
|
+
return (message) => {
|
|
215
|
+
console.info(
|
|
216
|
+
`
|
|
217
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.success, () => ( DEFAULT_COLOR_CONFIG.dark.success)))(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
218
|
+
`
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
223
|
+
return (message) => {
|
|
224
|
+
console.info(
|
|
225
|
+
`
|
|
226
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( DEFAULT_COLOR_CONFIG.dark.info)))(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
227
|
+
`
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
232
|
+
return (message) => {
|
|
233
|
+
console.debug(
|
|
234
|
+
`
|
|
235
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( DEFAULT_COLOR_CONFIG.dark.info)))(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
236
|
+
`
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
241
|
+
return (message) => {
|
|
242
|
+
console.debug(
|
|
243
|
+
`
|
|
244
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( DEFAULT_COLOR_CONFIG.dark.info)))(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
245
|
+
`
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return (message) => {
|
|
250
|
+
console.log(
|
|
251
|
+
`
|
|
252
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( DEFAULT_COLOR_CONFIG.dark.brand)))(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
253
|
+
`
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
|
|
258
|
+
var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
|
|
259
|
+
var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
|
|
260
|
+
var writeDebug = (message, config) => getLogFn(LogLevel.DEBUG, config)(message);
|
|
261
|
+
var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
|
|
262
|
+
var getStopwatch = (name) => {
|
|
263
|
+
const start = process.hrtime();
|
|
264
|
+
return () => {
|
|
265
|
+
const end = process.hrtime(start);
|
|
266
|
+
console.info(
|
|
267
|
+
`
|
|
268
|
+
> \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
|
|
269
|
+
end[0] * 1e3 + end[1] / 1e6
|
|
270
|
+
)}ms to complete
|
|
271
|
+
`
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
var MAX_DEPTH = 4;
|
|
276
|
+
var formatLogMessage = (message, options = {}, depth = 0) => {
|
|
277
|
+
if (depth > MAX_DEPTH) {
|
|
278
|
+
return "<max depth>";
|
|
279
|
+
}
|
|
280
|
+
const prefix = _nullishCoalesce(options.prefix, () => ( "-"));
|
|
281
|
+
const skip = _nullishCoalesce(options.skip, () => ( []));
|
|
282
|
+
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
|
|
283
|
+
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
|
|
284
|
+
${Object.keys(message).filter((key) => !skip.includes(key)).map(
|
|
285
|
+
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
|
|
286
|
+
message[key],
|
|
287
|
+
{ prefix: `${prefix}-`, skip },
|
|
288
|
+
depth + 1
|
|
289
|
+
) : message[key]}`
|
|
290
|
+
).join("\n")}` : message;
|
|
291
|
+
};
|
|
292
|
+
var _isFunction = (value) => {
|
|
293
|
+
try {
|
|
294
|
+
return value instanceof Function || typeof value === "function" || !!(_optionalChain([value, 'optionalAccess', _24 => _24.constructor]) && _optionalChain([value, 'optionalAccess', _25 => _25.call]) && _optionalChain([value, 'optionalAccess', _26 => _26.apply]));
|
|
295
|
+
} catch (e) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/clean.ts
|
|
301
|
+
var _promises = require('fs/promises');
|
|
302
|
+
async function clean(name = "TSDown", directory, config) {
|
|
303
|
+
writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
304
|
+
const stopwatch = getStopwatch(`${name} output clean`);
|
|
305
|
+
await cleanDirectories(name, directory, config);
|
|
306
|
+
stopwatch();
|
|
307
|
+
}
|
|
308
|
+
async function cleanDirectories(name = "TSDown", directory, config) {
|
|
309
|
+
await _promises.rm.call(void 0, directory, { recursive: true, force: true });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
exports.LogLevel = LogLevel; exports.getLogLevel = getLogLevel; exports.getLogLevelLabel = getLogLevelLabel; exports.isVerbose = isVerbose; exports.writeFatal = writeFatal; exports.writeWarning = writeWarning; exports.writeSuccess = writeSuccess; exports.writeDebug = writeDebug; exports.writeTrace = writeTrace; exports.getStopwatch = getStopwatch; exports.formatLogMessage = formatLogMessage; exports.clean = clean; exports.cleanDirectories = cleanDirectories;
|
package/dist/clean.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkIO7MJMVEcjs = require('./chunk-IO7MJMVE.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.clean =
|
|
8
|
+
exports.clean = _chunkIO7MJMVEcjs.clean; exports.cleanDirectories = _chunkIO7MJMVEcjs.cleanDirectories;
|
package/dist/clean.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk7L7BKTGQcjs = require('./chunk-7L7BKTGQ.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkIO7MJMVEcjs = require('./chunk-IO7MJMVE.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunk65E5RX7Icjs = require('./chunk-65E5RX7I.cjs');
|
|
@@ -16,4 +16,4 @@ require('./chunk-ZBPRDZS4.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.DEFAULT_BUILD_OPTIONS = _chunk65E5RX7Icjs.DEFAULT_BUILD_OPTIONS; exports.build =
|
|
19
|
+
exports.DEFAULT_BUILD_OPTIONS = _chunk65E5RX7Icjs.DEFAULT_BUILD_OPTIONS; exports.build = _chunk7L7BKTGQcjs.build; exports.clean = _chunkIO7MJMVEcjs.clean; exports.cleanDirectories = _chunkIO7MJMVEcjs.cleanDirectories; exports.cleanOutputPath = _chunk7L7BKTGQcjs.cleanOutputPath;
|