@storm-software/config-tools 1.190.120 → 1.190.122

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 (157) hide show
  1. package/README.md +1 -1
  2. package/bin/config.cjs +1272 -105
  3. package/bin/config.mjs +1271 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  5. package/dist/config-file/get-config-file.cjs +63 -79
  6. package/dist/config-file/get-config-file.d.cts +5 -5
  7. package/dist/config-file/{get-config-file.d.ts → get-config-file.d.mts} +7 -5
  8. package/dist/config-file/get-config-file.mjs +66 -0
  9. package/dist/config-file/index.cjs +4 -1
  10. package/dist/config-file/index.d.cts +2 -3
  11. package/dist/config-file/index.d.mts +4 -0
  12. package/dist/config-file/index.mjs +5 -0
  13. package/dist/create-storm-config.cjs +105 -136
  14. package/dist/create-storm-config.d.cts +5 -5
  15. package/dist/{create-storm-config.d.ts → create-storm-config.d.mts} +7 -5
  16. package/dist/create-storm-config.mjs +113 -0
  17. package/dist/env/get-env.cjs +190 -214
  18. package/dist/env/get-env.d.cts +5 -5
  19. package/dist/env/{get-env.d.ts → get-env.d.mts} +7 -5
  20. package/dist/env/get-env.mjs +203 -0
  21. package/dist/env/index.cjs +7 -2
  22. package/dist/env/index.d.cts +3 -4
  23. package/dist/env/index.d.mts +5 -0
  24. package/dist/env/index.mjs +6 -0
  25. package/dist/env/set-env.cjs +218 -374
  26. package/dist/env/set-env.d.cts +8 -8
  27. package/dist/env/{set-env.d.ts → set-env.d.mts} +10 -8
  28. package/dist/env/set-env.mjs +231 -0
  29. package/dist/get-config.cjs +40 -29
  30. package/dist/get-config.d.cts +18 -18
  31. package/dist/{get-config.d.ts → get-config.d.mts} +20 -18
  32. package/dist/get-config.mjs +46 -0
  33. package/dist/index.cjs +98 -7
  34. package/dist/index.d.cts +27 -28
  35. package/dist/index.d.mts +29 -0
  36. package/dist/index.mjs +26 -0
  37. package/dist/logger/chalk.cjs +38 -29
  38. package/dist/logger/chalk.d.cts +18 -17
  39. package/dist/logger/chalk.d.mts +37 -0
  40. package/dist/logger/chalk.mjs +43 -0
  41. package/dist/logger/console-icons.cjs +15 -14
  42. package/dist/logger/console-icons.d.cts +5 -8
  43. package/dist/logger/console-icons.d.mts +7 -0
  44. package/dist/logger/console-icons.mjs +20 -0
  45. package/dist/logger/console.cjs +187 -183
  46. package/dist/logger/console.d.cts +25 -25
  47. package/dist/logger/{console.d.ts → console.d.mts} +27 -25
  48. package/dist/logger/console.mjs +185 -0
  49. package/dist/logger/create-logger.cjs +31 -24
  50. package/dist/logger/create-logger.d.cts +5 -6
  51. package/dist/logger/{create-logger.d.ts → create-logger.d.mts} +7 -6
  52. package/dist/logger/create-logger.mjs +34 -0
  53. package/dist/logger/format-timestamp.cjs +12 -4
  54. package/dist/logger/format-timestamp.d.cts +3 -2
  55. package/dist/logger/{format-timestamp.d.ts → format-timestamp.d.mts} +5 -2
  56. package/dist/logger/format-timestamp.mjs +16 -0
  57. package/dist/logger/get-log-level.cjs +50 -60
  58. package/dist/logger/get-log-level.d.cts +4 -5
  59. package/dist/logger/{get-log-level.d.ts → get-log-level.d.mts} +6 -5
  60. package/dist/logger/get-log-level.mjs +54 -0
  61. package/dist/logger/index.cjs +29 -7
  62. package/dist/logger/index.d.cts +8 -10
  63. package/dist/logger/index.d.mts +10 -0
  64. package/dist/logger/index.mjs +11 -0
  65. package/dist/logger/is-unicode-supported.cjs +6 -10
  66. package/dist/logger/is-unicode-supported.d.cts +3 -2
  67. package/dist/logger/is-unicode-supported.d.mts +6 -0
  68. package/dist/logger/is-unicode-supported.mjs +10 -0
  69. package/dist/types.cjs +26 -25
  70. package/dist/types.d.cts +39 -41
  71. package/dist/types.d.mts +53 -0
  72. package/dist/types.mjs +30 -0
  73. package/dist/utilities/apply-workspace-tokens.cjs +31 -70
  74. package/dist/utilities/apply-workspace-tokens.d.cts +4 -5
  75. package/dist/utilities/{apply-workspace-tokens.d.ts → apply-workspace-tokens.d.mts} +6 -5
  76. package/dist/utilities/apply-workspace-tokens.mjs +37 -0
  77. package/dist/utilities/colors.cjs +91 -74
  78. package/dist/utilities/colors.d.cts +4 -4
  79. package/dist/utilities/{colors.d.ts → colors.d.mts} +6 -4
  80. package/dist/utilities/colors.mjs +97 -0
  81. package/dist/utilities/correct-paths.cjs +166 -196
  82. package/dist/utilities/correct-paths.d.cts +4 -4
  83. package/dist/utilities/{correct-paths.d.ts → correct-paths.d.mts} +6 -4
  84. package/dist/utilities/correct-paths.mjs +190 -0
  85. package/dist/utilities/file-path-utils.cjs +42 -27
  86. package/dist/utilities/file-path-utils.d.cts +15 -14
  87. package/dist/utilities/{file-path-utils.d.ts → file-path-utils.d.mts} +17 -14
  88. package/dist/utilities/file-path-utils.mjs +48 -0
  89. package/dist/utilities/find-up.cjs +12 -18
  90. package/dist/utilities/find-up.d.cts +3 -2
  91. package/dist/utilities/{find-up.d.ts → find-up.d.mts} +5 -2
  92. package/dist/utilities/find-up.mjs +19 -0
  93. package/dist/utilities/find-workspace-root.cjs +64 -69
  94. package/dist/utilities/find-workspace-root.d.cts +3 -2
  95. package/dist/utilities/{find-workspace-root.d.ts → find-workspace-root.d.mts} +5 -2
  96. package/dist/utilities/find-workspace-root.mjs +73 -0
  97. package/dist/utilities/get-default-config.cjs +69 -91
  98. package/dist/utilities/get-default-config.d.cts +4 -4
  99. package/dist/utilities/{get-default-config.d.ts → get-default-config.d.mts} +6 -4
  100. package/dist/utilities/get-default-config.mjs +74 -0
  101. package/dist/utilities/index.cjs +49 -9
  102. package/dist/utilities/index.d.cts +10 -14
  103. package/dist/utilities/index.d.mts +12 -0
  104. package/dist/utilities/index.mjs +13 -0
  105. package/dist/utilities/process-handler.cjs +32 -47
  106. package/dist/utilities/process-handler.d.cts +4 -4
  107. package/dist/utilities/process-handler.d.mts +9 -0
  108. package/dist/utilities/process-handler.mjs +38 -0
  109. package/dist/utilities/run.cjs +62 -36
  110. package/dist/utilities/run.d.cts +5 -6
  111. package/dist/utilities/{run.d.ts → run.d.mts} +7 -6
  112. package/dist/utilities/run.mjs +64 -0
  113. package/dist/utilities/toml.cjs +27 -32
  114. package/dist/utilities/toml.d.cts +148 -147
  115. package/dist/utilities/toml.d.mts +192 -0
  116. package/dist/utilities/toml.mjs +33 -0
  117. package/package.json +105 -157
  118. package/bin/config.js +0 -108
  119. package/dist/config-file/get-config-file.js +0 -83
  120. package/dist/config-file/index.d.ts +0 -3
  121. package/dist/config-file/index.js +0 -1
  122. package/dist/create-storm-config.js +0 -147
  123. package/dist/env/get-env.js +0 -226
  124. package/dist/env/index.d.ts +0 -4
  125. package/dist/env/index.js +0 -2
  126. package/dist/env/set-env.js +0 -386
  127. package/dist/get-config.js +0 -35
  128. package/dist/index.d.ts +0 -28
  129. package/dist/index.js +0 -7
  130. package/dist/logger/chalk.d.ts +0 -34
  131. package/dist/logger/chalk.js +0 -34
  132. package/dist/logger/console-icons.d.ts +0 -8
  133. package/dist/logger/console-icons.js +0 -17
  134. package/dist/logger/console.js +0 -191
  135. package/dist/logger/create-logger.js +0 -27
  136. package/dist/logger/format-timestamp.js +0 -6
  137. package/dist/logger/get-log-level.js +0 -64
  138. package/dist/logger/index.d.ts +0 -10
  139. package/dist/logger/index.js +0 -7
  140. package/dist/logger/is-unicode-supported.d.ts +0 -3
  141. package/dist/logger/is-unicode-supported.js +0 -12
  142. package/dist/types.d.ts +0 -53
  143. package/dist/types.js +0 -28
  144. package/dist/utilities/apply-workspace-tokens.js +0 -76
  145. package/dist/utilities/colors.js +0 -81
  146. package/dist/utilities/correct-paths.js +0 -231
  147. package/dist/utilities/file-path-utils.js +0 -33
  148. package/dist/utilities/find-up.js +0 -23
  149. package/dist/utilities/find-workspace-root.js +0 -77
  150. package/dist/utilities/get-default-config.js +0 -95
  151. package/dist/utilities/index.d.ts +0 -14
  152. package/dist/utilities/index.js +0 -9
  153. package/dist/utilities/process-handler.d.ts +0 -7
  154. package/dist/utilities/process-handler.js +0 -53
  155. package/dist/utilities/run.js +0 -38
  156. package/dist/utilities/toml.d.ts +0 -189
  157. package/dist/utilities/toml.js +0 -42
