@storm-software/config-tools 1.169.3 → 1.169.5

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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/chunk-3HILQOD7.js +40 -0
  3. package/dist/chunk-3TLEBPG2.cjs +55 -0
  4. package/dist/chunk-4DF7JJF3.js +92 -0
  5. package/dist/chunk-7BYG54D7.cjs +40 -0
  6. package/dist/chunk-BISNOW2V.cjs +47 -0
  7. package/dist/chunk-BYLFGW3E.cjs +40 -0
  8. package/dist/chunk-DBNZROVM.js +40 -0
  9. package/dist/chunk-FE4JVWUW.js +135 -0
  10. package/dist/chunk-G6IQUR2B.js +47 -0
  11. package/dist/chunk-GK6OSUUD.js +135 -0
  12. package/dist/chunk-GMHWE7ZI.js +55 -0
  13. package/dist/chunk-JYKZS46U.cjs +158 -0
  14. package/dist/chunk-PKYL423F.cjs +135 -0
  15. package/dist/chunk-Q6MCB3G2.cjs +92 -0
  16. package/dist/chunk-QPYH54PX.cjs +135 -0
  17. package/dist/chunk-SA3JCBON.js +158 -0
  18. package/dist/chunk-VTGRS36E.cjs +40 -0
  19. package/dist/chunk-YGCYQLTS.js +40 -0
  20. package/dist/config-file/get-config-file.cjs +8 -8
  21. package/dist/config-file/get-config-file.js +7 -7
  22. package/dist/config-file/index.cjs +8 -8
  23. package/dist/config-file/index.js +7 -7
  24. package/dist/create-storm-config.cjs +10 -10
  25. package/dist/create-storm-config.js +9 -9
  26. package/dist/env/index.cjs +2 -2
  27. package/dist/env/index.js +4 -4
  28. package/dist/get-config.cjs +11 -11
  29. package/dist/get-config.js +10 -10
  30. package/dist/index.cjs +17 -17
  31. package/dist/index.js +18 -18
  32. package/dist/logger/console.cjs +4 -4
  33. package/dist/logger/console.js +3 -3
  34. package/dist/logger/create-logger.cjs +5 -5
  35. package/dist/logger/create-logger.js +4 -4
  36. package/dist/logger/index.cjs +8 -8
  37. package/dist/logger/index.js +8 -8
  38. package/dist/utilities/index.cjs +7 -7
  39. package/dist/utilities/index.js +6 -6
  40. package/dist/utilities/process-handler.cjs +5 -5
  41. package/dist/utilities/process-handler.js +4 -4
  42. package/dist/utilities/toml.cjs +6 -6
  43. package/dist/utilities/toml.js +5 -5
  44. package/package.json +2 -2
