@storm-software/config-tools 1.176.23 → 1.177.3

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 (74) hide show
  1. package/README.md +1 -2
  2. package/bin/config.cjs +304 -260
  3. package/bin/config.js +307 -263
  4. package/dist/{chunk-3H56XJD4.js → chunk-2FH55GER.js} +30 -2
  5. package/dist/{chunk-SHD7ZUSQ.js → chunk-5BZL5JNY.js} +1 -30
  6. package/dist/{chunk-7MBEC23I.js → chunk-5WYSI634.js} +1 -1
  7. package/dist/{chunk-EVOHJKUO.cjs → chunk-AKMWVY6J.cjs} +10 -10
  8. package/dist/{chunk-2IFNLLUL.cjs → chunk-BWNFZH2S.cjs} +6 -6
  9. package/dist/{chunk-INZ6GCPT.cjs → chunk-CG3ZPQSH.cjs} +2 -2
  10. package/dist/{chunk-QGASWRUN.cjs → chunk-CLT4IIBS.cjs} +30 -2
  11. package/dist/{chunk-7GRIRHUQ.cjs → chunk-CO4ZADWX.cjs} +12 -1
  12. package/dist/{chunk-5DA26BV4.js → chunk-FNCPJCRZ.js} +4 -4
  13. package/dist/{chunk-LKCXHEY6.cjs → chunk-GVHRCPKH.cjs} +21 -21
  14. package/dist/{chunk-ENEFXS5D.js → chunk-HRYS4NSW.js} +1 -1
  15. package/dist/{chunk-C5L7VSBR.js → chunk-HUE33BQZ.js} +10 -10
  16. package/dist/{chunk-QLJYCKMD.cjs → chunk-J7BFGUIX.cjs} +2 -2
  17. package/dist/{chunk-YEFBKZON.js → chunk-KHLQU66A.js} +10 -10
  18. package/dist/{chunk-KH5SONKW.cjs → chunk-MBEJXPRQ.cjs} +3 -32
  19. package/dist/{chunk-UHSAPVE4.js → chunk-NAULCOC3.js} +1 -1
  20. package/dist/{chunk-U436743U.cjs → chunk-NOTWBXXM.cjs} +0 -1
  21. package/dist/{chunk-J2LN5PAX.cjs → chunk-QPNEQJUQ.cjs} +6 -6
  22. package/dist/{chunk-UCO4HZFN.cjs → chunk-R4QJBJ5S.cjs} +40 -9
  23. package/dist/{chunk-BEFQ5B4E.js → chunk-R4UCFEO2.js} +2 -2
  24. package/dist/{chunk-PTHGOJU6.js → chunk-SZXSPLS6.js} +0 -1
  25. package/dist/{chunk-W4C4Y3CW.js → chunk-UMSUK27E.js} +12 -1
  26. package/dist/{chunk-CL6NTH3D.js → chunk-VLS3MDSR.js} +35 -4
  27. package/dist/{chunk-YNDGTWLY.cjs → chunk-WUZAZNK3.cjs} +9 -9
  28. package/dist/{chunk-ZNODVZNQ.cjs → chunk-Z62ZL5WE.cjs} +9 -9
  29. package/dist/{chunk-HYJVQZYZ.js → chunk-ZVT775K3.js} +1 -1
  30. package/dist/config-file/get-config-file.cjs +11 -11
  31. package/dist/config-file/get-config-file.js +10 -10
  32. package/dist/config-file/index.cjs +11 -11
  33. package/dist/config-file/index.js +10 -10
  34. package/dist/create-storm-config.cjs +14 -14
  35. package/dist/create-storm-config.js +13 -13
  36. package/dist/env/get-env.cjs +2 -2
  37. package/dist/env/get-env.js +1 -1
  38. package/dist/env/index.cjs +3 -3
  39. package/dist/env/index.js +2 -2
  40. package/dist/env/set-env.cjs +2 -2
  41. package/dist/env/set-env.js +1 -1
  42. package/dist/get-config.cjs +15 -15
  43. package/dist/get-config.js +14 -14
  44. package/dist/index.cjs +17 -17
  45. package/dist/index.d.cts +2 -2
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +22 -22
  48. package/dist/logger/console.cjs +3 -6
  49. package/dist/logger/console.js +2 -5
  50. package/dist/logger/create-logger.cjs +4 -7
  51. package/dist/logger/create-logger.js +3 -6
  52. package/dist/logger/index.cjs +4 -7
  53. package/dist/logger/index.js +3 -6
  54. package/dist/utilities/apply-workspace-tokens.cjs +3 -3
  55. package/dist/utilities/apply-workspace-tokens.js +2 -2
  56. package/dist/utilities/colors.cjs +4 -6
  57. package/dist/utilities/colors.d.cts +38 -1
  58. package/dist/utilities/colors.d.ts +38 -1
  59. package/dist/utilities/colors.js +3 -5
  60. package/dist/utilities/find-workspace-root.cjs +2 -2
  61. package/dist/utilities/find-workspace-root.js +1 -1
  62. package/dist/utilities/get-default-config.cjs +3 -5
  63. package/dist/utilities/get-default-config.d.cts +2 -6
  64. package/dist/utilities/get-default-config.d.ts +2 -6
  65. package/dist/utilities/get-default-config.js +2 -4
  66. package/dist/utilities/index.cjs +12 -12
  67. package/dist/utilities/index.d.cts +2 -2
  68. package/dist/utilities/index.d.ts +2 -2
  69. package/dist/utilities/index.js +13 -13
  70. package/dist/utilities/process-handler.cjs +4 -7
  71. package/dist/utilities/process-handler.js +3 -6
  72. package/dist/utilities/toml.cjs +5 -8
  73. package/dist/utilities/toml.js +4 -7
  74. package/package.json +3 -3
