@storm-software/config-tools 1.190.118 → 1.190.120

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 (114) hide show
  1. package/README.md +1 -1
  2. package/bin/config.cjs +20 -1532
  3. package/bin/config.js +19 -1527
  4. package/dist/config-file/get-config-file.cjs +80 -25
  5. package/dist/config-file/get-config-file.js +79 -24
  6. package/dist/config-file/index.cjs +1 -29
  7. package/dist/config-file/index.js +1 -29
  8. package/dist/create-storm-config.cjs +138 -26
  9. package/dist/create-storm-config.js +140 -28
  10. package/dist/env/get-env.cjs +221 -6
  11. package/dist/env/get-env.js +221 -6
  12. package/dist/env/index.cjs +2 -18
  13. package/dist/env/index.js +2 -18
  14. package/dist/env/set-env.cjs +383 -8
  15. package/dist/env/set-env.js +382 -7
  16. package/dist/get-config.cjs +28 -27
  17. package/dist/get-config.js +29 -28
  18. package/dist/index.cjs +7 -201
  19. package/dist/index.js +7 -201
  20. package/dist/logger/chalk.cjs +32 -4
  21. package/dist/logger/chalk.js +31 -3
  22. package/dist/logger/console-icons.cjs +15 -6
  23. package/dist/logger/console-icons.js +14 -5
  24. package/dist/logger/console.cjs +191 -37
  25. package/dist/logger/console.js +176 -22
  26. package/dist/logger/create-logger.cjs +25 -12
  27. package/dist/logger/create-logger.js +24 -11
  28. package/dist/logger/format-timestamp.cjs +4 -4
  29. package/dist/logger/format-timestamp.js +3 -3
  30. package/dist/logger/get-log-level.cjs +60 -7
  31. package/dist/logger/get-log-level.js +59 -6
  32. package/dist/logger/index.cjs +7 -61
  33. package/dist/logger/index.js +7 -61
  34. package/dist/logger/is-unicode-supported.cjs +10 -4
  35. package/dist/logger/is-unicode-supported.js +9 -3
  36. package/dist/types.cjs +25 -5
  37. package/dist/types.js +24 -4
  38. package/dist/utilities/apply-workspace-tokens.cjs +72 -9
  39. package/dist/utilities/apply-workspace-tokens.js +71 -8
  40. package/dist/utilities/colors.cjs +76 -7
  41. package/dist/utilities/colors.js +75 -6
  42. package/dist/utilities/correct-paths.cjs +231 -32
  43. package/dist/utilities/correct-paths.js +215 -16
  44. package/dist/utilities/file-path-utils.cjs +29 -7
  45. package/dist/utilities/file-path-utils.js +28 -6
  46. package/dist/utilities/find-up.cjs +21 -4
  47. package/dist/utilities/find-up.js +20 -3
  48. package/dist/utilities/find-workspace-root.cjs +74 -7
  49. package/dist/utilities/find-workspace-root.js +73 -6
  50. package/dist/utilities/get-default-config.cjs +90 -6
  51. package/dist/utilities/get-default-config.js +90 -6
  52. package/dist/utilities/index.cjs +9 -109
  53. package/dist/utilities/index.js +9 -109
  54. package/dist/utilities/process-handler.cjs +46 -11
  55. package/dist/utilities/process-handler.js +47 -12
  56. package/dist/utilities/run.cjs +34 -6
  57. package/dist/utilities/run.js +33 -5
  58. package/dist/utilities/toml.cjs +42 -24
  59. package/dist/utilities/toml.js +35 -17
  60. package/package.json +4 -4
  61. package/dist/chunk-24B36RDB.cjs +0 -81
  62. package/dist/chunk-27N3QEX5.js +0 -40
  63. package/dist/chunk-2AVLCXLT.js +0 -0
  64. package/dist/chunk-2RLMTBVZ.js +0 -233
  65. package/dist/chunk-2WBD2G3E.cjs +0 -38
  66. package/dist/chunk-3COHMHPU.cjs +0 -1
  67. package/dist/chunk-4Q45WJYQ.js +0 -165
  68. package/dist/chunk-5C7PIENF.js +0 -92
  69. package/dist/chunk-5J2SS4QU.js +0 -83
  70. package/dist/chunk-65SWKEHV.cjs +0 -1
  71. package/dist/chunk-6Y623TCS.cjs +0 -40
  72. package/dist/chunk-7PV6L7I7.cjs +0 -1
  73. package/dist/chunk-7QBTVNMR.cjs +0 -30
  74. package/dist/chunk-BDATZ3UB.cjs +0 -233
  75. package/dist/chunk-BZRTSWH4.cjs +0 -395
  76. package/dist/chunk-D3FRXXDE.js +0 -947
  77. package/dist/chunk-DTGT4OI3.cjs +0 -14
  78. package/dist/chunk-EC2KPWRG.cjs +0 -24
  79. package/dist/chunk-EENQN6N2.js +0 -40
  80. package/dist/chunk-ENI4UUSK.cjs +0 -35
  81. package/dist/chunk-FJNXECWU.js +0 -395
  82. package/dist/chunk-FMDVBSP6.cjs +0 -83
  83. package/dist/chunk-G2MK47WL.js +0 -14
  84. package/dist/chunk-HFS7WJVW.js +0 -81
  85. package/dist/chunk-HVVJHTFS.js +0 -36
  86. package/dist/chunk-IWD6YQKX.cjs +0 -1
  87. package/dist/chunk-IWQRXQ4N.cjs +0 -84
  88. package/dist/chunk-JK4TT5IV.js +0 -35
  89. package/dist/chunk-JWLDCEBZ.cjs +0 -70
  90. package/dist/chunk-JZAYHDV3.js +0 -8
  91. package/dist/chunk-KSMN3HSC.js +0 -38
  92. package/dist/chunk-L6UNTUC4.js +0 -0
  93. package/dist/chunk-LOY6ICHZ.cjs +0 -36
  94. package/dist/chunk-MBG2FTBL.cjs +0 -47
  95. package/dist/chunk-MQG74XF7.js +0 -102
  96. package/dist/chunk-MSAQEGBK.cjs +0 -92
  97. package/dist/chunk-NJFLUTGH.cjs +0 -25
  98. package/dist/chunk-PCYB64MB.cjs +0 -40
  99. package/dist/chunk-RALMUN5C.js +0 -30
  100. package/dist/chunk-RRKB32OH.js +0 -0
  101. package/dist/chunk-RUKM6FCF.js +0 -25
  102. package/dist/chunk-SIW7AXUG.js +0 -56
  103. package/dist/chunk-SLICWTO2.cjs +0 -165
  104. package/dist/chunk-SO3FWVXC.js +0 -84
  105. package/dist/chunk-SXPH7ILL.js +0 -70
  106. package/dist/chunk-T7YISGRS.cjs +0 -102
  107. package/dist/chunk-TZZRLM5J.cjs +0 -947
  108. package/dist/chunk-UJ77IBHD.cjs +0 -233
  109. package/dist/chunk-UKGRDKIH.js +0 -0
  110. package/dist/chunk-V3GMJ4TX.js +0 -233
  111. package/dist/chunk-WQJYIPSL.cjs +0 -8
  112. package/dist/chunk-YBVOKYAM.cjs +0 -56
  113. package/dist/chunk-YX4736HU.js +0 -47
  114. package/dist/chunk-ZFNAUMQS.js +0 -24
package/bin/config.js CHANGED
@@ -1,1529 +1,21 @@
1
1
  #!/usr/bin/env node