@@ -0,0 +1,55 @@
1
+ import {
2
+ writeError,
3
+ writeFatal,
4
+ writeSuccess,
5
+ writeTrace
6
+ } from "./chunk-SA3JCBON.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
+ };
@@ -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 _chunkGIXUQACBcjs = require('./chunk-GIXUQACB.cjs');
4
+
5
+
6
+ var _chunkPSHJQ2NPcjs = require('./chunk-PSHJQ2NP.cjs');
7
+
8
+
9
+ var _chunkQNDF3RQLcjs = require('./chunk-QNDF3RQL.cjs');
10
+
11
+
12
+ var _chunk7BZWQZUVcjs = require('./chunk-7BZWQZUV.cjs');
13
+
14
+
15
+
16
+ var _chunkC5OTFOQBcjs = require('./chunk-C5OTFOQB.cjs');
17
+
18
+
19
+ var _chunkNS5PJ2RMcjs = require('./chunk-NS5PJ2RM.cjs');
20
+
21
+ // src/logger/console.ts
22
+ var getLogFn = (logLevel = _chunkC5OTFOQBcjs.LogLevel.INFO, config = {}, _chalk = _chunkNS5PJ2RMcjs.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]) ? _chunkGIXUQACBcjs.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"]]) : _chunkGIXUQACBcjs.DEFAULT_COLOR_CONFIG;
24
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || _chunkC5OTFOQBcjs.LogLevelLabel.INFO;
25
+ if (logLevel > _chunk7BZWQZUVcjs.getLogLevel.call(void 0, configLogLevel) || logLevel <= _chunkC5OTFOQBcjs.LogLevel.SILENT || _chunk7BZWQZUVcjs.getLogLevel.call(void 0, configLogLevel) <= _chunkC5OTFOQBcjs.LogLevel.SILENT) {
26
+ return (_) => {
27
+ };
28
+ }
29
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.FATAL >= logLevel) {
30
+ return (message) => {
31
+ console.error(
32
+ `
33
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.fatal, () => ( "#7d1a1a")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
34
+ `
35
+ );
36
+ };
37
+ }
38
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.ERROR >= logLevel) {
39
+ return (message) => {
40
+ console.error(
41
+ `
42
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.danger, () => ( "#f85149")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
43
+ `
44
+ );
45
+ };
46
+ }
47
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.WARN >= logLevel) {
48
+ return (message) => {
49
+ console.warn(
50
+ `
51
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.warning, () => ( "#e3b341")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
52
+ `
53
+ );
54
+ };
55
+ }
56
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.SUCCESS >= logLevel) {
57
+ return (message) => {
58
+ console.info(
59
+ `
60
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.success, () => ( "#56d364")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
61
+ `
62
+ );
63
+ };
64
+ }
65
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.INFO >= logLevel) {
66
+ return (message) => {
67
+ console.info(
68
+ `
69
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( "#58a6ff")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
70
+ `
71
+ );
72
+ };
73
+ }
74
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.DEBUG >= logLevel) {
75
+ return (message) => {
76
+ console.debug(
77
+ `
78
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
79
+ `
80
+ );
81
+ };
82
+ }
83
+ if (typeof logLevel === "number" && _chunkC5OTFOQBcjs.LogLevel.TRACE >= logLevel) {
84
+ return (message) => {
85
+ console.debug(
86
+ `
87
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
88
+ `
89
+ );
90
+ };
91
+ }
92
+ return (message) => {
93
+ console.log(
94
+ `
95
+ ${_chalk.gray(_chunkQNDF3RQLcjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkPSHJQ2NPcjs.CONSOLE_ICONS[_chunkC5OTFOQBcjs.LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
96
+ `
97
+ );
98
+ };
99
+ };
100
+ var writeFatal = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.FATAL, config)(message);
101
+ var writeError = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.ERROR, config)(message);
102
+ var writeWarning = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.WARN, config)(message);
103
+ var writeInfo = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.INFO, config)(message);
104
+ var writeSuccess = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.SUCCESS, config)(message);
105
+ var writeDebug = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.DEBUG, config)(message);
106
+ var writeTrace = (message, config) => getLogFn(_chunkC5OTFOQBcjs.LogLevel.TRACE, config)(message);
107
+ var writeSystem = (message, config) => getLogFn(_chunkC5OTFOQBcjs.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;
@@ -0,0 +1,135 @@
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
+
4
+ var _chunk56NGBR4Scjs = require('./chunk-56NGBR4S.cjs');
5
+
6
+
7
+ var _chunkH425P7G5cjs = require('./chunk-H425P7G5.cjs');
8
+
9
+
10
+ var _chunk7HCUD67Dcjs = require('./chunk-7HCUD67D.cjs');
11
+
12
+
13
+
14
+
15
+ var _chunk7SIKKF62cjs = require('./chunk-7SIKKF62.cjs');
16
+
17
+
18
+ var _chunkGIXUQACBcjs = require('./chunk-GIXUQACB.cjs');
19
+
20
+
21
+ var _chunkAEZINHEAcjs = require('./chunk-AEZINHEA.cjs');
22
+
23
+ // src/create-storm-config.ts
24
+ var _schema = require('@storm-software/config/schema');
25
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
26
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
27
+ var _static_cache = void 0;
28
+ var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
29
+ let result;
30
+ if (!_optionalChain([_static_cache, 'optionalAccess', _ => _.data]) || !_optionalChain([_static_cache, 'optionalAccess', _2 => _2.timestamp]) || _static_cache.timestamp < Date.now() - 8e3) {
31
+ let _workspaceRoot = workspaceRoot;
32
+ if (!_workspaceRoot) {
33
+ _workspaceRoot = _chunkAEZINHEAcjs.findWorkspaceRoot.call(void 0, );
34
+ }
35
+ const configEnv = _chunk56NGBR4Scjs.getConfigEnv.call(void 0, );
36
+ const configFile = await _chunk7HCUD67Dcjs.getConfigFile.call(void 0, _workspaceRoot);
37
+ if (!configFile) {
38
+ if (!skipLogs) {
39
+ _chunk7SIKKF62cjs.writeWarning.call(void 0,
40
+ "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",
41
+ { logLevel: "all" }
42
+ );
43
+ }
44
+ if (useDefault === false) {
45
+ return void 0;
46
+ }
47
+ }
48
+ const defaultConfig = await _chunkGIXUQACBcjs.getDefaultConfig.call(void 0, _workspaceRoot);
49
+ result = await _schema.stormWorkspaceConfigSchema.parseAsync(
50
+ _defu2.default.call(void 0, configEnv, configFile, defaultConfig)
51
+ );
52
+ result.workspaceRoot ??= _workspaceRoot;
53
+ } else {
54
+ result = _static_cache.data;
55
+ }
56
+ if (schema && extensionName) {
57
+ result.extensions = {
58
+ ...result.extensions,
59
+ [extensionName]: createConfigExtension(extensionName, schema)
60
+ };
61
+ }
62
+ _static_cache = {
63
+ timestamp: Date.now(),
64
+ data: result
65
+ };
66
+ return result;
67
+ };
68
+ var createConfigExtension = (extensionName, schema) => {
69
+ const extension_cache_key = { extensionName };
70
+ if (_extension_cache.has(extension_cache_key)) {
71
+ return _extension_cache.get(extension_cache_key);
72
+ }
73
+ let extension = _chunk56NGBR4Scjs.getExtensionEnv.call(void 0, extensionName);
74
+ if (schema) {
75
+ extension = schema.parse(extension);
76
+ }
77
+ _extension_cache.set(extension_cache_key, extension);
78
+ return extension;
79
+ };
80
+ var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
81
+ const config = await createStormWorkspaceConfig(
82
+ void 0,
83
+ void 0,
84
+ workspaceRoot,
85
+ skipLogs,
86
+ true
87
+ );
88
+ _chunkH425P7G5cjs.setConfigEnv.call(void 0, config);
89
+ if (!skipLogs && !config.skipConfigLogging) {
90
+ _chunk7SIKKF62cjs.writeTrace.call(void 0,
91
+ `\u2699\uFE0F Using Storm Workspace configuration:
92
+ ${_chunk7SIKKF62cjs.formatLogMessage.call(void 0, config)}`,
93
+ config
94
+ );
95
+ }
96
+ return config;
97
+ };
98
+ var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
99
+ try {
100
+ const config = await createStormWorkspaceConfig(
101
+ void 0,
102
+ void 0,
103
+ workspaceRoot,
104
+ skipLogs,
105
+ useDefault
106
+ );
107
+ if (!config) {
108
+ return void 0;
109
+ }
110
+ _chunkH425P7G5cjs.setConfigEnv.call(void 0, config);
111
+ if (!skipLogs && !config.skipConfigLogging) {
112
+ _chunk7SIKKF62cjs.writeTrace.call(void 0,
113
+ `\u2699\uFE0F Using Storm Workspace configuration:
114
+ ${_chunk7SIKKF62cjs.formatLogMessage.call(void 0, config)}`,
115
+ config
116
+ );
117
+ }
118
+ return config;
119
+ } catch (error) {
120
+ if (!skipLogs) {
121
+ _chunk7SIKKF62cjs.writeWarning.call(void 0,
122
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
123
+ { logLevel: "all" }
124
+ );
125
+ }
126
+ return void 0;
127
+ }
128
+ };
129
+
130
+
131
+
132
+
133
+
134
+
135
+ exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.createConfigExtension = createConfigExtension; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
@@ -0,0 +1,92 @@
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 _chunkJYKZS46Ucjs = require('./chunk-JYKZS46U.cjs');
4
+
5
+
6
+ var _chunkAEZINHEAcjs = require('./chunk-AEZINHEA.cjs');
7
+
8
+
9
+ var _chunk4JREL2GQcjs = require('./chunk-4JREL2GQ.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 || _chunkAEZINHEAcjs.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 : _chunk4JREL2GQcjs.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 : _chunk4JREL2GQcjs.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 : _chunkAEZINHEAcjs.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
+ _chunkJYKZS46Ucjs.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
+ _chunkJYKZS46Ucjs.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;
@@ -0,0 +1,135 @@
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 _chunkQ6MCB3G2cjs = require('./chunk-Q6MCB3G2.cjs');
4
+
5
+
6
+
7
+
8
+ var _chunkJYKZS46Ucjs = require('./chunk-JYKZS46U.cjs');
9
+
10
+
11
+ var _chunkGIXUQACBcjs = require('./chunk-GIXUQACB.cjs');
12
+
13
+
14
+ var _chunkAEZINHEAcjs = require('./chunk-AEZINHEA.cjs');
15
+
16
+
17
+
18
+ var _chunk56NGBR4Scjs = require('./chunk-56NGBR4S.cjs');
19
+
20
+
21
+ var _chunkH425P7G5cjs = require('./chunk-H425P7G5.cjs');
22
+
23
+ // src/create-storm-config.ts
24
+ var _schema = require('@storm-software/config/schema');
25
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
26
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
27
+ var _static_cache = void 0;
28
+ var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
29
+ let result;
30
+ if (!_optionalChain([_static_cache, 'optionalAccess', _ => _.data]) || !_optionalChain([_static_cache, 'optionalAccess', _2 => _2.timestamp]) || _static_cache.timestamp < Date.now() - 8e3) {
31
+ let _workspaceRoot = workspaceRoot;
32
+ if (!_workspaceRoot) {
33
+ _workspaceRoot = _chunkAEZINHEAcjs.findWorkspaceRoot.call(void 0, );
34
+ }
35
+ const configEnv = _chunk56NGBR4Scjs.getConfigEnv.call(void 0, );
36
+ const configFile = await _chunkQ6MCB3G2cjs.getConfigFile.call(void 0, _workspaceRoot);
37
+ if (!configFile) {
38
+ if (!skipLogs) {
39
+ _chunkJYKZS46Ucjs.writeWarning.call(void 0,
40
+ "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",
41
+ { logLevel: "all" }
42
+ );
43
+ }
44
+ if (useDefault === false) {
45
+ return void 0;
46
+ }
47
+ }
48
+ const defaultConfig = await _chunkGIXUQACBcjs.getDefaultConfig.call(void 0, _workspaceRoot);
49
+ result = await _schema.stormWorkspaceConfigSchema.parseAsync(
50
+ _defu2.default.call(void 0, configEnv, configFile, defaultConfig)
51
+ );
52
+ result.workspaceRoot ??= _workspaceRoot;
53
+ } else {
54
+ result = _static_cache.data;
55
+ }
56
+ if (schema && extensionName) {
57
+ result.extensions = {
58
+ ...result.extensions,
59
+ [extensionName]: createConfigExtension(extensionName, schema)
60
+ };
61
+ }
62
+ _static_cache = {
63
+ timestamp: Date.now(),
64
+ data: result
65
+ };
66
+ return result;
67
+ };
68
+ var createConfigExtension = (extensionName, schema) => {
69
+ const extension_cache_key = { extensionName };
70
+ if (_extension_cache.has(extension_cache_key)) {
71
+ return _extension_cache.get(extension_cache_key);
72
+ }
73
+ let extension = _chunk56NGBR4Scjs.getExtensionEnv.call(void 0, extensionName);
74
+ if (schema) {
75
+ extension = schema.parse(extension);
76
+ }
77
+ _extension_cache.set(extension_cache_key, extension);
78
+ return extension;
79
+ };
80
+ var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
81
+ const config = await createStormWorkspaceConfig(
82
+ void 0,
83
+ void 0,
84
+ workspaceRoot,
85
+ skipLogs,
86
+ true
87
+ );
88
+ _chunkH425P7G5cjs.setConfigEnv.call(void 0, config);
89
+ if (!skipLogs && !config.skipConfigLogging) {
90
+ _chunkJYKZS46Ucjs.writeTrace.call(void 0,
91
+ `\u2699\uFE0F Using Storm Workspace configuration:
92
+ ${_chunkJYKZS46Ucjs.formatLogMessage.call(void 0, config)}`,
93
+ config
94
+ );
95
+ }
96
+ return config;
97
+ };
98
+ var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
99
+ try {
100
+ const config = await createStormWorkspaceConfig(
101
+ void 0,
102
+ void 0,
103
+ workspaceRoot,
104
+ skipLogs,
105
+ useDefault
106
+ );
107
+ if (!config) {
108
+ return void 0;
109
+ }
110
+ _chunkH425P7G5cjs.setConfigEnv.call(void 0, config);
111
+ if (!skipLogs && !config.skipConfigLogging) {
112
+ _chunkJYKZS46Ucjs.writeTrace.call(void 0,
113
+ `\u2699\uFE0F Using Storm Workspace configuration:
114
+ ${_chunkJYKZS46Ucjs.formatLogMessage.call(void 0, config)}`,
115
+ config
116
+ );
117
+ }
118
+ return config;
119
+ } catch (error) {
120
+ if (!skipLogs) {
121
+ _chunkJYKZS46Ucjs.writeWarning.call(void 0,
122
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
123
+ { logLevel: "all" }
124
+ );
125
+ }
126
+ return void 0;
127
+ }
128
+ };
129
+
130
+
131
+
132
+
133
+
134
+
135
+ exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.createConfigExtension = createConfigExtension; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;