@storm-software/config-tools 1.190.119 → 1.190.120

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 (114) hide show
  1. package/README.md +1 -1
  2. package/bin/config.cjs +20 -1532
  3. package/bin/config.js +19 -1527
  4. package/dist/config-file/get-config-file.cjs +80 -25
  5. package/dist/config-file/get-config-file.js +79 -24
  6. package/dist/config-file/index.cjs +1 -29
  7. package/dist/config-file/index.js +1 -29
  8. package/dist/create-storm-config.cjs +138 -26
  9. package/dist/create-storm-config.js +140 -28
  10. package/dist/env/get-env.cjs +221 -6
  11. package/dist/env/get-env.js +221 -6
  12. package/dist/env/index.cjs +2 -18
  13. package/dist/env/index.js +2 -18
  14. package/dist/env/set-env.cjs +383 -8
  15. package/dist/env/set-env.js +382 -7
  16. package/dist/get-config.cjs +28 -27
  17. package/dist/get-config.js +29 -28
  18. package/dist/index.cjs +7 -201
  19. package/dist/index.js +7 -201
  20. package/dist/logger/chalk.cjs +32 -4
  21. package/dist/logger/chalk.js +31 -3
  22. package/dist/logger/console-icons.cjs +15 -6
  23. package/dist/logger/console-icons.js +14 -5
  24. package/dist/logger/console.cjs +191 -37
  25. package/dist/logger/console.js +176 -22
  26. package/dist/logger/create-logger.cjs +25 -12
  27. package/dist/logger/create-logger.js +24 -11
  28. package/dist/logger/format-timestamp.cjs +4 -4
  29. package/dist/logger/format-timestamp.js +3 -3
  30. package/dist/logger/get-log-level.cjs +60 -7
  31. package/dist/logger/get-log-level.js +59 -6
  32. package/dist/logger/index.cjs +7 -61
  33. package/dist/logger/index.js +7 -61
  34. package/dist/logger/is-unicode-supported.cjs +10 -4
  35. package/dist/logger/is-unicode-supported.js +9 -3
  36. package/dist/types.cjs +25 -5
  37. package/dist/types.js +24 -4
  38. package/dist/utilities/apply-workspace-tokens.cjs +72 -9
  39. package/dist/utilities/apply-workspace-tokens.js +71 -8
  40. package/dist/utilities/colors.cjs +76 -7
  41. package/dist/utilities/colors.js +75 -6
  42. package/dist/utilities/correct-paths.cjs +231 -32
  43. package/dist/utilities/correct-paths.js +215 -16
  44. package/dist/utilities/file-path-utils.cjs +29 -7
  45. package/dist/utilities/file-path-utils.js +28 -6
  46. package/dist/utilities/find-up.cjs +21 -4
  47. package/dist/utilities/find-up.js +20 -3
  48. package/dist/utilities/find-workspace-root.cjs +74 -7
  49. package/dist/utilities/find-workspace-root.js +73 -6
  50. package/dist/utilities/get-default-config.cjs +90 -6
  51. package/dist/utilities/get-default-config.js +90 -6
  52. package/dist/utilities/index.cjs +9 -109
  53. package/dist/utilities/index.js +9 -109
  54. package/dist/utilities/process-handler.cjs +46 -11
  55. package/dist/utilities/process-handler.js +47 -12
  56. package/dist/utilities/run.cjs +34 -6
  57. package/dist/utilities/run.js +33 -5
  58. package/dist/utilities/toml.cjs +42 -24
  59. package/dist/utilities/toml.js +35 -17
  60. package/package.json +4 -4
  61. package/dist/chunk-24B36RDB.cjs +0 -81
  62. package/dist/chunk-27N3QEX5.js +0 -40
  63. package/dist/chunk-2AVLCXLT.js +0 -0
  64. package/dist/chunk-2RLMTBVZ.js +0 -233
  65. package/dist/chunk-2WBD2G3E.cjs +0 -38
  66. package/dist/chunk-3COHMHPU.cjs +0 -1
  67. package/dist/chunk-4Q45WJYQ.js +0 -165
  68. package/dist/chunk-5C7PIENF.js +0 -92
  69. package/dist/chunk-5J2SS4QU.js +0 -83
  70. package/dist/chunk-65SWKEHV.cjs +0 -1
  71. package/dist/chunk-6Y623TCS.cjs +0 -40
  72. package/dist/chunk-7PV6L7I7.cjs +0 -1
  73. package/dist/chunk-7QBTVNMR.cjs +0 -30
  74. package/dist/chunk-BDATZ3UB.cjs +0 -233
  75. package/dist/chunk-BZRTSWH4.cjs +0 -395
  76. package/dist/chunk-D3FRXXDE.js +0 -947
  77. package/dist/chunk-DTGT4OI3.cjs +0 -14
  78. package/dist/chunk-EC2KPWRG.cjs +0 -24
  79. package/dist/chunk-EENQN6N2.js +0 -40
  80. package/dist/chunk-ENI4UUSK.cjs +0 -35
  81. package/dist/chunk-FJNXECWU.js +0 -395
  82. package/dist/chunk-FMDVBSP6.cjs +0 -83
  83. package/dist/chunk-G2MK47WL.js +0 -14
  84. package/dist/chunk-HFS7WJVW.js +0 -81
  85. package/dist/chunk-HVVJHTFS.js +0 -36
  86. package/dist/chunk-IWD6YQKX.cjs +0 -1
  87. package/dist/chunk-IWQRXQ4N.cjs +0 -84
  88. package/dist/chunk-JK4TT5IV.js +0 -35
  89. package/dist/chunk-JWLDCEBZ.cjs +0 -70
  90. package/dist/chunk-JZAYHDV3.js +0 -8
  91. package/dist/chunk-KSMN3HSC.js +0 -38
  92. package/dist/chunk-L6UNTUC4.js +0 -0
  93. package/dist/chunk-LOY6ICHZ.cjs +0 -36
  94. package/dist/chunk-MBG2FTBL.cjs +0 -47
  95. package/dist/chunk-MQG74XF7.js +0 -102
  96. package/dist/chunk-MSAQEGBK.cjs +0 -92
  97. package/dist/chunk-NJFLUTGH.cjs +0 -25
  98. package/dist/chunk-PCYB64MB.cjs +0 -40
  99. package/dist/chunk-RALMUN5C.js +0 -30
  100. package/dist/chunk-RRKB32OH.js +0 -0
  101. package/dist/chunk-RUKM6FCF.js +0 -25
  102. package/dist/chunk-SIW7AXUG.js +0 -56
  103. package/dist/chunk-SLICWTO2.cjs +0 -165
  104. package/dist/chunk-SO3FWVXC.js +0 -84
  105. package/dist/chunk-SXPH7ILL.js +0 -70
  106. package/dist/chunk-T7YISGRS.cjs +0 -102
  107. package/dist/chunk-TZZRLM5J.cjs +0 -947
  108. package/dist/chunk-UJ77IBHD.cjs +0 -233
  109. package/dist/chunk-UKGRDKIH.js +0 -0
  110. package/dist/chunk-V3GMJ4TX.js +0 -233
  111. package/dist/chunk-WQJYIPSL.cjs +0 -8
  112. package/dist/chunk-YBVOKYAM.cjs +0 -56
  113. package/dist/chunk-YX4736HU.js +0 -47
  114. package/dist/chunk-ZFNAUMQS.js +0 -24
