@storm-software/config-tools 1.190.19 → 1.190.21

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 (53) hide show
  1. package/bin/config.cjs +9 -3
  2. package/bin/config.js +9 -3
  3. package/dist/{chunk-FXQGOFJI.js → chunk-2JA3KDUW.js} +1 -1
  4. package/dist/{chunk-TIH4RSTL.js → chunk-3SX4SLEU.js} +1 -1
  5. package/dist/{chunk-4UFIHIMZ.js → chunk-4IHL3E5M.js} +37 -31
  6. package/dist/{chunk-KRVACLYZ.cjs → chunk-5OYYSFK5.cjs} +3 -3
  7. package/dist/{chunk-QXMSQMVN.cjs → chunk-7YIRETM2.cjs} +14 -14
  8. package/dist/{chunk-DFWIRJGH.cjs → chunk-BEFNWKPD.cjs} +3 -3
  9. package/dist/{chunk-AZJQFL6W.cjs → chunk-BF4MDUTR.cjs} +37 -31
  10. package/dist/{chunk-MOXINQRL.js → chunk-BUB7FBXA.js} +1 -1
  11. package/dist/{chunk-VEYONVTU.js → chunk-C47DWQVX.js} +1 -1
  12. package/dist/{chunk-5NAMOQCY.js → chunk-CBM6ZRFO.js} +1 -1
  13. package/dist/{chunk-44SHQAD4.cjs → chunk-DPHVF4QR.cjs} +10 -10
  14. package/dist/{chunk-UWI3QVYJ.js → chunk-DW5363CG.js} +9 -9
  15. package/dist/chunk-EYNQLRTA.cjs +165 -0
  16. package/dist/{chunk-R5BZDTQW.cjs → chunk-FOAMXVC2.cjs} +2 -2
  17. package/dist/chunk-FZ2ZJFWB.js +165 -0
  18. package/dist/{chunk-TW273ZN4.cjs → chunk-GXRAHLKT.cjs} +9 -9
  19. package/dist/chunk-H7J7UFAV.cjs +47 -0
  20. package/dist/chunk-IMRWBPKB.cjs +35 -0
  21. package/dist/chunk-JLLNUKG7.cjs +55 -0
  22. package/dist/chunk-KKF5NXBI.js +40 -0
  23. package/dist/chunk-MNUSVN5B.js +55 -0
  24. package/dist/chunk-NFL55S75.cjs +40 -0
  25. package/dist/chunk-NT26TB4H.js +92 -0
  26. package/dist/chunk-O76J367J.js +947 -0
  27. package/dist/chunk-SN6BVPYU.cjs +92 -0
  28. package/dist/chunk-T35FQNUH.cjs +947 -0
  29. package/dist/chunk-TAD4S6KA.js +47 -0
  30. package/dist/chunk-TLZTD7WU.js +35 -0
  31. package/dist/config-file/get-config-file.cjs +9 -9
  32. package/dist/config-file/get-config-file.js +8 -8
  33. package/dist/config-file/index.cjs +9 -9
  34. package/dist/config-file/index.js +8 -8
  35. package/dist/create-storm-config.cjs +12 -12
  36. package/dist/create-storm-config.js +11 -11
  37. package/dist/get-config.cjs +13 -13
  38. package/dist/get-config.js +12 -12
  39. package/dist/index.cjs +23 -23
  40. package/dist/index.js +25 -25
  41. package/dist/logger/console.cjs +4 -4
  42. package/dist/logger/console.js +3 -3
  43. package/dist/logger/create-logger.cjs +5 -5
  44. package/dist/logger/create-logger.js +4 -4
  45. package/dist/logger/index.cjs +8 -8
  46. package/dist/logger/index.js +10 -10
  47. package/dist/utilities/index.cjs +8 -8
  48. package/dist/utilities/index.js +7 -7
  49. package/dist/utilities/process-handler.cjs +5 -5
  50. package/dist/utilities/process-handler.js +4 -4
  51. package/dist/utilities/toml.cjs +6 -6
  52. package/dist/utilities/toml.js +5 -5
  53. package/package.json +5 -5