package/bin/config.js CHANGED
@@ -36,14 +36,264 @@ var LogLevelLabel = {
36
36
  ALL: "all"
37
37
  };
38
38
 
39
- // src/utilities/get-default-config.ts
40
- import {
41
- STORM_DEFAULT_ERROR_CODES_FILE,
42
- STORM_DEFAULT_LICENSE
43
- } from "@storm-software/config";
44
- import { existsSync as existsSync2 } from "node:fs";
45
- import { readFile } from "node:fs/promises";
46
- import { join as join2 } from "node:path";
39
+ // src/utilities/colors.ts
40
+ var DEFAULT_COLOR_CONFIG = {
41
+ light: {
42
+ background: "#fafafa",
43
+ foreground: "#1d1e22",
44
+ brand: "#1fb2a6",
45
+ alternate: "#db2777",
46
+ help: "#5C4EE5",
47
+ success: "#087f5b",
48
+ info: "#0550ae",
49
+ warning: "#e3b341",
50
+ danger: "#D8314A",
51
+ fatal: "#51070f",
52
+ link: "#3fa6ff",
53
+ positive: "#22c55e",
54
+ negative: "#dc2626",
55
+ gradient: ["#1fb2a6", "#db2777", "#5C4EE5"]
56
+ },
57
+ dark: {
58
+ background: "#1d1e22",
59
+ foreground: "#cbd5e1",
60
+ brand: "#2dd4bf",
61
+ alternate: "#db2777",
62
+ help: "#818cf8",
63
+ success: "#10b981",
64
+ info: "#58a6ff",
65
+ warning: "#f3d371",
66
+ danger: "#D8314A",
67
+ fatal: "#a40e26",
68
+ link: "#3fa6ff",
69
+ positive: "#22c55e",
70
+ negative: "#dc2626",
71
+ gradient: ["#1fb2a6", "#db2777", "#818cf8"]
72
+ }
73
+ };
74
+
75
+ // src/logger/chalk.ts
76
+ import chalk from "chalk";
77
+ var chalkDefault = {
78
+ hex: (_) => (message) => message,
79
+ bgHex: (_) => ({
80
+ whiteBright: (message) => message,
81
+ white: (message) => message
82
+ }),
83
+ white: (message) => message,
84
+ whiteBright: (message) => message,
85
+ gray: (message) => message,
86
+ bold: {
87
+ hex: (_) => (message) => message,
88
+ bgHex: (_) => ({
89
+ whiteBright: (message) => message,
90
+ white: (message) => message
91
+ }),
92
+ whiteBright: (message) => message,
93
+ white: (message) => message
94
+ },
95
+ dim: {
96
+ hex: (_) => (message) => message,
97
+ gray: (message) => message
98
+ }
99
+ };
100
+ var getChalk = () => {
101
+ let _chalk = chalk;
102
+ if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) {
103
+ _chalk = chalkDefault;
104
+ }
105
+ return _chalk;
106
+ };
107
+
108
+ // src/logger/is-unicode-supported.ts
109
+ function isUnicodeSupported() {
110
+ if (process.platform !== "win32") {
111
+ return process.env.TERM !== "linux";
112
+ }
113
+ return Boolean(process.env.WT_SESSION) || // Windows Terminal
114
+ Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
115
+ process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
116
+ 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";
117
+ }
118
+
119
+ // src/logger/console-icons.ts
120
+ var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
121
+ var CONSOLE_ICONS = {
122
+ [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
123
+ [LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
124
+ [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
125
+ [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
126
+ [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
127
+ [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
128
+ [LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
129
+ [LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
130
+ };
131
+
132
+ // src/logger/format-timestamp.ts
133
+ var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
134
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
135
+ };
136
+
137
+ // src/logger/get-log-level.ts
138
+ var getLogLevel = (label) => {
139
+ switch (label) {
140
+ case "all":
141
+ return LogLevel.ALL;
142
+ case "trace":
143
+ return LogLevel.TRACE;
144
+ case "debug":
145
+ return LogLevel.DEBUG;
146
+ case "info":
147
+ return LogLevel.INFO;
148
+ case "warn":
149
+ return LogLevel.WARN;
150
+ case "error":
151
+ return LogLevel.ERROR;
152
+ case "fatal":
153
+ return LogLevel.FATAL;
154
+ case "silent":
155
+ return LogLevel.SILENT;
156
+ default:
157
+ return LogLevel.INFO;
158
+ }
159
+ };
160
+ var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
161
+ if (logLevel >= LogLevel.ALL) {
162
+ return LogLevelLabel.ALL;
163
+ }
164
+ if (logLevel >= LogLevel.TRACE) {
165
+ return LogLevelLabel.TRACE;
166
+ }
167
+ if (logLevel >= LogLevel.DEBUG) {
168
+ return LogLevelLabel.DEBUG;
169
+ }
170
+ if (logLevel >= LogLevel.INFO) {
171
+ return LogLevelLabel.INFO;
172
+ }
173
+ if (logLevel >= LogLevel.WARN) {
174
+ return LogLevelLabel.WARN;
175
+ }
176
+ if (logLevel >= LogLevel.ERROR) {
177
+ return LogLevelLabel.ERROR;
178
+ }
179
+ if (logLevel >= LogLevel.FATAL) {
180
+ return LogLevelLabel.FATAL;
181
+ }
182
+ if (logLevel <= LogLevel.SILENT) {
183
+ return LogLevelLabel.SILENT;
184
+ }
185
+ return LogLevelLabel.INFO;
186
+ };
187
+
188
+ // src/logger/console.ts
189
+ var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
190
+ 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;
191
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
192
+ if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
193
+ return (_) => {
194
+ };
195
+ }
196
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
197
+ return (message) => {
198
+ console.error(
199
+ `
200
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? DEFAULT_COLOR_CONFIG.dark.fatal)(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
201
+ `
202
+ );
203
+ };
204
+ }
205
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
206
+ return (message) => {
207
+ console.error(
208
+ `
209
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? DEFAULT_COLOR_CONFIG.dark.danger)(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
210
+ `
211
+ );
212
+ };
213
+ }
214
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
215
+ return (message) => {
216
+ console.warn(
217
+ `
218
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? DEFAULT_COLOR_CONFIG.dark.warning)(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
219
+ `
220
+ );
221
+ };
222
+ }
223
+ if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
224
+ return (message) => {
225
+ console.info(
226
+ `
227
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? DEFAULT_COLOR_CONFIG.dark.success)(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
228
+ `
229
+ );
230
+ };
231
+ }
232
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
233
+ return (message) => {
234
+ console.info(
235
+ `
236
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
237
+ `
238
+ );
239
+ };
240
+ }
241
+ if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
242
+ return (message) => {
243
+ console.debug(
244
+ `
245
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
246
+ `
247
+ );
248
+ };
249
+ }
250
+ if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
251
+ return (message) => {
252
+ console.debug(
253
+ `
254
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
255
+ `
256
+ );
257
+ };
258
+ }
259
+ return (message) => {
260
+ console.log(
261
+ `
262
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CONFIG.dark.brand)(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
263
+ `
264
+ );
265
+ };
266
+ };
267
+ var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
268
+ var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
269
+ var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
270
+ var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
271
+ var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
272
+ var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
273
+ var MAX_DEPTH = 4;
274
+ var formatLogMessage = (message, options = {}, depth2 = 0) => {
275
+ if (depth2 > MAX_DEPTH) {
276
+ return "<max depth>";
277
+ }
278
+ const prefix = options.prefix ?? "-";
279
+ const skip = options.skip ?? [];
280
+ return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
281
+ ${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
282
+ ${Object.keys(message).filter((key) => !skip.includes(key)).map(
283
+ (key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
284
+ message[key],
285
+ { prefix: `${prefix}-`, skip },
286
+ depth2 + 1
287
+ ) : message[key]}`
288
+ ).join("\n")}` : message;
289
+ };
290
+ var _isFunction = (value) => {
291
+ try {
292
+ return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
293
+ } catch {
294
+ return false;
295
+ }
296
+ };
47
297
 
48
298
  // src/utilities/correct-paths.ts
49
299
  var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
@@ -196,7 +446,6 @@ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
196
446
 
197
447
  // src/utilities/find-workspace-root.ts
198
448
  var rootFiles = [
199
- "storm-workspace.json",
200
449
  "storm-workspace.json",
201
450
  "storm-workspace.yaml",
202
451
  "storm-workspace.yml",
@@ -266,34 +515,13 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
266
515
  }
267
516
 
268
517
  // src/utilities/get-default-config.ts
269
- var DEFAULT_COLOR_CONFIG = {
270
- light: {
271
- background: "#fafafa",
272
- foreground: "#1d1e22",
273
- brand: "#1fb2a6",
274
- alternate: "#db2777",
275
- help: "#5C4EE5",
276
- success: "#087f5b",
277
- info: "#0550ae",
278
- warning: "#e3b341",
279
- danger: "#D8314A",
280
- positive: "#22c55e",
281
- negative: "#dc2626"
282
- },
283
- dark: {
284
- background: "#1d1e22",
285
- foreground: "#cbd5e1",
286
- brand: "#2dd4bf",
287
- alternate: "#db2777",
288
- help: "#818cf8",
289
- success: "#10b981",
290
- info: "#58a6ff",
291
- warning: "#f3d371",
292
- danger: "#D8314A",
293
- positive: "#22c55e",
294
- negative: "#dc2626"
295
- }
296
- };
518
+ import {
519
+ STORM_DEFAULT_ERROR_CODES_FILE,
520
+ STORM_DEFAULT_LICENSE
521
+ } from "@storm-software/config";
522
+ import { existsSync as existsSync2 } from "node:fs";
523
+ import { readFile } from "node:fs/promises";
524
+ import { join as join2 } from "node:path";
297
525
  async function getPackageJsonConfig(root) {
298
526
  let license = STORM_DEFAULT_LICENSE;
299
527
  let homepage = void 0;
@@ -377,229 +605,6 @@ function applyDefaultConfig(config) {
377
605
  return config;
378
606
  }
379
607
 
380
- // src/logger/chalk.ts
381
- import chalk from "chalk";
382
- var chalkDefault = {
383
- hex: (_) => (message) => message,
384
- bgHex: (_) => ({
385
- whiteBright: (message) => message,
386
- white: (message) => message
387
- }),
388
- white: (message) => message,
389
- whiteBright: (message) => message,
390
- gray: (message) => message,
391
- bold: {
392
- hex: (_) => (message) => message,
393
- bgHex: (_) => ({
394
- whiteBright: (message) => message,
395
- white: (message) => message
396
- }),
397
- whiteBright: (message) => message,
398
- white: (message) => message
399
- },
400
- dim: {
401
- hex: (_) => (message) => message,
402
- gray: (message) => message
403
- }
404
- };
405
- var getChalk = () => {
406
- let _chalk = chalk;
407
- if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) {
408
- _chalk = chalkDefault;
409
- }
410
- return _chalk;
411
- };
412
-
413
- // src/logger/is-unicode-supported.ts
414
- function isUnicodeSupported() {
415
- if (process.platform !== "win32") {
416
- return process.env.TERM !== "linux";
417
- }
418
- return Boolean(process.env.WT_SESSION) || // Windows Terminal
419
- Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
420
- process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
421
- 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";
422
- }
423
-
424
- // src/logger/console-icons.ts
425
- var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
426
- var CONSOLE_ICONS = {
427
- [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
428
- [LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
429
- [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
430
- [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
431
- [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
432
- [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
433
- [LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
434
- [LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
435
- };
436
-
437
- // src/logger/format-timestamp.ts
438
- var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
439
- return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
440
- };
441
-
442
- // src/logger/get-log-level.ts
443
- var getLogLevel = (label) => {
444
- switch (label) {
445
- case "all":
446
- return LogLevel.ALL;
447
- case "trace":
448
- return LogLevel.TRACE;
449
- case "debug":
450
- return LogLevel.DEBUG;
451
- case "info":
452
- return LogLevel.INFO;
453
- case "warn":
454
- return LogLevel.WARN;
455
- case "error":
456
- return LogLevel.ERROR;
457
- case "fatal":
458
- return LogLevel.FATAL;
459
- case "silent":
460
- return LogLevel.SILENT;
461
- default:
462
- return LogLevel.INFO;
463
- }
464
- };
465
- var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
466
- if (logLevel >= LogLevel.ALL) {
467
- return LogLevelLabel.ALL;
468
- }
469
- if (logLevel >= LogLevel.TRACE) {
470
- return LogLevelLabel.TRACE;
471
- }
472
- if (logLevel >= LogLevel.DEBUG) {
473
- return LogLevelLabel.DEBUG;
474
- }
475
- if (logLevel >= LogLevel.INFO) {
476
- return LogLevelLabel.INFO;
477
- }
478
- if (logLevel >= LogLevel.WARN) {
479
- return LogLevelLabel.WARN;
480
- }
481
- if (logLevel >= LogLevel.ERROR) {
482
- return LogLevelLabel.ERROR;
483
- }
484
- if (logLevel >= LogLevel.FATAL) {
485
- return LogLevelLabel.FATAL;
486
- }
487
- if (logLevel <= LogLevel.SILENT) {
488
- return LogLevelLabel.SILENT;
489
- }
490
- return LogLevelLabel.INFO;
491
- };
492
-
493
- // src/logger/console.ts
494
- var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
495
- 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;
496
- const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
497
- if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
498
- return (_) => {
499
- };
500
- }
501
- if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
502
- return (message) => {
503
- console.error(
504
- `
505
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
506
- `
507
- );
508
- };
509
- }
510
- if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
511
- return (message) => {
512
- console.error(
513
- `
514
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
515
- `
516
- );
517
- };
518
- }
519
- if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
520
- return (message) => {
521
- console.warn(
522
- `
523
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
524
- `
525
- );
526
- };
527
- }
528
- if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
529
- return (message) => {
530
- console.info(
531
- `
532
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
533
- `
534
- );
535
- };
536
- }
537
- if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
538
- return (message) => {
539
- console.info(
540
- `
541
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
542
- `
543
- );
544
- };
545
- }
546
- if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
547
- return (message) => {
548
- console.debug(
549
- `
550
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex("#3e9eff")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
551
- `
552
- );
553
- };
554
- }
555
- if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
556
- return (message) => {
557
- console.debug(
558
- `
559
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex("#0070E0")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
560
- `
561
- );
562
- };
563
- }
564
- return (message) => {
565
- console.log(
566
- `
567
- ${_chalk.gray(formatTimestamp())} ${_chalk.hex("#0356a8")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
568
- `
569
- );
570
- };
571
- };
572
- var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
573
- var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
574
- var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
575
- var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
576
- var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
577
- var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
578
- var MAX_DEPTH = 4;
579
- var formatLogMessage = (message, options = {}, depth2 = 0) => {
580
- if (depth2 > MAX_DEPTH) {
581
- return "<max depth>";
582
- }
583
- const prefix = options.prefix ?? "-";
584
- const skip = options.skip ?? [];
585
- return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
586
- ${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
587
- ${Object.keys(message).filter((key) => !skip.includes(key)).map(
588
- (key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
589
- message[key],
590
- { prefix: `${prefix}-`, skip },
591
- depth2 + 1
592
- ) : message[key]}`
593
- ).join("\n")}` : message;
594
- };
595
- var _isFunction = (value) => {
596
- try {
597
- return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
598
- } catch (e) {
599
- return false;
600
- }
601
- };
602
-
603
608
  // src/utilities/process-handler.ts
604
609
  var exitWithError = (config) => {
605
610
  writeFatal("Exiting script with an error status...", config);
@@ -863,6 +868,19 @@ var getThemeColorConfigEnv = (prefix, theme) => {
863
868
  return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
864
869
  };
865
870
  var getSingleThemeColorConfigEnv = (prefix) => {
871
+ const gradient = [];
872
+ if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) {
873
+ gradient.push(
874
+ process.env[`${prefix}GRADIENT_START`],
875
+ process.env[`${prefix}GRADIENT_END`]
876
+ );
877
+ } else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
878
+ let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
879
+ while (process.env[`${prefix}GRADIENT_${index}`]) {
880
+ gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
881
+ index++;
882
+ }
883
+ }
866
884
  return {
867
885
  dark: process.env[`${prefix}DARK`],
868
886
  light: process.env[`${prefix}LIGHT`],
@@ -877,7 +895,8 @@ var getSingleThemeColorConfigEnv = (prefix) => {
877
895
  danger: process.env[`${prefix}DANGER`],
878
896
  fatal: process.env[`${prefix}FATAL`],
879
897
  positive: process.env[`${prefix}POSITIVE`],
880
- negative: process.env[`${prefix}NEGATIVE`]
898
+ negative: process.env[`${prefix}NEGATIVE`],
899
+ gradient
881
900
  };
882
901
  };
883
902
  var getMultiThemeColorConfigEnv = (prefix) => {
@@ -889,6 +908,19 @@ var getMultiThemeColorConfigEnv = (prefix) => {
889
908
  };
890
909
  };
891
910
  var getBaseThemeColorConfigEnv = (prefix) => {
911
+ const gradient = [];
912
+ if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) {
913
+ gradient.push(
914
+ process.env[`${prefix}GRADIENT_START`],
915
+ process.env[`${prefix}GRADIENT_END`]
916
+ );
917
+ } else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
918
+ let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
919
+ while (process.env[`${prefix}GRADIENT_${index}`]) {
920
+ gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
921
+ index++;
922
+ }
923
+ }
892
924
  return {
893
925
  foreground: process.env[`${prefix}FOREGROUND`],
894
926
  background: process.env[`${prefix}BACKGROUND`],
@@ -903,7 +935,8 @@ var getBaseThemeColorConfigEnv = (prefix) => {
903
935
  danger: process.env[`${prefix}DANGER`],
904
936
  fatal: process.env[`${prefix}FATAL`],
905
937
  positive: process.env[`${prefix}POSITIVE`],
906
- negative: process.env[`${prefix}NEGATIVE`]
938
+ negative: process.env[`${prefix}NEGATIVE`],
939
+ gradient
907
940
  };
908
941
  };
909
942
 
@@ -1034,11 +1067,12 @@ var setConfigEnv = (config) => {
1034
1067
  process.env[`${prefix}TIMEZONE`] = config.timezone;
1035
1068
  process.env.TZ = config.timezone;
1036
1069
  process.env.DEFAULT_TIMEZONE = config.timezone;
1070
+ process.env.TIMEZONE = config.timezone;
1037
1071
  }
1038
1072
  if (config.locale) {
1039
1073
  process.env[`${prefix}LOCALE`] = config.locale;
1040
- process.env.LOCALE = config.locale;
1041
1074
  process.env.DEFAULT_LOCALE = config.locale;
1075
+ process.env.LOCALE = config.locale;
1042
1076
  process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
1043
1077
  }
1044
1078
  if (config.configFile) {
@@ -1199,6 +1233,11 @@ var setSingleThemeColorConfigEnv = (prefix, config) => {
1199
1233
  if (config.negative) {
1200
1234
  process.env[`${prefix}NEGATIVE`] = config.negative;
1201
1235
  }
1236
+ if (config.gradient) {
1237
+ for (let i = 0; i < config.gradient.length; i++) {
1238
+ process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1239
+ }
1240
+ }
1202
1241
  };
1203
1242
  var setMultiThemeColorConfigEnv = (prefix, config) => {
1204
1243
  return {
@@ -1249,6 +1288,11 @@ var setBaseThemeColorConfigEnv = (prefix, config) => {
1249
1288
  if (config.negative) {
1250
1289
  process.env[`${prefix}NEGATIVE`] = config.negative;
1251
1290
  }
1291
+ if (config.gradient) {
1292
+ for (let i = 0; i < config.gradient.length; i++) {
1293
+ process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1294
+ }
1295
+ }
1252
1296
  };
1253
1297
 
1254
1298
  // src/create-storm-config.ts