@@ -1,28 +1,83 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
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; }var _c12 = require('c12');
2
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
3
+ var _console = require('../logger/console');
4
+ var _utilities = require('../utilities');
5
+ var _findworkspaceroot = require('../utilities/find-workspace-root');
6
+ const getConfigFileByName = async (fileName, filePath, options = {}) => {
7
+ const workspacePath = filePath || _findworkspaceroot.findWorkspaceRoot.call(void 0, filePath);
8
+ const configs = await Promise.all([
9
+ _c12.loadConfig.call(void 0, {
10
+ cwd: workspacePath,
11
+ packageJson: true,
12
+ name: fileName,
13
+ envName: _optionalChain([fileName, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]),
14
+ jitiOptions: {
15
+ debug: false,
16
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _utilities.joinPaths.call(void 0,
17
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
18
+ "jiti"
19
+ )
20
+ },
21
+ ...options
22
+ }),
23
+ _c12.loadConfig.call(void 0, {
24
+ cwd: workspacePath,
25
+ packageJson: true,
26
+ name: fileName,
27
+ envName: _optionalChain([fileName, 'optionalAccess', _3 => _3.toUpperCase, 'call', _4 => _4()]),
28
+ jitiOptions: {
29
+ debug: false,
30
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _utilities.joinPaths.call(void 0,
31
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
32
+ "jiti"
33
+ )
34
+ },
35
+ configFile: fileName,
36
+ ...options
37
+ })
38
+ ]);
39
+ return _defu2.default.call(void 0, _nullishCoalesce(configs[0], () => ( {})), _nullishCoalesce(configs[1], () => ( {})));
40
+ };
41
+ const getConfigFile = async (filePath, additionalFileNames = []) => {
42
+ const workspacePath = filePath ? filePath : _findworkspaceroot.findWorkspaceRoot.call(void 0, filePath);
43
+ const result = await getConfigFileByName("storm-workspace", workspacePath);
44
+ let config = result.config;
45
+ const configFile = result.configFile;
46
+ if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
47
+ _console.writeTrace.call(void 0,
48
+ `Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
49
+ {
50
+ logLevel: "all"
51
+ }
52
+ );
53
+ }
54
+ if (additionalFileNames && additionalFileNames.length > 0) {
55
+ const results = await Promise.all(
56
+ additionalFileNames.map(
57
+ (fileName) => getConfigFileByName(fileName, workspacePath)
58
+ )
59
+ );
60
+ for (const result2 of results) {
61
+ if (_optionalChain([result2, 'optionalAccess', _5 => _5.config]) && _optionalChain([result2, 'optionalAccess', _6 => _6.configFile]) && Object.keys(result2.config).length > 0) {
62
+ if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
63
+ _console.writeTrace.call(void 0,
64
+ `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
65
+ {
66
+ logLevel: "all"
67
+ }
68
+ );
69
+ }
70
+ config = _defu2.default.call(void 0, _nullishCoalesce(result2.config, () => ( {})), _nullishCoalesce(config, () => ( {})));
71
+ }
72
+ }
73
+ }
74
+ if (!config || Object.keys(config).length === 0) {
75
+ return void 0;
76
+ }
77
+ config.configFile = configFile;
78
+ return config;
79
+ };
2
80
 