package/bin/config.cjs CHANGED
@@ -1,130 +1,1297 @@
1
1
  #!/usr/bin/env node
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ //#region \0rolldown/runtime.js
2
4
  var __create = Object.create;
3
5
  var __defProp = Object.defineProperty;
4
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
8
  var __getProtoOf = Object.getPrototypeOf;
7
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
10
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var config_exports = {};
30
- __export(config_exports, {
31
- createProgram: () => createProgram,
32
- viewAction: () => viewAction
33
- });
34
- module.exports = __toCommonJS(config_exports);
35
- var import_chalk = __toESM(require("chalk"), 1);
36
- var import_commander = require("commander");
37
- var import_get_config = require("../src/get-config");
38
- var import_console = require("../src/logger/console");
39
- var import_utilities = require("../src/utilities");
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+ //#endregion
25
+ let chalk = require("chalk");
26
+ chalk = __toESM(chalk, 1);
27
+ let commander = require("commander");
28
+ let _storm_software_config_schema = require("@storm-software/config/schema");
29
+ let defu = require("defu");
30
+ defu = __toESM(defu, 1);
31
+ let node_fs = require("node:fs");
32
+ let c12 = require("c12");
33
+ require("date-fns/formatDistanceToNow");
34
+ let node_path = require("node:path");
35
+ let _storm_software_config = require("@storm-software/config");
36
+ let node_fs_promises = require("node:fs/promises");
37
+ //#region src/types.ts
38
+ const LogLevel = {
39
+ SILENT: 0,
40
+ FATAL: 10,
41
+ ERROR: 20,
42
+ WARN: 30,
43
+ SUCCESS: 35,
44
+ INFO: 40,
45
+ PERFORMANCE: 50,
46
+ DEBUG: 60,
47
+ TRACE: 70,
48
+ ALL: 100
49
+ };
50
+ const LogLevelLabel = {
51
+ SILENT: "silent",
52
+ FATAL: "fatal",
53
+ ERROR: "error",
54
+ WARN: "warn",
55
+ SUCCESS: "success",
56
+ INFO: "info",
57
+ PERFORMANCE: "performance",
58
+ DEBUG: "debug",
59
+ TRACE: "trace",
60
+ ALL: "all"
61
+ };
62
+ //#endregion
63
+ //#region src/utilities/colors.ts
64
+ /**
65
+ * Storm theme config values used for styling various workspace elements
66
+ */
67
+ const DEFAULT_COLOR_CONFIG = {
68
+ light: {
69
+ background: "#fafafa",
70
+ foreground: "#1d1e22",
71
+ brand: "#1fb2a6",
72
+ alternate: "#db2777",
73
+ discovery: "#5C4EE5",
74
+ success: "#087f5b",
75
+ info: "#0550ae",
76
+ debug: "#8afafc",
77
+ warning: "#e3b341",
78
+ danger: "#D8314A",
79
+ fatal: "#51070f",
80
+ performance: "#13c302",
81
+ link: "#3fa6ff",
82
+ positive: "#22c55e",
83
+ negative: "#dc2626",
84
+ gradient: [
85
+ "#1fb2a6",
86
+ "#db2777",
87
+ "#5C4EE5"
88
+ ]
89
+ },
90
+ dark: {
91
+ background: "#1e2124",
92
+ foreground: "#cbd5e1",
93
+ brand: "#2dd4bf",
94
+ alternate: "#db2777",
95
+ discovery: "#818cf8",
96
+ success: "#10b981",
97
+ info: "#58a6ff",
98
+ debug: "#8afafc",
99
+ warning: "#f3d371",
100
+ danger: "#D8314A",
101
+ fatal: "#a40e26",
102
+ performance: "#80fd74",
103
+ link: "#3fa6ff",
104
+ positive: "#22c55e",
105
+ negative: "#dc2626",
106
+ gradient: [
107
+ "#1fb2a6",
108
+ "#db2777",
109
+ "#818cf8"
110
+ ]
111
+ }
112
+ };
113
+ /**
114
+ * Get the color configuration from the Storm workspace configuration.
115
+ *
116
+ * @param config - An optional, partial color configuration for the Storm workspace.
117
+ * @returns The color configuration, or the default color configuration if not defined.
118
+ */
119
+ function getColors(config) {
120
+ if (!config?.colors || typeof config.colors !== "object" || !config.colors["dark"] && (!config.colors["base"] || typeof config.colors !== "object" || !config.colors["base"]?.["dark"])) return DEFAULT_COLOR_CONFIG;
121
+ if (config.colors["base"]) {
122
+ if (typeof config.colors["base"]["dark"] === "object") return config.colors["base"]["dark"];
123
+ else if (config.colors["base"]["dark"] === "string") return config.colors["base"];
124
+ }
125
+ if (typeof config.colors["dark"] === "object") return config.colors["dark"];
126
+ return config.colors ?? DEFAULT_COLOR_CONFIG;
127
+ }
128
+ /**
129
+ * Get a specific color from the Storm workspace configuration.
130
+ *
131
+ * @param key - The key of the color to retrieve.
132
+ * @param config - An optional, partial color configuration for the Storm workspace.
133
+ * @returns The color value for the specified key, or a default value if not defined.
134
+ */
135
+ function getColor(key, config) {
136
+ const colors = getColors(config);
137
+ const result = (typeof colors["dark"] === "object" ? colors["dark"][key] : colors[key]) || DEFAULT_COLOR_CONFIG["dark"][key] || DEFAULT_COLOR_CONFIG[key];
138
+ if (result) return result;
139
+ if (key === "link" || key === "debug") return getColor("info", config);
140
+ else if (key === "fatal") return getColor("danger", config);
141
+ return getColor("brand", config);
142
+ }
143
+ //#endregion
144
+ //#region src/logger/chalk.ts
145
+ const chalkDefault = {
146
+ hex: (_) => (message) => message,
147
+ bgHex: (_) => ({
148
+ whiteBright: (message) => message,
149
+ white: (message) => message
150
+ }),
151
+ white: (message) => message,
152
+ whiteBright: (message) => message,
153
+ gray: (message) => message,
154
+ bold: {
155
+ hex: (_) => (message) => message,
156
+ bgHex: (_) => ({
157
+ whiteBright: (message) => message,
158
+ white: (message) => message
159
+ }),
160
+ whiteBright: (message) => message,
161
+ white: (message) => message
162
+ },
163
+ dim: {
164
+ hex: (_) => (message) => message,
165
+ gray: (message) => message
166
+ }
167
+ };
168
+ /**
169
+ * Get the chalk instance
170
+ *
171
+ * @remarks
172
+ * Annoying polyfill to temporarily fix the issue with the `chalk` import
173
+ *
174
+ * @returns The chalk instance
175
+ */
176
+ const getChalk = () => {
177
+ let _chalk = chalk.default;
178
+ if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) _chalk = chalkDefault;
179
+ return _chalk;
180
+ };
181
+ //#endregion
182
+ //#region src/logger/is-unicode-supported.ts
183
+ function isUnicodeSupported() {
184
+ if (process.platform !== "win32") return process.env.TERM !== "linux";
185
+ return Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || 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";
186
+ }
187
+ //#endregion
188
+ //#region src/logger/console-icons.ts
189
+ const useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
190
+ const CONSOLE_ICONS = {
191
+ [LogLevelLabel.ERROR]: useIcon("✘", "×"),
192
+ [LogLevelLabel.FATAL]: useIcon("🕱", "×"),
193
+ [LogLevelLabel.WARN]: useIcon("⚠", "‼"),
194
+ [LogLevelLabel.INFO]: useIcon("ℹ", "i"),
195
+ [LogLevelLabel.PERFORMANCE]: useIcon("⏱", "⏱"),
196
+ [LogLevelLabel.SUCCESS]: useIcon("✔", "√"),
197
+ [LogLevelLabel.DEBUG]: useIcon("🛠", "D"),
198
+ [LogLevelLabel.TRACE]: useIcon("⚙", "T"),
199
+ [LogLevelLabel.ALL]: useIcon("✉", "→")
200
+ };
201
+ //#endregion
202
+ //#region src/logger/format-timestamp.ts
203
+ /**
204
+ * Format a timestamp to a human-readable string.
205
+ *
206
+ * @param fullDateTime Whether to include the full date and time in the formatted string (defaults to `false`, which only includes the time)
207
+ * @param date The date to format.
208
+ * @returns The formatted timestamp.
209
+ */
210
+ const formatTimestamp = (fullDateTime = false, date = /* @__PURE__ */ new Date()) => {
211
+ return fullDateTime ? `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` : `${date.toLocaleTimeString()}`;
212
+ };
213
+ //#endregion
214
+ //#region src/logger/get-log-level.ts
215
+ /**
216
+ * Convert the log level label to a log level
217
+ *
218
+ * @param label - The log level label to convert
219
+ * @returns The log level
220
+ */
221
+ const getLogLevel = (label) => {
222
+ switch (label) {
223
+ case "all": return LogLevel.ALL;
224
+ case "trace": return LogLevel.TRACE;
225
+ case "debug": return LogLevel.DEBUG;
226
+ case "performance": return LogLevel.PERFORMANCE;
227
+ case "info": return LogLevel.INFO;
228
+ case "warn": return LogLevel.WARN;
229
+ case "error": return LogLevel.ERROR;
230
+ case "fatal": return LogLevel.FATAL;
231
+ case "silent": return LogLevel.SILENT;
232
+ default: return LogLevel.INFO;
233
+ }
234
+ };
235
+ /**
236
+ * Convert the log level to a log level label
237
+ *
238
+ * @param logLevel - The log level to convert
239
+ * @returns The log level label
240
+ */
241
+ const getLogLevelLabel = (logLevel = LogLevel.INFO) => {
242
+ if (logLevel >= LogLevel.ALL) return LogLevelLabel.ALL;
243
+ if (logLevel >= LogLevel.TRACE) return LogLevelLabel.TRACE;
244
+ if (logLevel >= LogLevel.DEBUG) return LogLevelLabel.DEBUG;
245
+ if (logLevel >= LogLevel.PERFORMANCE) return LogLevelLabel.PERFORMANCE;
246
+ if (logLevel >= LogLevel.INFO) return LogLevelLabel.INFO;
247
+ if (logLevel >= LogLevel.WARN) return LogLevelLabel.WARN;
248
+ if (logLevel >= LogLevel.ERROR) return LogLevelLabel.ERROR;
249
+ if (logLevel >= LogLevel.FATAL) return LogLevelLabel.FATAL;
250
+ if (logLevel <= LogLevel.SILENT) return LogLevelLabel.SILENT;
251
+ return LogLevelLabel.INFO;
252
+ };
253
+ //#endregion
254
+ //#region src/logger/console.ts
255
+ /**
256
+ * Get the log function for a log level
257
+ *
258
+ * @param logLevel - The log level
259
+ * @param config - The Storm configuration
260
+ * @returns The log function
261
+ */
262
+ const getLogFn = (logLevel = LogLevel.INFO, config = {}, options = {}) => {
263
+ const { chalk: _chalk = getChalk(), fullDateTime = false, hideDateTime = false } = options;
264
+ 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;
265
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
266
+ if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) return (_) => {};
267
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) return (message) => {
268
+ console.error(`
269
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.fatal ?? DEFAULT_COLOR_CONFIG.dark.fatal)(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
270
+ `);
271
+ };
272
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) return (message) => {
273
+ console.error(`
274
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.danger ?? DEFAULT_COLOR_CONFIG.dark.danger)(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
275
+ `);
276
+ };
277
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) return (message) => {
278
+ console.warn(`
279
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.warning ?? DEFAULT_COLOR_CONFIG.dark.warning)(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
280
+ `);
281
+ };
282
+ if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) return (message) => {
283
+ console.info(`
284
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.success ?? DEFAULT_COLOR_CONFIG.dark.success)(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
285
+ `);
286
+ };
287
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) return (message) => {
288
+ console.info(`
289
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
290
+ `);
291
+ };
292
+ if (typeof logLevel === "number" && LogLevel.PERFORMANCE >= logLevel) return (message) => {
293
+ console.debug(`
294
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.performance ?? DEFAULT_COLOR_CONFIG.dark.performance)(`[${CONSOLE_ICONS[LogLevelLabel.PERFORMANCE]} Performance] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
295
+ `);
296
+ };
297
+ if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) return (message) => {
298
+ console.debug(`
299
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.debug ?? DEFAULT_COLOR_CONFIG.dark.debug)(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
300
+ `);
301
+ };
302
+ if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) return (message) => {
303
+ console.debug(`
304
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex("#bbbbbb")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
305
+ `);
306
+ };
307
+ return (message) => {
308
+ console.log(`
309
+ ${hideDateTime ? "" : `${_chalk.gray(formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CONFIG.dark.brand)(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
310
+ `);
311
+ };
312
+ };
313
+ /**
314
+ * Write a message to the console at the `fatal` log level
315
+ *
316
+ * @param message - The message to write
317
+ * @param config - The Storm configuration
318
+ */
319
+ const writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
320
+ /**
321
+ * Write a message to the console at the `error` log level
322
+ *
323
+ * @param message - The message to write
324
+ * @param config - The Storm configuration
325
+ */
326
+ const writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
327
+ /**
328
+ * Write a message to the console at the `warning` log level
329
+ *
330
+ * @param message - The message to write
331
+ * @param config - The Storm configuration
332
+ */
333
+ const writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
334
+ /**
335
+ * Write a message to the console at the `info` log level
336
+ *
337
+ * @param message - The message to write
338
+ * @param config - The Storm configuration
339
+ */
340
+ const writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
341
+ /**
342
+ * Write a message to the console at the `success` log level
343
+ *
344
+ * @param message - The message to write
345
+ * @param config - The Storm configuration
346
+ */
347
+ const writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
348
+ /**
349
+ * Write a message to the console at the `trace` log level
350
+ *
351
+ * @param message - The message to write
352
+ * @param config - The Storm configuration
353
+ */
354
+ const writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
355
+ const MAX_DEPTH = 10;
356
+ /**
357
+ * Format a log message for output to the console, handling different types of messages (e.g. strings, objects, arrays) and applying formatting options such as prefixing and skipping certain keys in objects.
358
+ *
359
+ * @param message - The message to format
360
+ * @param options - Formatting options
361
+ * @param depth - The current depth of recursion
362
+ * @returns The formatted log message
363
+ */
364
+ const formatLogMessage = (message, options = {}, depth = 0) => {
365
+ if (depth > MAX_DEPTH) return "<max depth>";
366
+ const prefix = options.prefix ?? "";
367
+ const skip = options.skip ?? [];
368
+ const sort = options.sort ?? true;
369
+ return typeof message === "undefined" || message === null ? "<empty>" : typeof message === "string" ? !message ? "<empty string>" : message : Array.isArray(message) ? `\n${message.sort(sort ? (a, b) => !a && !b ? 0 : !a ? 1 : !b ? -1 : String(a).localeCompare(String(b)) : void 0).map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
370
+ prefix: `${prefix}--`,
371
+ skip,
372
+ sort
373
+ }, depth + 1)}`).join("\n")}` : typeof message === "object" && message ? `\n${Object.keys(message).filter((key) => typeof key !== "string" || !skip.map((k) => k.toLowerCase().trim()).includes(key.toLowerCase().trim())).sort(sort ? (a, b) => !a && !b ? 0 : !a ? 1 : !b ? -1 : String(a).localeCompare(String(b)) : void 0).map((key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" && message[key] ? Object.keys(message[key]).filter((key) => typeof key !== "string" || !skip.map((k) => k.toLowerCase().trim()).includes(key.toLowerCase().trim())).length === 0 ? "{}" : formatLogMessage(message[key], {
374
+ prefix: `${prefix}--`,
375
+ skip,
376
+ sort
377
+ }, depth + 1) : message[key]}`).join("\n")}` : String(message);
378
+ };
379
+ const _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
+ /**
387
+ * Get the brand icon for the console
388
+ *
389
+ * @param config - The Storm configuration
390
+ * @param _chalk - The chalk instance
391
+ * @returns The brand icon
392
+ */
393
+ const brandIcon = (config = {}, _chalk = getChalk()) => _chalk.hex(getColor("brand", config))("🗲");
394
+ //#endregion
395
+ //#region src/utilities/correct-paths.ts
396
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
397
+ function normalizeWindowsPath(input = "") {
398
+ if (!input) return input;
399
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
400
+ }
401
+ const _UNC_REGEX = /^[/\\]{2}/;
402
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
403
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
404
+ const correctPaths = function(path) {
405
+ if (!path || path.length === 0) return ".";
406
+ path = normalizeWindowsPath(path);
407
+ const isUNCPath = path?.match(_UNC_REGEX);
408
+ const isPathAbsolute = isAbsolute(path);
409
+ const trailingSeparator = path[path.length - 1] === "/";
410
+ path = normalizeString(path, !isPathAbsolute);
411
+ if (path.length === 0) {
412
+ if (isPathAbsolute) return "/";
413
+ return trailingSeparator ? "./" : ".";
414
+ }
415
+ if (trailingSeparator) path += "/";
416
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
417
+ if (isUNCPath) {
418
+ if (!isPathAbsolute) return `//./${path}`;
419
+ return `//${path}`;
420
+ }
421
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
422
+ };
423
+ const joinPaths = function(...segments) {
424
+ let path = "";
425
+ for (const seg of segments) {
426
+ if (!seg) continue;
427
+ if (path.length > 0) {
428
+ const pathTrailing = path[path.length - 1] === "/";
429
+ const segLeading = seg[0] === "/";
430
+ if (pathTrailing && segLeading) path += seg.slice(1);
431
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
432
+ } else path += seg;
433
+ }
434
+ return correctPaths(path);
435
+ };
436
+ /**
437
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
438
+ *
439
+ * @param path - The path to normalise.
440
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
441
+ * @returns the normalised path string.
442
+ */
443
+ function normalizeString(path, allowAboveRoot) {
444
+ let res = "";
445
+ let lastSegmentLength = 0;
446
+ let lastSlash = -1;
447
+ let dots = 0;
448
+ let char = null;
449
+ for (let index = 0; index <= path.length; ++index) {
450
+ if (index < path.length) char = path[index];
451
+ else if (char === "/") break;
452
+ else char = "/";
453
+ if (char === "/") {
454
+ if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
455
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
456
+ if (res.length > 2) {
457
+ const lastSlashIndex = res.lastIndexOf("/");
458
+ if (lastSlashIndex === -1) {
459
+ res = "";
460
+ lastSegmentLength = 0;
461
+ } else {
462
+ res = res.slice(0, lastSlashIndex);
463
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
464
+ }
465
+ lastSlash = index;
466
+ dots = 0;
467
+ continue;
468
+ } else if (res.length > 0) {
469
+ res = "";
470
+ lastSegmentLength = 0;
471
+ lastSlash = index;
472
+ dots = 0;
473
+ continue;
474
+ }
475
+ }
476
+ if (allowAboveRoot) {
477
+ res += res.length > 0 ? "/.." : "..";
478
+ lastSegmentLength = 2;
479
+ }
480
+ } else {
481
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
482
+ else res = path.slice(lastSlash + 1, index);
483
+ lastSegmentLength = index - lastSlash - 1;
484
+ }
485
+ lastSlash = index;
486
+ dots = 0;
487
+ } else if (char === "." && dots !== -1) ++dots;
488
+ else dots = -1;
489
+ }
490
+ return res;
491
+ }
492
+ const isAbsolute = function(p) {
493
+ return _IS_ABSOLUTE_RE.test(p);
494
+ };
495
+ //#endregion
496
+ //#region src/utilities/find-up.ts
497
+ const MAX_PATH_SEARCH_DEPTH = 30;
498
+ let depth = 0;
499
+ /**
500
+ * Gets the nearest "node_modules" folder by walking up from start path.
501
+ */
502
+ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
503
+ const _startPath = startPath ?? process.cwd();
504
+ if (endDirectoryNames.some((endDirName) => (0, node_fs.existsSync)((0, node_path.join)(_startPath, endDirName)))) return _startPath;
505
+ if (endFileNames.some((endFileName) => (0, node_fs.existsSync)((0, node_path.join)(_startPath, endFileName)))) return _startPath;
506
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) return findFolderUp((0, node_path.join)(_startPath, ".."), endFileNames, endDirectoryNames);
507
+ }
508
+ //#endregion
509
+ //#region src/utilities/find-workspace-root.ts
510
+ const rootFiles = [
511
+ "storm-workspace.json",
512
+ "storm-workspace.yaml",
513
+ "storm-workspace.yml",
514
+ "storm-workspace.js",
515
+ "storm-workspace.ts",
516
+ ".storm-workspace.json",
517
+ ".storm-workspace.yaml",
518
+ ".storm-workspace.yml",
519
+ ".storm-workspace.js",
520
+ ".storm-workspace.ts",
521
+ "lerna.json",
522
+ "nx.json",
523
+ "turbo.json",
524
+ "npm-workspace.json",
525
+ "yarn-workspace.json",
526
+ "pnpm-workspace.json",
527
+ "npm-workspace.yaml",
528
+ "yarn-workspace.yaml",
529
+ "pnpm-workspace.yaml",
530
+ "npm-workspace.yml",
531
+ "yarn-workspace.yml",
532
+ "pnpm-workspace.yml",
533
+ "npm-lock.json",
534
+ "yarn-lock.json",
535
+ "pnpm-lock.json",
536
+ "npm-lock.yaml",
537
+ "yarn-lock.yaml",
538
+ "pnpm-lock.yaml",
539
+ "npm-lock.yml",
540
+ "yarn-lock.yml",
541
+ "pnpm-lock.yml",
542
+ "bun.lockb",
543
+ "bun.lock",
544
+ "bunfig.toml"
545
+ ];
546
+ const rootDirectories = [
547
+ ".storm-workspace",
548
+ ".nx",
549
+ ".git",
550
+ ".github",
551
+ ".vscode",
552
+ ".verdaccio"
553
+ ];
554
+ /**
555
+ * Find the monorepo root directory, searching upwards from `path`.
556
+ *
557
+ * @param pathInsideMonorepo - The path inside the monorepo to start searching from
558
+ * @returns The monorepo root directory
559
+ */
560
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
561
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return correctPaths(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
562
+ return correctPaths(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
563
+ }
564
+ /**
565
+ * Find the monorepo root directory, searching upwards from `path`.
566
+ *
567
+ * @param pathInsideMonorepo - The path inside the monorepo to start searching from
568
+ * @returns The monorepo root directory
569
+ */
570
+ function findWorkspaceRoot(pathInsideMonorepo) {
571
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
572
+ if (!result) throw new Error(`Cannot find workspace root upwards from known path. Files search list includes: \n${rootFiles.join("\n")}\nPath: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
573
+ return result;
574
+ }
575
+ //#endregion
576
+ //#region src/utilities/get-default-config.ts
577
+ /**
578
+ * Get the default Storm config values used during various dev-ops processes
579
+ *
580
+ * @returns The default Storm config values
581
+ */
582
+ async function getPackageJsonConfig(root) {
583
+ let license = _storm_software_config.STORM_DEFAULT_LICENSE;
584
+ let homepage = void 0;
585
+ let support = void 0;
586
+ let name = void 0;
587
+ let namespace = void 0;
588
+ let repository = void 0;
589
+ const workspaceRoot = findWorkspaceRoot(root);
590
+ if ((0, node_fs.existsSync)((0, node_path.join)(workspaceRoot, "package.json"))) {
591
+ const file = await (0, node_fs_promises.readFile)(joinPaths(workspaceRoot, "package.json"), "utf8");
592
+ if (file) {
593
+ const packageJson = JSON.parse(file);
594
+ if (packageJson.name) name = packageJson.name;
595
+ if (packageJson.namespace) namespace = packageJson.namespace;
596
+ if (packageJson.repository) {
597
+ if (typeof packageJson.repository === "string") repository = packageJson.repository;
598
+ else if (packageJson.repository.url) repository = packageJson.repository.url;
599
+ }
600
+ if (packageJson.license) license = packageJson.license;
601
+ if (packageJson.homepage) homepage = packageJson.homepage;
602
+ if (packageJson.bugs) {
603
+ if (typeof packageJson.bugs === "string") support = packageJson.bugs;
604
+ else if (packageJson.bugs.url) support = packageJson.bugs.url;
605
+ }
606
+ }
607
+ }
608
+ return {
609
+ workspaceRoot,
610
+ name,
611
+ namespace,
612
+ repository,
613
+ license,
614
+ homepage,
615
+ support
616
+ };
617
+ }
618
+ /**
619
+ * Apply default config values to the given config object
620
+ *
621
+ * @param config - The config object to apply defaults to
622
+ * @returns The config object with defaults applied
623
+ */
624
+ function applyDefaultConfig(config) {
625
+ if (!config.support && config.contact) config.support = config.contact;
626
+ if (!config.contact && config.support) config.contact = config.support;
627
+ if (config.homepage) {
628
+ if (!config.docs) config.docs = `${config.homepage}/docs`;
629
+ if (!config.license) config.license = `${config.homepage}/license`;
630
+ if (!config.support) config.support = `${config.homepage}/support`;
631
+ if (!config.contact) config.contact = `${config.homepage}/contact`;
632
+ if (!config.error?.codesFile || !config?.error?.url) {
633
+ config.error ??= { codesFile: _storm_software_config.STORM_DEFAULT_ERROR_CODES_FILE };
634
+ if (config.homepage) config.error.url ??= `${config.homepage}/errors`;
635
+ }
636
+ }
637
+ return config;
638
+ }
639
+ //#endregion
640
+ //#region src/utilities/process-handler.ts
641
+ const exitWithError = (config) => {
642
+ writeFatal("Exiting script with an error status...", config);
643
+ process.exit(1);
644
+ };
645
+ const exitWithSuccess = (config) => {
646
+ writeSuccess("Script completed successfully. Exiting...", config);
647
+ process.exit(0);
648
+ };
649
+ const handleProcess = (config) => {
650
+ writeTrace(`Using the following arguments to process the script: ${process.argv.join(", ")}`, config);
651
+ process.on("unhandledRejection", (error) => {
652
+ writeError(`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"} \nStacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`, config);
653
+ exitWithError(config);
654
+ });
655
+ process.on("uncaughtException", (error) => {
656
+ writeError(`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"} \nStacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`, config);
657
+ exitWithError(config);
658
+ });
659
+ process.on("SIGTERM", (signal) => {
660
+ writeError(`The program terminated with signal code: ${signal}`, config);
661
+ exitWithError(config);
662
+ });
663
+ process.on("SIGINT", (signal) => {
664
+ writeError(`The program terminated with signal code: ${signal}`, config);
665
+ exitWithError(config);
666
+ });
667
+ process.on("SIGHUP", (signal) => {
668
+ writeError(`The program terminated with signal code: ${signal}`, config);
669
+ exitWithError(config);
670
+ });
671
+ };
672
+ //#endregion
673
+ //#region src/config-file/get-config-file.ts
674
+ /**
675
+ * Get the config file for the current Storm workspace
676
+ *
677
+ * @param fileName - The name of the config file to search for
678
+ * @param filePath - The path to search for the config file in
679
+ * @returns The config file for the current Storm workspace
680
+ */
681
+ const getConfigFileByName = async (fileName, filePath, options = {}) => {
682
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
683
+ const configs = await Promise.all([(0, c12.loadConfig)({
684
+ cwd: workspacePath,
685
+ packageJson: true,
686
+ name: fileName,
687
+ envName: fileName?.toUpperCase(),
688
+ jitiOptions: {
689
+ debug: false,
690
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
691
+ },
692
+ ...options
693
+ }), (0, c12.loadConfig)({
694
+ cwd: workspacePath,
695
+ packageJson: true,
696
+ name: fileName,
697
+ envName: fileName?.toUpperCase(),
698
+ jitiOptions: {
699
+ debug: false,
700
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
701
+ },
702
+ configFile: fileName,
703
+ ...options
704
+ })]);
705
+ return (0, defu.default)(configs[0] ?? {}, configs[1] ?? {});
706
+ };
707
+ /**
708
+ * Get the config file for the current Storm workspace
709
+ *
710
+ * @returns The config file for the current Storm workspace
711
+ */
712
+ const getConfigFile = async (filePath, additionalFileNames = []) => {
713
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
714
+ const result = await getConfigFileByName("storm-workspace", workspacePath);
715
+ let config = result.config;
716
+ const configFile = result.configFile;
717
+ if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, { logLevel: "all" });
718
+ if (additionalFileNames && additionalFileNames.length > 0) {
719
+ const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
720
+ for (const result of results) if (result?.config && result?.configFile && Object.keys(result.config).length > 0) {
721
+ if (!config.skipConfigLogging && !result.config.skipConfigLogging) writeTrace(`Found alternative configuration file "${result.configFile.includes(`${workspacePath}/`) ? result.configFile.replace(`${workspacePath}/`, "") : result.configFile}" at "${workspacePath}"`, { logLevel: "all" });
722
+ config = (0, defu.default)(result.config ?? {}, config ?? {});
723
+ }
724
+ }
725
+ if (!config || Object.keys(config).length === 0) return;
726
+ config.configFile = configFile;
727
+ return config;
728
+ };
729
+ //#endregion
730
+ //#region src/env/get-env.ts
731
+ /**
732
+ * Get the config for an extension module of Storm workspace from environment variables
733
+ *
734
+ * @param extensionName - The name of the extension module
735
+ * @returns The config for the specified Storm extension module. If the module does not exist, `undefined` is returned.
736
+ */
737
+ const getExtensionEnv = (extensionName) => {
738
+ const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
739
+ return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
740
+ const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
741
+ if (name) ret[name] = process.env[key];
742
+ return ret;
743
+ }, {});
744
+ };
745
+ /**
746
+ * Get the config for the current Storm workspace
747
+ *
748
+ * @returns The config for the current Storm workspace from environment variables
749
+ */
750
+ const getConfigEnv = () => {
751
+ const prefix = "STORM_";
752
+ let config = {
753
+ extends: process.env[`${prefix}EXTENDS`] || void 0,
754
+ name: process.env[`${prefix}NAME`] || void 0,
755
+ variant: process.env[`${prefix}VARIANT`] || void 0,
756
+ namespace: process.env[`${prefix}NAMESPACE`] || void 0,
757
+ owner: process.env[`${prefix}OWNER`] || void 0,
758
+ bot: {
759
+ name: process.env[`${prefix}BOT_NAME`] || void 0,
760
+ email: process.env[`${prefix}BOT_EMAIL`] || void 0
761
+ },
762
+ release: {
763
+ banner: {
764
+ url: process.env[`${prefix}RELEASE_BANNER_URL`] || void 0,
765
+ alt: process.env[`${prefix}RELEASE_BANNER_ALT`] || void 0
766
+ },
767
+ header: process.env[`${prefix}RELEASE_HEADER`] || void 0,
768
+ footer: process.env[`${prefix}RELEASE_FOOTER`] || void 0
769
+ },
770
+ error: {
771
+ codesFile: process.env[`${prefix}ERROR_CODES_FILE`] || void 0,
772
+ url: process.env[`${prefix}ERROR_URL`] || void 0
773
+ },
774
+ socials: {
775
+ twitter: process.env[`${prefix}SOCIAL_TWITTER`] || void 0,
776
+ discord: process.env[`${prefix}SOCIAL_DISCORD`] || void 0,
777
+ telegram: process.env[`${prefix}SOCIAL_TELEGRAM`] || void 0,
778
+ slack: process.env[`${prefix}SOCIAL_SLACK`] || void 0,
779
+ medium: process.env[`${prefix}SOCIAL_MEDIUM`] || void 0,
780
+ github: process.env[`${prefix}SOCIAL_GITHUB`] || void 0
781
+ },
782
+ 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`] ? {
783
+ name: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`],
784
+ description: process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || void 0,
785
+ url: process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || void 0,
786
+ logo: process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] || void 0,
787
+ icon: process.env[`${prefix}ORG_ICON`] || process.env[`${prefix}ORGANIZATION_ICON`] || void 0
788
+ } : process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] : void 0,
789
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
790
+ license: process.env[`${prefix}LICENSE`] || void 0,
791
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
792
+ docs: process.env[`${prefix}DOCS`] || void 0,
793
+ portal: process.env[`${prefix}PORTAL`] || void 0,
794
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
795
+ contact: process.env[`${prefix}CONTACT`] || void 0,
796
+ support: process.env[`${prefix}SUPPORT`] || void 0,
797
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
798
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
799
+ configFile: process.env[`${prefix}WORKSPACE_CONFIG_FILE`] ? correctPaths(process.env[`${prefix}WORKSPACE_CONFIG_FILE`]) : void 0,
800
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
801
+ directories: {
802
+ 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,
803
+ 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,
804
+ 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,
805
+ 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,
806
+ 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,
807
+ 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
808
+ },
809
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
810
+ mode: (process.env[`${prefix}MODE`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
811
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
812
+ branch: process.env[`${prefix}BRANCH`] || void 0,
813
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
814
+ registry: {
815
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
816
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
817
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
818
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
819
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
820
+ },
821
+ logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0,
822
+ skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
823
+ };
824
+ const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && _storm_software_config.COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
825
+ config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
826
+ ret[themeName] = getThemeColorsEnv(prefix, themeName);
827
+ return ret;
828
+ }, {}) : getThemeColorsEnv(prefix);
829
+ if (config.docs === _storm_software_config.STORM_DEFAULT_DOCS) {
830
+ if (config.homepage === _storm_software_config.STORM_DEFAULT_HOMEPAGE) config.docs = `${_storm_software_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
831
+ else config.docs = `${config.homepage}/docs`;
832
+ }
833
+ if (config.licensing === _storm_software_config.STORM_DEFAULT_LICENSING) {
834
+ if (config.homepage === _storm_software_config.STORM_DEFAULT_HOMEPAGE) config.licensing = `${_storm_software_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
835
+ else config.licensing = `${config.homepage}/docs`;
836
+ }
837
+ const serializedConfig = process.env[`${prefix}WORKSPACE_CONFIG`];
838
+ if (serializedConfig) {
839
+ const parsed = JSON.parse(serializedConfig);
840
+ config = {
841
+ ...config,
842
+ ...parsed,
843
+ colors: {
844
+ ...config.colors,
845
+ ...parsed.colors
846
+ },
847
+ extensions: {
848
+ ...config.extensions,
849
+ ...parsed.extensions
850
+ }
851
+ };
852
+ }
853
+ return config;
854
+ };
855
+ const getThemeColorsEnv = (prefix, theme) => {
856
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
857
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorsEnv(prefix + themeName) : getSingleThemeColorsEnv(prefix + themeName);
858
+ };
859
+ const getSingleThemeColorsEnv = (prefix) => {
860
+ const gradient = [];
861
+ if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) gradient.push(process.env[`${prefix}GRADIENT_START`], process.env[`${prefix}GRADIENT_END`]);
862
+ else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
863
+ let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
864
+ while (process.env[`${prefix}GRADIENT_${index}`]) {
865
+ gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
866
+ index++;
867
+ }
868
+ }
869
+ return {
870
+ dark: process.env[`${prefix}DARK`],
871
+ light: process.env[`${prefix}LIGHT`],
872
+ brand: process.env[`${prefix}BRAND`],
873
+ alternate: process.env[`${prefix}ALTERNATE`],
874
+ accent: process.env[`${prefix}ACCENT`],
875
+ link: process.env[`${prefix}LINK`],
876
+ discovery: process.env[`${prefix}DISCOVERY`],
877
+ success: process.env[`${prefix}SUCCESS`],
878
+ info: process.env[`${prefix}INFO`],
879
+ debug: process.env[`${prefix}DEBUG`],
880
+ warning: process.env[`${prefix}WARNING`],
881
+ danger: process.env[`${prefix}DANGER`],
882
+ fatal: process.env[`${prefix}FATAL`],
883
+ performance: process.env[`${prefix}PERFORMANCE`],
884
+ positive: process.env[`${prefix}POSITIVE`],
885
+ negative: process.env[`${prefix}NEGATIVE`],
886
+ gradient
887
+ };
888
+ };
889
+ const getMultiThemeColorsEnv = (prefix) => {
890
+ return {
891
+ light: getBaseThemeColorsEnv(`${prefix}_LIGHT_`),
892
+ dark: getBaseThemeColorsEnv(`${prefix}_DARK_`)
893
+ };
894
+ };
895
+ const getBaseThemeColorsEnv = (prefix) => {
896
+ const gradient = [];
897
+ if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) gradient.push(process.env[`${prefix}GRADIENT_START`], process.env[`${prefix}GRADIENT_END`]);
898
+ else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
899
+ let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
900
+ while (process.env[`${prefix}GRADIENT_${index}`]) {
901
+ gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
902
+ index++;
903
+ }
904
+ }
905
+ return {
906
+ foreground: process.env[`${prefix}FOREGROUND`],
907
+ background: process.env[`${prefix}BACKGROUND`],
908
+ brand: process.env[`${prefix}BRAND`],
909
+ alternate: process.env[`${prefix}ALTERNATE`],
910
+ accent: process.env[`${prefix}ACCENT`],
911
+ link: process.env[`${prefix}LINK`],
912
+ discovery: process.env[`${prefix}DISCOVERY`],
913
+ success: process.env[`${prefix}SUCCESS`],
914
+ info: process.env[`${prefix}INFO`],
915
+ debug: process.env[`${prefix}DEBUG`],
916
+ warning: process.env[`${prefix}WARNING`],
917
+ danger: process.env[`${prefix}DANGER`],
918
+ fatal: process.env[`${prefix}FATAL`],
919
+ performance: process.env[`${prefix}PERFORMANCE`],
920
+ positive: process.env[`${prefix}POSITIVE`],
921
+ negative: process.env[`${prefix}NEGATIVE`],
922
+ gradient
923
+ };
924
+ };
925
+ //#endregion
926
+ //#region src/env/set-env.ts
927
+ /**
928
+ * Get the config for an extension module of Storm workspace from environment variables
929
+ *
930
+ * @param extensionName - The name of the extension module
931
+ * @returns The config for the specified Storm extension module. If the module does not exist, `undefined` is returned.
932
+ */
933
+ const setExtensionEnv = (extensionName, extension) => {
934
+ for (const key of Object.keys(extension ?? {})) if (extension[key]) {
935
+ const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
936
+ let extensionKey;
937
+ if (result.length === 0) return;
938
+ if (result.length === 1) extensionKey = result[0]?.toUpperCase() ?? "";
939
+ else extensionKey = result.reduce((ret, part) => {
940
+ return `${ret}_${part.toLowerCase()}`;
941
+ });
942
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
943
+ }
944
+ };
945
+ /**
946
+ * Get the config for the current Storm workspace
947
+ *
948
+ * @returns The config for the current Storm workspace from environment variables
949
+ */
950
+ const setConfigEnv = (config) => {
951
+ const prefix = "STORM_";
952
+ if (config.extends) process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
953
+ if (config.name) process.env[`${prefix}NAME`] = config.name;
954
+ if (config.variant) process.env[`${prefix}VARIANT`] = config.variant;
955
+ if (config.namespace) process.env[`${prefix}NAMESPACE`] = config.namespace;
956
+ if (config.owner) process.env[`${prefix}OWNER`] = config.owner;
957
+ if (config.bot) {
958
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
959
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
960
+ }
961
+ if (config.error) {
962
+ process.env[`${prefix}ERROR_CODES_FILE`] = config.error.codesFile;
963
+ process.env[`${prefix}ERROR_URL`] = config.error.url;
964
+ }
965
+ if (config.release) {
966
+ if (config.release.banner) {
967
+ if (typeof config.release.banner === "string") {
968
+ process.env[`${prefix}RELEASE_BANNER`] = config.release.banner;
969
+ process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner;
970
+ } else {
971
+ process.env[`${prefix}RELEASE_BANNER`] = config.release.banner.url;
972
+ process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner.url;
973
+ process.env[`${prefix}RELEASE_BANNER_ALT`] = config.release.banner.alt;
974
+ }
975
+ }
976
+ process.env[`${prefix}RELEASE_HEADER`] = config.release.header;
977
+ process.env[`${prefix}RELEASE_FOOTER`] = config.release.footer;
978
+ }
979
+ if (config.socials) {
980
+ if (config.socials.twitter) process.env[`${prefix}SOCIAL_TWITTER`] = config.socials.twitter;
981
+ if (config.socials.discord) process.env[`${prefix}SOCIAL_DISCORD`] = config.socials.discord;
982
+ if (config.socials.telegram) process.env[`${prefix}SOCIAL_TELEGRAM`] = config.socials.telegram;
983
+ if (config.socials.slack) process.env[`${prefix}SOCIAL_SLACK`] = config.socials.slack;
984
+ if (config.socials.medium) process.env[`${prefix}SOCIAL_MEDIUM`] = config.socials.medium;
985
+ if (config.socials.github) process.env[`${prefix}SOCIAL_GITHUB`] = config.socials.github;
986
+ }
987
+ if (config.organization) {
988
+ if (typeof config.organization === "string") {
989
+ process.env[`${prefix}ORG`] = config.organization;
990
+ process.env[`${prefix}ORG_NAME`] = config.organization;
991
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
992
+ process.env[`${prefix}ORGANIZATION_NAME`] = config.organization;
993
+ } else {
994
+ process.env[`${prefix}ORG`] = config.organization.name;
995
+ process.env[`${prefix}ORG_NAME`] = config.organization.name;
996
+ process.env[`${prefix}ORGANIZATION`] = config.organization.name;
997
+ process.env[`${prefix}ORGANIZATION_NAME`] = config.organization.name;
998
+ if (config.organization.url) {
999
+ process.env[`${prefix}ORG_URL`] = config.organization.url;
1000
+ process.env[`${prefix}ORGANIZATION_URL`] = config.organization.url;
1001
+ }
1002
+ if (config.organization.description) {
1003
+ process.env[`${prefix}ORG_DESCRIPTION`] = config.organization.description;
1004
+ process.env[`${prefix}ORGANIZATION_DESCRIPTION`] = config.organization.description;
1005
+ }
1006
+ if (config.organization.logo) {
1007
+ process.env[`${prefix}ORG_LOGO`] = config.organization.logo;
1008
+ process.env[`${prefix}ORGANIZATION_LOGO`] = config.organization.logo;
1009
+ }
1010
+ if (config.organization.icon) {
1011
+ process.env[`${prefix}ORG_ICON`] = config.organization.icon;
1012
+ process.env[`${prefix}ORGANIZATION_ICON`] = config.organization.icon;
1013
+ }
1014
+ }
1015
+ }
1016
+ if (config.packageManager) process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
1017
+ if (config.license) process.env[`${prefix}LICENSE`] = config.license;
1018
+ if (config.homepage) process.env[`${prefix}HOMEPAGE`] = config.homepage;
1019
+ if (config.docs) process.env[`${prefix}DOCS`] = config.docs;
1020
+ if (config.portal) process.env[`${prefix}PORTAL`] = config.portal;
1021
+ if (config.licensing) process.env[`${prefix}LICENSING`] = config.licensing;
1022
+ if (config.contact) process.env[`${prefix}CONTACT`] = config.contact;
1023
+ if (config.support) process.env[`${prefix}SUPPORT`] = config.support;
1024
+ if (config.timezone) {
1025
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
1026
+ process.env.TZ = config.timezone;
1027
+ process.env.DEFAULT_TIMEZONE = config.timezone;
1028
+ process.env.TIMEZONE = config.timezone;
1029
+ }
1030
+ if (config.locale) {
1031
+ process.env[`${prefix}LOCALE`] = config.locale;
1032
+ process.env.DEFAULT_LOCALE = config.locale;
1033
+ process.env.LOCALE = config.locale;
1034
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
1035
+ }
1036
+ if (config.configFile) process.env[`${prefix}WORKSPACE_CONFIG_FILE`] = correctPaths(config.configFile);
1037
+ if (config.workspaceRoot) {
1038
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
1039
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
1040
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
1041
+ }
1042
+ if (config.directories) {
1043
+ if (!config.skipCache && config.directories.cache) {
1044
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
1045
+ process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
1046
+ }
1047
+ if (config.directories.data) {
1048
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
1049
+ process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
1050
+ }
1051
+ if (config.directories.config) {
1052
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
1053
+ process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
1054
+ }
1055
+ if (config.directories.temp) {
1056
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
1057
+ process.env[`${prefix}TEMP_DIRECTORY`] = process.env[`${prefix}TEMP_DIR`];
1058
+ }
1059
+ if (config.directories.log) {
1060
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
1061
+ process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
1062
+ }
1063
+ if (config.directories.build) {
1064
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
1065
+ process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
1066
+ }
1067
+ }
1068
+ if (config.skipCache !== void 0) {
1069
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
1070
+ if (config.skipCache) {
1071
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
1072
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
1073
+ }
1074
+ }
1075
+ if (config.mode) {
1076
+ process.env[`${prefix}MODE`] = config.mode;
1077
+ process.env.NODE_ENV = config.mode;
1078
+ process.env.ENVIRONMENT = config.mode;
1079
+ }
1080
+ if (config.colors?.base?.light || config.colors?.base?.dark) for (const key of Object.keys(config.colors)) setThemeColorsEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
1081
+ else setThemeColorsEnv(`${prefix}COLOR_`, config.colors);
1082
+ if (config.repository) process.env[`${prefix}REPOSITORY`] = config.repository;
1083
+ if (config.branch) process.env[`${prefix}BRANCH`] = config.branch;
1084
+ if (config.preid) process.env[`${prefix}PRE_ID`] = String(config.preid);
1085
+ if (config.registry) {
1086
+ if (config.registry.github) process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
1087
+ if (config.registry.npm) process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
1088
+ if (config.registry.cargo) process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
1089
+ if (config.registry.cyclone) process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
1090
+ if (config.registry.container) process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.container);
1091
+ }
1092
+ if (config.logLevel) {
1093
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
1094
+ process.env.LOG_LEVEL = String(config.logLevel);
1095
+ process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
1096
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
1097
+ }
1098
+ if (config.skipConfigLogging !== void 0) process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(config.skipConfigLogging);
1099
+ process.env[`${prefix}WORKSPACE_CONFIG`] = JSON.stringify(config);
1100
+ for (const key of Object.keys(config.extensions ?? {})) if (config.extensions[key] && Object.keys(config.extensions[key])) setExtensionEnv(key, config.extensions[key]);
1101
+ };
1102
+ const setThemeColorsEnv = (prefix, config) => {
1103
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorsEnv(prefix, config) : setSingleThemeColorsEnv(prefix, config);
1104
+ };
1105
+ const setSingleThemeColorsEnv = (prefix, config) => {
1106
+ if (config.dark) process.env[`${prefix}DARK`] = config.dark;
1107
+ if (config.light) process.env[`${prefix}LIGHT`] = config.light;
1108
+ if (config.brand) process.env[`${prefix}BRAND`] = config.brand;
1109
+ if (config.alternate) process.env[`${prefix}ALTERNATE`] = config.alternate;
1110
+ if (config.accent) process.env[`${prefix}ACCENT`] = config.accent;
1111
+ if (config.link) process.env[`${prefix}LINK`] = config.link;
1112
+ if (config.discovery) process.env[`${prefix}DISCOVERY`] = config.discovery;
1113
+ if (config.success) process.env[`${prefix}SUCCESS`] = config.success;
1114
+ if (config.info) process.env[`${prefix}INFO`] = config.info;
1115
+ if (config.debug) process.env[`${prefix}DEBUG`] = config.debug;
1116
+ if (config.warning) process.env[`${prefix}WARNING`] = config.warning;
1117
+ if (config.danger) process.env[`${prefix}DANGER`] = config.danger;
1118
+ if (config.fatal) process.env[`${prefix}FATAL`] = config.fatal;
1119
+ if (config.performance) process.env[`${prefix}PERFORMANCE`] = config.performance;
1120
+ if (config.positive) process.env[`${prefix}POSITIVE`] = config.positive;
1121
+ if (config.negative) process.env[`${prefix}NEGATIVE`] = config.negative;
1122
+ if (config.gradient) for (let i = 0; i < config.gradient.length; i++) process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1123
+ };
1124
+ const setMultiThemeColorsEnv = (prefix, config) => {
1125
+ return {
1126
+ light: setBaseThemeColorsEnv(`${prefix}LIGHT_`, config.light),
1127
+ dark: setBaseThemeColorsEnv(`${prefix}DARK_`, config.dark)
1128
+ };
1129
+ };
1130
+ const setBaseThemeColorsEnv = (prefix, config) => {
1131
+ if (config.foreground) process.env[`${prefix}FOREGROUND`] = config.foreground;
1132
+ if (config.background) process.env[`${prefix}BACKGROUND`] = config.background;
1133
+ if (config.brand) process.env[`${prefix}BRAND`] = config.brand;
1134
+ if (config.alternate) process.env[`${prefix}ALTERNATE`] = config.alternate;
1135
+ if (config.accent) process.env[`${prefix}ACCENT`] = config.accent;
1136
+ if (config.link) process.env[`${prefix}LINK`] = config.link;
1137
+ if (config.discovery) process.env[`${prefix}DISCOVERY`] = config.discovery;
1138
+ if (config.success) process.env[`${prefix}SUCCESS`] = config.success;
1139
+ if (config.info) process.env[`${prefix}INFO`] = config.info;
1140
+ if (config.debug) process.env[`${prefix}DEBUG`] = config.debug;
1141
+ if (config.warning) process.env[`${prefix}WARNING`] = config.warning;
1142
+ if (config.danger) process.env[`${prefix}DANGER`] = config.danger;
1143
+ if (config.fatal) process.env[`${prefix}FATAL`] = config.fatal;
1144
+ if (config.performance) process.env[`${prefix}PERFORMANCE`] = config.performance;
1145
+ if (config.positive) process.env[`${prefix}POSITIVE`] = config.positive;
1146
+ if (config.negative) process.env[`${prefix}NEGATIVE`] = config.negative;
1147
+ if (config.gradient) for (let i = 0; i < config.gradient.length; i++) process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
1148
+ };
1149
+ //#endregion
1150
+ //#region src/create-storm-config.ts
1151
+ const _extension_cache = /* @__PURE__ */ new WeakMap();
1152
+ let _static_cache = void 0;
1153
+ /**
1154
+ * Get the config for the current Storm workspace
1155
+ *
1156
+ * @param extensionName - The name of the config extension
1157
+ * @param schema - The schema for the config extension
1158
+ * @param workspaceRoot - The root directory of the workspace
1159
+ * @param skipLogs - Skip writing logs to the console
1160
+ * @param useDefault - Whether to use the default config if no config file is found
1161
+ * @returns The config for the current Storm workspace
1162
+ */
1163
+ const createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
1164
+ let result;
1165
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
1166
+ let _workspaceRoot = workspaceRoot;
1167
+ if (!_workspaceRoot) _workspaceRoot = findWorkspaceRoot();
1168
+ const configEnv = getConfigEnv();
1169
+ const configFile = await getConfigFile(_workspaceRoot);
1170
+ if (!configFile) {
1171
+ if (!skipLogs) writeWarning("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", { logLevel: "all" });
1172
+ if (useDefault === false) return;
1173
+ }
1174
+ const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
1175
+ const configInput = (0, defu.default)(configEnv, configFile, defaultConfig);
1176
+ if (!configInput.variant) configInput.variant = (0, node_fs.existsSync)(joinPaths(_workspaceRoot, "nx.json")) || (0, node_fs.existsSync)(joinPaths(_workspaceRoot, ".nx")) || (0, node_fs.existsSync)(joinPaths(_workspaceRoot, "lerna.json")) || (0, node_fs.existsSync)(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
1177
+ try {
1178
+ result = applyDefaultConfig((await Promise.resolve(_storm_software_config_schema.workspaceConfigSchema._zod.parse({
1179
+ value: configInput,
1180
+ issues: []
1181
+ }, { async: true }))).value);
1182
+ result.workspaceRoot ??= _workspaceRoot;
1183
+ } catch (error) {
1184
+ throw new Error(`Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
1185
+
1186
+ Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(configInput)}`, { cause: error });
1187
+ }
1188
+ } else result = _static_cache.data;
1189
+ if (schema && extensionName) result.extensions = {
1190
+ ...result.extensions,
1191
+ [extensionName]: createConfigExtension(extensionName, schema)
1192
+ };
1193
+ _static_cache = {
1194
+ timestamp: Date.now(),
1195
+ data: result
1196
+ };
1197
+ return result;
1198
+ };
1199
+ /**
1200
+ * Get the config for a specific Storm config Extension
1201
+ *
1202
+ * @param extensionName - The name of the config extension
1203
+ * @param options - The options for the config extension
1204
+ * @returns The config for the specified Storm config extension. If the extension does not exist, `undefined` is returned.
1205
+ */
1206
+ const createConfigExtension = (extensionName, schema) => {
1207
+ const extension_cache_key = { extensionName };
1208
+ if (_extension_cache.has(extension_cache_key)) return _extension_cache.get(extension_cache_key);
1209
+ let extension = getExtensionEnv(extensionName);
1210
+ if (schema) extension = schema.parse(extension);
1211
+ _extension_cache.set(extension_cache_key, extension);
1212
+ return extension;
1213
+ };
1214
+ /**
1215
+ * Load the config file values for the current Storm workspace into environment variables
1216
+ *
1217
+ * @param workspaceRoot - The root directory of the workspace
1218
+ * @param skipLogs - Skip writing logs to the console
1219
+ * @returns The config for the current Storm workspace, throws an error if the config file could not be loaded
1220
+ */
1221
+ const loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
1222
+ const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs, true);
1223
+ setConfigEnv(config);
1224
+ if (!skipLogs && !config.skipConfigLogging) writeTrace(`⚙️ Using Storm Workspace configuration: \n${formatLogMessage(config)}`, config);
1225
+ return config;
1226
+ };
1227
+ //#endregion
1228
+ //#region src/get-config.ts
1229
+ /**
1230
+ * Get the config for the current Storm workspace
1231
+ *
1232
+ * @param workspaceRoot - The root directory of the workspace
1233
+ * @param skipLogs - Skip writing logs to the console
1234
+ * @returns The config for the current Storm workspace
1235
+ */
1236
+ function getConfig(workspaceRoot, skipLogs = false) {
1237
+ return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
1238
+ }
1239
+ //#endregion
1240
+ //#region bin/config.ts
40
1241
  function createProgram() {
41
- (0, import_console.writeInfo)(`${(0, import_console.brandIcon)()} Running Storm Configuration Tools`, {
42
- logLevel: "all"
43
- });
44
- const root = (0, import_utilities.findWorkspaceRootSafe)(process.cwd());
45
- process.env.STORM_WORKSPACE_ROOT ??= root;
46
- process.env.NX_WORKSPACE_ROOT_PATH ??= root;
47
- if (root) {
48
- process.chdir(root);
49
- }
50
- const program = new import_commander.Command("storm-config");
51
- program.version("1.0.0", "-v --version", "display CLI version");
52
- program.command("view", { isDefault: true }).description("View the current Storm configuration for the workspace.").option(
53
- "-d --dir <path>",
54
- "A directory that exists inside the workspace root",
55
- process.cwd()
56
- ).action(viewAction);
57
- return program;
1242
+ writeInfo(`${brandIcon()} Running Storm Configuration Tools`, { logLevel: "all" });
1243
+ const root = findWorkspaceRootSafe(process.cwd());
1244
+ process.env.STORM_WORKSPACE_ROOT ??= root;
1245
+ process.env.NX_WORKSPACE_ROOT_PATH ??= root;
1246
+ if (root) process.chdir(root);
1247
+ const program = new commander.Command("storm-config");
1248
+ program.version("1.0.0", "-v --version", "display CLI version");
1249
+ program.command("view", { isDefault: true }).description("View the current Storm configuration for the workspace.").option("-d --dir <path>", "A directory that exists inside the workspace root", process.cwd()).action(viewAction);
1250
+ return program;
58
1251
  }
