@storm-software/config-tools 1.173.2 → 1.173.4

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 CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-1.173.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-1.173.2-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/config-tools",
3
- "version": "1.173.2",
3
+ "version": "1.173.4",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.",
6
6
  "repository": {
@@ -211,7 +211,7 @@
211
211
  ],
212
212
  "dependencies": {
213
213
  "@ltd/j-toml": "1.38.0",
214
- "@storm-software/config": "^1.122.2",
214
+ "@storm-software/config": "^1.122.4",
215
215
  "c12": "^2.0.0-beta.2",
216
216
  "chalk": "^4.1.2",
217
217
  "commander": "^12.1.0",
@@ -1,92 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunk7STXZ7BNcjs = require('./chunk-7STXZ7BN.cjs');
4
-
5
-
6
- var _chunkU436743Ucjs = require('./chunk-U436743U.cjs');
7
-
8
-
9
- var _chunkM3REM2FUcjs = require('./chunk-M3REM2FU.cjs');
10
-
11
- // src/config-file/get-config-file.ts
12
- var _c12 = require('c12');
13
- var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
14
- var getConfigFileByName = async (fileName, filePath, options = {}) => {
15
- const workspacePath = filePath || _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, filePath);
16
- const configs = await Promise.all([
17
- _c12.loadConfig.call(void 0, {
18
- cwd: workspacePath,
19
- packageJson: true,
20
- name: fileName,
21
- envName: _optionalChain([fileName, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]),
22
- jitiOptions: {
23
- debug: false,
24
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkM3REM2FUcjs.joinPaths.call(void 0,
25
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
26
- "jiti"
27
- )
28
- },
29
- ...options
30
- }),
31
- _c12.loadConfig.call(void 0, {
32
- cwd: workspacePath,
33
- packageJson: true,
34
- name: fileName,
35
- envName: _optionalChain([fileName, 'optionalAccess', _3 => _3.toUpperCase, 'call', _4 => _4()]),
36
- jitiOptions: {
37
- debug: false,
38
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkM3REM2FUcjs.joinPaths.call(void 0,
39
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
40
- "jiti"
41
- )
42
- },
43
- configFile: fileName,
44
- ...options
45
- })
46
- ]);
47
- return _defu2.default.call(void 0, _nullishCoalesce(configs[0], () => ( {})), _nullishCoalesce(configs[1], () => ( {})));
48
- };
49
- var getConfigFile = async (filePath, additionalFileNames = []) => {
50
- const workspacePath = filePath ? filePath : _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, 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
- _chunk7STXZ7BNcjs.writeTrace.call(void 0,
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 (_optionalChain([result2, 'optionalAccess', _5 => _5.config]) && _optionalChain([result2, 'optionalAccess', _6 => _6.configFile]) && Object.keys(result2.config).length > 0) {
70
- if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
71
- _chunk7STXZ7BNcjs.writeTrace.call(void 0,
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 = _defu2.default.call(void 0, _nullishCoalesce(result2.config, () => ( {})), _nullishCoalesce(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
-
90
-
91
-
92
- exports.getConfigFileByName = getConfigFileByName; exports.getConfigFile = getConfigFile;
@@ -1,158 +0,0 @@
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 _chunkKH5SONKWcjs = require('./chunk-KH5SONKW.cjs');
4
-
5
-
6
- var _chunkBN6MEGGYcjs = require('./chunk-BN6MEGGY.cjs');
7
-
8
-
9
- var _chunk4PX5UVANcjs = require('./chunk-4PX5UVAN.cjs');
10
-
11
-
12
- var _chunkCTYIEJ7Ccjs = require('./chunk-CTYIEJ7C.cjs');
13
-
14
-
15
- var _chunkWBQ4VS7Ecjs = require('./chunk-WBQ4VS7E.cjs');
16
-
17
-
18
-
19
- var _chunkIRCFHYKZcjs = require('./chunk-IRCFHYKZ.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]) ? _chunkKH5SONKWcjs.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"]]) : _chunkKH5SONKWcjs.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(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_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(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_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(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_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;
@@ -1,40 +0,0 @@
1
- import {
2
- loadStormWorkspaceConfig,
3
- tryLoadStormWorkspaceConfig
4
- } from "./chunk-CMR737AZ.js";
5
- import {
6
- findWorkspaceRoot
7
- } from "./chunk-PTHGOJU6.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
- };
@@ -1,40 +0,0 @@
1
- import {
2
- getLogFn,
3
- getStopwatch
4
- } from "./chunk-JCPJSRHW.js";
5
- import {
6
- findWorkspaceRoot
7
- } from "./chunk-PTHGOJU6.js";
8
- import {
9
- LogLevel
10
- } from "./chunk-POXTJ6GF.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
- };
@@ -1,138 +0,0 @@
1
- import {
2
- setConfigEnv
3
- } from "./chunk-JB3OUBHN.js";
4
- import {
5
- getConfigEnv,
6
- getExtensionEnv
7
- } from "./chunk-SBTNBIMS.js";
8
- import {
9
- getConfigFile
10
- } from "./chunk-P7SO3C2J.js";
11
- import {
12
- formatLogMessage,
13
- writeTrace,
14
- writeWarning
15
- } from "./chunk-JCPJSRHW.js";
16
- import {
17
- applyDefaultConfig,
18
- getPackageJsonConfig
19
- } from "./chunk-SHD7ZUSQ.js";
20
- import {
21
- findWorkspaceRoot
22
- } from "./chunk-PTHGOJU6.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
- result = applyDefaultConfig(
51
- await stormWorkspaceConfigSchema.parseAsync(
52
- defu(configEnv, configFile, defaultConfig)
53
- )
54
- );
55
- result.workspaceRoot ??= _workspaceRoot;
56
- } else {
57
- result = _static_cache.data;
58
- }
59
- if (schema && extensionName) {
60
- result.extensions = {
61
- ...result.extensions,
62
- [extensionName]: createConfigExtension(extensionName, schema)
63
- };
64
- }
65
- _static_cache = {
66
- timestamp: Date.now(),
67
- data: result
68
- };
69
- return result;
70
- };
71
- var createConfigExtension = (extensionName, schema) => {
72
- const extension_cache_key = { extensionName };
73
- if (_extension_cache.has(extension_cache_key)) {
74
- return _extension_cache.get(extension_cache_key);
75
- }
76
- let extension = getExtensionEnv(extensionName);
77
- if (schema) {
78
- extension = schema.parse(extension);
79
- }
80
- _extension_cache.set(extension_cache_key, extension);
81
- return extension;
82
- };
83
- var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
84
- const config = await createStormWorkspaceConfig(
85
- void 0,
86
- void 0,
87
- workspaceRoot,
88
- skipLogs,
89
- true
90
- );
91
- setConfigEnv(config);
92
- if (!skipLogs && !config.skipConfigLogging) {
93
- writeTrace(
94
- `\u2699\uFE0F Using Storm Workspace configuration:
95
- ${formatLogMessage(config)}`,
96
- config
97
- );
98
- }
99
- return config;
100
- };
101
- var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
102
- try {
103
- const config = await createStormWorkspaceConfig(
104
- void 0,
105
- void 0,
106
- workspaceRoot,
107
- skipLogs,
108
- useDefault
109
- );
110
- if (!config) {
111
- return void 0;
112
- }
113
- setConfigEnv(config);
114
- if (!skipLogs && !config.skipConfigLogging) {
115
- writeTrace(
116
- `\u2699\uFE0F Using Storm Workspace configuration:
117
- ${formatLogMessage(config)}`,
118
- config
119
- );
120
- }
121
- return config;
122
- } catch (error) {
123
- if (!skipLogs) {
124
- writeWarning(
125
- `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
126
- { logLevel: "all" }
127
- );
128
- }
129
- return void 0;
130
- }
131
- };
132
-
133
- export {
134
- createStormWorkspaceConfig,
135
- createConfigExtension,
136
- loadStormWorkspaceConfig,
137
- tryLoadStormWorkspaceConfig
138
- };
@@ -1,55 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
- var _chunk7STXZ7BNcjs = require('./chunk-7STXZ7BN.cjs');
7
-
8
- // src/utilities/process-handler.ts
9
- var exitWithError = (config) => {
10
- _chunk7STXZ7BNcjs.writeFatal.call(void 0, "Exiting script with an error status...", config);
11
- process.exit(1);
12
- };
13
- var exitWithSuccess = (config) => {
14
- _chunk7STXZ7BNcjs.writeSuccess.call(void 0, "Script completed successfully. Exiting...", config);
15
- process.exit(0);
16
- };
17
- var handleProcess = (config) => {
18
- _chunk7STXZ7BNcjs.writeTrace.call(void 0,
19
- `Using the following arguments to process the script: ${process.argv.join(", ")}`,
20
- config
21
- );
22
- process.on("unhandledRejection", (error) => {
23
- _chunk7STXZ7BNcjs.writeError.call(void 0,
24
- `An Unhandled Rejection occurred while running the program: ${error}`,
25
- config
26
- );
27
- exitWithError(config);
28
- });
29
- process.on("uncaughtException", (error) => {
30
- _chunk7STXZ7BNcjs.writeError.call(void 0,
31
- `An Uncaught Exception occurred while running the program: ${error.message}
32
- Stacktrace: ${error.stack}`,
33
- config
34
- );
35
- exitWithError(config);
36
- });
37
- process.on("SIGTERM", (signal) => {
38
- _chunk7STXZ7BNcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
39
- exitWithError(config);
40
- });
41
- process.on("SIGINT", (signal) => {
42
- _chunk7STXZ7BNcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
43
- exitWithError(config);
44
- });
45
- process.on("SIGHUP", (signal) => {
46
- _chunk7STXZ7BNcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
47
- exitWithError(config);
48
- });
49
- };
50
-
51
-
52
-
53
-
54
-
55
- exports.exitWithError = exitWithError; exports.exitWithSuccess = exitWithSuccess; exports.handleProcess = handleProcess;
@@ -1,40 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
-
4
- var _chunk7STXZ7BNcjs = require('./chunk-7STXZ7BN.cjs');
5
-
6
-
7
- var _chunkU436743Ucjs = require('./chunk-U436743U.cjs');
8
-
9
-
10
- var _chunkIRCFHYKZcjs = require('./chunk-IRCFHYKZ.cjs');
11
-
12
- // src/logger/create-logger.ts
13
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
14
- async function createLogger(config) {
15
- const workspaceRoot = _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, );
16
- if (!workspaceRoot) {
17
- throw new Error("Cannot find workspace root");
18
- }
19
- const writeFatal = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.FATAL, config, _chalk2.default);
20
- const writeError = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.ERROR, config, _chalk2.default);
21
- const writeWarning = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.WARN, config, _chalk2.default);
22
- const writeInfo = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.INFO, config, _chalk2.default);
23
- const writeSuccess = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.SUCCESS, config, _chalk2.default);
24
- const writeDebug = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.DEBUG, config, _chalk2.default);
25
- const writeTrace = _chunk7STXZ7BNcjs.getLogFn.call(void 0, _chunkIRCFHYKZcjs.LogLevel.DEBUG, config, _chalk2.default);
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: _chunk7STXZ7BNcjs.getStopwatch
35
- };
36
- }
37
-
38
-
39
-
40
- exports.createLogger = createLogger;
@@ -1,55 +0,0 @@
1
- import {
2
- writeError,
3
- writeFatal,
4
- writeSuccess,
5
- writeTrace
6
- } from "./chunk-JCPJSRHW.js";
7
-
8
- // src/utilities/process-handler.ts
9
- var exitWithError = (config) => {
10
- writeFatal("Exiting script with an error status...", config);
11
- process.exit(1);
12
- };
13
- var exitWithSuccess = (config) => {
14
- writeSuccess("Script completed successfully. Exiting...", config);
15
- process.exit(0);
16
- };
17
- var handleProcess = (config) => {
18
- writeTrace(
19
- `Using the following arguments to process the script: ${process.argv.join(", ")}`,
20
- config
21
- );
22
- process.on("unhandledRejection", (error) => {
23
- writeError(
24
- `An Unhandled Rejection occurred while running the program: ${error}`,
25
- config
26
- );
27
- exitWithError(config);
28
- });
29
- process.on("uncaughtException", (error) => {
30
- writeError(
31
- `An Uncaught Exception occurred while running the program: ${error.message}
32
- Stacktrace: ${error.stack}`,
33
- config
34
- );
35
- exitWithError(config);
36
- });
37
- process.on("SIGTERM", (signal) => {
38
- writeError(`The program terminated with signal code: ${signal}`, config);
39
- exitWithError(config);
40
- });
41
- process.on("SIGINT", (signal) => {
42
- writeError(`The program terminated with signal code: ${signal}`, config);
43
- exitWithError(config);
44
- });
45
- process.on("SIGHUP", (signal) => {
46
- writeError(`The program terminated with signal code: ${signal}`, config);
47
- exitWithError(config);
48
- });
49
- };
50
-
51
- export {
52
- exitWithError,
53
- exitWithSuccess,
54
- handleProcess
55
- };
@@ -1,138 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkKYNO2VMScjs = require('./chunk-KYNO2VMS.cjs');
4
-
5
-
6
-
7
- var _chunkS2BDGENQcjs = require('./chunk-S2BDGENQ.cjs');
8
-
9
-
10
- var _chunk4G5FBDI6cjs = require('./chunk-4G5FBDI6.cjs');
11
-
12
-
13
-
14
-
15
- var _chunk7STXZ7BNcjs = require('./chunk-7STXZ7BN.cjs');
16
-
17
-
18
-
19
- var _chunkKH5SONKWcjs = require('./chunk-KH5SONKW.cjs');
20
-
21
-
22
- var _chunkU436743Ucjs = require('./chunk-U436743U.cjs');
23
-
24
- // src/create-storm-config.ts
25
- var _schema = require('@storm-software/config/schema');
26
- var _defu = require('defu'); var _defu2 = _interopRequireDefault(_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 (!_optionalChain([_static_cache, 'optionalAccess', _ => _.data]) || !_optionalChain([_static_cache, 'optionalAccess', _2 => _2.timestamp]) || _static_cache.timestamp < Date.now() - 8e3) {
32
- let _workspaceRoot = workspaceRoot;
33
- if (!_workspaceRoot) {
34
- _workspaceRoot = _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, );
35
- }
36
- const configEnv = _chunkS2BDGENQcjs.getConfigEnv.call(void 0, );
37
- const configFile = await _chunk4G5FBDI6cjs.getConfigFile.call(void 0, _workspaceRoot);
38
- if (!configFile) {
39
- if (!skipLogs) {
40
- _chunk7STXZ7BNcjs.writeWarning.call(void 0,
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 _chunkKH5SONKWcjs.getPackageJsonConfig.call(void 0, _workspaceRoot);
50
- result = _chunkKH5SONKWcjs.applyDefaultConfig.call(void 0,
51
- await _schema.stormWorkspaceConfigSchema.parseAsync(
52
- _defu2.default.call(void 0, configEnv, configFile, defaultConfig)
53
- )
54
- );
55
- result.workspaceRoot ??= _workspaceRoot;
56
- } else {
57
- result = _static_cache.data;
58
- }
59
- if (schema && extensionName) {
60
- result.extensions = {
61
- ...result.extensions,
62
- [extensionName]: createConfigExtension(extensionName, schema)
63
- };
64
- }
65
- _static_cache = {
66
- timestamp: Date.now(),
67
- data: result
68
- };
69
- return result;
70
- };
71
- var createConfigExtension = (extensionName, schema) => {
72
- const extension_cache_key = { extensionName };
73
- if (_extension_cache.has(extension_cache_key)) {
74
- return _extension_cache.get(extension_cache_key);
75
- }
76
- let extension = _chunkS2BDGENQcjs.getExtensionEnv.call(void 0, extensionName);
77
- if (schema) {
78
- extension = schema.parse(extension);
79
- }
80
- _extension_cache.set(extension_cache_key, extension);
81
- return extension;
82
- };
83
- var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
84
- const config = await createStormWorkspaceConfig(
85
- void 0,
86
- void 0,
87
- workspaceRoot,
88
- skipLogs,
89
- true
90
- );
91
- _chunkKYNO2VMScjs.setConfigEnv.call(void 0, config);
92
- if (!skipLogs && !config.skipConfigLogging) {
93
- _chunk7STXZ7BNcjs.writeTrace.call(void 0,
94
- `\u2699\uFE0F Using Storm Workspace configuration:
95
- ${_chunk7STXZ7BNcjs.formatLogMessage.call(void 0, config)}`,
96
- config
97
- );
98
- }
99
- return config;
100
- };
101
- var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
102
- try {
103
- const config = await createStormWorkspaceConfig(
104
- void 0,
105
- void 0,
106
- workspaceRoot,
107
- skipLogs,
108
- useDefault
109
- );
110
- if (!config) {
111
- return void 0;
112
- }
113
- _chunkKYNO2VMScjs.setConfigEnv.call(void 0, config);
114
- if (!skipLogs && !config.skipConfigLogging) {
115
- _chunk7STXZ7BNcjs.writeTrace.call(void 0,
116
- `\u2699\uFE0F Using Storm Workspace configuration:
117
- ${_chunk7STXZ7BNcjs.formatLogMessage.call(void 0, config)}`,
118
- config
119
- );
120
- }
121
- return config;
122
- } catch (error) {
123
- if (!skipLogs) {
124
- _chunk7STXZ7BNcjs.writeWarning.call(void 0,
125
- `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
126
- { logLevel: "all" }
127
- );
128
- }
129
- return void 0;
130
- }
131
- };
132
-
133
-
134
-
135
-
136
-
137
-
138
- exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.createConfigExtension = createConfigExtension; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
@@ -1,158 +0,0 @@
1
- import {
2
- DEFAULT_COLOR_CONFIG
3
- } from "./chunk-SHD7ZUSQ.js";
4
- import {
5
- formatTimestamp
6
- } from "./chunk-CZ4IE2QN.js";
7
- import {
8
- getLogLevel
9
- } from "./chunk-K4CDYUQR.js";
10
- import {
11
- getChalk
12
- } from "./chunk-P2KJ6EZO.js";
13
- import {
14
- CONSOLE_ICONS
15
- } from "./chunk-LM2UMGYA.js";
16
- import {
17
- LogLevel,
18
- LogLevelLabel
19
- } from "./chunk-POXTJ6GF.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
- };
@@ -1,92 +0,0 @@
1
- import {
2
- writeTrace
3
- } from "./chunk-JCPJSRHW.js";
4
- import {
5
- findWorkspaceRoot
6
- } from "./chunk-PTHGOJU6.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
- };
@@ -1,47 +0,0 @@
1
- import {
2
- writeError
3
- } from "./chunk-JCPJSRHW.js";
4
-
5
- // src/utilities/toml.ts
6
- import TOML from "@ltd/j-toml";
7
- function parseCargoTomlWithTree(tree, projectRoot, projectName) {
8
- const cargoTomlString = tree.read(`${projectRoot}/Cargo.toml`)?.toString();
9
- if (!cargoTomlString) {
10
- writeError(`Cannot find a Cargo.toml file in the ${projectName}`);
11
- throw new Error();
12
- }
13
- return parseCargoToml(cargoTomlString);
14
- }
15
- function parseCargoToml(cargoString) {
16
- if (!cargoString) {
17
- throw new Error("Cargo.toml is empty");
18
- }
19
- return TOML.parse(cargoString, {
20
- x: { comment: true }
21
- });
22
- }
23
- function stringifyCargoToml(cargoToml) {
24
- const tomlString = TOML.stringify(cargoToml, {
25
- newlineAround: "section"
26
- });
27
- if (Array.isArray(tomlString)) {
28
- return tomlString.join("\n");
29
- }
30
- return tomlString;
31
- }
32
- function modifyCargoTable(toml, section, key, value) {
33
- toml[section] ??= TOML.Section({});
34
- toml[section][key] = typeof value === "object" && !Array.isArray(value) ? TOML.inline(value) : typeof value === "function" ? value() : value;
35
- }
36
- function modifyCargoNestedTable(toml, section, key, value) {
37
- toml[section] ??= {};
38
- toml[section][key] = TOML.Section(value);
39
- }
40
-
41
- export {
42
- parseCargoTomlWithTree,
43
- parseCargoToml,
44
- stringifyCargoToml,
45
- modifyCargoTable,
46
- modifyCargoNestedTable
47
- };
@@ -1,40 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkFTTZBFXGcjs = require('./chunk-FTTZBFXG.cjs');
5
-
6
-
7
- var _chunkU436743Ucjs = require('./chunk-U436743U.cjs');
8
-
9
- // src/get-config.ts
10
- var getConfig = (workspaceRoot, skipLogs = false) => {
11
- return _chunkFTTZBFXGcjs.loadStormWorkspaceConfig.call(void 0, workspaceRoot, skipLogs);
12
- };
13
- var getWorkspaceConfig = (skipLogs = true, options = {}) => {
14
- let workspaceRoot = options.workspaceRoot;
15
- if (!workspaceRoot) {
16
- workspaceRoot = _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, 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 = _chunkU436743Ucjs.findWorkspaceRoot.call(void 0, options.cwd);
25
- }
26
- return _chunkFTTZBFXGcjs.tryLoadStormWorkspaceConfig.call(void 0,
27
- workspaceRoot,
28
- skipLogs,
29
- options.useDefault
30
- );
31
- } catch (e) {
32
- return void 0;
33
- }
34
- };
35
-
36
-
37
-
38
-
39
-
40
- exports.getConfig = getConfig; exports.getWorkspaceConfig = getWorkspaceConfig; exports.tryGetWorkspaceConfig = tryGetWorkspaceConfig;
@@ -1,47 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunk7STXZ7BNcjs = require('./chunk-7STXZ7BN.cjs');
4
-
5
- // src/utilities/toml.ts
6
- var _jtoml = require('@ltd/j-toml'); var _jtoml2 = _interopRequireDefault(_jtoml);
7
- function parseCargoTomlWithTree(tree, projectRoot, projectName) {
8
- const cargoTomlString = _optionalChain([tree, 'access', _ => _.read, 'call', _2 => _2(`${projectRoot}/Cargo.toml`), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
9
- if (!cargoTomlString) {
10
- _chunk7STXZ7BNcjs.writeError.call(void 0, `Cannot find a Cargo.toml file in the ${projectName}`);
11
- throw new Error();
12
- }
13
- return parseCargoToml(cargoTomlString);
14
- }
15
- function parseCargoToml(cargoString) {
16
- if (!cargoString) {
17
- throw new Error("Cargo.toml is empty");
18
- }
19
- return _jtoml2.default.parse(cargoString, {
20
- x: { comment: true }
21
- });
22
- }
23
- function stringifyCargoToml(cargoToml) {
24
- const tomlString = _jtoml2.default.stringify(cargoToml, {
25
- newlineAround: "section"
26
- });
27
- if (Array.isArray(tomlString)) {
28
- return tomlString.join("\n");
29
- }
30
- return tomlString;
31
- }
32
- function modifyCargoTable(toml, section, key, value) {
33
- toml[section] ??= _jtoml2.default.Section({});
34
- toml[section][key] = typeof value === "object" && !Array.isArray(value) ? _jtoml2.default.inline(value) : typeof value === "function" ? value() : value;
35
- }
36
- function modifyCargoNestedTable(toml, section, key, value) {
37
- toml[section] ??= {};
38
- toml[section][key] = _jtoml2.default.Section(value);
39
- }
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
- exports.parseCargoTomlWithTree = parseCargoTomlWithTree; exports.parseCargoToml = parseCargoToml; exports.stringifyCargoToml = stringifyCargoToml; exports.modifyCargoTable = modifyCargoTable; exports.modifyCargoNestedTable = modifyCargoNestedTable;