3
81
 
4
- var _chunkMSAQEGBKcjs = require('../chunk-MSAQEGBK.cjs');
5
- require('../chunk-3COHMHPU.cjs');
6
- require('../chunk-YBVOKYAM.cjs');
7
- require('../chunk-6Y623TCS.cjs');
8
- require('../chunk-MBG2FTBL.cjs');
9
- require('../chunk-24B36RDB.cjs');
10
- require('../chunk-2WBD2G3E.cjs');
11
- require('../chunk-T7YISGRS.cjs');
12
- require('../chunk-IWQRXQ4N.cjs');
13
- require('../chunk-NJFLUTGH.cjs');
14
- require('../chunk-7PV6L7I7.cjs');
15
- require('../chunk-ENI4UUSK.cjs');
16
- require('../chunk-TZZRLM5J.cjs');
17
- require('../chunk-FMDVBSP6.cjs');
18
- require('../chunk-LOY6ICHZ.cjs');
19
- require('../chunk-EC2KPWRG.cjs');
20
- require('../chunk-DTGT4OI3.cjs');
21
- require('../chunk-WQJYIPSL.cjs');
22
- require('../chunk-BDATZ3UB.cjs');
23
- require('../chunk-JWLDCEBZ.cjs');
24
- require('../chunk-7QBTVNMR.cjs');
25
82
 