2
-
3
- // bin/config.ts
4
- import chalk2 from "chalk";
5
- import { Command } from "commander";
6
-
7
- // src/create-storm-config.ts
8
- import { workspaceConfigSchema } from "@storm-software/config/schema";
9
- import defu2 from "defu";
10
- import { existsSync as existsSync3 } from "node:fs";
11
-
12
- // src/config-file/get-config-file.ts
13
- import { loadConfig } from "c12";
14
- import defu from "defu";
15
-
16
- // src/types.ts
17
- var LogLevel = {
18
- SILENT: 0,
19
- FATAL: 10,
20
- ERROR: 20,
21
- WARN: 30,
22
- SUCCESS: 35,
23
- INFO: 40,
24
- PERFORMANCE: 50,
25
- DEBUG: 60,
26
- TRACE: 70,
27
- ALL: 100
28
- };
29
- var LogLevelLabel = {
30
- SILENT: "silent",
31
- FATAL: "fatal",
32
- ERROR: "error",
33
- WARN: "warn",
34
- SUCCESS: "success",
35
- INFO: "info",
36
- PERFORMANCE: "performance",
37
- DEBUG: "debug",
38
- TRACE: "trace",
39
- ALL: "all"
40
- };
41
-
42
- // src/utilities/colors.ts
43
- var DEFAULT_COLOR_CONFIG = {
44
- light: {
45
- background: "#fafafa",
46
- foreground: "#1d1e22",
47
- brand: "#1fb2a6",
48
- alternate: "#db2777",
49
- discovery: "#5C4EE5",
50
- success: "#087f5b",
51
- info: "#0550ae",
52
- debug: "#8afafc",
53
- warning: "#e3b341",
54
- danger: "#D8314A",
55
- fatal: "#51070f",
56
- performance: "#13c302",
57
- link: "#3fa6ff",
58
- positive: "#22c55e",
59
- negative: "#dc2626",
60
- gradient: ["#1fb2a6", "#db2777", "#5C4EE5"]
61
- },
62
- dark: {
63
- background: "#1e2124",
64
- foreground: "#cbd5e1",
65
- brand: "#2dd4bf",
66
- alternate: "#db2777",
67
- discovery: "#818cf8",
68
- success: "#10b981",
69
- info: "#58a6ff",
70
- debug: "#8afafc",
71
- warning: "#f3d371",
72
- danger: "#D8314A",
73
- fatal: "#a40e26",
74
- performance: "#80fd74",
75
- link: "#3fa6ff",
76
- positive: "#22c55e",
77
- negative: "#dc2626",
78
- gradient: ["#1fb2a6", "#db2777", "#818cf8"]
79
- }
80
- };
81
- function getColors(config) {
82
- if (!config?.colors || typeof config.colors !== "object" || !config.colors["dark"] && (!config.colors["base"] || typeof config.colors !== "object" || !config.colors["base"]?.["dark"])) {
83
- return DEFAULT_COLOR_CONFIG;
84
- }
85
- if (config.colors["base"]) {
86
- if (typeof config.colors["base"]["dark"] === "object") {
87
- return config.colors["base"]["dark"];
88
- } else if (config.colors["base"]["dark"] === "string") {
89
- return config.colors["base"];
90
- }
91
- }
92
- if (typeof config.colors["dark"] === "object") {
93
- return config.colors["dark"];
94
- }
95
- return config.colors ?? DEFAULT_COLOR_CONFIG;
96
- }
97
- function getColor(key, config) {
98
- const colors = getColors(config);
99
- const result = (typeof colors["dark"] === "object" ? colors["dark"][key] : colors[key]) || DEFAULT_COLOR_CONFIG["dark"][key] || DEFAULT_COLOR_CONFIG[key];
100
- if (result) {
101
- return result;
102
- }
103
- if (key === "link" || key === "debug") {
104
- return getColor("info", config);
105
- } else if (key === "fatal") {
106
- return getColor("danger", config);
107
- }
108
- return getColor("brand", config);
109
- }
110
-
111
- // src/logger/chalk.ts
112
2
  import chalk from "chalk";