@@ -0,0 +1,165 @@
1
+ import {
2
+ getConfigFile
3
+ } from "./chunk-2JA3KDUW.js";
4
+ import {
5
+ applyDefaultConfig,
6
+ getPackageJsonConfig
7
+ } from "./chunk-RGET2UQV.js";
8
+ import {
9
+ findWorkspaceRoot
10
+ } from "./chunk-LF3SAK2O.js";
11
+ import {
12
+ formatLogMessage,
13
+ writeTrace,
14
+ writeWarning
15
+ } from "./chunk-4IHL3E5M.js";
16
+ import {
17
+ setConfigEnv
18
+ } from "./chunk-SDSQ2HHF.js";
19
+ import {
20
+ getConfigEnv,
21
+ getExtensionEnv
22
+ } from "./chunk-A5JXMY6X.js";
23
+ import {
24
+ joinPaths
25
+ } from "./chunk-V3GMJ4TX.js";
26
+
27
+ // src/create-storm-config.ts
28
+ import { workspaceConfigSchema } from "@storm-software/config/schema";
29
+ import defu from "defu";
30
+ import { existsSync } from "node:fs";
31
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
32
+ var _static_cache = void 0;
33
+ var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
34
+ let result;
35
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
36
+ let _workspaceRoot = workspaceRoot;
37
+ if (!_workspaceRoot) {
38
+ _workspaceRoot = findWorkspaceRoot();
39
+ }
40
+ const configEnv = getConfigEnv();
41
+ const configFile = await getConfigFile(_workspaceRoot);
42
+ if (!configFile) {
43
+ if (!skipLogs) {
44
+ writeWarning(
45
+ "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",
46
+ { logLevel: "all" }
47
+ );
48
+ }
49
+ if (useDefault === false) {
50
+ return void 0;
51
+ }
52
+ }
53
+ const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
54
+ const configInput = defu(
55
+ configEnv,
56
+ configFile,
57
+ defaultConfig
58
+ );
59
+ if (!configInput.variant) {
60
+ configInput.variant = existsSync(joinPaths(_workspaceRoot, "nx.json")) || existsSync(joinPaths(_workspaceRoot, ".nx")) || existsSync(joinPaths(_workspaceRoot, "lerna.json")) || existsSync(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
61
+ }
62
+ try {
63
+ const parseResult = await Promise.resolve(
64
+ workspaceConfigSchema._zod.parse(
65
+ { value: configInput, issues: [] },
66
+ { async: true }
67
+ )
68
+ );
69
+ result = applyDefaultConfig(parseResult.value);
70
+ result.workspaceRoot ??= _workspaceRoot;
71
+ } catch (error) {
72
+ throw new Error(
73
+ `Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
74
+
75
+ Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(
76
+ configInput
77
+ )}`,
78
+ {
79
+ cause: error
80
+ }
81
+ );
82
+ }
83
+ } else {
84
+ result = _static_cache.data;
85
+ }
86
+ if (schema && extensionName) {
87
+ result.extensions = {
88
+ ...result.extensions,
89
+ [extensionName]: createConfigExtension(extensionName, schema)
90
+ };
91
+ }
92
+ _static_cache = {
93
+ timestamp: Date.now(),
94
+ data: result
95
+ };
96
+ return result;
97
+ };
98
+ var createConfigExtension = (extensionName, schema) => {
99
+ const extension_cache_key = { extensionName };
100
+ if (_extension_cache.has(extension_cache_key)) {
101
+ return _extension_cache.get(extension_cache_key);
102
+ }
103
+ let extension = getExtensionEnv(extensionName);
104
+ if (schema) {
105
+ extension = schema.parse(extension);
106
+ }
107
+ _extension_cache.set(extension_cache_key, extension);
108
+ return extension;
109
+ };
110
+ var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
111
+ const config = await createStormWorkspaceConfig(
112
+ void 0,
113
+ void 0,
114
+ workspaceRoot,
115
+ skipLogs,
116
+ true
117
+ );
118
+ setConfigEnv(config);
119
+ if (!skipLogs && !config.skipConfigLogging) {
120
+ writeTrace(
121
+ `\u2699\uFE0F Using Storm Workspace configuration:
122
+ ${formatLogMessage(config)}`,
123
+ config
124
+ );
125
+ }
126
+ return config;
127
+ };
128
+ var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
129
+ try {
130
+ const config = await createStormWorkspaceConfig(
131
+ void 0,
132
+ void 0,
133
+ workspaceRoot,
134
+ skipLogs,
135
+ useDefault
136
+ );
137
+ if (!config) {
138
+ return void 0;
139
+ }
140
+ setConfigEnv(config);
141
+ if (!skipLogs && !config.skipConfigLogging) {
142
+ writeTrace(
143
+ `\u2699\uFE0F Using Storm Workspace configuration:
144
+ ${formatLogMessage(config)}`,
145
+ config
146
+ );
147
+ }
148
+ return config;
149
+ } catch (error) {
150
+ if (!skipLogs) {
151
+ writeWarning(
152
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
153
+ { logLevel: "all" }
154
+ );
155
+ }
156
+ return void 0;
157
+ }
158
+ };
159
+
160
+ export {
161
+ createStormWorkspaceConfig,
162
+ createConfigExtension,
163
+ loadStormWorkspaceConfig,
164
+ tryLoadStormWorkspaceConfig
165
+ };
@@ -3,31 +3,31 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkAZJQFL6Wcjs = require('./chunk-AZJQFL6W.cjs');
6
+ var _chunkBF4MDUTRcjs = require('./chunk-BF4MDUTR.cjs');
7
7
 