59
1252
  async function viewAction({ dir }) {
60
- (0, import_console.writeInfo)(
61
- `\u{1F50D} Searching for Storm configuration for the workspace at "${dir}"...`,
62
- {
63
- logLevel: "all"
64
- }
65
- );
66
- const config = await (0, import_get_config.getConfig)((0, import_utilities.findWorkspaceRootSafe)(dir), true);
67
- if (config) {
68
- (0, import_console.writeSuccess)(
69
- `The following Storm configuration values have been found for this repository:
1253
+ writeInfo(`🔍 Searching for Storm configuration for the workspace at "${dir}"...`, { logLevel: "all" });
1254
+ const config = await getConfig(findWorkspaceRootSafe(dir), true);
1255
+ if (config) writeSuccess(`The following Storm configuration values have been found for this repository:
70
1256
 
71
- ${(0, import_console.formatLogMessage)({ ...config, colors: void 0 })}
1257
+ ${formatLogMessage({
1258
+ ...config,
1259
+ colors: void 0
1260
+ })}
72
1261
 
73
1262
  ${typeof config.colors.light === "string" ? formatSingleThemeColors(config.colors) : formatMultiThemeColors(config.colors)}
74
- `,
75
- { ...config, logLevel: "all" }
76
- );
77
- } else {
78
- (0, import_console.writeError)(
79
- "No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n",
80
- { logLevel: "all" }
81
- );
82
- }
1263
+ `, {
1264
+ ...config,
1265
+ logLevel: "all"
1266
+ });
1267
+ else writeError("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", { logLevel: "all" });
83
1268
  }
84
- void (async () => {
85
- try {
86
- (0, import_utilities.handleProcess)();
87
- const program = createProgram();
88
- await program.parseAsync(process.argv);
89
- (0, import_utilities.exitWithSuccess)();
90
- } catch (error) {
91
- (0, import_console.writeFatal)(
92
- `A fatal error occurred while running the Storm Git tool:
1269
+ (async () => {
1270
+ try {
1271
+ handleProcess();
1272
+ await createProgram().parseAsync(process.argv);
1273
+ exitWithSuccess();
1274
+ } catch (error) {
1275
+ writeFatal(`A fatal error occurred while running the Storm Git tool:
93
1276
  ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
94
- Stack Trace: ${error.stack}` : ""}`,
95
- { logLevel: "all" }
96
- );
97
- (0, import_utilities.exitWithError)();
98
- process.exit(1);
99
- }
1277
+ Stack Trace: ${error.stack}` : ""}`, { logLevel: "all" });
1278
+ exitWithError();
1279
+ process.exit(1);
1280
+ }
100
1281
  })();
