@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,113 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { formatLogMessage, writeTrace, writeWarning } from "./logger/console.mjs";
|
|
5
|
+
import { joinPaths } from "./utilities/correct-paths.mjs";
|
|
6
|
+
import { findWorkspaceRoot } from "./utilities/find-workspace-root.mjs";
|
|
7
|
+
import { applyDefaultConfig, getPackageJsonConfig } from "./utilities/get-default-config.mjs";
|
|
8
|
+
import { getConfigFile } from "./config-file/get-config-file.mjs";
|
|
9
|
+
import { getConfigEnv, getExtensionEnv } from "./env/get-env.mjs";
|
|
10
|
+
import { setConfigEnv } from "./env/set-env.mjs";
|
|
11
|
+
import { workspaceConfigSchema } from "@storm-software/config/schema";
|
|
12
|
+
import defu from "defu";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
//#region src/create-storm-config.ts
|
|
15
|
+
const _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
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
|
+
*/
|
|
27
|
+
const createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
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 = findWorkspaceRoot();
|
|
32
|
+
const configEnv = getConfigEnv();
|
|
33
|
+
const configFile = await getConfigFile(_workspaceRoot);
|
|
34
|
+
if (!configFile) {
|
|
35
|
+
if (!skipLogs) 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 getPackageJsonConfig(_workspaceRoot);
|
|
39
|
+
const configInput = defu(configEnv, configFile, defaultConfig);
|
|
40
|
+
if (!configInput.variant) configInput.variant = existsSync(joinPaths(_workspaceRoot, "nx.json")) || existsSync(joinPaths(_workspaceRoot, ".nx")) || existsSync(joinPaths(_workspaceRoot, "lerna.json")) || existsSync(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
|
|
41
|
+
try {
|
|
42
|
+
const parseResult = await Promise.resolve(workspaceConfigSchema._zod.parse({
|
|
43
|
+
value: configInput,
|
|
44
|
+
issues: []
|
|
45
|
+
}, { async: true }));
|
|
46
|
+
result = applyDefaultConfig(parseResult.value);
|
|
47
|
+
result.workspaceRoot ??= _workspaceRoot;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new Error(`Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
|
|
50
|
+
|
|
51
|
+
Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${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;
|
|
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
|
+
*/
|
|
71
|
+
const createConfigExtension = (extensionName, schema) => {
|
|
72
|
+
const extension_cache_key = { extensionName };
|
|
73
|
+
if (_extension_cache.has(extension_cache_key)) return _extension_cache.get(extension_cache_key);
|
|
74
|
+
let extension = getExtensionEnv(extensionName);
|
|
75
|
+
if (schema) extension = schema.parse(extension);
|
|
76
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
77
|
+
return extension;
|
|
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
|
+
*/
|
|
86
|
+
const loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
87
|
+
const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs, true);
|
|
88
|
+
setConfigEnv(config);
|
|
89
|
+
if (!skipLogs && !config.skipConfigLogging) writeTrace(`⚙️ Using Storm Workspace configuration: \n${formatLogMessage(config)}`, config);
|
|
90
|
+
return config;
|
|
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
|
+
*/
|
|
100
|
+
const tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
|
|
101
|
+
try {
|
|
102
|
+
const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs, useDefault);
|
|
103
|
+
if (!config) return;
|
|
104
|
+
setConfigEnv(config);
|
|
105
|
+
if (!skipLogs && !config.skipConfigLogging) writeTrace(`⚙️ Using Storm Workspace configuration: \n${formatLogMessage(config)}`, config);
|
|
106
|
+
return config;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (!skipLogs) writeWarning(`⚠️ Failed to load Storm Workspace configuration: ${error}`, { logLevel: "all" });
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { createConfigExtension, createStormWorkspaceConfig, loadStormWorkspaceConfig, tryLoadStormWorkspaceConfig };
|
package/dist/env/get-env.cjs
CHANGED
|
@@ -1,226 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_logger_get_log_level = require("../logger/get-log-level.cjs");
|
|
3
|
+
const require_utilities_correct_paths = require("../utilities/correct-paths.cjs");
|
|
4
|
+
let _storm_software_config = require("@storm-software/config");
|
|
5
|
+
//#region src/env/get-env.ts
|
|
6
|
+
/**
|
|
7
|
+
* Get the config for an extension module of Storm workspace from environment variables
|
|
8
|
+
*
|
|
9
|
+
* @param extensionName - The name of the extension module
|
|
10
|
+
* @returns The config for the specified Storm extension module. If the module does not exist, `undefined` is returned.
|
|
11
|
+
*/
|
|
9
12
|
const getExtensionEnv = (extensionName) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ret[name] = process.env[key];
|
|
17
|
-
}
|
|
18
|
-
return ret;
|
|
19
|
-
}, {});
|
|
13
|
+
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
14
|
+
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
15
|
+
const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
|
|
16
|
+
if (name) ret[name] = process.env[key];
|
|
17
|
+
return ret;
|
|
18
|
+
}, {});
|
|
20
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the config for the current Storm workspace
|
|
22
|
+
*
|
|
23
|
+
* @returns The config for the current Storm workspace from environment variables
|
|
24
|
+
*/
|
|
21
25
|
const getConfigEnv = () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
if (config.licensing === _config.STORM_DEFAULT_LICENSING) {
|
|
127
|
-
if (config.homepage === _config.STORM_DEFAULT_HOMEPAGE) {
|
|
128
|
-
config.licensing = `${_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
|
|
129
|
-
} else {
|
|
130
|
-
config.licensing = `${config.homepage}/docs`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const serializedConfig = process.env[`${prefix}WORKSPACE_CONFIG`];
|
|
134
|
-
if (serializedConfig) {
|
|
135
|
-
const parsed = JSON.parse(serializedConfig);
|
|
136
|
-
config = {
|
|
137
|
-
...config,
|
|
138
|
-
...parsed,
|
|
139
|
-
colors: { ...config.colors, ...parsed.colors },
|
|
140
|
-
extensions: { ...config.extensions, ...parsed.extensions }
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return config;
|
|
26
|
+
const prefix = "STORM_";
|
|
27
|
+
let config = {
|
|
28
|
+
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
29
|
+
name: process.env[`${prefix}NAME`] || void 0,
|
|
30
|
+
variant: process.env[`${prefix}VARIANT`] || void 0,
|
|
31
|
+
namespace: process.env[`${prefix}NAMESPACE`] || void 0,
|
|
32
|
+
owner: process.env[`${prefix}OWNER`] || void 0,
|
|
33
|
+
bot: {
|
|
34
|
+
name: process.env[`${prefix}BOT_NAME`] || void 0,
|
|
35
|
+
email: process.env[`${prefix}BOT_EMAIL`] || void 0
|
|
36
|
+
},
|
|
37
|
+
release: {
|
|
38
|
+
banner: {
|
|
39
|
+
url: process.env[`${prefix}RELEASE_BANNER_URL`] || void 0,
|
|
40
|
+
alt: process.env[`${prefix}RELEASE_BANNER_ALT`] || void 0
|
|
41
|
+
},
|
|
42
|
+
header: process.env[`${prefix}RELEASE_HEADER`] || void 0,
|
|
43
|
+
footer: process.env[`${prefix}RELEASE_FOOTER`] || void 0
|
|
44
|
+
},
|
|
45
|
+
error: {
|
|
46
|
+
codesFile: process.env[`${prefix}ERROR_CODES_FILE`] || void 0,
|
|
47
|
+
url: process.env[`${prefix}ERROR_URL`] || void 0
|
|
48
|
+
},
|
|
49
|
+
socials: {
|
|
50
|
+
twitter: process.env[`${prefix}SOCIAL_TWITTER`] || void 0,
|
|
51
|
+
discord: process.env[`${prefix}SOCIAL_DISCORD`] || void 0,
|
|
52
|
+
telegram: process.env[`${prefix}SOCIAL_TELEGRAM`] || void 0,
|
|
53
|
+
slack: process.env[`${prefix}SOCIAL_SLACK`] || void 0,
|
|
54
|
+
medium: process.env[`${prefix}SOCIAL_MEDIUM`] || void 0,
|
|
55
|
+
github: process.env[`${prefix}SOCIAL_GITHUB`] || void 0
|
|
56
|
+
},
|
|
57
|
+
organization: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] ? process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] ? {
|
|
58
|
+
name: process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`],
|
|
59
|
+
description: process.env[`${prefix}ORG_DESCRIPTION`] || process.env[`${prefix}ORGANIZATION_DESCRIPTION`] || void 0,
|
|
60
|
+
url: process.env[`${prefix}ORG_URL`] || process.env[`${prefix}ORGANIZATION_URL`] || void 0,
|
|
61
|
+
logo: process.env[`${prefix}ORG_LOGO`] || process.env[`${prefix}ORGANIZATION_LOGO`] || void 0,
|
|
62
|
+
icon: process.env[`${prefix}ORG_ICON`] || process.env[`${prefix}ORGANIZATION_ICON`] || void 0
|
|
63
|
+
} : process.env[`${prefix}ORG`] || process.env[`${prefix}ORGANIZATION`] || process.env[`${prefix}ORG_NAME`] || process.env[`${prefix}ORGANIZATION_NAME`] : void 0,
|
|
64
|
+
packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
|
|
65
|
+
license: process.env[`${prefix}LICENSE`] || void 0,
|
|
66
|
+
homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
|
|
67
|
+
docs: process.env[`${prefix}DOCS`] || void 0,
|
|
68
|
+
portal: process.env[`${prefix}PORTAL`] || void 0,
|
|
69
|
+
licensing: process.env[`${prefix}LICENSING`] || void 0,
|
|
70
|
+
contact: process.env[`${prefix}CONTACT`] || void 0,
|
|
71
|
+
support: process.env[`${prefix}SUPPORT`] || void 0,
|
|
72
|
+
timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
|
|
73
|
+
locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
|
|
74
|
+
configFile: process.env[`${prefix}WORKSPACE_CONFIG_FILE`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}WORKSPACE_CONFIG_FILE`]) : void 0,
|
|
75
|
+
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
|
|
76
|
+
directories: {
|
|
77
|
+
cache: process.env[`${prefix}CACHE_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}CACHE_DIR`]) : process.env[`${prefix}CACHE_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}CACHE_DIRECTORY`]) : void 0,
|
|
78
|
+
data: process.env[`${prefix}DATA_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}DATA_DIR`]) : process.env[`${prefix}DATA_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}DATA_DIRECTORY`]) : void 0,
|
|
79
|
+
config: process.env[`${prefix}CONFIG_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}CONFIG_DIR`]) : process.env[`${prefix}CONFIG_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}CONFIG_DIRECTORY`]) : void 0,
|
|
80
|
+
temp: process.env[`${prefix}TEMP_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}TEMP_DIR`]) : process.env[`${prefix}TEMP_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}TEMP_DIRECTORY`]) : void 0,
|
|
81
|
+
log: process.env[`${prefix}LOG_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}LOG_DIR`]) : process.env[`${prefix}LOG_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}LOG_DIRECTORY`]) : void 0,
|
|
82
|
+
build: process.env[`${prefix}BUILD_DIR`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}BUILD_DIR`]) : process.env[`${prefix}BUILD_DIRECTORY`] ? require_utilities_correct_paths.correctPaths(process.env[`${prefix}BUILD_DIRECTORY`]) : void 0
|
|
83
|
+
},
|
|
84
|
+
skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
|
|
85
|
+
mode: (process.env[`${prefix}MODE`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
|
|
86
|
+
repository: process.env[`${prefix}REPOSITORY`] || void 0,
|
|
87
|
+
branch: process.env[`${prefix}BRANCH`] || void 0,
|
|
88
|
+
preid: process.env[`${prefix}PRE_ID`] || void 0,
|
|
89
|
+
registry: {
|
|
90
|
+
github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
|
|
91
|
+
npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
|
|
92
|
+
cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
|
|
93
|
+
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
94
|
+
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
95
|
+
},
|
|
96
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? require_logger_get_log_level.getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0,
|
|
97
|
+
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
|
|
98
|
+
};
|
|
99
|
+
const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && _storm_software_config.COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
|
|
100
|
+
config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
|
|
101
|
+
ret[themeName] = getThemeColorsEnv(prefix, themeName);
|
|
102
|
+
return ret;
|
|
103
|
+
}, {}) : getThemeColorsEnv(prefix);
|
|
104
|
+
if (config.docs === _storm_software_config.STORM_DEFAULT_DOCS) {
|
|
105
|
+
if (config.homepage === _storm_software_config.STORM_DEFAULT_HOMEPAGE) config.docs = `${_storm_software_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
106
|
+
else config.docs = `${config.homepage}/docs`;
|
|
107
|
+
}
|
|
108
|
+
if (config.licensing === _storm_software_config.STORM_DEFAULT_LICENSING) {
|
|
109
|
+
if (config.homepage === _storm_software_config.STORM_DEFAULT_HOMEPAGE) config.licensing = `${_storm_software_config.STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
|
|
110
|
+
else config.licensing = `${config.homepage}/docs`;
|
|
111
|
+
}
|
|
112
|
+
const serializedConfig = process.env[`${prefix}WORKSPACE_CONFIG`];
|
|
113
|
+
if (serializedConfig) {
|
|
114
|
+
const parsed = JSON.parse(serializedConfig);
|
|
115
|
+
config = {
|
|
116
|
+
...config,
|
|
117
|
+
...parsed,
|
|
118
|
+
colors: {
|
|
119
|
+
...config.colors,
|
|
120
|
+
...parsed.colors
|
|
121
|
+
},
|
|
122
|
+
extensions: {
|
|
123
|
+
...config.extensions,
|
|
124
|
+
...parsed.extensions
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return config;
|
|
144
129
|
};
|
|
145
130
|
const getThemeColorsEnv = (prefix, theme) => {
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
132
|
+
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorsEnv(prefix + themeName) : getSingleThemeColorsEnv(prefix + themeName);
|
|
148
133
|
};
|
|
149
134
|
const getSingleThemeColorsEnv = (prefix) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
179
|
-
negative: process.env[`${prefix}NEGATIVE`],
|
|
180
|
-
gradient
|
|
181
|
-
};
|
|
135
|
+
const gradient = [];
|
|
136
|
+
if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) gradient.push(process.env[`${prefix}GRADIENT_START`], process.env[`${prefix}GRADIENT_END`]);
|
|
137
|
+
else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
|
|
138
|
+
let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
|
|
139
|
+
while (process.env[`${prefix}GRADIENT_${index}`]) {
|
|
140
|
+
gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
|
|
141
|
+
index++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
dark: process.env[`${prefix}DARK`],
|
|
146
|
+
light: process.env[`${prefix}LIGHT`],
|
|
147
|
+
brand: process.env[`${prefix}BRAND`],
|
|
148
|
+
alternate: process.env[`${prefix}ALTERNATE`],
|
|
149
|
+
accent: process.env[`${prefix}ACCENT`],
|
|
150
|
+
link: process.env[`${prefix}LINK`],
|
|
151
|
+
discovery: process.env[`${prefix}DISCOVERY`],
|
|
152
|
+
success: process.env[`${prefix}SUCCESS`],
|
|
153
|
+
info: process.env[`${prefix}INFO`],
|
|
154
|
+
debug: process.env[`${prefix}DEBUG`],
|
|
155
|
+
warning: process.env[`${prefix}WARNING`],
|
|
156
|
+
danger: process.env[`${prefix}DANGER`],
|
|
157
|
+
fatal: process.env[`${prefix}FATAL`],
|
|
158
|
+
performance: process.env[`${prefix}PERFORMANCE`],
|
|
159
|
+
positive: process.env[`${prefix}POSITIVE`],
|
|
160
|
+
negative: process.env[`${prefix}NEGATIVE`],
|
|
161
|
+
gradient
|
|
162
|
+
};
|
|
182
163
|
};
|
|
183
164
|
const getMultiThemeColorsEnv = (prefix) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
165
|
+
return {
|
|
166
|
+
light: getBaseThemeColorsEnv(`${prefix}_LIGHT_`),
|
|
167
|
+
dark: getBaseThemeColorsEnv(`${prefix}_DARK_`)
|
|
168
|
+
};
|
|
188
169
|
};
|
|
189
170
|
const getBaseThemeColorsEnv = (prefix) => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
positive: process.env[`${prefix}POSITIVE`],
|
|
219
|
-
negative: process.env[`${prefix}NEGATIVE`],
|
|
220
|
-
gradient
|
|
221
|
-
};
|
|
171
|
+
const gradient = [];
|
|
172
|
+
if (process.env[`${prefix}GRADIENT_START`] && process.env[`${prefix}GRADIENT_END`]) gradient.push(process.env[`${prefix}GRADIENT_START`], process.env[`${prefix}GRADIENT_END`]);
|
|
173
|
+
else if (process.env[`${prefix}GRADIENT_0`] || process.env[`${prefix}GRADIENT_1`]) {
|
|
174
|
+
let index = process.env[`${prefix}GRADIENT_0`] ? 0 : 1;
|
|
175
|
+
while (process.env[`${prefix}GRADIENT_${index}`]) {
|
|
176
|
+
gradient.push(process.env[`${prefix}GRADIENT_${index}`]);
|
|
177
|
+
index++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
foreground: process.env[`${prefix}FOREGROUND`],
|
|
182
|
+
background: process.env[`${prefix}BACKGROUND`],
|
|
183
|
+
brand: process.env[`${prefix}BRAND`],
|
|
184
|
+
alternate: process.env[`${prefix}ALTERNATE`],
|
|
185
|
+
accent: process.env[`${prefix}ACCENT`],
|
|
186
|
+
link: process.env[`${prefix}LINK`],
|
|
187
|
+
discovery: process.env[`${prefix}DISCOVERY`],
|
|
188
|
+
success: process.env[`${prefix}SUCCESS`],
|
|
189
|
+
info: process.env[`${prefix}INFO`],
|
|
190
|
+
debug: process.env[`${prefix}DEBUG`],
|
|
191
|
+
warning: process.env[`${prefix}WARNING`],
|
|
192
|
+
danger: process.env[`${prefix}DANGER`],
|
|
193
|
+
fatal: process.env[`${prefix}FATAL`],
|
|
194
|
+
performance: process.env[`${prefix}PERFORMANCE`],
|
|
195
|
+
positive: process.env[`${prefix}POSITIVE`],
|
|
196
|
+
negative: process.env[`${prefix}NEGATIVE`],
|
|
197
|
+
gradient
|
|
198
|
+
};
|
|
222
199
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
exports.getConfigEnv = getConfigEnv; exports.getExtensionEnv = getExtensionEnv;
|
|
200
|
+
//#endregion
|
|
201
|
+
exports.getConfigEnv = getConfigEnv;
|
|
202
|
+
exports.getExtensionEnv = getExtensionEnv;
|
package/dist/env/get-env.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { DeepPartial } from "../types.cjs";
|
|
2
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
3
|
+
//#region src/env/get-env.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Get the config for an extension module of Storm workspace from environment variables
|
|
6
6
|
*
|
|
@@ -14,5 +14,5 @@ declare const getExtensionEnv: <TConfig extends Record<string, any> = Record<str
|
|
|
14
14
|
* @returns The config for the current Storm workspace from environment variables
|
|
15
15
|
*/
|
|
16
16
|
declare const getConfigEnv: () => DeepPartial<StormWorkspaceConfig>;
|
|
17
|
-
|
|
18
|
-
export { getConfigEnv, getExtensionEnv };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getConfigEnv, getExtensionEnv };
|
|
@@ -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 { DeepPartial } from "../types.mjs";
|
|
4
|
+
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
5
|
+
//#region src/env/get-env.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Get the config for an extension module of Storm workspace from environment variables
|
|
6
8
|
*
|
|
@@ -14,5 +16,5 @@ declare const getExtensionEnv: <TConfig extends Record<string, any> = Record<str
|
|
|
14
16
|
* @returns The config for the current Storm workspace from environment variables
|
|
15
17
|
*/
|
|
16
18
|
declare const getConfigEnv: () => DeepPartial<StormWorkspaceConfig>;
|
|
17
|
-
|
|
18
|
-
export { getConfigEnv, getExtensionEnv };
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getConfigEnv, getExtensionEnv };
|