8
8
  // src/utilities/process-handler.ts
9
9
  var exitWithError = (config) => {
10
- _chunkAZJQFL6Wcjs.writeFatal.call(void 0, "Exiting script with an error status...", config);
10
+ _chunkBF4MDUTRcjs.writeFatal.call(void 0, "Exiting script with an error status...", config);
11
11
  process.exit(1);
12
12
  };
13
13
  var exitWithSuccess = (config) => {
14
- _chunkAZJQFL6Wcjs.writeSuccess.call(void 0, "Script completed successfully. Exiting...", config);
14
+ _chunkBF4MDUTRcjs.writeSuccess.call(void 0, "Script completed successfully. Exiting...", config);
15
15
  process.exit(0);
16
16
  };
17
17
  var handleProcess = (config) => {
18
- _chunkAZJQFL6Wcjs.writeTrace.call(void 0,
18
+ _chunkBF4MDUTRcjs.writeTrace.call(void 0,
19
19
  `Using the following arguments to process the script: ${process.argv.join(", ")}`,
20
20
  config
21
21
  );
22
22
  process.on("unhandledRejection", (error) => {
23
- _chunkAZJQFL6Wcjs.writeError.call(void 0,
23
+ _chunkBF4MDUTRcjs.writeError.call(void 0,
24
24
  `An Unhandled Rejection occurred while running the program: ${error}`,
25
25
  config
26
26
  );
27
27
  exitWithError(config);
28
28
  });
29
29
  process.on("uncaughtException", (error) => {
30
- _chunkAZJQFL6Wcjs.writeError.call(void 0,
30
+ _chunkBF4MDUTRcjs.writeError.call(void 0,
31
31
  `An Uncaught Exception occurred while running the program: ${error.message}
32
32
  Stacktrace: ${error.stack}`,
33
33
  config
@@ -35,15 +35,15 @@ Stacktrace: ${error.stack}`,
35
35
  exitWithError(config);
36
36
  });
37
37
  process.on("SIGTERM", (signal) => {
38
- _chunkAZJQFL6Wcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
38
+ _chunkBF4MDUTRcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
39
39
  exitWithError(config);
40
40
  });
41
41
  process.on("SIGINT", (signal) => {
42
- _chunkAZJQFL6Wcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
42
+ _chunkBF4MDUTRcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
43
43
  exitWithError(config);
44
44
  });
45
45
  process.on("SIGHUP", (signal) => {
46
- _chunkAZJQFL6Wcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
46
+ _chunkBF4MDUTRcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
47
47
  exitWithError(config);
48
48
  });
49
49
  };
@@ -0,0 +1,47 @@
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 _chunkBF4MDUTRcjs = require('./chunk-BF4MDUTR.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
+ _chunkBF4MDUTRcjs.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;
@@ -0,0 +1,35 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+
4
+ var _chunkBF4MDUTRcjs = require('./chunk-BF4MDUTR.cjs');
5
+
6
+
7
+ var _chunk7QBTVNMRcjs = require('./chunk-7QBTVNMR.cjs');
8
+
9
+ // src/logger/create-logger.ts
10
+ var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
11
+ async function createLogger(config) {
12
+ const writeFatal = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.FATAL, config, { chalk: _chalk2.default });
13
+ const writeError = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.ERROR, config, { chalk: _chalk2.default });
14
+ const writeWarning = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.WARN, config, { chalk: _chalk2.default });
15
+ const writeInfo = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.INFO, config, { chalk: _chalk2.default });
16
+ const writeSuccess = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.SUCCESS, config, { chalk: _chalk2.default });
17
+ const writeDebug = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.DEBUG, config, { chalk: _chalk2.default });
18
+ const writePerformance = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.PERFORMANCE, config, { chalk: _chalk2.default });
19
+ const writeTrace = _chunkBF4MDUTRcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.TRACE, config, { chalk: _chalk2.default });
20
+ return {
21
+ fatal: writeFatal,
22
+ error: writeError,
23
+ warning: writeWarning,
24
+ info: writeInfo,
25
+ success: writeSuccess,
26
+ performance: writePerformance,
27
+ debug: writeDebug,
28
+ trace: writeTrace,
29
+ getStopwatch: _chunkBF4MDUTRcjs.getStopwatch
30
+ };
31
+ }
32
+
33
+
34
+
35
+ exports.createLogger = createLogger;
@@ -0,0 +1,55 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+ var _chunkT35FQNUHcjs = require('./chunk-T35FQNUH.cjs');
7
+
8
+ // src/utilities/process-handler.ts
9
+ var exitWithError = (config) => {
10
+ _chunkT35FQNUHcjs.writeFatal.call(void 0, "Exiting script with an error status...", config);
11
+ process.exit(1);
12
+ };
13
+ var exitWithSuccess = (config) => {
14
+ _chunkT35FQNUHcjs.writeSuccess.call(void 0, "Script completed successfully. Exiting...", config);
15
+ process.exit(0);
16
+ };
17
+ var handleProcess = (config) => {
18
+ _chunkT35FQNUHcjs.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
+ _chunkT35FQNUHcjs.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
+ _chunkT35FQNUHcjs.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
+ _chunkT35FQNUHcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
39
+ exitWithError(config);
40
+ });
41
+ process.on("SIGINT", (signal) => {
42
+ _chunkT35FQNUHcjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
43
+ exitWithError(config);
44
+ });
45
+ process.on("SIGHUP", (signal) => {
46
+ _chunkT35FQNUHcjs.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;
@@ -0,0 +1,40 @@
1
+ import {
2
+ loadStormWorkspaceConfig,
3
+ tryLoadStormWorkspaceConfig
4
+ } from "./chunk-DW5363CG.js";
5
+ import {
6
+ findWorkspaceRoot
7
+ } from "./chunk-LF3SAK2O.js";
8
+
9
+ // src/get-config.ts
10
+ function getConfig(workspaceRoot, skipLogs = false) {
11
+ return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
12
+ }
13
+ function 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
+ async function tryGetWorkspaceConfig(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,55 @@
1
+ import {
2
+ writeError,
3
+ writeFatal,
4
+ writeSuccess,
5
+ writeTrace
6
+ } from "./chunk-4IHL3E5M.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,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkEYNQLRTAcjs = require('./chunk-EYNQLRTA.cjs');
5
+
6
+
7
+ var _chunk3CNCDDWZcjs = require('./chunk-3CNCDDWZ.cjs');
8
+
9
+ // src/get-config.ts
10
+ function getConfig(workspaceRoot, skipLogs = false) {
11
+ return _chunkEYNQLRTAcjs.loadStormWorkspaceConfig.call(void 0, workspaceRoot, skipLogs);
12
+ }
13
+ function getWorkspaceConfig(skipLogs = true, options = {}) {
14
+ let workspaceRoot = options.workspaceRoot;
15
+ if (!workspaceRoot) {
16
+ workspaceRoot = _chunk3CNCDDWZcjs.findWorkspaceRoot.call(void 0, options.cwd);
17
+ }
18
+ return getConfig(workspaceRoot, skipLogs);
19
+ }
20
+ async function tryGetWorkspaceConfig(skipLogs = true, options = {}) {
21
+ try {
22
+ let workspaceRoot = options.workspaceRoot;
23
+ if (!workspaceRoot) {
24
+ workspaceRoot = _chunk3CNCDDWZcjs.findWorkspaceRoot.call(void 0, options.cwd);
25
+ }
26
+ return _chunkEYNQLRTAcjs.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;
@@ -0,0 +1,92 @@
1
+ import {
2
+ findWorkspaceRoot
3
+ } from "./chunk-LF3SAK2O.js";
4
+ import {
5
+ writeTrace
6
+ } from "./chunk-O76J367J.js";
7
+ import {
8
+ joinPaths
9
+ } from "./chunk-V3GMJ4TX.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
+ };