113
- var chalkDefault = {
114
- hex: (_) => (message) => message,
115
- bgHex: (_) => ({
116
- whiteBright: (message) => message,
117
- white: (message) => message
118
- }),
119
- white: (message) => message,
120
- whiteBright: (message) => message,
121
- gray: (message) => message,
122
- bold: {
123
- hex: (_) => (message) => message,
124
- bgHex: (_) => ({
125
- whiteBright: (message) => message,
126
- white: (message) => message
127
- }),
128
- whiteBright: (message) => message,
129
- white: (message) => message
130
- },
131
- dim: {
132
- hex: (_) => (message) => message,
133
- gray: (message) => message
134
- }
135
- };
136
- var getChalk = () => {
137
- let _chalk = chalk;
138
- if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) {
139
- _chalk = chalkDefault;
140
- }
141
- return _chalk;
142
- };
143
-
144
- // src/logger/is-unicode-supported.ts
145
- function isUnicodeSupported() {
146
- if (process.platform !== "win32") {
147
- return process.env.TERM !== "linux";
148
- }
149
- return Boolean(process.env.WT_SESSION) || // Windows Terminal
150
- Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
151
- process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
152
- 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";
153
- }
154
-
155
- // src/logger/console-icons.ts
156
- var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
157
- var CONSOLE_ICONS = {
158
- [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
159
- [LogLevelLabel.FATAL]: useIcon("\u{1F571}", "\xD7"),
160
- [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
161
- [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
162
- [LogLevelLabel.PERFORMANCE]: useIcon("\u23F1", "\u23F1"),
163
- [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
164
- [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
165
- [LogLevelLabel.TRACE]: useIcon("\u2699", "T"),
166
- [LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
167
- };
168
-
169
- // src/logger/format-timestamp.ts
170
- var formatTimestamp = (fullDateTime = false, date = /* @__PURE__ */ new Date()) => {
171
- return fullDateTime ? `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` : `${date.toLocaleTimeString()}`;
172
- };
173
-
174
- // src/logger/get-log-level.ts
175
- var getLogLevel = (label) => {
176
- switch (label) {
177
- case "all":
178
- return LogLevel.ALL;
179
- case "trace":
180
- return LogLevel.TRACE;
181
- case "debug":
182
- return LogLevel.DEBUG;
183
- case "performance":
184
- return LogLevel.PERFORMANCE;
185
- case "info":
186
- return LogLevel.INFO;
187
- case "warn":
188
- return LogLevel.WARN;
189
- case "error":
190
- return LogLevel.ERROR;
191
- case "fatal":
192
- return LogLevel.FATAL;
193
- case "silent":
194
- return LogLevel.SILENT;
195
- default:
196
- return LogLevel.INFO;
197
- }
198
- };
199
- var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
200
- if (logLevel >= LogLevel.ALL) {
201
- return LogLevelLabel.ALL;
202
- }
203
- if (logLevel >= LogLevel.TRACE) {
204
- return LogLevelLabel.TRACE;
205
- }
206
- if (logLevel >= LogLevel.DEBUG) {
207
- return LogLevelLabel.DEBUG;
208
- }
209
- if (logLevel >= LogLevel.PERFORMANCE) {
210
- return LogLevelLabel.PERFORMANCE;
211
- }
212
- if (logLevel >= LogLevel.INFO) {
213
- return LogLevelLabel.INFO;
214
- }
215
- if (logLevel >= LogLevel.WARN) {
216
- return LogLevelLabel.WARN;
217
- }
218
- if (logLevel >= LogLevel.ERROR) {
219
- return LogLevelLabel.ERROR;
220
- }
221
- if (logLevel >= LogLevel.FATAL) {
222
- return LogLevelLabel.FATAL;
223
- }
224
- if (logLevel <= LogLevel.SILENT) {
225
- return LogLevelLabel.SILENT;
226
- }
227
- return LogLevelLabel.INFO;
228
- };
229
-
230
- // src/logger/console.ts
231
- var getLogFn = (logLevel = LogLevel.INFO, config = {}, options = {}) => {
232
- const {
233
- chalk: _chalk = getChalk(),
234
- fullDateTime = false,
235
- hideDateTime = false
236
- } = options;
237
- 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;
238
- const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
239
- if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
240
- return (_) => {
241
- };
242
- }
243
- if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
244
- return (message) => {
245
- console.error(
246
- `
247
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.fatal ?? DEFAULT_COLOR_CONFIG.dark.fatal)(
248
- `[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `
249
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
250
- `
251
- );
252
- };
253
- }
254
- if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
255
- return (message) => {
256
- console.error(
257
- `
258
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.danger ?? DEFAULT_COLOR_CONFIG.dark.danger)(
259
- `[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `
260
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
261
- `
262
- );
263
- };
264
- }
265
- if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
266
- return (message) => {
267
- console.warn(
268
- `
269
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.warning ?? DEFAULT_COLOR_CONFIG.dark.warning)(
270
- `[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `
271
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
272
- `
273
- );
274
- };
275
- }
276
- if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
277
- return (message) => {
278
- console.info(
279
- `
280
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.success ?? DEFAULT_COLOR_CONFIG.dark.success)(
281
- `[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `
282
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
283
- `
284
- );
285
- };
286
- }
287
- if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
288
- return (message) => {
289
- console.info(
290
- `
291
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(
292
- `[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `
293
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
294
- `
295
- );
296
- };
297
- }
298
- if (typeof logLevel === "number" && LogLevel.PERFORMANCE >= logLevel) {
299
- return (message) => {
300
- console.debug(
301
- `
302
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.performance ?? DEFAULT_COLOR_CONFIG.dark.performance)(
303
- `[${CONSOLE_ICONS[LogLevelLabel.PERFORMANCE]} Performance] `
304
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
305
- `
306
- );
307
- };
308
- }
309
- if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
310
- return (message) => {
311
- console.debug(
312
- `
313
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.debug ?? DEFAULT_COLOR_CONFIG.dark.debug)(
314
- `[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `
315
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
316
- `
317
- );
318
- };
319
- }
320
- if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
321
- return (message) => {
322
- console.debug(
323
- `
324
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex("#bbbbbb")(
325
- `[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `
326
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
327
- `
328
- );
329
- };
330
- }
331
- return (message) => {
332
- console.log(
333
- `
334
- ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CONFIG.dark.brand)(
335
- `[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `
336
- )}${_chalk.bold.whiteBright(formatLogMessage(message))}
337
- `
338
- );
339
- };
340
- };
341
- var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
342
- var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
343
- var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
344
- var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
345
- var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
346
- var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
347
- var MAX_DEPTH = 10;
348
- var formatLogMessage = (message, options = {}, depth2 = 0) => {
349
- if (depth2 > MAX_DEPTH) {
350
- return "<max depth>";
351
- }
352
- const prefix = options.prefix ?? "";
353
- const skip = options.skip ?? [];
354
- const sort = options.sort ?? true;
355
- return typeof message === "undefined" || message === null ? "<empty>" : typeof message === "string" ? !message ? "<empty string>" : message : Array.isArray(message) ? `
356
- ${message.sort(
357
- sort ? (a, b) => !a && !b ? 0 : !a ? 1 : !b ? -1 : String(a).localeCompare(String(b)) : void 0
358
- ).map(
359
- (item, index) => ` ${prefix}> #${index} = ${formatLogMessage(
360
- item,
361
- { prefix: `${prefix}--`, skip, sort },
362
- depth2 + 1
363
- )}`
364
- ).join("\n")}` : typeof message === "object" && message ? `
365
- ${Object.keys(message).filter(
366
- (key) => typeof key !== "string" || !skip.map((k) => k.toLowerCase().trim()).includes(key.toLowerCase().trim())
367
- ).sort(
368
- sort ? (a, b) => !a && !b ? 0 : !a ? 1 : !b ? -1 : String(a).localeCompare(String(b)) : void 0
369
- ).map(
370
- (key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" && message[key] ? Object.keys(message[key]).filter(
371
- (key2) => typeof key2 !== "string" || !skip.map((k) => k.toLowerCase().trim()).includes(key2.toLowerCase().trim())
372
- ).length === 0 ? "{}" : formatLogMessage(
373
- message[key],
374
- { prefix: `${prefix}--`, skip, sort },
375
- depth2 + 1
376
- ) : message[key]}`
377
- ).join("\n")}` : String(message);
378
- };
379
- var _isFunction = (value) => {
380
- try {
381
- return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
382
- } catch {
383
- return false;
384
- }
385
- };
386
- var brandIcon = (config = {}, _chalk = getChalk()) => _chalk.hex(getColor("brand", config))("\u{1F5F2}");
387
-
388
- // src/utilities/correct-paths.ts
389
- var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
390
- function normalizeWindowsPath(input = "") {
391
- if (!input) {
392
- return input;
393
- }
394
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
395
- }
396
- var _UNC_REGEX = /^[/\\]{2}/;
397
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
398
- var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
399
- var correctPaths = function(path) {
400
- if (!path || path.length === 0) {
401
- return ".";
402
- }
403
- path = normalizeWindowsPath(path);
404
- const isUNCPath = path?.match(_UNC_REGEX);
405
- const isPathAbsolute = isAbsolute(path);
406
- const trailingSeparator = path[path.length - 1] === "/";
407
- path = normalizeString(path, !isPathAbsolute);
408
- if (path.length === 0) {
409
- if (isPathAbsolute) {
410
- return "/";
411
- }
412
- return trailingSeparator ? "./" : ".";
413
- }
414
- if (trailingSeparator) {
415
- path += "/";
416
- }
417
- if (_DRIVE_LETTER_RE.test(path)) {
418
- path += "/";
419
- }
420
- if (isUNCPath) {
421
- if (!isPathAbsolute) {
422
- return `//./${path}`;
423
- }
424
- return `//${path}`;
425
- }
426
- return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
427
- };
428
- var joinPaths = function(...segments) {
429
- let path = "";
430
- for (const seg of segments) {
431
- if (!seg) {
432
- continue;
433
- }
434
- if (path.length > 0) {
435
- const pathTrailing = path[path.length - 1] === "/";
436
- const segLeading = seg[0] === "/";
437
- const both = pathTrailing && segLeading;
438
- if (both) {
439
- path += seg.slice(1);
440
- } else {
441
- path += pathTrailing || segLeading ? seg : `/${seg}`;
442
- }
443
- } else {
444
- path += seg;
445
- }
446
- }
447
- return correctPaths(path);
448
- };
449
- function normalizeString(path, allowAboveRoot) {
450
- let res = "";
451
- let lastSegmentLength = 0;
452
- let lastSlash = -1;
453
- let dots = 0;
454
- let char = null;
455
- for (let index = 0; index <= path.length; ++index) {
456
- if (index < path.length) {
457
- char = path[index];
458
- } else if (char === "/") {
459
- break;
460
- } else {
461
- char = "/";
462
- }
463
- if (char === "/") {
464
- if (lastSlash === index - 1 || dots === 1) {
465
- } else if (dots === 2) {
466
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
467
- if (res.length > 2) {
468
- const lastSlashIndex = res.lastIndexOf("/");
469
- if (lastSlashIndex === -1) {
470
- res = "";
471
- lastSegmentLength = 0;
472
- } else {
473
- res = res.slice(0, lastSlashIndex);
474
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
475
- }
476
- lastSlash = index;
477
- dots = 0;
478
- continue;
479
- } else if (res.length > 0) {
480
- res = "";
481
- lastSegmentLength = 0;
482
- lastSlash = index;
483
- dots = 0;
484
- continue;
485
- }
486
- }
487
- if (allowAboveRoot) {
488
- res += res.length > 0 ? "/.." : "..";
489
- lastSegmentLength = 2;
490
- }
491
- } else {
492
- if (res.length > 0) {
493
- res += `/${path.slice(lastSlash + 1, index)}`;
494
- } else {
495
- res = path.slice(lastSlash + 1, index);
496
- }
497
- lastSegmentLength = index - lastSlash - 1;
498
- }
499
- lastSlash = index;
500
- dots = 0;
501
- } else if (char === "." && dots !== -1) {
502
- ++dots;
503
- } else {
504
- dots = -1;
505
- }
506
- }
507
- return res;
508
- }
509
- var isAbsolute = function(p) {
510
- return _IS_ABSOLUTE_RE.test(p);
511
- };
512
-
513
- // src/utilities/find-up.ts
514
- import { existsSync } from "node:fs";
515
- import { join } from "node:path";
516
- var MAX_PATH_SEARCH_DEPTH = 30;
517
- var depth = 0;
518
- function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
519
- const _startPath = startPath ?? process.cwd();
520
- if (endDirectoryNames.some(
521
- (endDirName) => existsSync(join(_startPath, endDirName))
522
- )) {
523
- return _startPath;
524
- }
525
- if (endFileNames.some((endFileName) => existsSync(join(_startPath, endFileName)))) {
526
- return _startPath;
527
- }
528
- if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
529
- const parent = join(_startPath, "..");
530
- return findFolderUp(parent, endFileNames, endDirectoryNames);
531
- }
532
- return void 0;
533
- }
534
-
535
- // src/utilities/find-workspace-root.ts
536
- var rootFiles = [
537
- "storm-workspace.json",
538
- "storm-workspace.yaml",
539
- "storm-workspace.yml",
540
- "storm-workspace.js",
541
- "storm-workspace.ts",
542
- ".storm-workspace.json",
543
- ".storm-workspace.yaml",
544
- ".storm-workspace.yml",
545
- ".storm-workspace.js",
546
- ".storm-workspace.ts",
547
- "lerna.json",
548
- "nx.json",
549
- "turbo.json",
550
- "npm-workspace.json",
551
- "yarn-workspace.json",
552
- "pnpm-workspace.json",
553
- "npm-workspace.yaml",
554
- "yarn-workspace.yaml",
555
- "pnpm-workspace.yaml",
556
- "npm-workspace.yml",
557
- "yarn-workspace.yml",
558
- "pnpm-workspace.yml",
559
- "npm-lock.json",
560
- "yarn-lock.json",
561
- "pnpm-lock.json",
562
- "npm-lock.yaml",
563
- "yarn-lock.yaml",
564
- "pnpm-lock.yaml",
565
- "npm-lock.yml",
566
- "yarn-lock.yml",
567
- "pnpm-lock.yml",
568
- "bun.lockb",
569
- "bun.lock",
570
- "bunfig.toml"
571
- ];
572
- var rootDirectories = [
573
- ".storm-workspace",
574
- ".nx",
575
- ".git",
576
- ".github",
577
- ".vscode",
578
- ".verdaccio"
579
- ];
580
- function findWorkspaceRootSafe(pathInsideMonorepo) {
581
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
582
- return correctPaths(
583
- process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
584
- );
585
- }
586
- return correctPaths(
587
- findFolderUp(
588
- pathInsideMonorepo ?? process.cwd(),
589
- rootFiles,
590
- rootDirectories
591
- )
592
- );
593
- }
594
- function findWorkspaceRoot(pathInsideMonorepo) {
595
- const result = findWorkspaceRootSafe(pathInsideMonorepo);
596
- if (!result) {
597
- throw new Error(
598
- `Cannot find workspace root upwards from known path. Files search list includes:
599
- ${rootFiles.join(
600
- "\n"
601
- )}
602
- Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
603
- );
604
- }
605
- return result;
606
- }
607
-
608
- // src/utilities/get-default-config.ts
3
+ import { Command } from "commander";
4
+ import { getConfig } from "../src/get-config";
609
5
  import {
610
- STORM_DEFAULT_ERROR_CODES_FILE,
611
- STORM_DEFAULT_LICENSE
612
- } from "@storm-software/config";
613
- import { existsSync as existsSync2 } from "node:fs";
614
- import { readFile } from "node:fs/promises";
615
- import { join as join2 } from "node:path";
616
- async function getPackageJsonConfig(root) {
617
- let license = STORM_DEFAULT_LICENSE;
618
- let homepage = void 0;
619
- let support = void 0;
620
- let name = void 0;
621
- let namespace = void 0;
622
- let repository = void 0;
623
- const workspaceRoot = findWorkspaceRoot(root);
624
- if (existsSync2(join2(workspaceRoot, "package.json"))) {
625
- const file = await readFile(
626
- joinPaths(workspaceRoot, "package.json"),
627
- "utf8"
628
- );
629
- if (file) {
630
- const packageJson = JSON.parse(file);
631
- if (packageJson.name) {
632
- name = packageJson.name;
633
- }
634
- if (packageJson.namespace) {
635
- namespace = packageJson.namespace;
636
- }
637
- if (packageJson.repository) {
638
- if (typeof packageJson.repository === "string") {
639
- repository = packageJson.repository;
640
- } else if (packageJson.repository.url) {
641
- repository = packageJson.repository.url;
642
- }
643
- }
644
- if (packageJson.license) {
645
- license = packageJson.license;
646
- }
647
- if (packageJson.homepage) {
648
- homepage = packageJson.homepage;
649
- }
650
- if (packageJson.bugs) {
651
- if (typeof packageJson.bugs === "string") {
652
- support = packageJson.bugs;
653
- } else if (packageJson.bugs.url) {
654
- support = packageJson.bugs.url;
655
- }
656
- }
657
- }
658
- }
659
- return {
660
- workspaceRoot,
661
- name,
662
- namespace,
663
- repository,
664
- license,
665
- homepage,
666
- support
667
- };
668
- }
669
- function applyDefaultConfig(config) {
670
- if (!config.support && config.contact) {
671
- config.support = config.contact;
672
- }
673
- if (!config.contact && config.support) {
674
- config.contact = config.support;
675
- }
676
- if (config.homepage) {
677
- if (!config.docs) {
678
- config.docs = `${config.homepage}/docs`;
679
- }
680
- if (!config.license) {
681
- config.license = `${config.homepage}/license`;
682
- }
683
- if (!config.support) {
684
- config.support = `${config.homepage}/support`;
685
- }
686
- if (!config.contact) {
687
- config.contact = `${config.homepage}/contact`;
688
- }
689
- if (!config.error?.codesFile || !config?.error?.url) {
690
- config.error ??= { codesFile: STORM_DEFAULT_ERROR_CODES_FILE };
691
- if (config.homepage) {
692
- config.error.url ??= `${config.homepage}/errors`;
693
- }
694
- }
695
- }
696
- return config;
697
- }
698
-
699
- // src/utilities/process-handler.ts
700
- var exitWithError = (config) => {
701
- writeFatal("Exiting script with an error status...", config);
702
- process.exit(1);
703
- };
704
- var exitWithSuccess = (config) => {
705
- writeSuccess("Script completed successfully. Exiting...", config);
706
- process.exit(0);
707
- };
708
- var handleProcess = (config) => {
709
- writeTrace(
710
- `Using the following arguments to process the script: ${process.argv.join(", ")}`,
711
- config
712
- );
713
- process.on("unhandledRejection", (error) => {
714
- writeError(
715
- `An Unhandled Rejection occurred while running the program: ${error && typeof error === "object" && "message" in error && error?.message ? error.message : typeof error === "string" ? error : "Unknown error"}
716
- Stacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`,
717
- config
718
- );
719
- exitWithError(config);
720
- });
721
- process.on("uncaughtException", (error) => {
722
- writeError(
723
- `An Uncaught Exception occurred while running the program: ${error && typeof error === "object" && "message" in error && error?.message ? error.message : typeof error === "string" ? error : "Unknown error"}
724
- Stacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`,
725
- config
726
- );
727
- exitWithError(config);
728
- });
729
- process.on("SIGTERM", (signal) => {
730
- writeError(`The program terminated with signal code: ${signal}`, config);
731
- exitWithError(config);
732
- });
733
- process.on("SIGINT", (signal) => {
734
- writeError(`The program terminated with signal code: ${signal}`, config);
735
- exitWithError(config);
736
- });
737
- process.on("SIGHUP", (signal) => {
738
- writeError(`The program terminated with signal code: ${signal}`, config);
739
- exitWithError(config);
740
- });
741
- };
742
-
743
- // src/config-file/get-config-file.ts
744
- var getConfigFileByName = async (fileName, filePath, options = {}) => {
745
- const workspacePath = filePath || findWorkspaceRoot(filePath);
746
- const configs = await Promise.all([
747
- loadConfig({
748
- cwd: workspacePath,
749
- packageJson: true,
750
- name: fileName,
751
- envName: fileName?.toUpperCase(),
752
- jitiOptions: {
753
- debug: false,
754
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
755
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
756
- "jiti"
757
- )
758
- },
759
- ...options
760
- }),
761
- loadConfig({
762
- cwd: workspacePath,
763
- packageJson: true,
764
- name: fileName,
765
- envName: fileName?.toUpperCase(),
766
- jitiOptions: {
767
- debug: false,
768
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
769
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
770
- "jiti"
771
- )
772
- },
773
- configFile: fileName,
774
- ...options
775
- })
776
- ]);
777
- return defu(configs[0] ?? {}, configs[1] ?? {});
778
- };
779
- var getConfigFile = async (filePath, additionalFileNames = []) => {
780
- const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
781
- const result = await getConfigFileByName("storm-workspace", workspacePath);
782
- let config = result.config;
783
- const configFile = result.configFile;
784
- if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
785
- writeTrace(
786
- `Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
787
- {
788
- logLevel: "all"
789
- }
790
- );
791
- }
792
- if (additionalFileNames && additionalFileNames.length > 0) {
793
- const results = await Promise.all(
794
- additionalFileNames.map(
795
- (fileName) => getConfigFileByName(fileName, workspacePath)
796
- )
797
- );
798
- for (const result2 of results) {
799
- if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
800
- if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
801
- writeTrace(
802
- `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
803
- {
804
- logLevel: "all"
805
- }
806
- );
807
- }
808
- config = defu(result2.config ?? {}, config ?? {});
809
- }
810
- }
811
- }
812
- if (!config || Object.keys(config).length === 0) {
813
- return void 0;
814
- }
815
- config.configFile = configFile;
816
- return config;
817
- };
818
-
819
- // src/env/get-env.ts
6
+ brandIcon,
7
+ formatLogMessage,
8
+ writeError,
9
+ writeFatal,
10
+ writeInfo,
11
+ writeSuccess
12
+ } from "../src/logger/console";
820
13
  import {
821
- COLOR_KEYS,
822
- STORM_DEFAULT_DOCS,
823
- STORM_DEFAULT_HOMEPAGE,
824
- STORM_DEFAULT_LICENSING
825
- } from "@storm-software/config";
826
- var getExtensionEnv = (extensionName) => {
827
- const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
828
- return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
829
- const name = key.replace(prefix, "").split("_").map(
830
- (i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
831
- ).join("");
832
- if (name) {
833
- ret[name] = process.env[key];
834
- }
835
- return ret;
836
- }, {});
837
- };
838
- var getConfigEnv = () => {
839
- const prefix = "STORM_";
840
- let config = {
841
- extends: process.env[`${prefix}EXTENDS`] || void 0,
842
- name: process.env[`${prefix}NAME`] || void 0,
843
- variant: process.env[`${prefix}VARIANT`] || void 0,
844
- namespace: process.env[`${prefix}NAMESPACE`] || void 0,
845
- owner: process.env[`${prefix}OWNER`] || void 0,
846
- bot: {
847
- name: process.env[`${prefix}BOT_NAME`] || void 0,
848
- email: process.env[`${prefix}BOT_EMAIL`] || void 0
849
- },
850
- release: {
851
- banner: {
852
- url: process.env[`${prefix}RELEASE_BANNER_URL`] || void 0,
853
- alt: process.env[`${prefix}RELEASE_BANNER_ALT`] || void 0
854
- },
855
- header: process.env[`${prefix}RELEASE_HEADER`] || void 0,
856
- footer: process.env[`${prefix}RELEASE_FOOTER`] || void 0
857
- },
858
- error: {
859
- codesFile: process.env[`${prefix}ERROR_CODES_FILE`] || void 0,
860
- url: process.env[`${prefix}ERROR_URL`] || void 0
861
- },
862
- socials: {
863
- twitter: process.env[`${prefix}SOCIAL_TWITTER`] || void 0,
864
- discord: process.env[`${prefix}SOCIAL_DISCORD`] || void 0,
865
- telegram: process.env[`${prefix}SOCIAL_TELEGRAM`] || void 0,
866
- slack: process.env[`${prefix}SOCIAL_SLACK`] || void 0,
867
- medium: process.env[`${prefix}SOCIAL_MEDIUM`] || void 0,
868
- github: process.env[`${prefix}SOCIAL_GITHUB`] || void 0
869
- },
870
- organization: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] ? process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] ? {
871
- name: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`],
872
- description: process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || void 0,
873
- url: process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || void 0,
874
- logo: process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] || void 0,
875
- icon: process.env[`${prefix}ORG_ICON`] || process.env[`${prefix}ORGANIZATION_ICON`] || void 0
876
- } : process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] : void 0,
877
- packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
878
- license: process.env[`${prefix}LICENSE`] || void 0,
879
- homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
880
- docs: process.env[`${prefix}DOCS`] || void 0,
881
- portal: process.env[`${prefix}PORTAL`] || void 0,
882
- licensing: process.env[`${prefix}LICENSING`] || void 0,
883
- contact: process.env[`${prefix}CONTACT`] || void 0,
884
- support: process.env[`${prefix}SUPPORT`] || void 0,
885
- timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
886
- locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
887
- configFile: process.env[`${prefix}WORKSPACE_CONFIG_FILE`] ? correctPaths(process.env[`${prefix}WORKSPACE_CONFIG_FILE`]) : void 0,
888
- workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
889
- directories: {
890
- cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : process.env[`${prefix}CACHE_DIRECTORY`] ? correctPaths(process.env[`${prefix}CACHE_DIRECTORY`]) : void 0,
891
- data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : process.env[`${prefix}DATA_DIRECTORY`] ? correctPaths(process.env[`${prefix}DATA_DIRECTORY`]) : void 0,
892
- config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : process.env[`${prefix}CONFIG_DIRECTORY`] ? correctPaths(process.env[`${prefix}CONFIG_DIRECTORY`]) : void 0,
893
- temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : process.env[`${prefix}TEMP_DIRECTORY`] ? correctPaths(process.env[`${prefix}TEMP_DIRECTORY`]) : void 0,
894
- log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : process.env[`${prefix}LOG_DIRECTORY`] ? correctPaths(process.env[`${prefix}LOG_DIRECTORY`]) : void 0,
895
- build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : process.env[`${prefix}BUILD_DIRECTORY`] ? correctPaths(process.env[`${prefix}BUILD_DIRECTORY`]) : void 0
896
- },
897
- skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
898
- mode: (process.env[`${prefix}MODE`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
899
- // ci:
900
- // process.env[`${prefix}CI`] !== undefined
901
- // ? Boolean(
902
- // process.env[`${prefix}CI`] ??
903
- // process.env.CI ??
904
- // process.env.CONTINUOUS_INTEGRATION
905
- // )
906
- // : undefined,
907
- repository: process.env[`${prefix}REPOSITORY`] || void 0,
908
- branch: process.env[`${prefix}BRANCH`] || void 0,
909
- preid: process.env[`${prefix}PRE_ID`] || void 0,
910
- registry: {
911
- github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
912
- npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
913
- cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
914
- cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
915
- container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
916
- },
917
- logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
918
- Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
919
- ) ? getLogLevelLabel(
920
- Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
921
- ) : process.env[`${prefix}LOG_LEVEL`] : void 0,
922
- skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
923
- };
924
- const themeNames = Object.keys(process.env).filter(
925
- (envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every(
926
- (colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
927
- )
928
- );
929
- config.colors = themeNames.length > 0 ? themeNames.reduce(
930
- (ret, themeName) => {
931
- ret[themeName] = getThemeColorsEnv(prefix, themeName);
932
- return ret;
933
- },
934
- {}
935
- ) : getThemeColorsEnv(prefix);
936
- if (config.docs === STORM_DEFAULT_DOCS) {
937
- if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
938
- config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
939
- } else {
940
- config.docs = `${config.homepage}/docs`;
941
- }
942
- }
943
- if (config.licensing === STORM_DEFAULT_LICENSING) {
944
- if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
945
- config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
946
- } else {
947
- config.licensing = `${config.homepage}/docs`;
948
- }
949
- }
950
- const serializedConfig = process.env[`${prefix}WORKSPACE_CONFIG`];
951
- if (serializedConfig) {
952
- const parsed = JSON.parse(serializedConfig);
953
- config = {
954
- ...config,
955
- ...parsed,
956
- colors: { ...config.colors, ...parsed.colors },
957
- extensions: { ...config.extensions, ...parsed.extensions }
958
- };
959
- }
960
- return config;
961
- };
962
- var getThemeColorsEnv = (prefix, theme) => {
963
- const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
964
- return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorsEnv(prefix + themeName) : getSingleThemeColorsEnv(prefix + themeName);
965
- };
966
- var getSingleThemeColorsEnv = (prefix) => {
967
- const gradient = [];
968
- if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) {
969
- gradient.push(
970
- process.env[`${prefix}GRADIENT_START`],
971
- process.env[`${prefix}GRADIENT_END`]
972
- );
973
- } else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
974
- let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
975
- while (process.env[`${prefix}GRADIENT_${index}`]) {
976
- gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
977
- index++;
978
- }
979
- }
980
- return {
981
- dark: process.env[`${prefix}DARK`],
982
- light: process.env[`${prefix}LIGHT`],
983
- brand: process.env[`${prefix}BRAND`],
984
- alternate: process.env[`${prefix}ALTERNATE`],
985
- accent: process.env[`${prefix}ACCENT`],
986
- link: process.env[`${prefix}LINK`],
987
- discovery: process.env[`${prefix}DISCOVERY`],
988
- success: process.env[`${prefix}SUCCESS`],
989
- info: process.env[`${prefix}INFO`],
990
- debug: process.env[`${prefix}DEBUG`],
991
- warning: process.env[`${prefix}WARNING`],
992
- danger: process.env[`${prefix}DANGER`],
993
- fatal: process.env[`${prefix}FATAL`],
994
- performance: process.env[`${prefix}PERFORMANCE`],
995
- positive: process.env[`${prefix}POSITIVE`],
996
- negative: process.env[`${prefix}NEGATIVE`],
997
- gradient
998
- };
999
- };
1000
- var getMultiThemeColorsEnv = (prefix) => {
1001
- return {
1002
- light: getBaseThemeColorsEnv(`${prefix}_LIGHT_`),
1003
- dark: getBaseThemeColorsEnv(`${prefix}_DARK_`)
1004
- };
1005
- };
1006
- var getBaseThemeColorsEnv = (prefix) => {
1007
- const gradient = [];
1008
- if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) {
1009
- gradient.push(
1010
- process.env[`${prefix}GRADIENT_START`],
1011
- process.env[`${prefix}GRADIENT_END`]
1012
- );
1013
- } else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
1014
- let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
1015
- while (process.env[`${prefix}GRADIENT_${index}`]) {
1016
- gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
1017
- index++;
1018
- }
1019
- }
1020
- return {
1021
- foreground: process.env[`${prefix}FOREGROUND`],
1022
- background: process.env[`${prefix}BACKGROUND`],
1023
- brand: process.env[`${prefix}BRAND`],
1024
- alternate: process.env[`${prefix}ALTERNATE`],
1025
- accent: process.env[`${prefix}ACCENT`],
1026
- link: process.env[`${prefix}LINK`],
1027
- discovery: process.env[`${prefix}DISCOVERY`],
1028
- success: process.env[`${prefix}SUCCESS`],
1029
- info: process.env[`${prefix}INFO`],
1030
- debug: process.env[`${prefix}DEBUG`],
1031
- warning: process.env[`${prefix}WARNING`],
1032
- danger: process.env[`${prefix}DANGER`],
1033
- fatal: process.env[`${prefix}FATAL`],
1034
- performance: process.env[`${prefix}PERFORMANCE`],
1035
- positive: process.env[`${prefix}POSITIVE`],
1036
- negative: process.env[`${prefix}NEGATIVE`],
1037
- gradient
1038
- };
1039
- };
1040
-
1041
- // src/env/set-env.ts
1042
- var setExtensionEnv = (extensionName, extension) => {
1043
- for (const key of Object.keys(extension ?? {})) {
1044
- if (extension[key]) {
1045
- const result = key?.replace(
1046
- /([A-Z])+/g,
1047
- (input) => input ? input[0]?.toUpperCase() + input.slice(1) : ""
1048
- ).split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
1049
- let extensionKey;
1050
- if (result.length === 0) {
1051
- return;
1052
- }
1053
- if (result.length === 1) {
1054
- extensionKey = result[0]?.toUpperCase() ?? "";
1055
- } else {
1056
- extensionKey = result.reduce((ret, part) => {
1057
- return `${ret}_${part.toLowerCase()}`;
1058
- });
1059
- }
1060
- process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
1061
- }
1062
- }
1063
- };
1064
- var setConfigEnv = (config) => {
1065
- const prefix = "STORM_";
1066
- if (config.extends) {
1067
- process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
1068
- }
1069
- if (config.name) {
1070
- process.env[`${prefix}NAME`] = config.name;
1071
- }
1072
- if (config.variant) {
1073
- process.env[`${prefix}VARIANT`] = config.variant;
1074
- }
1075
- if (config.namespace) {
1076
- process.env[`${prefix}NAMESPACE`] = config.namespace;
1077
- }
1078
- if (config.owner) {
1079
- process.env[`${prefix}OWNER`] = config.owner;
1080
- }
1081
- if (config.bot) {
1082
- process.env[`${prefix}BOT_NAME`] = config.bot.name;
1083
- process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
1084
- }
1085
- if (config.error) {
1086
- process.env[`${prefix}ERROR_CODES_FILE`] = config.error.codesFile;
1087
- process.env[`${prefix}ERROR_URL`] = config.error.url;
1088
- }
1089
- if (config.release) {
1090
- if (config.release.banner) {
1091
- if (typeof config.release.banner === "string") {
1092
- process.env[`${prefix}RELEASE_BANNER`] = config.release.banner;
1093
- process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner;
1094
- } else {
1095
- process.env[`${prefix}RELEASE_BANNER`] = config.release.banner.url;
1096
- process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner.url;
1097
- process.env[`${prefix}RELEASE_BANNER_ALT`] = config.release.banner.alt;
1098
- }
1099
- }
1100
- process.env[`${prefix}RELEASE_HEADER`] = config.release.header;
1101
- process.env[`${prefix}RELEASE_FOOTER`] = config.release.footer;
1102
- }
1103
- if (config.socials) {
1104
- if (config.socials.twitter) {
1105
- process.env[`${prefix}SOCIAL_TWITTER`] = config.socials.twitter;
1106
- }
1107
- if (config.socials.discord) {
1108
- process.env[`${prefix}SOCIAL_DISCORD`] = config.socials.discord;
1109
- }
1110
- if (config.socials.telegram) {
1111
- process.env[`${prefix}SOCIAL_TELEGRAM`] = config.socials.telegram;
1112
- }
1113
- if (config.socials.slack) {
1114
- process.env[`${prefix}SOCIAL_SLACK`] = config.socials.slack;
1115
- }
1116
- if (config.socials.medium) {
1117
- process.env[`${prefix}SOCIAL_MEDIUM`] = config.socials.medium;
1118
- }
1119
- if (config.socials.github) {
1120
- process.env[`${prefix}SOCIAL_GITHUB`] = config.socials.github;
1121
- }
1122
- }
1123
- if (config.organization) {
1124
- if (typeof config.organization === "string") {
1125
- process.env[`${prefix}ORG`] = config.organization;
1126
- process.env[`${prefix}ORG_NAME`] = config.organization;
1127
- process.env[`${prefix}ORGANIZATION`] = config.organization;
1128
- process.env[`${prefix}ORGANIZATION_NAME`] = config.organization;
1129
- } else {
1130
- process.env[`${prefix}ORG`] = config.organization.name;
1131
- process.env[`${prefix}ORG_NAME`] = config.organization.name;
1132
- process.env[`${prefix}ORGANIZATION`] = config.organization.name;
1133
- process.env[`${prefix}ORGANIZATION_NAME`] = config.organization.name;
1134
- if (config.organization.url) {
1135
- process.env[`${prefix}ORG_URL`] = config.organization.url;
1136
- process.env[`${prefix}ORGANIZATION_URL`] = config.organization.url;
1137
- }
1138
- if (config.organization.description) {
1139
- process.env[`${prefix}ORG_DESCRIPTION`] = config.organization.description;
1140
- process.env[`${prefix}ORGANIZATION_DESCRIPTION`] = config.organization.description;
1141
- }
1142
- if (config.organization.logo) {
1143
- process.env[`${prefix}ORG_LOGO`] = config.organization.logo;
1144
- process.env[`${prefix}ORGANIZATION_LOGO`] = config.organization.logo;
1145
- }
1146
- if (config.organization.icon) {
1147
- process.env[`${prefix}ORG_ICON`] = config.organization.icon;
1148
- process.env[`${prefix}ORGANIZATION_ICON`] = config.organization.icon;
1149
- }
1150
- }
1151
- }
1152
- if (config.packageManager) {
1153
- process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
1154
- }
1155
- if (config.license) {
1156
- process.env[`${prefix}LICENSE`] = config.license;
1157
- }
1158
- if (config.homepage) {
1159
- process.env[`${prefix}HOMEPAGE`] = config.homepage;
1160
- }
1161
- if (config.docs) {
1162
- process.env[`${prefix}DOCS`] = config.docs;
1163
- }
1164
- if (config.portal) {
1165
- process.env[`${prefix}PORTAL`] = config.portal;
1166
- }
1167
- if (config.licensing) {
1168
- process.env[`${prefix}LICENSING`] = config.licensing;
1169
- }
1170
- if (config.contact) {
1171
- process.env[`${prefix}CONTACT`] = config.contact;
1172
- }
1173
- if (config.support) {
1174
- process.env[`${prefix}SUPPORT`] = config.support;
1175
- }
1176
- if (config.timezone) {
1177
- process.env[`${prefix}TIMEZONE`] = config.timezone;
1178
- process.env.TZ = config.timezone;
1179
- process.env.DEFAULT_TIMEZONE = config.timezone;
1180
- process.env.TIMEZONE = config.timezone;
1181
- }
1182
- if (config.locale) {
1183
- process.env[`${prefix}LOCALE`] = config.locale;
1184
- process.env.DEFAULT_LOCALE = config.locale;
1185
- process.env.LOCALE = config.locale;
1186
- process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
1187
- }
1188
- if (config.configFile) {
1189
- process.env[`${prefix}WORKSPACE_CONFIG_FILE`] = correctPaths(
1190
- config.configFile
1191
- );
1192
- }
1193
- if (config.workspaceRoot) {
1194
- process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
1195
- process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
1196
- process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
1197
- }
1198
- if (config.directories) {
1199
- if (!config.skipCache && config.directories.cache) {
1200
- process.env[`${prefix}CACHE_DIR`] = correctPaths(
1201
- config.directories.cache
1202
- );
1203
- process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
1204
- }
1205
- if (config.directories.data) {
1206
- process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
1207
- process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
1208
- }
1209
- if (config.directories.config) {
1210
- process.env[`${prefix}CONFIG_DIR`] = correctPaths(
1211
- config.directories.config
1212
- );
1213
- process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
1214
- }
1215
- if (config.directories.temp) {
1216
- process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
1217
- process.env[`${prefix}TEMP_DIRECTORY`] = process.env[`${prefix}TEMP_DIR`];
1218
- }
1219
- if (config.directories.log) {
1220
- process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
1221
- process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
1222
- }
1223
- if (config.directories.build) {
1224
- process.env[`${prefix}BUILD_DIR`] = correctPaths(
1225
- config.directories.build
1226
- );
1227
- process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
1228
- }
1229
- }
1230
- if (config.skipCache !== void 0) {
1231
- process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
1232
- if (config.skipCache) {
1233
- process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
1234
- process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
1235
- }
1236
- }
1237
- if (config.mode) {
1238
- process.env[`${prefix}MODE`] = config.mode;
1239
- process.env.NODE_ENV = config.mode;
1240
- process.env.ENVIRONMENT = config.mode;
1241
- }
1242
- if (config.colors?.base?.light || config.colors?.base?.dark) {
1243
- for (const key of Object.keys(config.colors)) {
1244
- setThemeColorsEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
1245
- }
1246
- } else {
1247
- setThemeColorsEnv(
1248
- `${prefix}COLOR_`,
1249
- config.colors
1250
- );
1251
- }
1252
- if (config.repository) {
1253
- process.env[`${prefix}REPOSITORY`] = config.repository;
1254
- }
1255
- if (config.branch) {
1256
- process.env[`${prefix}BRANCH`] = config.branch;
1257
- }
1258
- if (config.preid) {
1259
- process.env[`${prefix}PRE_ID`] = String(config.preid);
1260
- }
1261
- if (config.registry) {
1262
- if (config.registry.github) {
1263
- process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
1264
- }
1265
- if (config.registry.npm) {
1266
- process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
1267
- }
1268
- if (config.registry.cargo) {
1269
- process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
1270
- }
1271
- if (config.registry.cyclone) {
1272
- process.env[`${prefix}REGISTRY_CYCLONE`] = String(
1273
- config.registry.cyclone
1274
- );
1275
- }
1276
- if (config.registry.container) {
1277
- process.env[`${prefix}REGISTRY_CONTAINER`] = String(
1278
- config.registry.container
1279
- );
1280
- }
1281
- }
1282
- if (config.logLevel) {
1283
- process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
1284
- process.env.LOG_LEVEL = String(config.logLevel);
1285
- process.env.NX_VERBOSE_LOGGING = String(
1286
- getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
1287
- );
1288
- process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
1289
- }
1290
- if (config.skipConfigLogging !== void 0) {
1291
- process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
1292
- config.skipConfigLogging
1293
- );
1294
- }
1295
- process.env[`${prefix}WORKSPACE_CONFIG`] = JSON.stringify(config);
1296
- for (const key of Object.keys(config.extensions ?? {})) {
1297
- if (config.extensions[key] && Object.keys(config.extensions[key])) {
1298
- setExtensionEnv(key, config.extensions[key]);
1299
- }
1300
- }
1301
- };
1302
- var setThemeColorsEnv = (prefix, config) => {
1303
- return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorsEnv(prefix, config) : setSingleThemeColorsEnv(prefix, config);
1304
- };
1305
- var setSingleThemeColorsEnv = (prefix, config) => {
1306
- if (config.dark) {
1307
- process.env[`${prefix}DARK`] = config.dark;
1308
- }
1309
- if (config.light) {
1310
- process.env[`${prefix}LIGHT`] = config.light;
1311
- }
1312
- if (config.brand) {
1313
- process.env[`${prefix}BRAND`] = config.brand;
1314
- }
1315
- if (config.alternate) {
1316
- process.env[`${prefix}ALTERNATE`] = config.alternate;
1317
- }
1318
- if (config.accent) {
1319
- process.env[`${prefix}ACCENT`] = config.accent;
1320
- }
1321
- if (config.link) {
1322
- process.env[`${prefix}LINK`] = config.link;
1323
- }
1324
- if (config.discovery) {
1325
- process.env[`${prefix}DISCOVERY`] = config.discovery;
1326
- }
1327
- if (config.success) {
1328
- process.env[`${prefix}SUCCESS`] = config.success;
1329
- }
1330
- if (config.info) {
1331
- process.env[`${prefix}INFO`] = config.info;
1332
- }
1333
- if (config.debug) {
1334
- process.env[`${prefix}DEBUG`] = config.debug;
1335
- }
1336
- if (config.warning) {
1337
- process.env[`${prefix}WARNING`] = config.warning;
1338
- }
1339
- if (config.danger) {
1340
- process.env[`${prefix}DANGER`] = config.danger;
1341
- }
1342
- if (config.fatal) {
1343
- process.env[`${prefix}FATAL`] = config.fatal;
1344
- }
1345
- if (config.performance) {
1346
- process.env[`${prefix}PERFORMANCE`] = config.performance;
1347
- }
1348
- if (config.positive) {
1349
- process.env[`${prefix}POSITIVE`] = config.positive;
1350
- }
1351
- if (config.negative) {
1352
- process.env[`${prefix}NEGATIVE`] = config.negative;
1353
- }
1354
- if (config.gradient) {
1355
- for (let i = 0; i < config.gradient.length; i++) {
1356
- process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1357
- }
1358
- }
1359
- };
1360
- var setMultiThemeColorsEnv = (prefix, config) => {
1361
- return {
1362
- light: setBaseThemeColorsEnv(`${prefix}LIGHT_`, config.light),
1363
- dark: setBaseThemeColorsEnv(`${prefix}DARK_`, config.dark)
1364
- };
1365
- };
1366
- var setBaseThemeColorsEnv = (prefix, config) => {
1367
- if (config.foreground) {
1368
- process.env[`${prefix}FOREGROUND`] = config.foreground;
1369
- }
1370
- if (config.background) {
1371
- process.env[`${prefix}BACKGROUND`] = config.background;
1372
- }
1373
- if (config.brand) {
1374
- process.env[`${prefix}BRAND`] = config.brand;
1375
- }
1376
- if (config.alternate) {
1377
- process.env[`${prefix}ALTERNATE`] = config.alternate;
1378
- }
1379
- if (config.accent) {
1380
- process.env[`${prefix}ACCENT`] = config.accent;
1381
- }
1382
- if (config.link) {
1383
- process.env[`${prefix}LINK`] = config.link;
1384
- }
1385
- if (config.discovery) {
1386
- process.env[`${prefix}DISCOVERY`] = config.discovery;
1387
- }
1388
- if (config.success) {
1389
- process.env[`${prefix}SUCCESS`] = config.success;
1390
- }
1391
- if (config.info) {
1392
- process.env[`${prefix}INFO`] = config.info;
1393
- }
1394
- if (config.debug) {
1395
- process.env[`${prefix}DEBUG`] = config.debug;
1396
- }
1397
- if (config.warning) {
1398
- process.env[`${prefix}WARNING`] = config.warning;
1399
- }
1400
- if (config.danger) {
1401
- process.env[`${prefix}DANGER`] = config.danger;
1402
- }
1403
- if (config.fatal) {
1404
- process.env[`${prefix}FATAL`] = config.fatal;
1405
- }
1406
- if (config.performance) {
1407
- process.env[`${prefix}PERFORMANCE`] = config.performance;
1408
- }
1409
- if (config.positive) {
1410
- process.env[`${prefix}POSITIVE`] = config.positive;
1411
- }
1412
- if (config.negative) {
1413
- process.env[`${prefix}NEGATIVE`] = config.negative;
1414
- }
1415
- if (config.gradient) {
1416
- for (let i = 0; i < config.gradient.length; i++) {
1417
- process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1418
- }
1419
- }
1420
- };
1421
-
1422
- // src/create-storm-config.ts
1423
- var _extension_cache = /* @__PURE__ */ new WeakMap();
1424
- var _static_cache = void 0;
1425
- var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
1426
- let result;
1427
- if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
1428
- let _workspaceRoot = workspaceRoot;
1429
- if (!_workspaceRoot) {
1430
- _workspaceRoot = findWorkspaceRoot();
1431
- }
1432
- const configEnv = getConfigEnv();
1433
- const configFile = await getConfigFile(_workspaceRoot);
1434
- if (!configFile) {
1435
- if (!skipLogs) {
1436
- writeWarning(
1437
- "No Storm Workspace configuration file found in the current repository. Please ensure this is the expected behavior - you can add a `storm-workspace.json` file to the root of your workspace if it is not.\n",
1438
- { logLevel: "all" }
1439
- );
1440
- }
1441
- if (useDefault === false) {
1442
- return void 0;
1443
- }
1444
- }
1445
- const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
1446
- const configInput = defu2(
1447
- configEnv,
1448
- configFile,
1449
- defaultConfig
1450
- );
1451
- if (!configInput.variant) {
1452
- configInput.variant = existsSync3(joinPaths(_workspaceRoot, "nx.json")) || existsSync3(joinPaths(_workspaceRoot, ".nx")) || existsSync3(joinPaths(_workspaceRoot, "lerna.json")) || existsSync3(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
1453
- }
1454
- try {
1455
- const parseResult = await Promise.resolve(
1456
- workspaceConfigSchema._zod.parse(
1457
- { value: configInput, issues: [] },
1458
- { async: true }
1459
- )
1460
- );
1461
- result = applyDefaultConfig(parseResult.value);
1462
- result.workspaceRoot ??= _workspaceRoot;
1463
- } catch (error) {
1464
- throw new Error(
1465
- `Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
1466
-
1467
- Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(
1468
- configInput
1469
- )}`,
1470
- {
1471
- cause: error
1472
- }
1473
- );
1474
- }
1475
- } else {
1476
- result = _static_cache.data;
1477
- }
1478
- if (schema && extensionName) {
1479
- result.extensions = {
1480
- ...result.extensions,
1481
- [extensionName]: createConfigExtension(extensionName, schema)
1482
- };
1483
- }
1484
- _static_cache = {
1485
- timestamp: Date.now(),
1486
- data: result
1487
- };
1488
- return result;
1489
- };
1490
- var createConfigExtension = (extensionName, schema) => {
1491
- const extension_cache_key = { extensionName };
1492
- if (_extension_cache.has(extension_cache_key)) {
1493
- return _extension_cache.get(extension_cache_key);
1494
- }
1495
- let extension = getExtensionEnv(extensionName);
1496
- if (schema) {
1497
- extension = schema.parse(extension);
1498
- }
1499
- _extension_cache.set(extension_cache_key, extension);
1500
- return extension;
1501
- };
1502
- var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
1503
- const config = await createStormWorkspaceConfig(
1504
- void 0,
1505
- void 0,
1506
- workspaceRoot,
1507
- skipLogs,
1508
- true
1509
- );
1510
- setConfigEnv(config);
1511
- if (!skipLogs && !config.skipConfigLogging) {
1512
- writeTrace(
1513
- `\u2699\uFE0F Using Storm Workspace configuration:
1514
- ${formatLogMessage(config)}`,
1515
- config
1516
- );
1517
- }
1518
- return config;
1519
- };
1520
-
1521
- // src/get-config.ts
1522
- function getConfig(workspaceRoot, skipLogs = false) {
1523
- return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
1524
- }
1525
-
1526
- // bin/config.ts
14
+ exitWithError,
15
+ exitWithSuccess,
16
+ findWorkspaceRootSafe,
17
+ handleProcess
18
+ } from "../src/utilities";
1527
19
  function createProgram() {
1528
20
  writeInfo(`${brandIcon()} Running Storm Configuration Tools`, {
1529
21
  logLevel: "all"
@@ -1585,28 +77,28 @@ Stack Trace: ${error.stack}` : ""}`,
1585
77
  process.exit(1);
1586
78
  }
1587
79
  })();
