@storm-software/config-tools 1.163.25 → 1.163.27
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 -2
- package/bin/config.cjs +298 -205
- package/bin/config.js +308 -208
- package/dist/chunk-42TCRG4H.js +38 -0
- package/dist/{chunk-E5AUC34G.cjs → chunk-4JREL2GQ.cjs} +31 -43
- package/dist/{chunk-NKHVLY3K.js → chunk-4XRV4CVP.js} +6 -9
- package/dist/{chunk-GBY7M6XX.cjs → chunk-56NGBR4S.cjs} +51 -40
- package/dist/{chunk-2HSUVM5I.js → chunk-64DXC5WM.js} +4 -8
- package/dist/{chunk-7HCO3WBN.cjs → chunk-7BZWQZUV.cjs} +6 -9
- package/dist/{chunk-4AM2CTWO.cjs → chunk-7HCUD67D.cjs} +34 -21
- package/dist/{chunk-DLO4KL2Z.cjs → chunk-7SIKKF62.cjs} +78 -61
- package/dist/{chunk-6LIPH2JW.cjs → chunk-AEZINHEA.cjs} +19 -12
- package/dist/{chunk-WZSBZDAU.cjs → chunk-AQ2NOVJF.cjs} +32 -16
- package/dist/{chunk-JT77N7TT.js → chunk-BAWQ37NK.js} +13 -12
- package/dist/chunk-BJ2W75ZO.cjs +135 -0
- package/dist/{chunk-SFDIRWJY.js → chunk-ELNIDXR5.js} +20 -14
- package/dist/chunk-FCWF3I34.cjs +55 -0
- package/dist/{chunk-D6E6GZD2.js → chunk-FRR2ZRWD.js} +30 -42
- package/dist/{chunk-YSSMM2WQ.cjs → chunk-GIXUQACB.cjs} +11 -8
- package/dist/chunk-H2GU4JMJ.cjs +40 -0
- package/dist/{chunk-2LQBYJT5.cjs → chunk-H425P7G5.cjs} +54 -35
- package/dist/{chunk-CERDEPKZ.js → chunk-IETV2DPL.js} +32 -16
- package/dist/{chunk-ZFRJR2OY.cjs → chunk-J2LCTMCI.cjs} +11 -15
- package/dist/{chunk-2V4WR4HU.js → chunk-JX5NLB4S.js} +12 -9
- package/dist/chunk-NS5PJ2RM.cjs +32 -0
- package/dist/{chunk-FVYBJYYR.js → chunk-OJP4XIBV.js} +2 -5
- package/dist/{chunk-OSY5X2AI.cjs → chunk-PLLCZVZO.cjs} +1 -6
- package/dist/{chunk-KBPYCUVG.cjs → chunk-PSHJQ2NP.cjs} +2 -5
- package/dist/{chunk-OB4WNEXN.js → chunk-QDJMKPQQ.js} +2 -6
- package/dist/{chunk-XDS6C7HI.js → chunk-QJUAU656.js} +68 -51
- package/dist/chunk-QNDF3RQL.cjs +8 -0
- package/dist/{chunk-AWCU6JTS.js → chunk-R6A4VPC4.js} +0 -5
- package/dist/{chunk-G2XISPLW.cjs → chunk-RKGXITNB.cjs} +7 -8
- package/dist/{chunk-QRKAMMHF.js → chunk-RSKVXFI5.js} +45 -34
- package/dist/{chunk-NQFXB5CV.js → chunk-RWBPUJIZ.js} +6 -7
- package/dist/chunk-T3MUE32G.js +32 -0
- package/dist/{chunk-VULQ4N4Z.cjs → chunk-T4ZMKMEG.cjs} +21 -8
- package/dist/{chunk-K6PUXRK3.js → chunk-VLWSWYG7.js} +19 -12
- package/dist/{chunk-BC2QD5QZ.js → chunk-WITKEKZ5.js} +50 -33
- package/dist/chunk-XEZGYUS2.js +8 -0
- package/dist/{chunk-GYFE7GKG.js → chunk-XO6ICAFH.js} +32 -19
- package/dist/{chunk-ETZGNPAA.js → chunk-XS7LVKAI.js} +46 -27
- package/dist/{chunk-CHA6766N.cjs → chunk-ZGLOKOL3.cjs} +5 -9
- package/dist/config-file/get-config-file.cjs +16 -17
- package/dist/config-file/get-config-file.js +15 -16
- package/dist/config-file/index.cjs +16 -17
- package/dist/config-file/index.js +15 -16
- package/dist/create-storm-config.cjs +19 -20
- package/dist/create-storm-config.js +18 -19
- package/dist/env/get-env.cjs +4 -5
- package/dist/env/get-env.js +3 -4
- package/dist/env/index.cjs +5 -6
- package/dist/env/index.js +4 -5
- package/dist/env/set-env.cjs +4 -5
- package/dist/env/set-env.js +3 -4
- package/dist/get-config.cjs +20 -21
- package/dist/get-config.js +19 -20
- package/dist/index.cjs +23 -22
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -21
- package/dist/logger/chalk.cjs +2 -3
- package/dist/logger/chalk.js +1 -2
- package/dist/logger/console-icons.cjs +3 -4
- package/dist/logger/console-icons.js +2 -3
- package/dist/logger/console.cjs +11 -12
- package/dist/logger/console.js +10 -11
- package/dist/logger/create-logger.cjs +12 -13
- package/dist/logger/create-logger.js +11 -12
- package/dist/logger/format-timestamp.cjs +2 -3
- package/dist/logger/format-timestamp.js +1 -2
- package/dist/logger/get-log-level.cjs +2 -3
- package/dist/logger/get-log-level.js +1 -2
- package/dist/logger/index.cjs +12 -13
- package/dist/logger/index.js +11 -12
- package/dist/logger/is-unicode-supported.cjs +2 -3
- package/dist/logger/is-unicode-supported.js +1 -2
- package/dist/types.cjs +0 -1
- package/dist/types.js +0 -1
- package/dist/utilities/apply-workspace-tokens.cjs +5 -6
- package/dist/utilities/apply-workspace-tokens.js +4 -5
- package/dist/utilities/correct-paths.cjs +2 -3
- package/dist/utilities/correct-paths.js +1 -2
- package/dist/utilities/file-path-utils.cjs +5 -3
- package/dist/utilities/file-path-utils.d.cts +42 -2
- package/dist/utilities/file-path-utils.d.ts +42 -2
- package/dist/utilities/file-path-utils.js +4 -2
- package/dist/utilities/find-up.cjs +2 -3
- package/dist/utilities/find-up.js +1 -2
- package/dist/utilities/find-workspace-root.cjs +4 -5
- package/dist/utilities/find-workspace-root.js +3 -4
- package/dist/utilities/get-default-config.cjs +5 -6
- package/dist/utilities/get-default-config.js +4 -5
- package/dist/utilities/index.cjs +17 -16
- package/dist/utilities/index.d.cts +1 -1
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +16 -15
- package/dist/utilities/process-handler.cjs +12 -13
- package/dist/utilities/process-handler.js +11 -12
- package/dist/utilities/run.cjs +2 -3
- package/dist/utilities/run.js +1 -2
- package/package.json +1 -1
- package/dist/chunk-75PQRIWX.js +0 -25
- package/dist/chunk-7DEX73IB.js +0 -36
- package/dist/chunk-HFKBN5GE.cjs +0 -118
- package/dist/chunk-IGUYFX5B.cjs +0 -12
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-SIU3CSEY.cjs +0 -49
- package/dist/chunk-TKQCRNGC.js +0 -12
- package/dist/chunk-USNT2KNT.cjs +0 -6
- package/dist/chunk-VICC23NV.cjs +0 -36
- package/dist/chunk-VKTQOXWO.cjs +0 -39
package/bin/config.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
2
|
|
|
5
3
|
// bin/config.ts
|
|
6
4
|
import { Command, Option } from "commander";
|
|
@@ -38,7 +36,10 @@ var LogLevelLabel = {
|
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
// src/utilities/get-default-config.ts
|
|
41
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
STORM_DEFAULT_HOMEPAGE,
|
|
41
|
+
STORM_DEFAULT_LICENSE
|
|
42
|
+
} from "@storm-software/config";
|
|
42
43
|
import { existsSync as existsSync2 } from "node:fs";
|
|
43
44
|
import { readFile } from "node:fs/promises";
|
|
44
45
|
import { join as join2 } from "node:path";
|
|
@@ -51,11 +52,10 @@ function normalizeWindowsPath(input = "") {
|
|
|
51
52
|
}
|
|
52
53
|
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
53
54
|
}
|
|
54
|
-
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
55
55
|
var _UNC_REGEX = /^[/\\]{2}/;
|
|
56
56
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
57
57
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
58
|
-
var correctPaths =
|
|
58
|
+
var correctPaths = function(path) {
|
|
59
59
|
if (!path || path.length === 0) {
|
|
60
60
|
return ".";
|
|
61
61
|
}
|
|
@@ -83,8 +83,8 @@ var correctPaths = /* @__PURE__ */ __name(function(path) {
|
|
|
83
83
|
return `//${path}`;
|
|
84
84
|
}
|
|
85
85
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
86
|
-
}
|
|
87
|
-
var joinPaths =
|
|
86
|
+
};
|
|
87
|
+
var joinPaths = function(...segments) {
|
|
88
88
|
let path = "";
|
|
89
89
|
for (const seg of segments) {
|
|
90
90
|
if (!seg) {
|
|
@@ -104,7 +104,7 @@ var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
return correctPaths(path);
|
|
107
|
-
}
|
|
107
|
+
};
|
|
108
108
|
function normalizeString(path, allowAboveRoot) {
|
|
109
109
|
let res = "";
|
|
110
110
|
let lastSegmentLength = 0;
|
|
@@ -165,10 +165,9 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
165
165
|
}
|
|
166
166
|
return res;
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
168
|
+
var isAbsolute = function(p) {
|
|
170
169
|
return _IS_ABSOLUTE_RE.test(p);
|
|
171
|
-
}
|
|
170
|
+
};
|
|
172
171
|
|
|
173
172
|
// src/utilities/find-up.ts
|
|
174
173
|
import { existsSync } from "node:fs";
|
|
@@ -177,10 +176,14 @@ var MAX_PATH_SEARCH_DEPTH = 30;
|
|
|
177
176
|
var depth = 0;
|
|
178
177
|
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
179
178
|
const _startPath = startPath ?? process.cwd();
|
|
180
|
-
if (endDirectoryNames.some(
|
|
179
|
+
if (endDirectoryNames.some(
|
|
180
|
+
(endDirName) => existsSync(join(_startPath, endDirName))
|
|
181
|
+
)) {
|
|
181
182
|
return _startPath;
|
|
182
183
|
}
|
|
183
|
-
if (endFileNames.some(
|
|
184
|
+
if (endFileNames.some(
|
|
185
|
+
(endFileName) => existsSync(join(_startPath, endFileName))
|
|
186
|
+
)) {
|
|
184
187
|
return _startPath;
|
|
185
188
|
}
|
|
186
189
|
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
@@ -189,7 +192,6 @@ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
|
189
192
|
}
|
|
190
193
|
return void 0;
|
|
191
194
|
}
|
|
192
|
-
__name(findFolderUp, "findFolderUp");
|
|
193
195
|
|
|
194
196
|
// src/utilities/find-workspace-root.ts
|
|
195
197
|
var rootFiles = [
|
|
@@ -236,21 +238,31 @@ var rootDirectories = [
|
|
|
236
238
|
];
|
|
237
239
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
238
240
|
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
239
|
-
return correctPaths(
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
return correctPaths(
|
|
242
|
+
process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
return correctPaths(
|
|
246
|
+
findFolderUp(
|
|
247
|
+
pathInsideMonorepo ?? process.cwd(),
|
|
248
|
+
rootFiles,
|
|
249
|
+
rootDirectories
|
|
250
|
+
)
|
|
251
|
+
);
|
|
242
252
|
}
|
|
243
|
-
__name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
|
|
244
253
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
245
254
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
246
255
|
if (!result) {
|
|
247
|
-
throw new Error(
|
|
248
|
-
|
|
249
|
-
|
|
256
|
+
throw new Error(
|
|
257
|
+
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
258
|
+
${rootFiles.join(
|
|
259
|
+
"\n"
|
|
260
|
+
)}
|
|
261
|
+
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
262
|
+
);
|
|
250
263
|
}
|
|
251
264
|
return result;
|
|
252
265
|
}
|
|
253
|
-
__name(findWorkspaceRoot, "findWorkspaceRoot");
|
|
254
266
|
|
|
255
267
|
// src/utilities/get-default-config.ts
|
|
256
268
|
var DEFAULT_COLOR_CONFIG = {
|
|
@@ -281,7 +293,7 @@ var DEFAULT_COLOR_CONFIG = {
|
|
|
281
293
|
negative: "#dc2626"
|
|
282
294
|
}
|
|
283
295
|
};
|
|
284
|
-
var getDefaultConfig =
|
|
296
|
+
var getDefaultConfig = async (root) => {
|
|
285
297
|
let license = STORM_DEFAULT_LICENSE;
|
|
286
298
|
let homepage = STORM_DEFAULT_HOMEPAGE;
|
|
287
299
|
let name = void 0;
|
|
@@ -289,7 +301,10 @@ var getDefaultConfig = /* @__PURE__ */ __name(async (root) => {
|
|
|
289
301
|
let repository = void 0;
|
|
290
302
|
const workspaceRoot = findWorkspaceRoot(root);
|
|
291
303
|
if (existsSync2(join2(workspaceRoot, "package.json"))) {
|
|
292
|
-
const file = await readFile(
|
|
304
|
+
const file = await readFile(
|
|
305
|
+
joinPaths(workspaceRoot, "package.json"),
|
|
306
|
+
"utf8"
|
|
307
|
+
);
|
|
293
308
|
if (file) {
|
|
294
309
|
const packageJson = JSON.parse(file);
|
|
295
310
|
if (packageJson.name) {
|
|
@@ -326,36 +341,36 @@ var getDefaultConfig = /* @__PURE__ */ __name(async (root) => {
|
|
|
326
341
|
url: `${homepage || STORM_DEFAULT_HOMEPAGE}/errors`
|
|
327
342
|
}
|
|
328
343
|
};
|
|
329
|
-
}
|
|
344
|
+
};
|
|
330
345
|
|
|
331
346
|
// src/logger/chalk.ts
|
|
332
347
|
import chalk from "chalk";
|
|
333
348
|
var chalkDefault = {
|
|
334
|
-
hex:
|
|
335
|
-
bgHex:
|
|
336
|
-
whiteBright:
|
|
337
|
-
}),
|
|
338
|
-
whiteBright:
|
|
339
|
-
gray:
|
|
349
|
+
hex: (_) => (message) => message,
|
|
350
|
+
bgHex: (_) => ({
|
|
351
|
+
whiteBright: (message) => message
|
|
352
|
+
}),
|
|
353
|
+
whiteBright: (message) => message,
|
|
354
|
+
gray: (message) => message,
|
|
340
355
|
bold: {
|
|
341
|
-
hex:
|
|
342
|
-
bgHex:
|
|
343
|
-
whiteBright:
|
|
344
|
-
}),
|
|
345
|
-
whiteBright:
|
|
356
|
+
hex: (_) => (message) => message,
|
|
357
|
+
bgHex: (_) => ({
|
|
358
|
+
whiteBright: (message) => message
|
|
359
|
+
}),
|
|
360
|
+
whiteBright: (message) => message
|
|
346
361
|
},
|
|
347
362
|
dim: {
|
|
348
|
-
hex:
|
|
349
|
-
gray:
|
|
363
|
+
hex: (_) => (message) => message,
|
|
364
|
+
gray: (message) => message
|
|
350
365
|
}
|
|
351
366
|
};
|
|
352
|
-
var getChalk =
|
|
367
|
+
var getChalk = () => {
|
|
353
368
|
let _chalk = chalk;
|
|
354
369
|
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
|
|
355
370
|
_chalk = chalkDefault;
|
|
356
371
|
}
|
|
357
372
|
return _chalk;
|
|
358
|
-
}
|
|
373
|
+
};
|
|
359
374
|
|
|
360
375
|
// src/logger/is-unicode-supported.ts
|
|
361
376
|
function isUnicodeSupported() {
|
|
@@ -367,10 +382,9 @@ function isUnicodeSupported() {
|
|
|
367
382
|
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
|
|
368
383
|
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";
|
|
369
384
|
}
|
|
370
|
-
__name(isUnicodeSupported, "isUnicodeSupported");
|
|
371
385
|
|
|
372
386
|
// src/logger/console-icons.ts
|
|
373
|
-
var useIcon =
|
|
387
|
+
var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
|
|
374
388
|
var CONSOLE_ICONS = {
|
|
375
389
|
[LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
|
|
376
390
|
[LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
|
|
@@ -383,12 +397,12 @@ var CONSOLE_ICONS = {
|
|
|
383
397
|
};
|
|
384
398
|
|
|
385
399
|
// src/logger/format-timestamp.ts
|
|
386
|
-
var formatTimestamp =
|
|
400
|
+
var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
|
|
387
401
|
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
388
|
-
}
|
|
402
|
+
};
|
|
389
403
|
|
|
390
404
|
// src/logger/get-log-level.ts
|
|
391
|
-
var getLogLevel =
|
|
405
|
+
var getLogLevel = (label) => {
|
|
392
406
|
switch (label) {
|
|
393
407
|
case "all":
|
|
394
408
|
return LogLevel.ALL;
|
|
@@ -409,8 +423,8 @@ var getLogLevel = /* @__PURE__ */ __name((label) => {
|
|
|
409
423
|
default:
|
|
410
424
|
return LogLevel.INFO;
|
|
411
425
|
}
|
|
412
|
-
}
|
|
413
|
-
var getLogLevelLabel =
|
|
426
|
+
};
|
|
427
|
+
var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
|
|
414
428
|
if (logLevel >= LogLevel.ALL) {
|
|
415
429
|
return LogLevelLabel.ALL;
|
|
416
430
|
}
|
|
@@ -436,10 +450,10 @@ var getLogLevelLabel = /* @__PURE__ */ __name((logLevel = LogLevel.INFO) => {
|
|
|
436
450
|
return LogLevelLabel.SILENT;
|
|
437
451
|
}
|
|
438
452
|
return LogLevelLabel.INFO;
|
|
439
|
-
}
|
|
453
|
+
};
|
|
440
454
|
|
|
441
455
|
// src/logger/console.ts
|
|
442
|
-
var getLogFn =
|
|
456
|
+
var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
443
457
|
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;
|
|
444
458
|
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
445
459
|
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
@@ -448,108 +462,133 @@ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}, _c
|
|
|
448
462
|
}
|
|
449
463
|
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
450
464
|
return (message) => {
|
|
451
|
-
console.error(
|
|
465
|
+
console.error(
|
|
466
|
+
`
|
|
452
467
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
453
|
-
`
|
|
468
|
+
`
|
|
469
|
+
);
|
|
454
470
|
};
|
|
455
471
|
}
|
|
456
472
|
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
457
473
|
return (message) => {
|
|
458
|
-
console.error(
|
|
474
|
+
console.error(
|
|
475
|
+
`
|
|
459
476
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
460
|
-
`
|
|
477
|
+
`
|
|
478
|
+
);
|
|
461
479
|
};
|
|
462
480
|
}
|
|
463
481
|
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
464
482
|
return (message) => {
|
|
465
|
-
console.warn(
|
|
483
|
+
console.warn(
|
|
484
|
+
`
|
|
466
485
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
467
|
-
`
|
|
486
|
+
`
|
|
487
|
+
);
|
|
468
488
|
};
|
|
469
489
|
}
|
|
470
490
|
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
471
491
|
return (message) => {
|
|
472
|
-
console.info(
|
|
492
|
+
console.info(
|
|
493
|
+
`
|
|
473
494
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
474
|
-
`
|
|
495
|
+
`
|
|
496
|
+
);
|
|
475
497
|
};
|
|
476
498
|
}
|
|
477
499
|
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
478
500
|
return (message) => {
|
|
479
|
-
console.info(
|
|
501
|
+
console.info(
|
|
502
|
+
`
|
|
480
503
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
481
|
-
`
|
|
504
|
+
`
|
|
505
|
+
);
|
|
482
506
|
};
|
|
483
507
|
}
|
|
484
508
|
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
485
509
|
return (message) => {
|
|
486
|
-
console.debug(
|
|
510
|
+
console.debug(
|
|
511
|
+
`
|
|
487
512
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
488
|
-
`
|
|
513
|
+
`
|
|
514
|
+
);
|
|
489
515
|
};
|
|
490
516
|
}
|
|
491
517
|
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
492
518
|
return (message) => {
|
|
493
|
-
console.debug(
|
|
519
|
+
console.debug(
|
|
520
|
+
`
|
|
494
521
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
495
|
-
`
|
|
522
|
+
`
|
|
523
|
+
);
|
|
496
524
|
};
|
|
497
525
|
}
|
|
498
526
|
return (message) => {
|
|
499
|
-
console.log(
|
|
527
|
+
console.log(
|
|
528
|
+
`
|
|
500
529
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
501
|
-
`
|
|
530
|
+
`
|
|
531
|
+
);
|
|
502
532
|
};
|
|
503
|
-
}
|
|
504
|
-
var writeFatal =
|
|
505
|
-
var writeError =
|
|
506
|
-
var writeWarning =
|
|
507
|
-
var writeInfo =
|
|
508
|
-
var writeSuccess =
|
|
509
|
-
var writeTrace =
|
|
533
|
+
};
|
|
534
|
+
var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
|
|
535
|
+
var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
|
|
536
|
+
var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
|
|
537
|
+
var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
|
|
538
|
+
var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
|
|
539
|
+
var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
|
|
510
540
|
var MAX_DEPTH = 4;
|
|
511
|
-
var formatLogMessage =
|
|
541
|
+
var formatLogMessage = (message, options = {}, depth2 = 0) => {
|
|
512
542
|
if (depth2 > MAX_DEPTH) {
|
|
513
543
|
return "<max depth>";
|
|
514
544
|
}
|
|
515
545
|
const prefix = options.prefix ?? "-";
|
|
516
546
|
const skip = options.skip ?? [];
|
|
517
547
|
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
|
|
518
|
-
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
var _isFunction =
|
|
548
|
+
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
|
|
549
|
+
${Object.keys(message).filter((key) => !skip.includes(key)).map(
|
|
550
|
+
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
|
|
551
|
+
message[key],
|
|
552
|
+
{ prefix: `${prefix}-`, skip },
|
|
553
|
+
depth2 + 1
|
|
554
|
+
) : message[key]}`
|
|
555
|
+
).join("\n")}` : message;
|
|
556
|
+
};
|
|
557
|
+
var _isFunction = (value) => {
|
|
528
558
|
try {
|
|
529
559
|
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
|
|
530
560
|
} catch (e) {
|
|
531
561
|
return false;
|
|
532
562
|
}
|
|
533
|
-
}
|
|
563
|
+
};
|
|
534
564
|
|
|
535
565
|
// src/utilities/process-handler.ts
|
|
536
|
-
var exitWithError =
|
|
566
|
+
var exitWithError = (config) => {
|
|
537
567
|
writeFatal("Exiting script with an error status...", config);
|
|
538
568
|
process.exit(1);
|
|
539
|
-
}
|
|
540
|
-
var exitWithSuccess =
|
|
569
|
+
};
|
|
570
|
+
var exitWithSuccess = (config) => {
|
|
541
571
|
writeSuccess("Script completed successfully. Exiting...", config);
|
|
542
572
|
process.exit(0);
|
|
543
|
-
}
|
|
544
|
-
var handleProcess =
|
|
545
|
-
writeTrace(
|
|
573
|
+
};
|
|
574
|
+
var handleProcess = (config) => {
|
|
575
|
+
writeTrace(
|
|
576
|
+
`Using the following arguments to process the script: ${process.argv.join(", ")}`,
|
|
577
|
+
config
|
|
578
|
+
);
|
|
546
579
|
process.on("unhandledRejection", (error) => {
|
|
547
|
-
writeError(
|
|
580
|
+
writeError(
|
|
581
|
+
`An Unhandled Rejection occurred while running the program: ${error}`,
|
|
582
|
+
config
|
|
583
|
+
);
|
|
548
584
|
exitWithError(config);
|
|
549
585
|
});
|
|
550
586
|
process.on("uncaughtException", (error) => {
|
|
551
|
-
writeError(
|
|
552
|
-
|
|
587
|
+
writeError(
|
|
588
|
+
`An Uncaught Exception occurred while running the program: ${error.message}
|
|
589
|
+
Stacktrace: ${error.stack}`,
|
|
590
|
+
config
|
|
591
|
+
);
|
|
553
592
|
exitWithError(config);
|
|
554
593
|
});
|
|
555
594
|
process.on("SIGTERM", (signal) => {
|
|
@@ -564,10 +603,10 @@ Stacktrace: ${error.stack}`, config);
|
|
|
564
603
|
writeError(`The program terminated with signal code: ${signal}`, config);
|
|
565
604
|
exitWithError(config);
|
|
566
605
|
});
|
|
567
|
-
}
|
|
606
|
+
};
|
|
568
607
|
|
|
569
608
|
// src/config-file/get-config-file.ts
|
|
570
|
-
var getConfigFileByName =
|
|
609
|
+
var getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
571
610
|
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
572
611
|
const configs = await Promise.all([
|
|
573
612
|
loadConfig({
|
|
@@ -577,7 +616,10 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
577
616
|
envName: fileName?.toUpperCase(),
|
|
578
617
|
jitiOptions: {
|
|
579
618
|
debug: false,
|
|
580
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
619
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
620
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
621
|
+
"jiti"
|
|
622
|
+
)
|
|
581
623
|
},
|
|
582
624
|
...options
|
|
583
625
|
}),
|
|
@@ -588,32 +630,45 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
588
630
|
envName: fileName?.toUpperCase(),
|
|
589
631
|
jitiOptions: {
|
|
590
632
|
debug: false,
|
|
591
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
633
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
634
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
635
|
+
"jiti"
|
|
636
|
+
)
|
|
592
637
|
},
|
|
593
638
|
configFile: fileName,
|
|
594
639
|
...options
|
|
595
640
|
})
|
|
596
641
|
]);
|
|
597
642
|
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
598
|
-
}
|
|
599
|
-
var getConfigFile =
|
|
643
|
+
};
|
|
644
|
+
var getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
600
645
|
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
601
646
|
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
602
647
|
let config = result.config;
|
|
603
648
|
const configFile = result.configFile;
|
|
604
649
|
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
|
|
605
|
-
writeTrace(
|
|
606
|
-
|
|
607
|
-
|
|
650
|
+
writeTrace(
|
|
651
|
+
`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
|
|
652
|
+
{
|
|
653
|
+
logLevel: "all"
|
|
654
|
+
}
|
|
655
|
+
);
|
|
608
656
|
}
|
|
609
657
|
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
610
|
-
const results = await Promise.all(
|
|
658
|
+
const results = await Promise.all(
|
|
659
|
+
additionalFileNames.map(
|
|
660
|
+
(fileName) => getConfigFileByName(fileName, workspacePath)
|
|
661
|
+
)
|
|
662
|
+
);
|
|
611
663
|
for (const result2 of results) {
|
|
612
664
|
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
613
665
|
if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
|
|
614
|
-
writeTrace(
|
|
615
|
-
|
|
616
|
-
|
|
666
|
+
writeTrace(
|
|
667
|
+
`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
|
|
668
|
+
{
|
|
669
|
+
logLevel: "all"
|
|
670
|
+
}
|
|
671
|
+
);
|
|
617
672
|
}
|
|
618
673
|
config = defu(result2.config ?? {}, config ?? {});
|
|
619
674
|
}
|
|
@@ -624,21 +679,28 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
624
679
|
}
|
|
625
680
|
config.configFile = configFile;
|
|
626
681
|
return config;
|
|
627
|
-
}
|
|
682
|
+
};
|
|
628
683
|
|
|
629
684
|
// src/env/get-env.ts
|
|
630
|
-
import {
|
|
631
|
-
|
|
685
|
+
import {
|
|
686
|
+
COLOR_KEYS,
|
|
687
|
+
STORM_DEFAULT_DOCS,
|
|
688
|
+
STORM_DEFAULT_HOMEPAGE as STORM_DEFAULT_HOMEPAGE2,
|
|
689
|
+
STORM_DEFAULT_LICENSING
|
|
690
|
+
} from "@storm-software/config";
|
|
691
|
+
var getExtensionEnv = (extensionName) => {
|
|
632
692
|
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
633
693
|
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
634
|
-
const name = key.replace(prefix, "").split("_").map(
|
|
694
|
+
const name = key.replace(prefix, "").split("_").map(
|
|
695
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
696
|
+
).join("");
|
|
635
697
|
if (name) {
|
|
636
698
|
ret[name] = process.env[key];
|
|
637
699
|
}
|
|
638
700
|
return ret;
|
|
639
701
|
}, {});
|
|
640
|
-
}
|
|
641
|
-
var getConfigEnv =
|
|
702
|
+
};
|
|
703
|
+
var getConfigEnv = () => {
|
|
642
704
|
const prefix = "STORM_";
|
|
643
705
|
let config = {
|
|
644
706
|
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
@@ -706,14 +768,25 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
706
768
|
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
707
769
|
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
708
770
|
},
|
|
709
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
771
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
772
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
773
|
+
) ? getLogLevelLabel(
|
|
774
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
775
|
+
) : process.env[`${prefix}LOG_LEVEL`] : void 0,
|
|
710
776
|
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
|
|
711
777
|
};
|
|
712
|
-
const themeNames = Object.keys(process.env).filter(
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
778
|
+
const themeNames = Object.keys(process.env).filter(
|
|
779
|
+
(envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every(
|
|
780
|
+
(colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
|
|
781
|
+
)
|
|
782
|
+
);
|
|
783
|
+
config.colors = themeNames.length > 0 ? themeNames.reduce(
|
|
784
|
+
(ret, themeName) => {
|
|
785
|
+
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
786
|
+
return ret;
|
|
787
|
+
},
|
|
788
|
+
{}
|
|
789
|
+
) : getThemeColorConfigEnv(prefix);
|
|
717
790
|
if (config.docs === STORM_DEFAULT_DOCS) {
|
|
718
791
|
if (config.homepage === STORM_DEFAULT_HOMEPAGE2) {
|
|
719
792
|
config.docs = `${STORM_DEFAULT_HOMEPAGE2}/projects/${config.name}/docs`;
|
|
@@ -734,23 +807,17 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
734
807
|
config = {
|
|
735
808
|
...config,
|
|
736
809
|
...parsed,
|
|
737
|
-
colors: {
|
|
738
|
-
|
|
739
|
-
...parsed.colors
|
|
740
|
-
},
|
|
741
|
-
extensions: {
|
|
742
|
-
...config.extensions,
|
|
743
|
-
...parsed.extensions
|
|
744
|
-
}
|
|
810
|
+
colors: { ...config.colors, ...parsed.colors },
|
|
811
|
+
extensions: { ...config.extensions, ...parsed.extensions }
|
|
745
812
|
};
|
|
746
813
|
}
|
|
747
814
|
return config;
|
|
748
|
-
}
|
|
749
|
-
var getThemeColorConfigEnv =
|
|
815
|
+
};
|
|
816
|
+
var getThemeColorConfigEnv = (prefix, theme) => {
|
|
750
817
|
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
751
818
|
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
752
|
-
}
|
|
753
|
-
var getSingleThemeColorConfigEnv =
|
|
819
|
+
};
|
|
820
|
+
var getSingleThemeColorConfigEnv = (prefix) => {
|
|
754
821
|
return {
|
|
755
822
|
dark: process.env[`${prefix}DARK`],
|
|
756
823
|
light: process.env[`${prefix}LIGHT`],
|
|
@@ -767,14 +834,16 @@ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
767
834
|
positive: process.env[`${prefix}POSITIVE`],
|
|
768
835
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
769
836
|
};
|
|
770
|
-
}
|
|
771
|
-
var getMultiThemeColorConfigEnv =
|
|
837
|
+
};
|
|
838
|
+
var getMultiThemeColorConfigEnv = (prefix) => {
|
|
772
839
|
return {
|
|
773
|
-
light: getBaseThemeColorConfigEnv(
|
|
840
|
+
light: getBaseThemeColorConfigEnv(
|
|
841
|
+
`${prefix}_LIGHT_`
|
|
842
|
+
),
|
|
774
843
|
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
775
844
|
};
|
|
776
|
-
}
|
|
777
|
-
var getBaseThemeColorConfigEnv =
|
|
845
|
+
};
|
|
846
|
+
var getBaseThemeColorConfigEnv = (prefix) => {
|
|
778
847
|
return {
|
|
779
848
|
foreground: process.env[`${prefix}FOREGROUND`],
|
|
780
849
|
background: process.env[`${prefix}BACKGROUND`],
|
|
@@ -791,13 +860,16 @@ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
791
860
|
positive: process.env[`${prefix}POSITIVE`],
|
|
792
861
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
793
862
|
};
|
|
794
|
-
}
|
|
863
|
+
};
|
|
795
864
|
|
|
796
865
|
// src/env/set-env.ts
|
|
797
|
-
var setExtensionEnv =
|
|
866
|
+
var setExtensionEnv = (extensionName, extension) => {
|
|
798
867
|
for (const key of Object.keys(extension ?? {})) {
|
|
799
868
|
if (extension[key]) {
|
|
800
|
-
const result = key?.replace(
|
|
869
|
+
const result = key?.replace(
|
|
870
|
+
/([A-Z])+/g,
|
|
871
|
+
(input) => input ? input[0]?.toUpperCase() + input.slice(1) : ""
|
|
872
|
+
).split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
801
873
|
let extensionKey;
|
|
802
874
|
if (result.length === 0) {
|
|
803
875
|
return;
|
|
@@ -812,8 +884,8 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
|
|
|
812
884
|
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
813
885
|
}
|
|
814
886
|
}
|
|
815
|
-
}
|
|
816
|
-
var setConfigEnv =
|
|
887
|
+
};
|
|
888
|
+
var setConfigEnv = (config) => {
|
|
817
889
|
const prefix = "STORM_";
|
|
818
890
|
if (config.extends) {
|
|
819
891
|
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
|
|
@@ -902,7 +974,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
902
974
|
}
|
|
903
975
|
if (config.directories) {
|
|
904
976
|
if (!config.skipCache && config.directories.cache) {
|
|
905
|
-
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
977
|
+
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
978
|
+
config.directories.cache
|
|
979
|
+
);
|
|
906
980
|
process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
|
|
907
981
|
}
|
|
908
982
|
if (config.directories.data) {
|
|
@@ -910,7 +984,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
910
984
|
process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
|
|
911
985
|
}
|
|
912
986
|
if (config.directories.config) {
|
|
913
|
-
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
987
|
+
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
988
|
+
config.directories.config
|
|
989
|
+
);
|
|
914
990
|
process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
|
|
915
991
|
}
|
|
916
992
|
if (config.directories.temp) {
|
|
@@ -922,7 +998,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
922
998
|
process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
|
|
923
999
|
}
|
|
924
1000
|
if (config.directories.build) {
|
|
925
|
-
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
1001
|
+
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
1002
|
+
config.directories.build
|
|
1003
|
+
);
|
|
926
1004
|
process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
|
|
927
1005
|
}
|
|
928
1006
|
}
|
|
@@ -943,7 +1021,10 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
943
1021
|
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
|
|
944
1022
|
}
|
|
945
1023
|
} else {
|
|
946
|
-
setThemeColorConfigEnv(
|
|
1024
|
+
setThemeColorConfigEnv(
|
|
1025
|
+
`${prefix}COLOR_`,
|
|
1026
|
+
config.colors
|
|
1027
|
+
);
|
|
947
1028
|
}
|
|
948
1029
|
if (config.repository) {
|
|
949
1030
|
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
@@ -955,7 +1036,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
955
1036
|
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
956
1037
|
}
|
|
957
1038
|
if (config.externalPackagePatterns) {
|
|
958
|
-
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
1039
|
+
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
1040
|
+
config.externalPackagePatterns
|
|
1041
|
+
);
|
|
959
1042
|
}
|
|
960
1043
|
if (config.registry) {
|
|
961
1044
|
if (config.registry.github) {
|
|
@@ -968,20 +1051,28 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
968
1051
|
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
|
|
969
1052
|
}
|
|
970
1053
|
if (config.registry.cyclone) {
|
|
971
|
-
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
1054
|
+
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
1055
|
+
config.registry.cyclone
|
|
1056
|
+
);
|
|
972
1057
|
}
|
|
973
1058
|
if (config.registry.container) {
|
|
974
|
-
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
1059
|
+
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
1060
|
+
config.registry.container
|
|
1061
|
+
);
|
|
975
1062
|
}
|
|
976
1063
|
}
|
|
977
1064
|
if (config.logLevel) {
|
|
978
1065
|
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
979
1066
|
process.env.LOG_LEVEL = String(config.logLevel);
|
|
980
|
-
process.env.NX_VERBOSE_LOGGING = String(
|
|
1067
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
1068
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
1069
|
+
);
|
|
981
1070
|
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
982
1071
|
}
|
|
983
1072
|
if (config.skipConfigLogging !== void 0) {
|
|
984
|
-
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
1073
|
+
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
1074
|
+
config.skipConfigLogging
|
|
1075
|
+
);
|
|
985
1076
|
}
|
|
986
1077
|
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
987
1078
|
for (const key of Object.keys(config.extensions ?? {})) {
|
|
@@ -989,11 +1080,11 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
989
1080
|
setExtensionEnv(key, config.extensions[key]);
|
|
990
1081
|
}
|
|
991
1082
|
}
|
|
992
|
-
}
|
|
993
|
-
var setThemeColorConfigEnv =
|
|
1083
|
+
};
|
|
1084
|
+
var setThemeColorConfigEnv = (prefix, config) => {
|
|
994
1085
|
return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
|
|
995
|
-
}
|
|
996
|
-
var setSingleThemeColorConfigEnv =
|
|
1086
|
+
};
|
|
1087
|
+
var setSingleThemeColorConfigEnv = (prefix, config) => {
|
|
997
1088
|
if (config.dark) {
|
|
998
1089
|
process.env[`${prefix}DARK`] = config.dark;
|
|
999
1090
|
}
|
|
@@ -1036,14 +1127,14 @@ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
1036
1127
|
if (config.negative) {
|
|
1037
1128
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
1038
1129
|
}
|
|
1039
|
-
}
|
|
1040
|
-
var setMultiThemeColorConfigEnv =
|
|
1130
|
+
};
|
|
1131
|
+
var setMultiThemeColorConfigEnv = (prefix, config) => {
|
|
1041
1132
|
return {
|
|
1042
1133
|
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
|
|
1043
1134
|
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
|
|
1044
1135
|
};
|
|
1045
|
-
}
|
|
1046
|
-
var setBaseThemeColorConfigEnv =
|
|
1136
|
+
};
|
|
1137
|
+
var setBaseThemeColorConfigEnv = (prefix, config) => {
|
|
1047
1138
|
if (config.foreground) {
|
|
1048
1139
|
process.env[`${prefix}FOREGROUND`] = config.foreground;
|
|
1049
1140
|
}
|
|
@@ -1086,12 +1177,12 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
1086
1177
|
if (config.negative) {
|
|
1087
1178
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
1088
1179
|
}
|
|
1089
|
-
}
|
|
1180
|
+
};
|
|
1090
1181
|
|
|
1091
1182
|
// src/create-storm-config.ts
|
|
1092
1183
|
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
1093
1184
|
var _static_cache = void 0;
|
|
1094
|
-
var createStormWorkspaceConfig =
|
|
1185
|
+
var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
1095
1186
|
let result;
|
|
1096
1187
|
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
1097
1188
|
let _workspaceRoot = workspaceRoot;
|
|
@@ -1102,16 +1193,19 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
1102
1193
|
const configFile = await getConfigFile(_workspaceRoot);
|
|
1103
1194
|
if (!configFile) {
|
|
1104
1195
|
if (!skipLogs) {
|
|
1105
|
-
writeWarning(
|
|
1106
|
-
|
|
1107
|
-
|
|
1196
|
+
writeWarning(
|
|
1197
|
+
"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",
|
|
1198
|
+
{ logLevel: "all" }
|
|
1199
|
+
);
|
|
1108
1200
|
}
|
|
1109
1201
|
if (useDefault === false) {
|
|
1110
1202
|
return void 0;
|
|
1111
1203
|
}
|
|
1112
1204
|
}
|
|
1113
1205
|
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
1114
|
-
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
1206
|
+
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
1207
|
+
defu2(configEnv, configFile, defaultConfig)
|
|
1208
|
+
);
|
|
1115
1209
|
result.workspaceRoot ??= _workspaceRoot;
|
|
1116
1210
|
} else {
|
|
1117
1211
|
result = _static_cache.data;
|
|
@@ -1127,11 +1221,9 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
1127
1221
|
data: result
|
|
1128
1222
|
};
|
|
1129
1223
|
return result;
|
|
1130
|
-
}
|
|
1131
|
-
var createConfigExtension =
|
|
1132
|
-
const extension_cache_key = {
|
|
1133
|
-
extensionName
|
|
1134
|
-
};
|
|
1224
|
+
};
|
|
1225
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
1226
|
+
const extension_cache_key = { extensionName };
|
|
1135
1227
|
if (_extension_cache.has(extension_cache_key)) {
|
|
1136
1228
|
return _extension_cache.get(extension_cache_key);
|
|
1137
1229
|
}
|
|
@@ -1141,66 +1233,73 @@ var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
|
|
|
1141
1233
|
}
|
|
1142
1234
|
_extension_cache.set(extension_cache_key, extension);
|
|
1143
1235
|
return extension;
|
|
1144
|
-
}
|
|
1145
|
-
var loadStormWorkspaceConfig =
|
|
1146
|
-
const config = await createStormWorkspaceConfig(
|
|
1236
|
+
};
|
|
1237
|
+
var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
1238
|
+
const config = await createStormWorkspaceConfig(
|
|
1239
|
+
void 0,
|
|
1240
|
+
void 0,
|
|
1241
|
+
workspaceRoot,
|
|
1242
|
+
skipLogs,
|
|
1243
|
+
true
|
|
1244
|
+
);
|
|
1147
1245
|
setConfigEnv(config);
|
|
1148
1246
|
if (!skipLogs && !config.skipConfigLogging) {
|
|
1149
|
-
writeTrace(
|
|
1150
|
-
|
|
1247
|
+
writeTrace(
|
|
1248
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
1249
|
+
${formatLogMessage(config)}`,
|
|
1250
|
+
config
|
|
1251
|
+
);
|
|
1151
1252
|
}
|
|
1152
1253
|
return config;
|
|
1153
|
-
}
|
|
1254
|
+
};
|
|
1154
1255
|
|
|
1155
1256
|
// src/get-config.ts
|
|
1156
|
-
var getConfig =
|
|
1257
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
1157
1258
|
return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
|
|
1158
|
-
}
|
|
1259
|
+
};
|
|
1159
1260
|
|
|
1160
1261
|
// bin/config.ts
|
|
1161
1262
|
import chalk2 from "chalk";
|
|
1162
1263
|
function createProgram() {
|
|
1163
|
-
writeInfo("\u26A1 Running Storm Configuration Tools", {
|
|
1164
|
-
logLevel: "all"
|
|
1165
|
-
});
|
|
1264
|
+
writeInfo("\u26A1 Running Storm Configuration Tools", { logLevel: "all" });
|
|
1166
1265
|
const root = findWorkspaceRootSafe(process.cwd());
|
|
1167
1266
|
process.env.STORM_WORKSPACE_ROOT ??= root;
|
|
1168
1267
|
process.env.NX_WORKSPACE_ROOT_PATH ??= root;
|
|
1169
1268
|
root && process.chdir(root);
|
|
1170
1269
|
const program = new Command("storm-config");
|
|
1171
1270
|
program.version("1.0.0", "-v --version", "display CLI version");
|
|
1172
|
-
const directory = new Option(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1271
|
+
const directory = new Option(
|
|
1272
|
+
"-d --dir <path>",
|
|
1273
|
+
"A directory that exists inside the workspace root"
|
|
1274
|
+
).default(process.cwd());
|
|
1275
|
+
program.command("view", { isDefault: true }).description("View the current Storm configuration for the workspace.").addOption(directory).action(viewAction);
|
|
1176
1276
|
return program;
|
|
1177
1277
|
}
|
|
1178
|
-
__name(createProgram, "createProgram");
|
|
1179
1278
|
async function viewAction({ dir }) {
|
|
1180
|
-
writeInfo(
|
|
1181
|
-
|
|
1182
|
-
|
|
1279
|
+
writeInfo(
|
|
1280
|
+
`\u{1F50D} Searching for Storm configuration for the workspace at "${dir}"...`,
|
|
1281
|
+
{
|
|
1282
|
+
logLevel: "all"
|
|
1283
|
+
}
|
|
1284
|
+
);
|
|
1183
1285
|
const config = await getConfig(findWorkspaceRootSafe(dir), true);
|
|
1184
1286
|
if (config) {
|
|
1185
|
-
writeSuccess(
|
|
1287
|
+
writeSuccess(
|
|
1288
|
+
`The following Storm configuration values have been found for this repository:
|
|
1186
1289
|
|
|
1187
|
-
${formatLogMessage({
|
|
1188
|
-
...config,
|
|
1189
|
-
colors: void 0
|
|
1190
|
-
})}
|
|
1290
|
+
${formatLogMessage({ ...config, colors: void 0 })}
|
|
1191
1291
|
|
|
1192
1292
|
${typeof config.colors.light === "string" ? formatSingleThemeColors(config.colors) : formatMultiThemeColors(config.colors)}
|
|
1193
|
-
`,
|
|
1194
|
-
...config,
|
|
1195
|
-
|
|
1196
|
-
});
|
|
1293
|
+
`,
|
|
1294
|
+
{ ...config, logLevel: "all" }
|
|
1295
|
+
);
|
|
1197
1296
|
} else {
|
|
1198
|
-
writeError(
|
|
1199
|
-
|
|
1200
|
-
|
|
1297
|
+
writeError(
|
|
1298
|
+
"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",
|
|
1299
|
+
{ logLevel: "all" }
|
|
1300
|
+
);
|
|
1201
1301
|
}
|
|
1202
1302
|
}
|
|
1203
|
-
__name(viewAction, "viewAction");
|
|
1204
1303
|
void (async () => {
|
|
1205
1304
|
try {
|
|
1206
1305
|
handleProcess();
|
|
@@ -1208,28 +1307,29 @@ void (async () => {
|
|
|
1208
1307
|
await program.parseAsync(process.argv);
|
|
1209
1308
|
exitWithSuccess();
|
|
1210
1309
|
} catch (error) {
|
|
1211
|
-
writeFatal(
|
|
1310
|
+
writeFatal(
|
|
1311
|
+
`A fatal error occurred while running the Storm Git tool:
|
|
1212
1312
|
${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
|
|
1213
|
-
Stack Trace: ${error.stack}` : ""}`,
|
|
1214
|
-
logLevel: "all"
|
|
1215
|
-
|
|
1313
|
+
Stack Trace: ${error.stack}` : ""}`,
|
|
1314
|
+
{ logLevel: "all" }
|
|
1315
|
+
);
|
|
1216
1316
|
exitWithError();
|
|
1217
1317
|
process.exit(1);
|
|
1218
1318
|
}
|
|
1219
1319
|
})();
|
|
1220
|
-
var formatSingleThemeColors =
|
|
1320
|
+
var formatSingleThemeColors = (config) => {
|
|
1221
1321
|
return `---- Theme Colors ----
|
|
1222
1322
|
${Object.entries(config).filter(([key, value]) => typeof value === "string" && value.length > 0).map(([key, value]) => chalk2.hex(value)(`${key}: ${chalk2.bold(value)}`)).join(" \n")}
|
|
1223
1323
|
`;
|
|
1224
|
-
}
|
|
1225
|
-
var formatMultiThemeColors =
|
|
1324
|
+
};
|
|
1325
|
+
var formatMultiThemeColors = (config) => {
|
|
1226
1326
|
return ` ---- Light Theme Colors ----
|
|
1227
1327
|
${Object.entries(config.light).filter(([key, value]) => typeof value === "string" && value.length > 0).map(([key, value]) => chalk2.hex(value)(`${key}: ${chalk2.bold(value)}`)).join(" \n")}
|
|
1228
1328
|
|
|
1229
1329
|
---- Dark Theme Colors ----
|
|
1230
1330
|
${Object.entries(config.dark).filter(([key, value]) => typeof value === "string" && value.length > 0).map(([key, value]) => chalk2.hex(value)(`${key}: ${chalk2.bold(value)}`)).join(" \n")}
|
|
1231
1331
|
`;
|
|
1232
|
-
}
|
|
1332
|
+
};
|
|
1233
1333
|
export {
|
|
1234
1334
|
createProgram,
|
|
1235
1335
|
viewAction
|