101
1282
  const formatSingleThemeColors = (config) => {
102
- return `---- Theme Colors ----
103
- ${Object.entries(config).filter(
104
- ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
105
- ).map(
106
- ([key, value]) => import_chalk.default.hex(String(value))(`${key}: ${import_chalk.default.bold(value)}`)
107
- ).join(" \n")}
1283
+ return `---- Theme Colors ----
1284
+ ${Object.entries(config).filter(([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0).map(([key, value]) => chalk.default.hex(String(value))(`${key}: ${chalk.default.bold(value)}`)).join(" \n")}
108
1285
  `;
109
1286
  };
110
1287
  const formatMultiThemeColors = (config) => {
111
- return ` ---- Light Theme Colors ----
112
- ${Object.entries(config.light).filter(
113
- ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
114
- ).map(
115
- ([key, value]) => import_chalk.default.hex(String(value))(`${key}: ${import_chalk.default.bold(value)}`)
116
- ).join(" \n")}
1288
+ return ` ---- Light Theme Colors ----
1289
+ ${Object.entries(config.light).filter(([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0).map(([key, value]) => chalk.default.hex(String(value))(`${key}: ${chalk.default.bold(value)}`)).join(" \n")}
117
1290
 
118
1291
  ---- Dark Theme Colors ----
119
- ${Object.entries(config.dark).filter(
120
- ([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0
121
- ).map(
122
- ([key, value]) => import_chalk.default.hex(String(value))(`${key}: ${import_chalk.default.bold(value)}`)
123
- ).join(" \n")}
1292
+ ${Object.entries(config.dark).filter(([key, value]) => key !== "gradient" && typeof value === "string" && value.length > 0).map(([key, value]) => chalk.default.hex(String(value))(`${key}: ${chalk.default.bold(value)}`)).join(" \n")}
124
1293
  `;
125
1294
  };
126
- // Annotate the CommonJS export names for ESM import in node:
127
- 0 && (module.exports = {
128
- createProgram,
129
- viewAction
130
- });
1295
+ //#endregion
1296
+ exports.createProgram = createProgram;
1297
+ exports.viewAction = viewAction;