1588
- var formatSingleThemeColors = (config) => {
80
+ const formatSingleThemeColors = (config) => {
1589
81
  return `---- Theme Colors ----
1590
82
  ${Object.entries(config).filter(
1591
83
  ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
1592
84
  ).map(
1593
- ([key, value]) => chalk2.hex(String(value))(`${key}: ${chalk2.bold(value)}`)
85
+ ([key, value]) => chalk.hex(String(value))(`${key}: ${chalk.bold(value)}`)
1594
86
  ).join(" \n")}
1595
87
  `;
1596
88
  };
1597
- var formatMultiThemeColors = (config) => {
89
+ const formatMultiThemeColors = (config) => {
1598
90
  return ` ---- Light Theme Colors ----
1599
91
  ${Object.entries(config.light).filter(
1600
92
  ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
1601
93
  ).map(
1602
- ([key, value]) => chalk2.hex(String(value))(`${key}: ${chalk2.bold(value)}`)
94
+ ([key, value]) => chalk.hex(String(value))(`${key}: ${chalk.bold(value)}`)
1603
95
  ).join(" \n")}
1604
96
 
1605
97
  ---- Dark Theme Colors ----
1606
98
  ${Object.entries(config.dark).filter(
1607
99
  ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
1608
100
  ).map(
1609
- ([key, value]) => chalk2.hex(String(value))(`${key}: ${chalk2.bold(value)}`)
101
+ ([key, value]) => chalk.hex(String(value))(`${key}: ${chalk.bold(value)}`)
1610
102
  ).join(" \n")}
1611
103
  `;
1612
104
  };