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