26
-
27
-
28
- exports.getConfigFile = _chunkMSAQEGBKcjs.getConfigFile; exports.getConfigFileByName = _chunkMSAQEGBKcjs.getConfigFileByName;
83
+ exports.getConfigFile = getConfigFile; exports.getConfigFileByName = getConfigFileByName;
@@ -1,27 +1,82 @@
1
- import {
2
- getConfigFile,
3
- getConfigFileByName
4
- } from "../chunk-5C7PIENF.js";
5
- import "../chunk-UKGRDKIH.js";
6
- import "../chunk-SIW7AXUG.js";
7
- import "../chunk-EENQN6N2.js";
8
- import "../chunk-YX4736HU.js";
9
- import "../chunk-HFS7WJVW.js";
10
- import "../chunk-KSMN3HSC.js";
11
- import "../chunk-MQG74XF7.js";
12
- import "../chunk-SO3FWVXC.js";
13
- import "../chunk-RUKM6FCF.js";
14
- import "../chunk-RRKB32OH.js";
15
- import "../chunk-JK4TT5IV.js";
16
- import "../chunk-D3FRXXDE.js";
17
- import "../chunk-5J2SS4QU.js";
18
- import "../chunk-HVVJHTFS.js";
19
- import "../chunk-ZFNAUMQS.js";
20
- import "../chunk-G2MK47WL.js";
21
- import "../chunk-JZAYHDV3.js";
22
- import "../chunk-V3GMJ4TX.js";
23
- import "../chunk-SXPH7ILL.js";
24
- import "../chunk-RALMUN5C.js";
1
+ import { loadConfig } from "c12";
2
+ import defu from "defu";
3
+ import { writeTrace } from "../logger/console";
4
+ import { joinPaths } from "../utilities";
5
+ import { findWorkspaceRoot } from "../utilities/find-workspace-root";
6
+ const getConfigFileByName = async (fileName, filePath, options = {}) => {
7
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
8
+ const configs = await Promise.all([
9
+ loadConfig({
10
+ cwd: workspacePath,
11
+ packageJson: true,
12
+ name: fileName,
13
+ envName: fileName?.toUpperCase(),
14
+ jitiOptions: {
15
+ debug: false,
16
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
17
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
18
+ "jiti"
19
+ )
20
+ },
21
+ ...options
22
+ }),
23
+ loadConfig({
24
+ cwd: workspacePath,
25
+ packageJson: true,
26
+ name: fileName,
27
+ envName: fileName?.toUpperCase(),
28
+ jitiOptions: {
29
+ debug: false,
30
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
31
+ process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
32
+ "jiti"
33
+ )
34
+ },
35
+ configFile: fileName,
36
+ ...options
37
+ })
38
+ ]);
39
+ return defu(configs[0] ?? {}, configs[1] ?? {});
40
+ };
41
+ const getConfigFile = async (filePath, additionalFileNames = []) => {
42
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
43
+ const result = await getConfigFileByName("storm-workspace", workspacePath);
44
+ let config = result.config;
45
+ const configFile = result.configFile;
46
+ if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
47
+ writeTrace(
48
+ `Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
49
+ {
50
+ logLevel: "all"
51
+ }
52
+ );
53
+ }
54
+ if (additionalFileNames && additionalFileNames.length > 0) {
55
+ const results = await Promise.all(
56
+ additionalFileNames.map(
57
+ (fileName) => getConfigFileByName(fileName, workspacePath)
58
+ )
59
+ );
60
+ for (const result2 of results) {
61
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
62
+ if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
63
+ writeTrace(
64
+ `Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
65
+ {
66
+ logLevel: "all"
67
+ }
68
+ );
69
+ }
70
+ config = defu(result2.config ?? {}, config ?? {});
71
+ }
72
+ }
73
+ }
74
+ if (!config || Object.keys(config).length === 0) {
75
+ return void 0;
76
+ }
77
+ config.configFile = configFile;
78
+ return config;
79
+ };
25
80
  export {
26
81
  getConfigFile,
27
82
  getConfigFileByName
@@ -1,29 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-IWD6YQKX.cjs');
2
-
3
-
4
-
5
- var _chunkMSAQEGBKcjs = require('../chunk-MSAQEGBK.cjs');
6
- require('../chunk-3COHMHPU.cjs');
7
- require('../chunk-YBVOKYAM.cjs');
8
- require('../chunk-6Y623TCS.cjs');
9
- require('../chunk-MBG2FTBL.cjs');
10
- require('../chunk-24B36RDB.cjs');
11
- require('../chunk-2WBD2G3E.cjs');
12
- require('../chunk-T7YISGRS.cjs');
13
- require('../chunk-IWQRXQ4N.cjs');
14
- require('../chunk-NJFLUTGH.cjs');
15
- require('../chunk-7PV6L7I7.cjs');
16
- require('../chunk-ENI4UUSK.cjs');
17
- require('../chunk-TZZRLM5J.cjs');
18
- require('../chunk-FMDVBSP6.cjs');
19
- require('../chunk-LOY6ICHZ.cjs');
20
- require('../chunk-EC2KPWRG.cjs');
21
- require('../chunk-DTGT4OI3.cjs');
22
- require('../chunk-WQJYIPSL.cjs');
23
- require('../chunk-BDATZ3UB.cjs');
24
- require('../chunk-JWLDCEBZ.cjs');
25
- require('../chunk-7QBTVNMR.cjs');
26
-
27
-
28
-
29
- exports.getConfigFile = _chunkMSAQEGBKcjs.getConfigFile; exports.getConfigFileByName = _chunkMSAQEGBKcjs.getConfigFileByName;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _getconfigfile = require('./get-config-file'); _createStarExport(_getconfigfile);
@@ -1,29 +1 @@
1
- import "../chunk-2AVLCXLT.js";
2
- import {
3
- getConfigFile,
4
- getConfigFileByName
5
- } from "../chunk-5C7PIENF.js";
6
- import "../chunk-UKGRDKIH.js";
7
- import "../chunk-SIW7AXUG.js";
8
- import "../chunk-EENQN6N2.js";
9
- import "../chunk-YX4736HU.js";
10
- import "../chunk-HFS7WJVW.js";
11
- import "../chunk-KSMN3HSC.js";
12
- import "../chunk-MQG74XF7.js";
13
- import "../chunk-SO3FWVXC.js";
14
- import "../chunk-RUKM6FCF.js";
15
- import "../chunk-RRKB32OH.js";
16
- import "../chunk-JK4TT5IV.js";
17
- import "../chunk-D3FRXXDE.js";
18
- import "../chunk-5J2SS4QU.js";
19
- import "../chunk-HVVJHTFS.js";
20
- import "../chunk-ZFNAUMQS.js";
21
- import "../chunk-G2MK47WL.js";
22
- import "../chunk-JZAYHDV3.js";
23
- import "../chunk-V3GMJ4TX.js";
24
- import "../chunk-SXPH7ILL.js";
25
- import "../chunk-RALMUN5C.js";
26
- export {
27
- getConfigFile,
28
- getConfigFileByName
29
- };
1
+ export * from "./get-config-file";
@@ -1,35 +1,147 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
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; }var _schema = require('@storm-software/config/schema');
2
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
3
+ var _nodefs = require('node:fs');
4
+ var _getconfigfile = require('./config-file/get-config-file');
5
+ var _getenv = require('./env/get-env');
6
+ var _setenv = require('./env/set-env');
7
+ var _console = require('./logger/console');
8
+ var _utilities = require('./utilities');
9
+ var _findworkspaceroot = require('./utilities/find-workspace-root');
2
10
 
