@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region src/logger/chalk.d.ts
|
|
4
|
+
type GetChalkReturn = {
|
|
5
|
+
hex: (_: string) => (message?: string) => string | undefined;
|
|
6
|
+
bgHex: (_: string) => {
|
|
7
|
+
whiteBright: (message?: string) => string | undefined;
|
|
8
|
+
white: (message?: string) => string | undefined;
|
|
9
|
+
};
|
|
10
|
+
whiteBright: (message?: string) => string | undefined;
|
|
11
|
+
white: (message?: string) => string | undefined;
|
|
12
|
+
gray: (message?: string) => string | undefined;
|
|
13
|
+
bold: {
|
|
14
|
+
hex: (_: string) => (message?: string) => string | undefined;
|
|
15
|
+
bgHex: (_: string) => {
|
|
16
|
+
whiteBright: (message?: string) => string | undefined;
|
|
17
|
+
white: (message?: string) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
whiteBright: (message?: string) => string | undefined;
|
|
20
|
+
white: (message?: string) => string | undefined;
|
|
21
|
+
};
|
|
22
|
+
dim: {
|
|
23
|
+
hex: (_: string) => (message?: string) => string | undefined;
|
|
24
|
+
gray: (message?: string) => string | undefined;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get the chalk instance
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Annoying polyfill to temporarily fix the issue with the `chalk` import
|
|
32
|
+
*
|
|
33
|
+
* @returns The chalk instance
|
|
34
|
+
*/
|
|
35
|
+
declare const getChalk: () => GetChalkReturn;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { GetChalkReturn, getChalk };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
//#region src/logger/chalk.ts
|
|
6
|
+
const chalkDefault = {
|
|
7
|
+
hex: (_) => (message) => message,
|
|
8
|
+
bgHex: (_) => ({
|
|
9
|
+
whiteBright: (message) => message,
|
|
10
|
+
white: (message) => message
|
|
11
|
+
}),
|
|
12
|
+
white: (message) => message,
|
|
13
|
+
whiteBright: (message) => message,
|
|
14
|
+
gray: (message) => message,
|
|
15
|
+
bold: {
|
|
16
|
+
hex: (_) => (message) => message,
|
|
17
|
+
bgHex: (_) => ({
|
|
18
|
+
whiteBright: (message) => message,
|
|
19
|
+
white: (message) => message
|
|
20
|
+
}),
|
|
21
|
+
whiteBright: (message) => message,
|
|
22
|
+
white: (message) => message
|
|
23
|
+
},
|
|
24
|
+
dim: {
|
|
25
|
+
hex: (_) => (message) => message,
|
|
26
|
+
gray: (message) => message
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get the chalk instance
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Annoying polyfill to temporarily fix the issue with the `chalk` import
|
|
34
|
+
*
|
|
35
|
+
* @returns The chalk instance
|
|
36
|
+
*/
|
|
37
|
+
const getChalk = () => {
|
|
38
|
+
let _chalk = chalk;
|
|
39
|
+
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) _chalk = chalkDefault;
|
|
40
|
+
return _chalk;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { getChalk };
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_types = require("../types.cjs");
|
|
3
|
+
const require_logger_is_unicode_supported = require("./is-unicode-supported.cjs");
|
|
4
|
+
//#region src/logger/console-icons.ts
|
|
5
|
+
const useIcon = (c, fallback) => require_logger_is_unicode_supported.isUnicodeSupported() ? c : fallback;
|
|
6
|
+
const CONSOLE_ICONS = {
|
|
7
|
+
[require_types.LogLevelLabel.ERROR]: useIcon("✘", "×"),
|
|
8
|
+
[require_types.LogLevelLabel.FATAL]: useIcon("🕱", "×"),
|
|
9
|
+
[require_types.LogLevelLabel.WARN]: useIcon("⚠", "‼"),
|
|
10
|
+
[require_types.LogLevelLabel.INFO]: useIcon("ℹ", "i"),
|
|
11
|
+
[require_types.LogLevelLabel.PERFORMANCE]: useIcon("⏱", "⏱"),
|
|
12
|
+
[require_types.LogLevelLabel.SUCCESS]: useIcon("✔", "√"),
|
|
13
|
+
[require_types.LogLevelLabel.DEBUG]: useIcon("🛠", "D"),
|
|
14
|
+
[require_types.LogLevelLabel.TRACE]: useIcon("⚙", "T"),
|
|
15
|
+
[require_types.LogLevelLabel.ALL]: useIcon("✉", "→")
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.CONSOLE_ICONS = CONSOLE_ICONS;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { LogLevelLabel } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { CONSOLE_ICONS };
|
|
1
|
+
import { LogLevelLabel } from "../types.cjs";
|
|
2
|
+
//#region src/logger/console-icons.d.ts
|
|
3
|
+
declare const CONSOLE_ICONS: { [k in LogLevelLabel]?: string; };
|
|
4
|
+
//#endregion
|
|
5
|
+
export { CONSOLE_ICONS };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { LogLevelLabel } from "../types.mjs";
|
|
4
|
+
//#region src/logger/console-icons.d.ts
|
|
5
|
+
declare const CONSOLE_ICONS: { [k in LogLevelLabel]?: string; };
|
|
6
|
+
//#endregion
|
|
7
|
+
export { CONSOLE_ICONS };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { LogLevelLabel } from "../types.mjs";
|
|
5
|
+
import { isUnicodeSupported } from "./is-unicode-supported.mjs";
|
|
6
|
+
//#region src/logger/console-icons.ts
|
|
7
|
+
const useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
|
|
8
|
+
const CONSOLE_ICONS = {
|
|
9
|
+
[LogLevelLabel.ERROR]: useIcon("✘", "×"),
|
|
10
|
+
[LogLevelLabel.FATAL]: useIcon("🕱", "×"),
|
|
11
|
+
[LogLevelLabel.WARN]: useIcon("⚠", "‼"),
|
|
12
|
+
[LogLevelLabel.INFO]: useIcon("ℹ", "i"),
|
|
13
|
+
[LogLevelLabel.PERFORMANCE]: useIcon("⏱", "⏱"),
|
|
14
|
+
[LogLevelLabel.SUCCESS]: useIcon("✔", "√"),
|
|
15
|
+
[LogLevelLabel.DEBUG]: useIcon("🛠", "D"),
|
|
16
|
+
[LogLevelLabel.TRACE]: useIcon("⚙", "T"),
|
|
17
|
+
[LogLevelLabel.ALL]: useIcon("✉", "→")
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CONSOLE_ICONS };
|
package/dist/logger/console.cjs
CHANGED
|
@@ -1,37 +1,195 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_types = require("../types.cjs");
|
|
3
|
+
const require_utilities_colors = require("../utilities/colors.cjs");
|
|
4
|
+
const require_logger_chalk = require("./chalk.cjs");
|
|
5
|
+
const require_logger_console_icons = require("./console-icons.cjs");
|
|
6
|
+
const require_logger_format_timestamp = require("./format-timestamp.cjs");
|
|
7
|
+
const require_logger_get_log_level = require("./get-log-level.cjs");
|
|
8
|
+
let date_fns_formatDistanceToNow = require("date-fns/formatDistanceToNow");
|
|
9
|
+
//#region src/logger/console.ts
|
|
10
|
+
/**
|
|
11
|
+
* Get the log function for a log level
|
|
12
|
+
*
|
|
13
|
+
* @param logLevel - The log level
|
|
14
|
+
* @param config - The Storm configuration
|
|
15
|
+
* @returns The log function
|
|
16
|
+
*/
|
|
17
|
+
const getLogFn = (logLevel = require_types.LogLevel.INFO, config = {}, options = {}) => {
|
|
18
|
+
const { chalk: _chalk = require_logger_chalk.getChalk(), fullDateTime = false, hideDateTime = false } = options;
|
|
19
|
+
const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? require_utilities_colors.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"] : require_utilities_colors.DEFAULT_COLOR_CONFIG;
|
|
20
|
+
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || require_types.LogLevelLabel.INFO;
|
|
21
|
+
if (logLevel > require_logger_get_log_level.getLogLevel(configLogLevel) || logLevel <= require_types.LogLevel.SILENT || require_logger_get_log_level.getLogLevel(configLogLevel) <= require_types.LogLevel.SILENT) return (_) => {};
|
|
22
|
+
if (typeof logLevel === "number" && require_types.LogLevel.FATAL >= logLevel) return (message) => {
|
|
23
|
+
console.error(`
|
|
24
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.fatal ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.fatal)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
25
|
+
`);
|
|
26
|
+
};
|
|
27
|
+
if (typeof logLevel === "number" && require_types.LogLevel.ERROR >= logLevel) return (message) => {
|
|
28
|
+
console.error(`
|
|
29
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.danger ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.danger)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
30
|
+
`);
|
|
31
|
+
};
|
|
32
|
+
if (typeof logLevel === "number" && require_types.LogLevel.WARN >= logLevel) return (message) => {
|
|
33
|
+
console.warn(`
|
|
34
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.warning ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.warning)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
35
|
+
`);
|
|
36
|
+
};
|
|
37
|
+
if (typeof logLevel === "number" && require_types.LogLevel.SUCCESS >= logLevel) return (message) => {
|
|
38
|
+
console.info(`
|
|
39
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.success ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.success)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
40
|
+
`);
|
|
41
|
+
};
|
|
42
|
+
if (typeof logLevel === "number" && require_types.LogLevel.INFO >= logLevel) return (message) => {
|
|
43
|
+
console.info(`
|
|
44
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.info ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.info)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
45
|
+
`);
|
|
46
|
+
};
|
|
47
|
+
if (typeof logLevel === "number" && require_types.LogLevel.PERFORMANCE >= logLevel) return (message) => {
|
|
48
|
+
console.debug(`
|
|
49
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.performance ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.performance)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.PERFORMANCE]} Performance] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
50
|
+
`);
|
|
51
|
+
};
|
|
52
|
+
if (typeof logLevel === "number" && require_types.LogLevel.DEBUG >= logLevel) return (message) => {
|
|
53
|
+
console.debug(`
|
|
54
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.debug ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.debug)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
55
|
+
`);
|
|
56
|
+
};
|
|
57
|
+
if (typeof logLevel === "number" && require_types.LogLevel.TRACE >= logLevel) return (message) => {
|
|
58
|
+
console.debug(`
|
|
59
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex("#bbbbbb")(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
60
|
+
`);
|
|
61
|
+
};
|
|
62
|
+
return (message) => {
|
|
63
|
+
console.log(`
|
|
64
|
+
${hideDateTime ? "" : `${_chalk.gray(require_logger_format_timestamp.formatTimestamp(fullDateTime))} `}${_chalk.hex(colors.brand ?? require_utilities_colors.DEFAULT_COLOR_CONFIG.dark.brand)(`[${require_logger_console_icons.CONSOLE_ICONS[require_types.LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
65
|
+
`);
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Write a message to the console at the `fatal` log level
|
|
70
|
+
*
|
|
71
|
+
* @param message - The message to write
|
|
72
|
+
* @param config - The Storm configuration
|
|
73
|
+
*/
|
|
74
|
+
const writeFatal = (message, config) => getLogFn(require_types.LogLevel.FATAL, config)(message);
|
|
75
|
+
/**
|
|
76
|
+
* Write a message to the console at the `error` log level
|
|
77
|
+
*
|
|
78
|
+
* @param message - The message to write
|
|
79
|
+
* @param config - The Storm configuration
|
|
80
|
+
*/
|
|
81
|
+
const writeError = (message, config) => getLogFn(require_types.LogLevel.ERROR, config)(message);
|
|
82
|
+
/**
|
|
83
|
+
* Write a message to the console at the `warning` log level
|
|
84
|
+
*
|
|
85
|
+
* @param message - The message to write
|
|
86
|
+
* @param config - The Storm configuration
|
|
87
|
+
*/
|
|
88
|
+
const writeWarning = (message, config) => getLogFn(require_types.LogLevel.WARN, config)(message);
|
|
89
|
+
/**
|
|
90
|
+
* Write a message to the console at the `info` log level
|
|
91
|
+
*
|
|
92
|
+
* @param message - The message to write
|
|
93
|
+
* @param config - The Storm configuration
|
|
94
|
+
*/
|
|
95
|
+
const writeInfo = (message, config) => getLogFn(require_types.LogLevel.INFO, config)(message);
|
|
96
|
+
/**
|
|
97
|
+
* Write a message to the console at the `success` log level
|
|
98
|
+
*
|
|
99
|
+
* @param message - The message to write
|
|
100
|
+
* @param config - The Storm configuration
|
|
101
|
+
*/
|
|
102
|
+
const writeSuccess = (message, config) => getLogFn(require_types.LogLevel.SUCCESS, config)(message);
|
|
103
|
+
/**
|
|
104
|
+
* Write a message to the console at the `performance` log level
|
|
105
|
+
*
|
|
106
|
+
* @param message - The message to write
|
|
107
|
+
* @param config - The Storm configuration
|
|
108
|
+
*/
|
|
109
|
+
const writePerformance = (message, config) => getLogFn(require_types.LogLevel.PERFORMANCE, config)(message);
|
|
110
|
+
/**
|
|
111
|
+
* Write a message to the console at the `debug` log level
|
|
112
|
+
*
|
|
113
|
+
* @param message - The message to write
|
|
114
|
+
* @param config - The Storm configuration
|
|
115
|
+
*/
|
|
116
|
+
const writeDebug = (message, config) => getLogFn(require_types.LogLevel.DEBUG, config)(message);
|
|
117
|
+
/**
|
|
118
|
+
* Write a message to the console at the `trace` log level
|
|
119
|
+
*
|
|
120
|
+
* @param message - The message to write
|
|
121
|
+
* @param config - The Storm configuration
|
|
122
|
+
*/
|
|
123
|
+
const writeTrace = (message, config) => getLogFn(require_types.LogLevel.TRACE, config)(message);
|
|
124
|
+
/**
|
|
125
|
+
* Write a message to the console at the `all` log level
|
|
126
|
+
*
|
|
127
|
+
* @param message - The message to write
|
|
128
|
+
* @param config - The Storm configuration
|
|
129
|
+
*/
|
|
130
|
+
const writeSystem = (message, config) => getLogFn(require_types.LogLevel.ALL, config)(message);
|
|
131
|
+
/**
|
|
132
|
+
* Get a stopwatch function
|
|
133
|
+
*
|
|
134
|
+
* @param name - The name of the process
|
|
135
|
+
* @returns The stopwatch function
|
|
136
|
+
*/
|
|
137
|
+
const getStopwatch = (name) => {
|
|
138
|
+
const start = /* @__PURE__ */ new Date();
|
|
139
|
+
return () => {
|
|
140
|
+
writePerformance(`The${name ? ` ${name}` : ""} process took ${(0, date_fns_formatDistanceToNow.formatDistanceToNow)(start, { includeSeconds: true })} to complete`);
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const MAX_DEPTH = 10;
|
|
144
|
+
/**
|
|
145
|
+
* 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.
|
|
146
|
+
*
|
|
147
|
+
* @param message - The message to format
|
|
148
|
+
* @param options - Formatting options
|
|
149
|
+
* @param depth - The current depth of recursion
|
|
150
|
+
* @returns The formatted log message
|
|
151
|
+
*/
|
|
152
|
+
const formatLogMessage = (message, options = {}, depth = 0) => {
|
|
153
|
+
if (depth > MAX_DEPTH) return "<max depth>";
|
|
154
|
+
const prefix = options.prefix ?? "";
|
|
155
|
+
const skip = options.skip ?? [];
|
|
156
|
+
const sort = options.sort ?? true;
|
|
157
|
+
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, {
|
|
158
|
+
prefix: `${prefix}--`,
|
|
159
|
+
skip,
|
|
160
|
+
sort
|
|
161
|
+
}, 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], {
|
|
162
|
+
prefix: `${prefix}--`,
|
|
163
|
+
skip,
|
|
164
|
+
sort
|
|
165
|
+
}, depth + 1) : message[key]}`).join("\n")}` : String(message);
|
|
166
|
+
};
|
|
167
|
+
const _isFunction = (value) => {
|
|
168
|
+
try {
|
|
169
|
+
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
|
|
170
|
+
} catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Get the brand icon for the console
|
|
176
|
+
*
|
|
177
|
+
* @param config - The Storm configuration
|
|
178
|
+
* @param _chalk - The chalk instance
|
|
179
|
+
* @returns The brand icon
|
|
180
|
+
*/
|
|
181
|
+
const brandIcon = (config = {}, _chalk = require_logger_chalk.getChalk()) => _chalk.hex(require_utilities_colors.getColor("brand", config))("🗲");
|
|
182
|
+
//#endregion
|
|
183
|
+
exports.brandIcon = brandIcon;
|
|
184
|
+
exports.formatLogMessage = formatLogMessage;
|
|
185
|
+
exports.getLogFn = getLogFn;
|
|
186
|
+
exports.getStopwatch = getStopwatch;
|
|
187
|
+
exports.writeDebug = writeDebug;
|
|
188
|
+
exports.writeError = writeError;
|
|
189
|
+
exports.writeFatal = writeFatal;
|
|
190
|
+
exports.writeInfo = writeInfo;
|
|
191
|
+
exports.writePerformance = writePerformance;
|
|
192
|
+
exports.writeSuccess = writeSuccess;
|
|
193
|
+
exports.writeSystem = writeSystem;
|
|
194
|
+
exports.writeTrace = writeTrace;
|
|
195
|
+
exports.writeWarning = writeWarning;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { LogLevel } from "../types.cjs";
|
|
2
|
+
import { getChalk } from "./chalk.cjs";
|
|
3
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
4
|
+
//#region src/logger/console.d.ts
|
|
5
5
|
interface GetLogFnOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Whether to include the full date and time in the log message (defaults to `false`, which only includes the time)
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue false
|
|
10
|
+
*/
|
|
11
|
+
fullDateTime?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to hide the date and time in the log message (defaults to `false`, which includes the date and time based on the `fullDateTime` option)
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
hideDateTime?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The color configuration to use for the log message (defaults to the default Storm color configuration)
|
|
20
|
+
*/
|
|
21
|
+
chalk?: ReturnType<typeof getChalk>;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Get the log function for a log level
|
|
@@ -99,9 +99,9 @@ declare const writeSystem: (message?: any, config?: Partial<StormWorkspaceConfig
|
|
|
99
99
|
*/
|
|
100
100
|
declare const getStopwatch: (name: string) => () => void;
|
|
101
101
|
type FormatLogMessageOptions = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
prefix?: string;
|
|
103
|
+
skip?: string[];
|
|
104
|
+
sort?: boolean;
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
107
|
* 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.
|
|
@@ -120,5 +120,5 @@ declare const formatLogMessage: (message?: any, options?: FormatLogMessageOption
|
|
|
120
120
|
* @returns The brand icon
|
|
121
121
|
*/
|
|
122
122
|
declare const brandIcon: (config?: Partial<StormWorkspaceConfig>, _chalk?: ReturnType<typeof getChalk>) => string | undefined;
|
|
123
|
-
|
|
124
|
-
export {
|
|
123
|
+
//#endregion
|
|
124
|
+
export { FormatLogMessageOptions, GetLogFnOptions, brandIcon, formatLogMessage, getLogFn, getStopwatch, writeDebug, writeError, writeFatal, writeInfo, writePerformance, writeSuccess, writeSystem, writeTrace, writeWarning };
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { LogLevel } from "../types.mjs";
|
|
4
|
+
import { getChalk } from "./chalk.mjs";
|
|
5
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
6
|
+
//#region src/logger/console.d.ts
|
|
5
7
|
interface GetLogFnOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Whether to include the full date and time in the log message (defaults to `false`, which only includes the time)
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue false
|
|
12
|
+
*/
|
|
13
|
+
fullDateTime?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to hide the date and time in the log message (defaults to `false`, which includes the date and time based on the `fullDateTime` option)
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue false
|
|
18
|
+
*/
|
|
19
|
+
hideDateTime?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The color configuration to use for the log message (defaults to the default Storm color configuration)
|
|
22
|
+
*/
|
|
23
|
+
chalk?: ReturnType<typeof getChalk>;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Get the log function for a log level
|
|
@@ -99,9 +101,9 @@ declare const writeSystem: (message?: any, config?: Partial<StormWorkspaceConfig
|
|
|
99
101
|
*/
|
|
100
102
|
declare const getStopwatch: (name: string) => () => void;
|
|
101
103
|
type FormatLogMessageOptions = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
prefix?: string;
|
|
105
|
+
skip?: string[];
|
|
106
|
+
sort?: boolean;
|
|
105
107
|
};
|
|
106
108
|
/**
|
|
107
109
|
* 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.
|
|
@@ -120,5 +122,5 @@ declare const formatLogMessage: (message?: any, options?: FormatLogMessageOption
|
|
|
120
122
|
* @returns The brand icon
|
|
121
123
|
*/
|
|
122
124
|
declare const brandIcon: (config?: Partial<StormWorkspaceConfig>, _chalk?: ReturnType<typeof getChalk>) => string | undefined;
|
|
123
|
-
|
|
124
|
-
export {
|
|
125
|
+
//#endregion
|
|
126
|
+
export { FormatLogMessageOptions, GetLogFnOptions, brandIcon, formatLogMessage, getLogFn, getStopwatch, writeDebug, writeError, writeFatal, writeInfo, writePerformance, writeSuccess, writeSystem, writeTrace, writeWarning };
|