@storm-software/config-tools 1.169.7 → 1.169.8
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/package.json +1 -1
- package/dist/chunk-3TLEBPG2.cjs +0 -55
- package/dist/chunk-4DF7JJF3.js +0 -92
- package/dist/chunk-5ZIDRDGG.js +0 -331
- package/dist/chunk-7V5ZWT3O.js +0 -192
- package/dist/chunk-BISNOW2V.cjs +0 -47
- package/dist/chunk-BYLFGW3E.cjs +0 -40
- package/dist/chunk-D2H6Y42I.cjs +0 -331
- package/dist/chunk-G6IQUR2B.js +0 -47
- package/dist/chunk-GMHWE7ZI.js +0 -55
- package/dist/chunk-IYQC7ESZ.js +0 -40
- package/dist/chunk-JYKZS46U.cjs +0 -158
- package/dist/chunk-LDDYJHK5.cjs +0 -135
- package/dist/chunk-LEJKESBR.cjs +0 -40
- package/dist/chunk-MU2JW35A.js +0 -135
- package/dist/chunk-Q6MCB3G2.cjs +0 -92
- package/dist/chunk-QXXXAJVP.cjs +0 -192
- package/dist/chunk-SA3JCBON.js +0 -158
- package/dist/chunk-YGCYQLTS.js +0 -40
package/dist/chunk-QXXXAJVP.cjs
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunk7BZWQZUVcjs = require('./chunk-7BZWQZUV.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk4JREL2GQcjs = require('./chunk-4JREL2GQ.cjs');
|
|
7
|
-
|
|
8
|
-
// src/env/get-env.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _config = require('@storm-software/config');
|
|
15
|
-
var getExtensionEnv = (extensionName) => {
|
|
16
|
-
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
17
|
-
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
18
|
-
const name = key.replace(prefix, "").split("_").map(
|
|
19
|
-
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
20
|
-
).join("");
|
|
21
|
-
if (name) {
|
|
22
|
-
ret[name] = process.env[key];
|
|
23
|
-
}
|
|
24
|
-
return ret;
|
|
25
|
-
}, {});
|
|
26
|
-
};
|
|
27
|
-
var getConfigEnv = () => {
|
|
28
|
-
const prefix = "STORM_";
|
|
29
|
-
let config = {
|
|
30
|
-
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
31
|
-
name: process.env[`${prefix}NAME`] || void 0,
|
|
32
|
-
namespace: process.env[`${prefix}NAMESPACE`] || void 0,
|
|
33
|
-
owner: process.env[`${prefix}OWNER`] || void 0,
|
|
34
|
-
bot: {
|
|
35
|
-
name: process.env[`${prefix}BOT_NAME`] || void 0,
|
|
36
|
-
email: process.env[`${prefix}BOT_EMAIL`] || void 0
|
|
37
|
-
},
|
|
38
|
-
release: {
|
|
39
|
-
banner: process.env[`${prefix}RELEASE_BANNER`] || void 0,
|
|
40
|
-
header: process.env[`${prefix}RELEASE_HEADER`] || void 0,
|
|
41
|
-
footer: process.env[`${prefix}RELEASE_FOOTER`] || void 0
|
|
42
|
-
},
|
|
43
|
-
error: {
|
|
44
|
-
codesFile: process.env[`${prefix}ERROR_CODES_FILE`] || void 0,
|
|
45
|
-
url: process.env[`${prefix}ERROR_URL`] || void 0
|
|
46
|
-
},
|
|
47
|
-
account: {
|
|
48
|
-
twitter: process.env[`${prefix}ACCOUNT_TWITTER`] || void 0,
|
|
49
|
-
discord: process.env[`${prefix}ACCOUNT_DISCORD`] || void 0,
|
|
50
|
-
telegram: process.env[`${prefix}ACCOUNT_TELEGRAM`] || void 0,
|
|
51
|
-
slack: process.env[`${prefix}ACCOUNT_SLACK`] || void 0,
|
|
52
|
-
medium: process.env[`${prefix}ACCOUNT_MEDIUM`] || void 0,
|
|
53
|
-
github: process.env[`${prefix}ACCOUNT_GITHUB`] || void 0
|
|
54
|
-
},
|
|
55
|
-
organization: process.env[`${prefix}ORGANIZATION`] || void 0,
|
|
56
|
-
packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
|
|
57
|
-
license: process.env[`${prefix}LICENSE`] || void 0,
|
|
58
|
-
homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
|
|
59
|
-
docs: process.env[`${prefix}DOCS`] || void 0,
|
|
60
|
-
licensing: process.env[`${prefix}LICENSING`] || void 0,
|
|
61
|
-
contact: process.env[`${prefix}CONTACT`] || void 0,
|
|
62
|
-
timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
|
|
63
|
-
locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
|
|
64
|
-
configFile: process.env[`${prefix}CONFIG_FILE`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_FILE`]) : void 0,
|
|
65
|
-
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
|
|
66
|
-
directories: {
|
|
67
|
-
cache: process.env[`${prefix}CACHE_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}CACHE_DIR`]) : process.env[`${prefix}CACHE_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}CACHE_DIRECTORY`]) : void 0,
|
|
68
|
-
data: process.env[`${prefix}DATA_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}DATA_DIR`]) : process.env[`${prefix}DATA_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}DATA_DIRECTORY`]) : void 0,
|
|
69
|
-
config: process.env[`${prefix}CONFIG_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_DIR`]) : process.env[`${prefix}CONFIG_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_DIRECTORY`]) : void 0,
|
|
70
|
-
temp: process.env[`${prefix}TEMP_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}TEMP_DIR`]) : process.env[`${prefix}TEMP_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}TEMP_DIRECTORY`]) : void 0,
|
|
71
|
-
log: process.env[`${prefix}LOG_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}LOG_DIR`]) : process.env[`${prefix}LOG_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}LOG_DIRECTORY`]) : void 0,
|
|
72
|
-
build: process.env[`${prefix}BUILD_DIR`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}BUILD_DIR`]) : process.env[`${prefix}BUILD_DIRECTORY`] ? _chunk4JREL2GQcjs.correctPaths.call(void 0, process.env[`${prefix}BUILD_DIRECTORY`]) : void 0
|
|
73
|
-
},
|
|
74
|
-
skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
|
|
75
|
-
mode: (_nullishCoalesce(_nullishCoalesce(process.env[`${prefix}MODE`], () => ( process.env.NODE_ENV)), () => ( process.env.ENVIRONMENT))) || void 0,
|
|
76
|
-
// ci:
|
|
77
|
-
// process.env[`${prefix}CI`] !== undefined
|
|
78
|
-
// ? Boolean(
|
|
79
|
-
// process.env[`${prefix}CI`] ??
|
|
80
|
-
// process.env.CI ??
|
|
81
|
-
// process.env.CONTINUOUS_INTEGRATION
|
|
82
|
-
// )
|
|
83
|
-
// : undefined,
|
|
84
|
-
repository: process.env[`${prefix}REPOSITORY`] || void 0,
|
|
85
|
-
branch: process.env[`${prefix}BRANCH`] || void 0,
|
|
86
|
-
preid: process.env[`${prefix}PRE_ID`] || void 0,
|
|
87
|
-
externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
|
|
88
|
-
registry: {
|
|
89
|
-
github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
|
|
90
|
-
npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
|
|
91
|
-
cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
|
|
92
|
-
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
93
|
-
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
94
|
-
},
|
|
95
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
96
|
-
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
97
|
-
) ? _chunk7BZWQZUVcjs.getLogLevelLabel.call(void 0,
|
|
98
|
-
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
99
|
-
) : process.env[`${prefix}LOG_LEVEL`] : void 0,
|
|
100
|
-
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
|
|
101
|
-
};
|
|
102
|
-
const themeNames = Object.keys(process.env).filter(
|
|
103
|
-
(envKey) => envKey.startsWith(`${prefix}COLOR_`) && _config.COLOR_KEYS.every(
|
|
104
|
-
(colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
config.colors = themeNames.length > 0 ? themeNames.reduce(
|
|
108
|
-
(ret, themeName) => {
|
|
109
|
-
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
110
|
-
return ret;
|
|
111
|
-
},
|
|
112
|
-
{}
|
|
113
|
-
) : getThemeColorConfigEnv(prefix);
|
|
114
|
-
if (config.docs === _config.STORM_DEFAULT_DOCS) {
|
|
115
|
-
if (config.homepage === _config.STORM_DEFAULT_HOMEPAGE) {
|
|
116
|
-
config.docs = `${_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
117
|
-
} else {
|
|
118
|
-
config.docs = `${config.homepage}/docs`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (config.licensing === _config.STORM_DEFAULT_LICENSING) {
|
|
122
|
-
if (config.homepage === _config.STORM_DEFAULT_HOMEPAGE) {
|
|
123
|
-
config.licensing = `${_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
|
|
124
|
-
} else {
|
|
125
|
-
config.licensing = `${config.homepage}/docs`;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
129
|
-
if (serializedConfig) {
|
|
130
|
-
const parsed = JSON.parse(serializedConfig);
|
|
131
|
-
config = {
|
|
132
|
-
...config,
|
|
133
|
-
...parsed,
|
|
134
|
-
colors: { ...config.colors, ...parsed.colors },
|
|
135
|
-
extensions: { ...config.extensions, ...parsed.extensions }
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return config;
|
|
139
|
-
};
|
|
140
|
-
var getThemeColorConfigEnv = (prefix, theme) => {
|
|
141
|
-
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
142
|
-
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
143
|
-
};
|
|
144
|
-
var getSingleThemeColorConfigEnv = (prefix) => {
|
|
145
|
-
return {
|
|
146
|
-
dark: process.env[`${prefix}DARK`],
|
|
147
|
-
light: process.env[`${prefix}LIGHT`],
|
|
148
|
-
brand: process.env[`${prefix}BRAND`],
|
|
149
|
-
alternate: process.env[`${prefix}ALTERNATE`],
|
|
150
|
-
accent: process.env[`${prefix}ACCENT`],
|
|
151
|
-
link: process.env[`${prefix}LINK`],
|
|
152
|
-
help: process.env[`${prefix}HELP`],
|
|
153
|
-
success: process.env[`${prefix}SUCCESS`],
|
|
154
|
-
info: process.env[`${prefix}INFO`],
|
|
155
|
-
warning: process.env[`${prefix}WARNING`],
|
|
156
|
-
danger: process.env[`${prefix}DANGER`],
|
|
157
|
-
fatal: process.env[`${prefix}FATAL`],
|
|
158
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
159
|
-
negative: process.env[`${prefix}NEGATIVE`]
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
var getMultiThemeColorConfigEnv = (prefix) => {
|
|
163
|
-
return {
|
|
164
|
-
light: getBaseThemeColorConfigEnv(
|
|
165
|
-
`${prefix}_LIGHT_`
|
|
166
|
-
),
|
|
167
|
-
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
var getBaseThemeColorConfigEnv = (prefix) => {
|
|
171
|
-
return {
|
|
172
|
-
foreground: process.env[`${prefix}FOREGROUND`],
|
|
173
|
-
background: process.env[`${prefix}BACKGROUND`],
|
|
174
|
-
brand: process.env[`${prefix}BRAND`],
|
|
175
|
-
alternate: process.env[`${prefix}ALTERNATE`],
|
|
176
|
-
accent: process.env[`${prefix}ACCENT`],
|
|
177
|
-
link: process.env[`${prefix}LINK`],
|
|
178
|
-
help: process.env[`${prefix}HELP`],
|
|
179
|
-
success: process.env[`${prefix}SUCCESS`],
|
|
180
|
-
info: process.env[`${prefix}INFO`],
|
|
181
|
-
warning: process.env[`${prefix}WARNING`],
|
|
182
|
-
danger: process.env[`${prefix}DANGER`],
|
|
183
|
-
fatal: process.env[`${prefix}FATAL`],
|
|
184
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
185
|
-
negative: process.env[`${prefix}NEGATIVE`]
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
exports.getExtensionEnv = getExtensionEnv; exports.getConfigEnv = getConfigEnv;
|
package/dist/chunk-SA3JCBON.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_COLOR_CONFIG
|
|
3
|
-
} from "./chunk-JX5NLB4S.js";
|
|
4
|
-
import {
|
|
5
|
-
CONSOLE_ICONS
|
|
6
|
-
} from "./chunk-OJP4XIBV.js";
|
|
7
|
-
import {
|
|
8
|
-
formatTimestamp
|
|
9
|
-
} from "./chunk-XEZGYUS2.js";
|
|
10
|
-
import {
|
|
11
|
-
getLogLevel
|
|
12
|
-
} from "./chunk-4XRV4CVP.js";
|
|
13
|
-
import {
|
|
14
|
-
LogLevel,
|
|
15
|
-
LogLevelLabel
|
|
16
|
-
} from "./chunk-3QAWRU2B.js";
|
|
17
|
-
import {
|
|
18
|
-
getChalk
|
|
19
|
-
} from "./chunk-T3MUE32G.js";
|
|
20
|
-
|
|
21
|
-
// src/logger/console.ts
|
|
22
|
-
var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
23
|
-
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;
|
|
24
|
-
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
25
|
-
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
26
|
-
return (_) => {
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
30
|
-
return (message) => {
|
|
31
|
-
console.error(
|
|
32
|
-
`
|
|
33
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
34
|
-
`
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
39
|
-
return (message) => {
|
|
40
|
-
console.error(
|
|
41
|
-
`
|
|
42
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
43
|
-
`
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
48
|
-
return (message) => {
|
|
49
|
-
console.warn(
|
|
50
|
-
`
|
|
51
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
52
|
-
`
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
57
|
-
return (message) => {
|
|
58
|
-
console.info(
|
|
59
|
-
`
|
|
60
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
61
|
-
`
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
66
|
-
return (message) => {
|
|
67
|
-
console.info(
|
|
68
|
-
`
|
|
69
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
70
|
-
`
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
75
|
-
return (message) => {
|
|
76
|
-
console.debug(
|
|
77
|
-
`
|
|
78
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
79
|
-
`
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
84
|
-
return (message) => {
|
|
85
|
-
console.debug(
|
|
86
|
-
`
|
|
87
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
88
|
-
`
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return (message) => {
|
|
93
|
-
console.log(
|
|
94
|
-
`
|
|
95
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
96
|
-
`
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
|
|
101
|
-
var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
|
|
102
|
-
var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
|
|
103
|
-
var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
|
|
104
|
-
var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
|
|
105
|
-
var writeDebug = (message, config) => getLogFn(LogLevel.DEBUG, config)(message);
|
|
106
|
-
var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
|
|
107
|
-
var writeSystem = (message, config) => getLogFn(LogLevel.ALL, config)(message);
|
|
108
|
-
var getStopwatch = (name) => {
|
|
109
|
-
const start = process.hrtime();
|
|
110
|
-
return () => {
|
|
111
|
-
const end = process.hrtime(start);
|
|
112
|
-
console.info(
|
|
113
|
-
`
|
|
114
|
-
> \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
|
|
115
|
-
end[0] * 1e3 + end[1] / 1e6
|
|
116
|
-
)}ms to complete
|
|
117
|
-
`
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
var MAX_DEPTH = 4;
|
|
122
|
-
var formatLogMessage = (message, options = {}, depth = 0) => {
|
|
123
|
-
if (depth > MAX_DEPTH) {
|
|
124
|
-
return "<max depth>";
|
|
125
|
-
}
|
|
126
|
-
const prefix = options.prefix ?? "-";
|
|
127
|
-
const skip = options.skip ?? [];
|
|
128
|
-
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
|
|
129
|
-
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
|
|
130
|
-
${Object.keys(message).filter((key) => !skip.includes(key)).map(
|
|
131
|
-
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
|
|
132
|
-
message[key],
|
|
133
|
-
{ prefix: `${prefix}-`, skip },
|
|
134
|
-
depth + 1
|
|
135
|
-
) : message[key]}`
|
|
136
|
-
).join("\n")}` : message;
|
|
137
|
-
};
|
|
138
|
-
var _isFunction = (value) => {
|
|
139
|
-
try {
|
|
140
|
-
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
getLogFn,
|
|
148
|
-
writeFatal,
|
|
149
|
-
writeError,
|
|
150
|
-
writeWarning,
|
|
151
|
-
writeInfo,
|
|
152
|
-
writeSuccess,
|
|
153
|
-
writeDebug,
|
|
154
|
-
writeTrace,
|
|
155
|
-
writeSystem,
|
|
156
|
-
getStopwatch,
|
|
157
|
-
formatLogMessage
|
|
158
|
-
};
|
package/dist/chunk-YGCYQLTS.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getLogFn,
|
|
3
|
-
getStopwatch
|
|
4
|
-
} from "./chunk-SA3JCBON.js";
|
|
5
|
-
import {
|
|
6
|
-
findWorkspaceRoot
|
|
7
|
-
} from "./chunk-VLWSWYG7.js";
|
|
8
|
-
import {
|
|
9
|
-
LogLevel
|
|
10
|
-
} from "./chunk-3QAWRU2B.js";
|
|
11
|
-
|
|
12
|
-
// src/logger/create-logger.ts
|
|
13
|
-
import chalk from "chalk";
|
|
14
|
-
async function createLogger(config) {
|
|
15
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
16
|
-
if (!workspaceRoot) {
|
|
17
|
-
throw new Error("Cannot find workspace root");
|
|
18
|
-
}
|
|
19
|
-
const writeFatal = getLogFn(LogLevel.FATAL, config, chalk);
|
|
20
|
-
const writeError = getLogFn(LogLevel.ERROR, config, chalk);
|
|
21
|
-
const writeWarning = getLogFn(LogLevel.WARN, config, chalk);
|
|
22
|
-
const writeInfo = getLogFn(LogLevel.INFO, config, chalk);
|
|
23
|
-
const writeSuccess = getLogFn(LogLevel.SUCCESS, config, chalk);
|
|
24
|
-
const writeDebug = getLogFn(LogLevel.DEBUG, config, chalk);
|
|
25
|
-
const writeTrace = getLogFn(LogLevel.DEBUG, config, chalk);
|
|
26
|
-
return {
|
|
27
|
-
fatal: writeFatal,
|
|
28
|
-
error: writeError,
|
|
29
|
-
warning: writeWarning,
|
|
30
|
-
info: writeInfo,
|
|
31
|
-
success: writeSuccess,
|
|
32
|
-
debug: writeDebug,
|
|
33
|
-
trace: writeTrace,
|
|
34
|
-
getStopwatch
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
createLogger
|
|
40
|
-
};
|