3
11
 
4
12
 
13
+ var _getdefaultconfig = require('./utilities/get-default-config');
14
+ const _extension_cache = /* @__PURE__ */ new WeakMap();
15
+ let _static_cache = void 0;
16
+ const createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
17
+ let result;
18
+ if (!_optionalChain([_static_cache, 'optionalAccess', _ => _.data]) || !_optionalChain([_static_cache, 'optionalAccess', _2 => _2.timestamp]) || _static_cache.timestamp < Date.now() - 8e3) {
19
+ let _workspaceRoot = workspaceRoot;
20
+ if (!_workspaceRoot) {
21
+ _workspaceRoot = _findworkspaceroot.findWorkspaceRoot.call(void 0, );
22
+ }
23
+ const configEnv = _getenv.getConfigEnv.call(void 0, );
24
+ const configFile = await _getconfigfile.getConfigFile.call(void 0, _workspaceRoot);
25
+ if (!configFile) {
26
+ if (!skipLogs) {
27
+ _console.writeWarning.call(void 0,
28
+ "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",
29
+ { logLevel: "all" }
30
+ );
31
+ }
32
+ if (useDefault === false) {
33
+ return void 0;
34
+ }
35
+ }
36
+ const defaultConfig = await _getdefaultconfig.getPackageJsonConfig.call(void 0, _workspaceRoot);
37
+ const configInput = _defu2.default.call(void 0,
38
+ configEnv,
39
+ configFile,
40
+ defaultConfig
41
+ );
42
+ if (!configInput.variant) {
43
+ configInput.variant = _nodefs.existsSync.call(void 0, _utilities.joinPaths.call(void 0, _workspaceRoot, "nx.json")) || _nodefs.existsSync.call(void 0, _utilities.joinPaths.call(void 0, _workspaceRoot, ".nx")) || _nodefs.existsSync.call(void 0, _utilities.joinPaths.call(void 0, _workspaceRoot, "lerna.json")) || _nodefs.existsSync.call(void 0, _utilities.joinPaths.call(void 0, _workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
44
+ }
45
+ try {
46
+ const parseResult = await Promise.resolve(
47
+ _schema.workspaceConfigSchema._zod.parse(
48
+ { value: configInput, issues: [] },
49
+ { async: true }
50
+ )
51
+ );
52
+ result = _getdefaultconfig.applyDefaultConfig.call(void 0, parseResult.value);
53
+ result.workspaceRoot ??= _workspaceRoot;
54
+ } catch (error) {
55
+ throw new Error(
56
+ `Failed to parse Storm Workspace configuration${_optionalChain([error, 'optionalAccess', _3 => _3.message]) ? `: ${error.message}` : ""}
5
57
 
6
- var _chunkSLICWTO2cjs = require('./chunk-SLICWTO2.cjs');
7
- require('./chunk-MSAQEGBK.cjs');
8
- require('./chunk-3COHMHPU.cjs');
9
- require('./chunk-YBVOKYAM.cjs');
10
- require('./chunk-6Y623TCS.cjs');
11
- require('./chunk-MBG2FTBL.cjs');
12
- require('./chunk-24B36RDB.cjs');
13
- require('./chunk-2WBD2G3E.cjs');
14
- require('./chunk-T7YISGRS.cjs');
15
- require('./chunk-IWQRXQ4N.cjs');
16
- require('./chunk-NJFLUTGH.cjs');
17
- require('./chunk-7PV6L7I7.cjs');
18
- require('./chunk-ENI4UUSK.cjs');
19
- require('./chunk-TZZRLM5J.cjs');
20
- require('./chunk-FMDVBSP6.cjs');
21
- require('./chunk-LOY6ICHZ.cjs');
22
- require('./chunk-EC2KPWRG.cjs');
23
- require('./chunk-DTGT4OI3.cjs');
24
- require('./chunk-WQJYIPSL.cjs');
25
- require('./chunk-BZRTSWH4.cjs');
26
- require('./chunk-UJ77IBHD.cjs');
27
- require('./chunk-BDATZ3UB.cjs');
28
- require('./chunk-JWLDCEBZ.cjs');
29
- require('./chunk-7QBTVNMR.cjs');
58
+ Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${_console.formatLogMessage.call(void 0,
59
+ configInput
60
+ )}`,
61
+ {
62
+ cause: error
63
+ }
64
+ );
65
+ }
66
+ } else {
67
+ result = _static_cache.data;
68
+ }
69
+ if (schema && extensionName) {
70
+ result.extensions = {
71
+ ...result.extensions,
72
+ [extensionName]: createConfigExtension(extensionName, schema)
73
+ };
74
+ }
75
+ _static_cache = {
76
+ timestamp: Date.now(),
77
+ data: result
78
+ };
79
+ return result;
80
+ };
81
+ const createConfigExtension = (extensionName, schema) => {
82
+ const extension_cache_key = { extensionName };
83
+ if (_extension_cache.has(extension_cache_key)) {
84
+ return _extension_cache.get(extension_cache_key);
85
+ }
86
+ let extension = _getenv.getExtensionEnv.call(void 0, extensionName);
87
+ if (schema) {
88
+ extension = schema.parse(extension);
89
+ }
90
+ _extension_cache.set(extension_cache_key, extension);
91
+ return extension;
92
+ };
93
+ const loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
94
+ const config = await createStormWorkspaceConfig(
95
+ void 0,
96
+ void 0,
97
+ workspaceRoot,
98
+ skipLogs,
99
+ true
100
+ );
101
+ _setenv.setConfigEnv.call(void 0, config);
102
+ if (!skipLogs && !config.skipConfigLogging) {
103
+ _console.writeTrace.call(void 0,
104
+ `\u2699\uFE0F Using Storm Workspace configuration:
105
+ ${_console.formatLogMessage.call(void 0, config)}`,
106
+ config
107
+ );
108
+ }
109
+ return config;
110
+ };
111
+ const tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
112
+ try {
113
+ const config = await createStormWorkspaceConfig(
114
+ void 0,
115
+ void 0,
116
+ workspaceRoot,
117
+ skipLogs,
118
+ useDefault
119
+ );
120
+ if (!config) {
121
+ return void 0;
122
+ }
123
+ _setenv.setConfigEnv.call(void 0, config);
124
+ if (!skipLogs && !config.skipConfigLogging) {
125
+ _console.writeTrace.call(void 0,
126
+ `\u2699\uFE0F Using Storm Workspace configuration:
127
+ ${_console.formatLogMessage.call(void 0, config)}`,
128
+ config
129
+ );
130
+ }
131
+ return config;
132
+ } catch (error) {
133
+ if (!skipLogs) {
134
+ _console.writeWarning.call(void 0,
135
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
136
+ { logLevel: "all" }
137
+ );
138
+ }
139
+ return void 0;
140
+ }
141
+ };
30
142
 
