@storm-software/config-tools 1.176.13 → 1.176.15

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.
@@ -0,0 +1,154 @@
1
+ import {
2
+ getConfigEnv,
3
+ getExtensionEnv
4
+ } from "./chunk-HGKCHX5V.js";
5
+ import {
6
+ setConfigEnv
7
+ } from "./chunk-B3GCBJWU.js";
8
+ import {
9
+ getConfigFile
10
+ } from "./chunk-H23BFVJZ.js";
11
+ import {
12
+ formatLogMessage,
13
+ writeTrace,
14
+ writeWarning
15
+ } from "./chunk-PQFFXKJC.js";
16
+ import {
17
+ applyDefaultConfig,
18
+ getPackageJsonConfig
19
+ } from "./chunk-66NG3IMH.js";
20
+ import {
21
+ findWorkspaceRoot
22
+ } from "./chunk-6RRYSEZX.js";
23
+
24
+ // src/create-storm-config.ts
25
+ import { stormWorkspaceConfigSchema } from "@storm-software/config/schema";
26
+ import defu from "defu";
27
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
28
+ var _static_cache = void 0;
29
+ var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
30
+ let result;
31
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
32
+ let _workspaceRoot = workspaceRoot;
33
+ if (!_workspaceRoot) {
34
+ _workspaceRoot = findWorkspaceRoot();
35
+ }
36
+ const configEnv = getConfigEnv();
37
+ const configFile = await getConfigFile(_workspaceRoot);
38
+ if (!configFile) {
39
+ if (!skipLogs) {
40
+ writeWarning(
41
+ "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",
42
+ { logLevel: "all" }
43
+ );
44
+ }
45
+ if (useDefault === false) {
46
+ return void 0;
47
+ }
48
+ }
49
+ const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
50
+ const configInput = defu(
51
+ configEnv,
52
+ configFile,
53
+ defaultConfig
54
+ );
55
+ try {
56
+ result = applyDefaultConfig(
57
+ await stormWorkspaceConfigSchema.parseAsync(configInput)
58
+ );
59
+ result.workspaceRoot ??= _workspaceRoot;
60
+ } catch (error) {
61
+ throw new Error(
62
+ `Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
63
+
64
+ Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(
65
+ configInput
66
+ )}`,
67
+ {
68
+ cause: error
69
+ }
70
+ );
71
+ }
72
+ } else {
73
+ result = _static_cache.data;
74
+ }
75
+ if (schema && extensionName) {
76
+ result.extensions = {
77
+ ...result.extensions,
78
+ [extensionName]: createConfigExtension(extensionName, schema)
79
+ };
80
+ }
81
+ _static_cache = {
82
+ timestamp: Date.now(),
83
+ data: result
84
+ };
85
+ return result;
86
+ };
87
+ var createConfigExtension = (extensionName, schema) => {
88
+ const extension_cache_key = { extensionName };
89
+ if (_extension_cache.has(extension_cache_key)) {
90
+ return _extension_cache.get(extension_cache_key);
91
+ }
92
+ let extension = getExtensionEnv(extensionName);
93
+ if (schema) {
94
+ extension = schema.parse(extension);
95
+ }
96
+ _extension_cache.set(extension_cache_key, extension);
97
+ return extension;
98
+ };
99
+ var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
100
+ const config = await createStormWorkspaceConfig(
101
+ void 0,
102
+ void 0,
103
+ workspaceRoot,
104
+ skipLogs,
105
+ true
106
+ );
107
+ setConfigEnv(config);
108
+ if (!skipLogs && !config.skipConfigLogging) {
109
+ writeTrace(
110
+ `\u2699\uFE0F Using Storm Workspace configuration:
111
+ ${formatLogMessage(config)}`,
112
+ config
113
+ );
114
+ }
115
+ return config;
116
+ };
117
+ var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
118
+ try {
119
+ const config = await createStormWorkspaceConfig(
120
+ void 0,
121
+ void 0,
122
+ workspaceRoot,
123
+ skipLogs,
124
+ useDefault
125
+ );
126
+ if (!config) {
127
+ return void 0;
128
+ }
129
+ setConfigEnv(config);
130
+ if (!skipLogs && !config.skipConfigLogging) {
131
+ writeTrace(
132
+ `\u2699\uFE0F Using Storm Workspace configuration:
133
+ ${formatLogMessage(config)}`,
134
+ config
135
+ );
136
+ }
137
+ return config;
138
+ } catch (error) {
139
+ if (!skipLogs) {
140
+ writeWarning(
141
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
142
+ { logLevel: "all" }
143
+ );
144
+ }
145
+ return void 0;
146
+ }
147
+ };
148
+
149
+ export {
150
+ createStormWorkspaceConfig,
151
+ createConfigExtension,
152
+ loadStormWorkspaceConfig,
153
+ tryLoadStormWorkspaceConfig
154
+ };
@@ -0,0 +1,199 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunk4PX5UVANcjs = require('./chunk-4PX5UVAN.cjs');
4
+
5
+
6
+ var _chunkM3REM2FUcjs = require('./chunk-M3REM2FU.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
+ socials: {
48
+ twitter: process.env[`${prefix}SOCIAL_TWITTER`] || void 0,
49
+ discord: process.env[`${prefix}SOCIAL_DISCORD`] || void 0,
50
+ telegram: process.env[`${prefix}SOCIAL_TELEGRAM`] || void 0,
51
+ slack: process.env[`${prefix}SOCIAL_SLACK`] || void 0,
52
+ medium: process.env[`${prefix}SOCIAL_MEDIUM`] || void 0,
53
+ github: process.env[`${prefix}SOCIAL_GITHUB`] || void 0
54
+ },
55
+ 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`] ? {
56
+ name: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`],
57
+ description: process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || void 0,
58
+ url: process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || void 0,
59
+ logo: process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] || void 0,
60
+ icon: process.env[`${prefix}ORG_ICON`] || process.env[`${prefix}ORGANIZATION_ICON`] || void 0
61
+ } : process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] : void 0,
62
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
63
+ license: process.env[`${prefix}LICENSE`] || void 0,
64
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
65
+ docs: process.env[`${prefix}DOCS`] || void 0,
66
+ portal: process.env[`${prefix}PORTAL`] || void 0,
67
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
68
+ contact: process.env[`${prefix}CONTACT`] || void 0,
69
+ support: process.env[`${prefix}SUPPORT`] || void 0,
70
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
71
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
72
+ configFile: process.env[`${prefix}CONFIG_FILE`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_FILE`]) : void 0,
73
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
74
+ directories: {
75
+ cache: process.env[`${prefix}CACHE_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}CACHE_DIR`]) : process.env[`${prefix}CACHE_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}CACHE_DIRECTORY`]) : void 0,
76
+ data: process.env[`${prefix}DATA_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}DATA_DIR`]) : process.env[`${prefix}DATA_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}DATA_DIRECTORY`]) : void 0,
77
+ config: process.env[`${prefix}CONFIG_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_DIR`]) : process.env[`${prefix}CONFIG_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}CONFIG_DIRECTORY`]) : void 0,
78
+ temp: process.env[`${prefix}TEMP_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}TEMP_DIR`]) : process.env[`${prefix}TEMP_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}TEMP_DIRECTORY`]) : void 0,
79
+ log: process.env[`${prefix}LOG_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}LOG_DIR`]) : process.env[`${prefix}LOG_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}LOG_DIRECTORY`]) : void 0,
80
+ build: process.env[`${prefix}BUILD_DIR`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}BUILD_DIR`]) : process.env[`${prefix}BUILD_DIRECTORY`] ? _chunkM3REM2FUcjs.correctPaths.call(void 0, process.env[`${prefix}BUILD_DIRECTORY`]) : void 0
81
+ },
82
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
83
+ mode: (_nullishCoalesce(_nullishCoalesce(process.env[`${prefix}MODE`], () => ( process.env.NODE_ENV)), () => ( process.env.ENVIRONMENT))) || void 0,
84
+ // ci:
85
+ // process.env[`${prefix}CI`] !== undefined
86
+ // ? Boolean(
87
+ // process.env[`${prefix}CI`] ??
88
+ // process.env.CI ??
89
+ // process.env.CONTINUOUS_INTEGRATION
90
+ // )
91
+ // : undefined,
92
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
93
+ branch: process.env[`${prefix}BRANCH`] || void 0,
94
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
95
+ registry: {
96
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
97
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
98
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
99
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
100
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
101
+ },
102
+ logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
103
+ Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
104
+ ) ? _chunk4PX5UVANcjs.getLogLevelLabel.call(void 0,
105
+ Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
106
+ ) : process.env[`${prefix}LOG_LEVEL`] : void 0,
107
+ skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
108
+ };
109
+ const themeNames = Object.keys(process.env).filter(
110
+ (envKey) => envKey.startsWith(`${prefix}COLOR_`) && _config.COLOR_KEYS.every(
111
+ (colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
112
+ )
113
+ );
114
+ config.colors = themeNames.length > 0 ? themeNames.reduce(
115
+ (ret, themeName) => {
116
+ ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
117
+ return ret;
118
+ },
119
+ {}
120
+ ) : getThemeColorConfigEnv(prefix);
121
+ if (config.docs === _config.STORM_DEFAULT_DOCS) {
122
+ if (config.homepage === _config.STORM_DEFAULT_HOMEPAGE) {
123
+ config.docs = `${_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
124
+ } else {
125
+ config.docs = `${config.homepage}/docs`;
126
+ }
127
+ }
128
+ if (config.licensing === _config.STORM_DEFAULT_LICENSING) {
129
+ if (config.homepage === _config.STORM_DEFAULT_HOMEPAGE) {
130
+ config.licensing = `${_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
131
+ } else {
132
+ config.licensing = `${config.homepage}/docs`;
133
+ }
134
+ }
135
+ const serializedConfig = process.env[`${prefix}CONFIG`];
136
+ if (serializedConfig) {
137
+ const parsed = JSON.parse(serializedConfig);
138
+ config = {
139
+ ...config,
140
+ ...parsed,
141
+ colors: { ...config.colors, ...parsed.colors },
142
+ extensions: { ...config.extensions, ...parsed.extensions }
143
+ };
144
+ }
145
+ return config;
146
+ };
147
+ var getThemeColorConfigEnv = (prefix, theme) => {
148
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
149
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
150
+ };
151
+ var getSingleThemeColorConfigEnv = (prefix) => {
152
+ return {
153
+ dark: process.env[`${prefix}DARK`],
154
+ light: process.env[`${prefix}LIGHT`],
155
+ brand: process.env[`${prefix}BRAND`],
156
+ alternate: process.env[`${prefix}ALTERNATE`],
157
+ accent: process.env[`${prefix}ACCENT`],
158
+ link: process.env[`${prefix}LINK`],
159
+ help: process.env[`${prefix}HELP`],
160
+ success: process.env[`${prefix}SUCCESS`],
161
+ info: process.env[`${prefix}INFO`],
162
+ warning: process.env[`${prefix}WARNING`],
163
+ danger: process.env[`${prefix}DANGER`],
164
+ fatal: process.env[`${prefix}FATAL`],
165
+ positive: process.env[`${prefix}POSITIVE`],
166
+ negative: process.env[`${prefix}NEGATIVE`]
167
+ };
168
+ };
169
+ var getMultiThemeColorConfigEnv = (prefix) => {
170
+ return {
171
+ light: getBaseThemeColorConfigEnv(
172
+ `${prefix}_LIGHT_`
173
+ ),
174
+ dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
175
+ };
176
+ };
177
+ var getBaseThemeColorConfigEnv = (prefix) => {
178
+ return {
179
+ foreground: process.env[`${prefix}FOREGROUND`],
180
+ background: process.env[`${prefix}BACKGROUND`],
181
+ brand: process.env[`${prefix}BRAND`],
182
+ alternate: process.env[`${prefix}ALTERNATE`],
183
+ accent: process.env[`${prefix}ACCENT`],
184
+ link: process.env[`${prefix}LINK`],
185
+ help: process.env[`${prefix}HELP`],
186
+ success: process.env[`${prefix}SUCCESS`],
187
+ info: process.env[`${prefix}INFO`],
188
+ warning: process.env[`${prefix}WARNING`],
189
+ danger: process.env[`${prefix}DANGER`],
190
+ fatal: process.env[`${prefix}FATAL`],
191
+ positive: process.env[`${prefix}POSITIVE`],
192
+ negative: process.env[`${prefix}NEGATIVE`]
193
+ };
194
+ };
195
+
196
+
197
+
198
+
199
+ exports.getExtensionEnv = getExtensionEnv; exports.getConfigEnv = getConfigEnv;
@@ -0,0 +1,33 @@
1
+ import {
2
+ getLogFn,
3
+ getStopwatch
4
+ } from "./chunk-PQFFXKJC.js";
5
+ import {
6
+ LogLevel
7
+ } from "./chunk-POXTJ6GF.js";
8
+
9
+ // src/logger/create-logger.ts
10
+ import chalk from "chalk";
11
+ async function createLogger(config) {
12
+ const writeFatal = getLogFn(LogLevel.FATAL, config, chalk);
13
+ const writeError = getLogFn(LogLevel.ERROR, config, chalk);
14
+ const writeWarning = getLogFn(LogLevel.WARN, config, chalk);
15
+ const writeInfo = getLogFn(LogLevel.INFO, config, chalk);
16
+ const writeSuccess = getLogFn(LogLevel.SUCCESS, config, chalk);
17
+ const writeDebug = getLogFn(LogLevel.DEBUG, config, chalk);
18
+ const writeTrace = getLogFn(LogLevel.DEBUG, config, chalk);
19
+ return {
20
+ fatal: writeFatal,
21
+ error: writeError,
22
+ warning: writeWarning,
23
+ info: writeInfo,
24
+ success: writeSuccess,
25
+ debug: writeDebug,
26
+ trace: writeTrace,
27
+ getStopwatch
28
+ };
29
+ }
30
+
31
+ export {
32
+ createLogger
33
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ loadStormWorkspaceConfig,
3
+ tryLoadStormWorkspaceConfig
4
+ } from "./chunk-CGZUIRJC.js";
5
+ import {
6
+ findWorkspaceRoot
7
+ } from "./chunk-6RRYSEZX.js";
8
+
9
+ // src/get-config.ts
10
+ var getConfig = (workspaceRoot, skipLogs = false) => {
11
+ return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
12
+ };
13
+ var getWorkspaceConfig = (skipLogs = true, options = {}) => {
14
+ let workspaceRoot = options.workspaceRoot;
15
+ if (!workspaceRoot) {
16
+ workspaceRoot = findWorkspaceRoot(options.cwd);
17
+ }
18
+ return getConfig(workspaceRoot, skipLogs);
19
+ };
20
+ var tryGetWorkspaceConfig = async (skipLogs = true, options = {}) => {
21
+ try {
22
+ let workspaceRoot = options.workspaceRoot;
23
+ if (!workspaceRoot) {
24
+ workspaceRoot = findWorkspaceRoot(options.cwd);
25
+ }
26
+ return tryLoadStormWorkspaceConfig(
27
+ workspaceRoot,
28
+ skipLogs,
29
+ options.useDefault
30
+ );
31
+ } catch {
32
+ return void 0;
33
+ }
34
+ };
35
+
36
+ export {
37
+ getConfig,
38
+ getWorkspaceConfig,
39
+ tryGetWorkspaceConfig
40
+ };
@@ -0,0 +1,92 @@
1
+ import {
2
+ writeTrace
3
+ } from "./chunk-PQFFXKJC.js";
4
+ import {
5
+ findWorkspaceRoot
6
+ } from "./chunk-6RRYSEZX.js";
7
+ import {
8
+ joinPaths
9
+ } from "./chunk-7IMLZPZF.js";
10
+
11
+ // src/config-file/get-config-file.ts
12
+ import { loadConfig } from "c12";
13
+ import defu from "defu";
14
+ var getConfigFileByName = async (fileName, filePath, options = {}) => {
15
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
16
+ const configs = await Promise.all([
17
+ loadConfig({
18
+ cwd: workspacePath,
19
+ packageJson: true,
20
+ name: fileName,
21
+ envName: fileName?.toUpperCase(),
22
+ jitiOptions: {
23
+ debug: false,
24
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
25
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
26
+ "jiti"
27
+ )
28
+ },
29
+ ...options
30
+ }),
31
+ loadConfig({
32
+ cwd: workspacePath,
33
+ packageJson: true,
34
+ name: fileName,
35
+ envName: fileName?.toUpperCase(),
36
+ jitiOptions: {
37
+ debug: false,
38
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
39
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
40
+ "jiti"
41
+ )
42
+ },
43
+ configFile: fileName,
44
+ ...options
45
+ })
46
+ ]);
47
+ return defu(configs[0] ?? {}, configs[1] ?? {});
48
+ };
49
+ var getConfigFile = async (filePath, additionalFileNames = []) => {
50
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
51
+ const result = await getConfigFileByName("storm-workspace", workspacePath);
52
+ let config = result.config;
53
+ const configFile = result.configFile;
54
+ if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
55
+ writeTrace(
56
+ `Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
57
+ {
58
+ logLevel: "all"
59
+ }
60
+ );
61
+ }
62
+ if (additionalFileNames && additionalFileNames.length > 0) {
63
+ const results = await Promise.all(
64
+ additionalFileNames.map(
65
+ (fileName) => getConfigFileByName(fileName, workspacePath)
66
+ )
67
+ );
68
+ for (const result2 of results) {
69
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
70
+ if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
71
+ writeTrace(
72
+ `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
73
+ {
74
+ logLevel: "all"
75
+ }
76
+ );
77
+ }
78
+ config = defu(result2.config ?? {}, config ?? {});
79
+ }
80
+ }
81
+ }
82
+ if (!config || Object.keys(config).length === 0) {
83
+ return void 0;
84
+ }
85
+ config.configFile = configFile;
86
+ return config;
87
+ };
88
+
89
+ export {
90
+ getConfigFileByName,
91
+ getConfigFile
92
+ };
@@ -0,0 +1,158 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkBN6MEGGYcjs = require('./chunk-BN6MEGGY.cjs');
4
+
5
+
6
+ var _chunk4PX5UVANcjs = require('./chunk-4PX5UVAN.cjs');
7
+
8
+
9
+ var _chunkCTYIEJ7Ccjs = require('./chunk-CTYIEJ7C.cjs');
10
+
11
+
12
+ var _chunkWBQ4VS7Ecjs = require('./chunk-WBQ4VS7E.cjs');
13
+
14
+
15
+
16
+ var _chunkIRCFHYKZcjs = require('./chunk-IRCFHYKZ.cjs');
17
+
18
+
19
+ var _chunkXGOYEDHPcjs = require('./chunk-XGOYEDHP.cjs');
20
+
21
+ // src/logger/console.ts
22
+ var getLogFn = (logLevel = _chunkIRCFHYKZcjs.LogLevel.INFO, config = {}, _chalk = _chunkCTYIEJ7Ccjs.getChalk.call(void 0, )) => {
23
+ const colors = !_optionalChain([config, 'access', _2 => _2.colors, 'optionalAccess', _3 => _3.dark]) && !_optionalChain([config, 'access', _4 => _4.colors, 'optionalAccess', _5 => _5["base"]]) && !_optionalChain([config, 'access', _6 => _6.colors, 'optionalAccess', _7 => _7["base"], 'optionalAccess', _8 => _8.dark]) ? _chunkXGOYEDHPcjs.DEFAULT_COLOR_CONFIG : _optionalChain([config, 'access', _9 => _9.colors, 'optionalAccess', _10 => _10.dark]) && typeof config.colors.dark === "string" ? config.colors : _optionalChain([config, 'access', _11 => _11.colors, 'optionalAccess', _12 => _12["base"], 'optionalAccess', _13 => _13.dark]) && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : _optionalChain([config, 'access', _14 => _14.colors, 'optionalAccess', _15 => _15["base"]]) ? _optionalChain([config, 'access', _16 => _16.colors, 'optionalAccess', _17 => _17["base"]]) : _chunkXGOYEDHPcjs.DEFAULT_COLOR_CONFIG;
24
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || _chunkIRCFHYKZcjs.LogLevelLabel.INFO;
25
+ if (logLevel > _chunk4PX5UVANcjs.getLogLevel.call(void 0, configLogLevel) || logLevel <= _chunkIRCFHYKZcjs.LogLevel.SILENT || _chunk4PX5UVANcjs.getLogLevel.call(void 0, configLogLevel) <= _chunkIRCFHYKZcjs.LogLevel.SILENT) {
26
+ return (_) => {
27
+ };
28
+ }
29
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.FATAL >= logLevel) {
30
+ return (message) => {
31
+ console.error(
32
+ `
33
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.fatal, () => ( "#7d1a1a")))(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
34
+ `
35
+ );
36
+ };
37
+ }
38
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.ERROR >= logLevel) {
39
+ return (message) => {
40
+ console.error(
41
+ `
42
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.danger, () => ( "#f85149")))(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
43
+ `
44
+ );
45
+ };
46
+ }
47
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.WARN >= logLevel) {
48
+ return (message) => {
49
+ console.warn(
50
+ `
51
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.warning, () => ( "#e3b341")))(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
52
+ `
53
+ );
54
+ };
55
+ }
56
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.SUCCESS >= logLevel) {
57
+ return (message) => {
58
+ console.info(
59
+ `
60
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.success, () => ( "#56d364")))(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
61
+ `
62
+ );
63
+ };
64
+ }
65
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.INFO >= logLevel) {
66
+ return (message) => {
67
+ console.info(
68
+ `
69
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( "#58a6ff")))(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
70
+ `
71
+ );
72
+ };
73
+ }
74
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.DEBUG >= logLevel) {
75
+ return (message) => {
76
+ console.debug(
77
+ `
78
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex("#3e9eff")(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
79
+ `
80
+ );
81
+ };
82
+ }
83
+ if (typeof logLevel === "number" && _chunkIRCFHYKZcjs.LogLevel.TRACE >= logLevel) {
84
+ return (message) => {
85
+ console.debug(
86
+ `
87
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex("#0070E0")(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
88
+ `
89
+ );
90
+ };
91
+ }
92
+ return (message) => {
93
+ console.log(
94
+ `
95
+ ${_chalk.gray(_chunkBN6MEGGYcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex("#0356a8")(`[${_chunkWBQ4VS7Ecjs.CONSOLE_ICONS[_chunkIRCFHYKZcjs.LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
96
+ `
97
+ );
98
+ };
99
+ };
100
+ var writeFatal = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.FATAL, config)(message);
101
+ var writeError = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.ERROR, config)(message);
102
+ var writeWarning = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.WARN, config)(message);
103
+ var writeInfo = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.INFO, config)(message);
104
+ var writeSuccess = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.SUCCESS, config)(message);
105
+ var writeDebug = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.DEBUG, config)(message);
106
+ var writeTrace = (message, config) => getLogFn(_chunkIRCFHYKZcjs.LogLevel.TRACE, config)(message);
107
+ var writeSystem = (message, config) => getLogFn(_chunkIRCFHYKZcjs.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 = _nullishCoalesce(options.prefix, () => ( "-"));
127
+ const skip = _nullishCoalesce(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" || !!(_optionalChain([value, 'optionalAccess', _18 => _18.constructor]) && _optionalChain([value, 'optionalAccess', _19 => _19.call]) && _optionalChain([value, 'optionalAccess', _20 => _20.apply]));
141
+ } catch (e) {
142
+ return false;
143
+ }
144
+ };
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ exports.getLogFn = getLogFn; exports.writeFatal = writeFatal; exports.writeError = writeError; exports.writeWarning = writeWarning; exports.writeInfo = writeInfo; exports.writeSuccess = writeSuccess; exports.writeDebug = writeDebug; exports.writeTrace = writeTrace; exports.writeSystem = writeSystem; exports.getStopwatch = getStopwatch; exports.formatLogMessage = formatLogMessage;