@storm-software/config-tools 1.190.120 → 1.190.122
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 +1 -1
- package/bin/config.cjs +1272 -105
- package/bin/config.mjs +1271 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/config-file/get-config-file.cjs +63 -79
- package/dist/config-file/get-config-file.d.cts +5 -5
- package/dist/config-file/{get-config-file.d.ts → get-config-file.d.mts} +7 -5
- package/dist/config-file/get-config-file.mjs +66 -0
- package/dist/config-file/index.cjs +4 -1
- package/dist/config-file/index.d.cts +2 -3
- package/dist/config-file/index.d.mts +4 -0
- package/dist/config-file/index.mjs +5 -0
- package/dist/create-storm-config.cjs +105 -136
- package/dist/create-storm-config.d.cts +5 -5
- package/dist/{create-storm-config.d.ts → create-storm-config.d.mts} +7 -5
- package/dist/create-storm-config.mjs +113 -0
- package/dist/env/get-env.cjs +190 -214
- package/dist/env/get-env.d.cts +5 -5
- package/dist/env/{get-env.d.ts → get-env.d.mts} +7 -5
- package/dist/env/get-env.mjs +203 -0
- package/dist/env/index.cjs +7 -2
- package/dist/env/index.d.cts +3 -4
- package/dist/env/index.d.mts +5 -0
- package/dist/env/index.mjs +6 -0
- package/dist/env/set-env.cjs +218 -374
- package/dist/env/set-env.d.cts +8 -8
- package/dist/env/{set-env.d.ts → set-env.d.mts} +10 -8
- package/dist/env/set-env.mjs +231 -0
- package/dist/get-config.cjs +40 -29
- package/dist/get-config.d.cts +18 -18
- package/dist/{get-config.d.ts → get-config.d.mts} +20 -18
- package/dist/get-config.mjs +46 -0
- package/dist/index.cjs +98 -7
- package/dist/index.d.cts +27 -28
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +26 -0
- package/dist/logger/chalk.cjs +38 -29
- package/dist/logger/chalk.d.cts +18 -17
- package/dist/logger/chalk.d.mts +37 -0
- package/dist/logger/chalk.mjs +43 -0
- package/dist/logger/console-icons.cjs +15 -14
- package/dist/logger/console-icons.d.cts +5 -8
- package/dist/logger/console-icons.d.mts +7 -0
- package/dist/logger/console-icons.mjs +20 -0
- package/dist/logger/console.cjs +187 -183
- package/dist/logger/console.d.cts +25 -25
- package/dist/logger/{console.d.ts → console.d.mts} +27 -25
- package/dist/logger/console.mjs +185 -0
- package/dist/logger/create-logger.cjs +31 -24
- package/dist/logger/create-logger.d.cts +5 -6
- package/dist/logger/{create-logger.d.ts → create-logger.d.mts} +7 -6
- package/dist/logger/create-logger.mjs +34 -0
- package/dist/logger/format-timestamp.cjs +12 -4
- package/dist/logger/format-timestamp.d.cts +3 -2
- package/dist/logger/{format-timestamp.d.ts → format-timestamp.d.mts} +5 -2
- package/dist/logger/format-timestamp.mjs +16 -0
- package/dist/logger/get-log-level.cjs +50 -60
- package/dist/logger/get-log-level.d.cts +4 -5
- package/dist/logger/{get-log-level.d.ts → get-log-level.d.mts} +6 -5
- package/dist/logger/get-log-level.mjs +54 -0
- package/dist/logger/index.cjs +29 -7
- package/dist/logger/index.d.cts +8 -10
- package/dist/logger/index.d.mts +10 -0
- package/dist/logger/index.mjs +11 -0
- package/dist/logger/is-unicode-supported.cjs +6 -10
- package/dist/logger/is-unicode-supported.d.cts +3 -2
- package/dist/logger/is-unicode-supported.d.mts +6 -0
- package/dist/logger/is-unicode-supported.mjs +10 -0
- package/dist/types.cjs +26 -25
- package/dist/types.d.cts +39 -41
- package/dist/types.d.mts +53 -0
- package/dist/types.mjs +30 -0
- package/dist/utilities/apply-workspace-tokens.cjs +31 -70
- package/dist/utilities/apply-workspace-tokens.d.cts +4 -5
- package/dist/utilities/{apply-workspace-tokens.d.ts → apply-workspace-tokens.d.mts} +6 -5
- package/dist/utilities/apply-workspace-tokens.mjs +37 -0
- package/dist/utilities/colors.cjs +91 -74
- package/dist/utilities/colors.d.cts +4 -4
- package/dist/utilities/{colors.d.ts → colors.d.mts} +6 -4
- package/dist/utilities/colors.mjs +97 -0
- package/dist/utilities/correct-paths.cjs +166 -196
- package/dist/utilities/correct-paths.d.cts +4 -4
- package/dist/utilities/{correct-paths.d.ts → correct-paths.d.mts} +6 -4
- package/dist/utilities/correct-paths.mjs +190 -0
- package/dist/utilities/file-path-utils.cjs +42 -27
- package/dist/utilities/file-path-utils.d.cts +15 -14
- package/dist/utilities/{file-path-utils.d.ts → file-path-utils.d.mts} +17 -14
- package/dist/utilities/file-path-utils.mjs +48 -0
- package/dist/utilities/find-up.cjs +12 -18
- package/dist/utilities/find-up.d.cts +3 -2
- package/dist/utilities/{find-up.d.ts → find-up.d.mts} +5 -2
- package/dist/utilities/find-up.mjs +19 -0
- package/dist/utilities/find-workspace-root.cjs +64 -69
- package/dist/utilities/find-workspace-root.d.cts +3 -2
- package/dist/utilities/{find-workspace-root.d.ts → find-workspace-root.d.mts} +5 -2
- package/dist/utilities/find-workspace-root.mjs +73 -0
- package/dist/utilities/get-default-config.cjs +69 -91
- package/dist/utilities/get-default-config.d.cts +4 -4
- package/dist/utilities/{get-default-config.d.ts → get-default-config.d.mts} +6 -4
- package/dist/utilities/get-default-config.mjs +74 -0
- package/dist/utilities/index.cjs +49 -9
- package/dist/utilities/index.d.cts +10 -14
- package/dist/utilities/index.d.mts +12 -0
- package/dist/utilities/index.mjs +13 -0
- package/dist/utilities/process-handler.cjs +32 -47
- package/dist/utilities/process-handler.d.cts +4 -4
- package/dist/utilities/process-handler.d.mts +9 -0
- package/dist/utilities/process-handler.mjs +38 -0
- package/dist/utilities/run.cjs +62 -36
- package/dist/utilities/run.d.cts +5 -6
- package/dist/utilities/{run.d.ts → run.d.mts} +7 -6
- package/dist/utilities/run.mjs +64 -0
- package/dist/utilities/toml.cjs +27 -32
- package/dist/utilities/toml.d.cts +148 -147
- package/dist/utilities/toml.d.mts +192 -0
- package/dist/utilities/toml.mjs +33 -0
- package/package.json +105 -157
- package/bin/config.js +0 -108
- package/dist/config-file/get-config-file.js +0 -83
- package/dist/config-file/index.d.ts +0 -3
- package/dist/config-file/index.js +0 -1
- package/dist/create-storm-config.js +0 -147
- package/dist/env/get-env.js +0 -226
- package/dist/env/index.d.ts +0 -4
- package/dist/env/index.js +0 -2
- package/dist/env/set-env.js +0 -386
- package/dist/get-config.js +0 -35
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -7
- package/dist/logger/chalk.d.ts +0 -34
- package/dist/logger/chalk.js +0 -34
- package/dist/logger/console-icons.d.ts +0 -8
- package/dist/logger/console-icons.js +0 -17
- package/dist/logger/console.js +0 -191
- package/dist/logger/create-logger.js +0 -27
- package/dist/logger/format-timestamp.js +0 -6
- package/dist/logger/get-log-level.js +0 -64
- package/dist/logger/index.d.ts +0 -10
- package/dist/logger/index.js +0 -7
- package/dist/logger/is-unicode-supported.d.ts +0 -3
- package/dist/logger/is-unicode-supported.js +0 -12
- package/dist/types.d.ts +0 -53
- package/dist/types.js +0 -28
- package/dist/utilities/apply-workspace-tokens.js +0 -76
- package/dist/utilities/colors.js +0 -81
- package/dist/utilities/correct-paths.js +0 -231
- package/dist/utilities/file-path-utils.js +0 -33
- package/dist/utilities/find-up.js +0 -23
- package/dist/utilities/find-workspace-root.js +0 -77
- package/dist/utilities/get-default-config.js +0 -95
- package/dist/utilities/index.d.ts +0 -14
- package/dist/utilities/index.js +0 -9
- package/dist/utilities/process-handler.d.ts +0 -7
- package/dist/utilities/process-handler.js +0 -53
- package/dist/utilities/run.js +0 -38
- package/dist/utilities/toml.d.ts +0 -189
- package/dist/utilities/toml.js +0 -42
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
|
@@ -1,83 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_logger_console = require("../logger/console.cjs");
|
|
4
|
+
const require_utilities_correct_paths = require("../utilities/correct-paths.cjs");
|
|
5
|
+
const require_utilities_find_workspace_root = require("../utilities/find-workspace-root.cjs");
|
|
6
|
+
let defu = require("defu");
|
|
7
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
8
|
+
let c12 = require("c12");
|
|
9
|
+
//#region src/config-file/get-config-file.ts
|
|
10
|
+
/**
|
|
11
|
+
* Get the config file for the current Storm workspace
|
|
12
|
+
*
|
|
13
|
+
* @param fileName - The name of the config file to search for
|
|
14
|
+
* @param filePath - The path to search for the config file in
|
|
15
|
+
* @returns The config file for the current Storm workspace
|
|
16
|
+
*/
|
|
6
17
|
const getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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], () => ( {})));
|
|
18
|
+
const workspacePath = filePath || require_utilities_find_workspace_root.findWorkspaceRoot(filePath);
|
|
19
|
+
const configs = await Promise.all([(0, c12.loadConfig)({
|
|
20
|
+
cwd: workspacePath,
|
|
21
|
+
packageJson: true,
|
|
22
|
+
name: fileName,
|
|
23
|
+
envName: fileName?.toUpperCase(),
|
|
24
|
+
jitiOptions: {
|
|
25
|
+
debug: false,
|
|
26
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : require_utilities_correct_paths.joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
27
|
+
},
|
|
28
|
+
...options
|
|
29
|
+
}), (0, c12.loadConfig)({
|
|
30
|
+
cwd: workspacePath,
|
|
31
|
+
packageJson: true,
|
|
32
|
+
name: fileName,
|
|
33
|
+
envName: fileName?.toUpperCase(),
|
|
34
|
+
jitiOptions: {
|
|
35
|
+
debug: false,
|
|
36
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : require_utilities_correct_paths.joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
37
|
+
},
|
|
38
|
+
configFile: fileName,
|
|
39
|
+
...options
|
|
40
|
+
})]);
|
|
41
|
+
return (0, defu.default)(configs[0] ?? {}, configs[1] ?? {});
|
|
40
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Get the config file for the current Storm workspace
|
|
45
|
+
*
|
|
46
|
+
* @returns The config file for the current Storm workspace
|
|
47
|
+
*/
|
|
41
48
|
const getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
|
49
|
+
const workspacePath = filePath ? filePath : require_utilities_find_workspace_root.findWorkspaceRoot(filePath);
|
|
50
|
+
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
51
|
+
let config = result.config;
|
|
52
|
+
const configFile = result.configFile;
|
|
53
|
+
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) require_logger_console.writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, { logLevel: "all" });
|
|
54
|
+
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
55
|
+
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
56
|
+
for (const result of results) if (result?.config && result?.configFile && Object.keys(result.config).length > 0) {
|
|
57
|
+
if (!config.skipConfigLogging && !result.config.skipConfigLogging) require_logger_console.writeTrace(`Found alternative configuration file "${result.configFile.includes(`${workspacePath}/`) ? result.configFile.replace(`${workspacePath}/`, "") : result.configFile}" at "${workspacePath}"`, { logLevel: "all" });
|
|
58
|
+
config = (0, defu.default)(result.config ?? {}, config ?? {});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!config || Object.keys(config).length === 0) return;
|
|
62
|
+
config.configFile = configFile;
|
|
63
|
+
return config;
|
|
79
64
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports.getConfigFile = getConfigFile; exports.getConfigFileByName = getConfigFileByName;
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.getConfigFile = getConfigFile;
|
|
67
|
+
exports.getConfigFileByName = getConfigFileByName;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StormWorkspaceConfigInput } from
|
|
2
|
-
import { LoadConfigOptions, ResolvedConfig } from
|
|
3
|
-
|
|
1
|
+
import { StormWorkspaceConfigInput } from "@storm-software/config";
|
|
2
|
+
import { LoadConfigOptions, ResolvedConfig } from "c12";
|
|
3
|
+
//#region src/config-file/get-config-file.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Get the config file for the current Storm workspace
|
|
6
6
|
*
|
|
@@ -15,5 +15,5 @@ declare const getConfigFileByName: (fileName: string, filePath?: string, options
|
|
|
15
15
|
* @returns The config file for the current Storm workspace
|
|
16
16
|
*/
|
|
17
17
|
declare const getConfigFile: (filePath?: string, additionalFileNames?: string[]) => Promise<Partial<StormWorkspaceConfigInput> | undefined>;
|
|
18
|
-
|
|
19
|
-
export { getConfigFile, getConfigFileByName };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getConfigFile, getConfigFileByName };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { LoadConfigOptions, ResolvedConfig } from "c12";
|
|
4
|
+
import { StormWorkspaceConfigInput } from "@storm-software/config";
|
|
5
|
+
//#region src/config-file/get-config-file.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Get the config file for the current Storm workspace
|
|
6
8
|
*
|
|
@@ -15,5 +17,5 @@ declare const getConfigFileByName: (fileName: string, filePath?: string, options
|
|
|
15
17
|
* @returns The config file for the current Storm workspace
|
|
16
18
|
*/
|
|
17
19
|
declare const getConfigFile: (filePath?: string, additionalFileNames?: string[]) => Promise<Partial<StormWorkspaceConfigInput> | undefined>;
|
|
18
|
-
|
|
19
|
-
export { getConfigFile, getConfigFileByName };
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getConfigFile, getConfigFileByName };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { writeTrace } from "../logger/console.mjs";
|
|
5
|
+
import { joinPaths } from "../utilities/correct-paths.mjs";
|
|
6
|
+
import { findWorkspaceRoot } from "../utilities/find-workspace-root.mjs";
|
|
7
|
+
import defu from "defu";
|
|
8
|
+
import { loadConfig } from "c12";
|
|
9
|
+
//#region src/config-file/get-config-file.ts
|
|
10
|
+
/**
|
|
11
|
+
* Get the config file for the current Storm workspace
|
|
12
|
+
*
|
|
13
|
+
* @param fileName - The name of the config file to search for
|
|
14
|
+
* @param filePath - The path to search for the config file in
|
|
15
|
+
* @returns The config file for the current Storm workspace
|
|
16
|
+
*/
|
|
17
|
+
const getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
18
|
+
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
19
|
+
const configs = await Promise.all([loadConfig({
|
|
20
|
+
cwd: workspacePath,
|
|
21
|
+
packageJson: true,
|
|
22
|
+
name: fileName,
|
|
23
|
+
envName: fileName?.toUpperCase(),
|
|
24
|
+
jitiOptions: {
|
|
25
|
+
debug: false,
|
|
26
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
27
|
+
},
|
|
28
|
+
...options
|
|
29
|
+
}), loadConfig({
|
|
30
|
+
cwd: workspacePath,
|
|
31
|
+
packageJson: true,
|
|
32
|
+
name: fileName,
|
|
33
|
+
envName: fileName?.toUpperCase(),
|
|
34
|
+
jitiOptions: {
|
|
35
|
+
debug: false,
|
|
36
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
37
|
+
},
|
|
38
|
+
configFile: fileName,
|
|
39
|
+
...options
|
|
40
|
+
})]);
|
|
41
|
+
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Get the config file for the current Storm workspace
|
|
45
|
+
*
|
|
46
|
+
* @returns The config file for the current Storm workspace
|
|
47
|
+
*/
|
|
48
|
+
const getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
49
|
+
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
50
|
+
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
51
|
+
let config = result.config;
|
|
52
|
+
const configFile = result.configFile;
|
|
53
|
+
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, { logLevel: "all" });
|
|
54
|
+
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
55
|
+
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
56
|
+
for (const result of results) if (result?.config && result?.configFile && Object.keys(result.config).length > 0) {
|
|
57
|
+
if (!config.skipConfigLogging && !result.config.skipConfigLogging) writeTrace(`Found alternative configuration file "${result.configFile.includes(`${workspacePath}/`) ? result.configFile.replace(`${workspacePath}/`, "") : result.configFile}" at "${workspacePath}"`, { logLevel: "all" });
|
|
58
|
+
config = defu(result.config ?? {}, config ?? {});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!config || Object.keys(config).length === 0) return;
|
|
62
|
+
config.configFile = configFile;
|
|
63
|
+
return config;
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { getConfigFile, getConfigFileByName };
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_config_file_get_config_file = require("./get-config-file.cjs");
|
|
3
|
+
exports.getConfigFile = require_config_file_get_config_file.getConfigFile;
|
|
4
|
+
exports.getConfigFileByName = require_config_file_get_config_file.getConfigFileByName;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import 'c12';
|
|
1
|
+
import { getConfigFile, getConfigFileByName } from "./get-config-file.cjs";
|
|
2
|
+
export { getConfigFile, getConfigFileByName };
|
|
@@ -1,147 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_logger_console = require("./logger/console.cjs");
|
|
4
|
+
const require_utilities_correct_paths = require("./utilities/correct-paths.cjs");
|
|
5
|
+
const require_utilities_find_workspace_root = require("./utilities/find-workspace-root.cjs");
|
|
6
|
+
const require_utilities_get_default_config = require("./utilities/get-default-config.cjs");
|
|
7
|
+
const require_config_file_get_config_file = require("./config-file/get-config-file.cjs");
|
|
8
|
+
const require_env_get_env = require("./env/get-env.cjs");
|
|
9
|
+
const require_env_set_env = require("./env/set-env.cjs");
|
|
10
|
+
let _storm_software_config_schema = require("@storm-software/config/schema");
|
|
11
|
+
let defu = require("defu");
|
|
12
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
13
|
+
let node_fs = require("node:fs");
|
|
14
|
+
//#region src/create-storm-config.ts
|
|
14
15
|
const _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
15
16
|
let _static_cache = void 0;
|
|
17
|
+
/**
|
|
18
|
+
* Get the config for the current Storm workspace
|
|
19
|
+
*
|
|
20
|
+
* @param extensionName - The name of the config extension
|
|
21
|
+
* @param schema - The schema for the config extension
|
|
22
|
+
* @param workspaceRoot - The root directory of the workspace
|
|
23
|
+
* @param skipLogs - Skip writing logs to the console
|
|
24
|
+
* @param useDefault - Whether to use the default config if no config file is found
|
|
25
|
+
* @returns The config for the current Storm workspace
|
|
26
|
+
*/
|
|
16
27
|
const createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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}` : ""}
|
|
28
|
+
let result;
|
|
29
|
+
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
30
|
+
let _workspaceRoot = workspaceRoot;
|
|
31
|
+
if (!_workspaceRoot) _workspaceRoot = require_utilities_find_workspace_root.findWorkspaceRoot();
|
|
32
|
+
const configEnv = require_env_get_env.getConfigEnv();
|
|
33
|
+
const configFile = await require_config_file_get_config_file.getConfigFile(_workspaceRoot);
|
|
34
|
+
if (!configFile) {
|
|
35
|
+
if (!skipLogs) require_logger_console.writeWarning("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", { logLevel: "all" });
|
|
36
|
+
if (useDefault === false) return;
|
|
37
|
+
}
|
|
38
|
+
const defaultConfig = await require_utilities_get_default_config.getPackageJsonConfig(_workspaceRoot);
|
|
39
|
+
const configInput = (0, defu.default)(configEnv, configFile, defaultConfig);
|
|
40
|
+
if (!configInput.variant) configInput.variant = (0, node_fs.existsSync)(require_utilities_correct_paths.joinPaths(_workspaceRoot, "nx.json")) || (0, node_fs.existsSync)(require_utilities_correct_paths.joinPaths(_workspaceRoot, ".nx")) || (0, node_fs.existsSync)(require_utilities_correct_paths.joinPaths(_workspaceRoot, "lerna.json")) || (0, node_fs.existsSync)(require_utilities_correct_paths.joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
|
|
41
|
+
try {
|
|
42
|
+
const parseResult = await Promise.resolve(_storm_software_config_schema.workspaceConfigSchema._zod.parse({
|
|
43
|
+
value: configInput,
|
|
44
|
+
issues: []
|
|
45
|
+
}, { async: true }));
|
|
46
|
+
result = require_utilities_get_default_config.applyDefaultConfig(parseResult.value);
|
|
47
|
+
result.workspaceRoot ??= _workspaceRoot;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new Error(`Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
|
|
57
50
|
|
|
58
|
-
Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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;
|
|
51
|
+
Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${require_logger_console.formatLogMessage(configInput)}`, { cause: error });
|
|
52
|
+
}
|
|
53
|
+
} else result = _static_cache.data;
|
|
54
|
+
if (schema && extensionName) result.extensions = {
|
|
55
|
+
...result.extensions,
|
|
56
|
+
[extensionName]: createConfigExtension(extensionName, schema)
|
|
57
|
+
};
|
|
58
|
+
_static_cache = {
|
|
59
|
+
timestamp: Date.now(),
|
|
60
|
+
data: result
|
|
61
|
+
};
|
|
62
|
+
return result;
|
|
80
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Get the config for a specific Storm config Extension
|
|
66
|
+
*
|
|
67
|
+
* @param extensionName - The name of the config extension
|
|
68
|
+
* @param options - The options for the config extension
|
|
69
|
+
* @returns The config for the specified Storm config extension. If the extension does not exist, `undefined` is returned.
|
|
70
|
+
*/
|
|
81
71
|
const createConfigExtension = (extensionName, schema) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
extension = schema.parse(extension);
|
|
89
|
-
}
|
|
90
|
-
_extension_cache.set(extension_cache_key, extension);
|
|
91
|
-
return extension;
|
|
72
|
+
const extension_cache_key = { extensionName };
|
|
73
|
+
if (_extension_cache.has(extension_cache_key)) return _extension_cache.get(extension_cache_key);
|
|
74
|
+
let extension = require_env_get_env.getExtensionEnv(extensionName);
|
|
75
|
+
if (schema) extension = schema.parse(extension);
|
|
76
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
77
|
+
return extension;
|
|
92
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Load the config file values for the current Storm workspace into environment variables
|
|
81
|
+
*
|
|
82
|
+
* @param workspaceRoot - The root directory of the workspace
|
|
83
|
+
* @param skipLogs - Skip writing logs to the console
|
|
84
|
+
* @returns The config for the current Storm workspace, throws an error if the config file could not be loaded
|
|
85
|
+
*/
|
|
93
86
|
const loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
|
87
|
+
const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs, true);
|
|
88
|
+
require_env_set_env.setConfigEnv(config);
|
|
89
|
+
if (!skipLogs && !config.skipConfigLogging) require_logger_console.writeTrace(`⚙️ Using Storm Workspace configuration: \n${require_logger_console.formatLogMessage(config)}`, config);
|
|
90
|
+
return config;
|
|
110
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Try to load the config file values for the current Storm workspace into environment variables
|
|
94
|
+
*
|
|
95
|
+
* @param workspaceRoot - The root directory of the workspace
|
|
96
|
+
* @param skipLogs - Skip writing logs to the console
|
|
97
|
+
* @param useDefault - Whether to use the default config if no config file is found
|
|
98
|
+
* @returns The config for the current Storm workspace, or undefined if the config file could not be loaded
|
|
99
|
+
*/
|
|
111
100
|
const tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
}
|
|
101
|
+
try {
|
|
102
|
+
const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs, useDefault);
|
|
103
|
+
if (!config) return;
|
|
104
|
+
require_env_set_env.setConfigEnv(config);
|
|
105
|
+
if (!skipLogs && !config.skipConfigLogging) require_logger_console.writeTrace(`⚙️ Using Storm Workspace configuration: \n${require_logger_console.formatLogMessage(config)}`, config);
|
|
106
|
+
return config;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (!skipLogs) require_logger_console.writeWarning(`⚠️ Failed to load Storm Workspace configuration: ${error}`, { logLevel: "all" });
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
141
111
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
exports.createConfigExtension = createConfigExtension; exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
|
|
112
|
+
//#endregion
|
|
113
|
+
exports.createConfigExtension = createConfigExtension;
|
|
114
|
+
exports.createStormWorkspaceConfig = createStormWorkspaceConfig;
|
|
115
|
+
exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig;
|
|
116
|
+
exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StormWorkspaceConfig } from
|
|
2
|
-
import * as z from
|
|
3
|
-
|
|
1
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
//#region src/create-storm-config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Get the config for the current Storm workspace
|
|
6
6
|
*
|
|
@@ -37,5 +37,5 @@ declare const loadStormWorkspaceConfig: (workspaceRoot?: string, skipLogs?: bool
|
|
|
37
37
|
* @returns The config for the current Storm workspace, or undefined if the config file could not be loaded
|
|
38
38
|
*/
|
|
39
39
|
declare const tryLoadStormWorkspaceConfig: (workspaceRoot?: string, skipLogs?: boolean, useDefault?: boolean) => Promise<StormWorkspaceConfig | undefined>;
|
|
40
|
-
|
|
41
|
-
export { createConfigExtension, createStormWorkspaceConfig, loadStormWorkspaceConfig, tryLoadStormWorkspaceConfig };
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createConfigExtension, createStormWorkspaceConfig, loadStormWorkspaceConfig, tryLoadStormWorkspaceConfig };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
//#region src/create-storm-config.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Get the config for the current Storm workspace
|
|
6
8
|
*
|
|
@@ -37,5 +39,5 @@ declare const loadStormWorkspaceConfig: (workspaceRoot?: string, skipLogs?: bool
|
|
|
37
39
|
* @returns The config for the current Storm workspace, or undefined if the config file could not be loaded
|
|
38
40
|
*/
|
|
39
41
|
declare const tryLoadStormWorkspaceConfig: (workspaceRoot?: string, skipLogs?: boolean, useDefault?: boolean) => Promise<StormWorkspaceConfig | undefined>;
|
|
40
|
-
|
|
41
|
-
export { createConfigExtension, createStormWorkspaceConfig, loadStormWorkspaceConfig, tryLoadStormWorkspaceConfig };
|
|
42
|
+
//#endregion
|
|
43
|
+
export { createConfigExtension, createStormWorkspaceConfig, loadStormWorkspaceConfig, tryLoadStormWorkspaceConfig };
|