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