31
143
 
32
144
 
33
145
 
34
146
 
35
- exports.createConfigExtension = _chunkSLICWTO2cjs.createConfigExtension; exports.createStormWorkspaceConfig = _chunkSLICWTO2cjs.createStormWorkspaceConfig; exports.loadStormWorkspaceConfig = _chunkSLICWTO2cjs.loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = _chunkSLICWTO2cjs.tryLoadStormWorkspaceConfig;
147
+ exports.createConfigExtension = createConfigExtension; exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
@@ -1,32 +1,144 @@
1
+ import { workspaceConfigSchema } from "@storm-software/config/schema";
2
+ import defu from "defu";
3
+ import { existsSync } from "node:fs";
4
+ import { getConfigFile } from "./config-file/get-config-file";
5
+ import { getConfigEnv, getExtensionEnv } from "./env/get-env";
6
+ import { setConfigEnv } from "./env/set-env";
7
+ import { formatLogMessage, writeTrace, writeWarning } from "./logger/console";
8
+ import { joinPaths } from "./utilities";
9
+ import { findWorkspaceRoot } from "./utilities/find-workspace-root";
1
10
  import {
2
- createConfigExtension,
3
- createStormWorkspaceConfig,
4
- loadStormWorkspaceConfig,
5
- tryLoadStormWorkspaceConfig
6
- } from "./chunk-4Q45WJYQ.js";
7
- import "./chunk-5C7PIENF.js";
8
- import "./chunk-UKGRDKIH.js";
9
- import "./chunk-SIW7AXUG.js";
10
- import "./chunk-EENQN6N2.js";
11
- import "./chunk-YX4736HU.js";
12
- import "./chunk-HFS7WJVW.js";
13
- import "./chunk-KSMN3HSC.js";
14
- import "./chunk-MQG74XF7.js";
15
- import "./chunk-SO3FWVXC.js";
16
- import "./chunk-RUKM6FCF.js";
17
- import "./chunk-RRKB32OH.js";
18
- import "./chunk-JK4TT5IV.js";
19
- import "./chunk-D3FRXXDE.js";
20
- import "./chunk-5J2SS4QU.js";
21
- import "./chunk-HVVJHTFS.js";
22
- import "./chunk-ZFNAUMQS.js";
23
- import "./chunk-G2MK47WL.js";
24
- import "./chunk-JZAYHDV3.js";
25
- import "./chunk-FJNXECWU.js";
26
- import "./chunk-2RLMTBVZ.js";
27
- import "./chunk-V3GMJ4TX.js";
28
- import "./chunk-SXPH7ILL.js";
29
- import "./chunk-RALMUN5C.js";
11
+ applyDefaultConfig,
12
+ getPackageJsonConfig
13
+ } from "./utilities/get-default-config";
14
+ const _extension_cache = /* @__PURE__ */ new WeakMap();
15
+ let _static_cache = void 0;
16
+ const createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
17
+ let result;
18
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
19
+ let _workspaceRoot = workspaceRoot;
20
+ if (!_workspaceRoot) {
21
+ _workspaceRoot = findWorkspaceRoot();
22
+ }
23
+ const configEnv = getConfigEnv();
24
+ const configFile = await getConfigFile(_workspaceRoot);
25
+ if (!configFile) {
26
+ if (!skipLogs) {
27
+ writeWarning(
28
+ "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",
29
+ { logLevel: "all" }
30
+ );
31
+ }
32
+ if (useDefault === false) {
33
+ return void 0;
34
+ }
35
+ }
36
+ const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
37
+ const configInput = defu(
38
+ configEnv,
39
+ configFile,
40
+ defaultConfig
41
+ );
42
+ if (!configInput.variant) {
43
+ configInput.variant = existsSync(joinPaths(_workspaceRoot, "nx.json")) || existsSync(joinPaths(_workspaceRoot, ".nx")) || existsSync(joinPaths(_workspaceRoot, "lerna.json")) || existsSync(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
44
+ }
45
+ try {
46
+ const parseResult = await Promise.resolve(
47
+ workspaceConfigSchema._zod.parse(
48
+ { value: configInput, issues: [] },
49
+ { async: true }
50
+ )
51
+ );
52
+ result = applyDefaultConfig(parseResult.value);
53
+ result.workspaceRoot ??= _workspaceRoot;
54
+ } catch (error) {
55
+ throw new Error(
56
+ `Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
57
+
58
+ Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(
59
+ configInput
60
+ )}`,
61
+ {
62
+ cause: error
63
+ }
64
+ );
65
+ }
66
+ } else {
67
+ result = _static_cache.data;
68
+ }
69
+ if (schema && extensionName) {
70
+ result.extensions = {
71
+ ...result.extensions,
72
+ [extensionName]: createConfigExtension(extensionName, schema)
73
+ };
74
+ }
75
+ _static_cache = {
76
+ timestamp: Date.now(),
77
+ data: result
78
+ };
79
+ return result;
80
+ };
81
+ const createConfigExtension = (extensionName, schema) => {
82
+ const extension_cache_key = { extensionName };
83
+ if (_extension_cache.has(extension_cache_key)) {
84
+ return _extension_cache.get(extension_cache_key);
85
+ }
86
+ let extension = getExtensionEnv(extensionName);
87
+ if (schema) {
88
+ extension = schema.parse(extension);
89
+ }
90
+ _extension_cache.set(extension_cache_key, extension);
91
+ return extension;
92
+ };
93
+ const loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
94
+ const config = await createStormWorkspaceConfig(
95
+ void 0,
96
+ void 0,
97
+ workspaceRoot,
98
+ skipLogs,
99
+ true
100
+ );
101
+ setConfigEnv(config);
102
+ if (!skipLogs && !config.skipConfigLogging) {
103
+ writeTrace(
104
+ `\u2699\uFE0F Using Storm Workspace configuration:
105
+ ${formatLogMessage(config)}`,
106
+ config
107
+ );
108
+ }
109
+ return config;
110
+ };
111
+ const tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
112
+ try {
113
+ const config = await createStormWorkspaceConfig(
114
+ void 0,
115
+ void 0,
116
+ workspaceRoot,
117
+ skipLogs,
118
+ useDefault
119
+ );
120
+ if (!config) {
121
+ return void 0;
122
+ }
123
+ setConfigEnv(config);
124
+ if (!skipLogs && !config.skipConfigLogging) {
125
+ writeTrace(
126
+ `\u2699\uFE0F Using Storm Workspace configuration:
127
+ ${formatLogMessage(config)}`,
128
+ config
129
+ );
130
+ }
131
+ return config;
132
+ } catch (error) {
133
+ if (!skipLogs) {
134
+ writeWarning(
135
+ `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
136
+ { logLevel: "all" }
137
+ );
138
+ }
139
+ return void 0;
140
+ }
141
+ };
30
142
  export {
31
143
  createConfigExtension,
32
144
  createStormWorkspaceConfig,