@storm-software/config-tools 1.5.5 → 1.5.6
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/CHANGELOG.md +7 -0
- package/index.cjs +457 -34
- package/index.js +414 -0
- package/meta.cjs.json +1 -1
- package/meta.esm.json +1 -1
- package/package.json +1 -1
- package/declarations.d.js +0 -0
- package/packages/config-tools/declarations.d.cjs +0 -15
- package/packages/config-tools/src/config-file/get-config-file.cjs +0 -61
- package/packages/config-tools/src/config-file/index.cjs +0 -21
- package/packages/config-tools/src/create-storm-config.cjs +0 -61
- package/packages/config-tools/src/env/get-env.cjs +0 -92
- package/packages/config-tools/src/env/index.cjs +0 -23
- package/packages/config-tools/src/env/set-env.cjs +0 -102
- package/packages/config-tools/src/index.cjs +0 -31
- package/packages/config-tools/src/schema.cjs +0 -89
- package/packages/config-tools/src/types.cjs +0 -46
- package/packages/config-tools/src/utilities/get-default-config.cjs +0 -102
- package/packages/config-tools/src/utilities/get-log-level.cjs +0 -68
- package/packages/config-tools/src/utilities/index.cjs +0 -23
- package/packages/testing-tools/src/index.cjs +0 -23
- package/packages/testing-tools/src/jest/package.config.cjs +0 -37
- package/packages/testing-tools/src/jest/workspace.config.cjs +0 -72
- package/src/config-file/get-config-file.js +0 -38
- package/src/config-file/index.js +0 -1
- package/src/create-storm-config.js +0 -37
- package/src/env/get-env.js +0 -68
- package/src/env/index.js +0 -2
- package/src/env/set-env.js +0 -78
- package/src/index.js +0 -6
- package/src/schema.js +0 -55
- package/src/types.js +0 -22
- package/src/utilities/get-default-config.js +0 -77
- package/src/utilities/get-log-level.js +0 -44
- package/src/utilities/index.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.5.5](https://github.com/storm-software/storm-ops/compare/config-tools-v1.5.4...config-tools-v1.5.5) (2023-12-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **config-tools:** Update project config to no longer bundle ([06b72cd](https://github.com/storm-software/storm-ops/commit/06b72cdea2b85826571d177dad1cb352769c0f76))
|
|
7
|
+
|
|
1
8
|
## [1.5.4](https://github.com/storm-software/storm-ops/compare/config-tools-v1.5.3...config-tools-v1.5.4) (2023-12-20)
|
|
2
9
|
|
|
3
10
|
|
package/index.cjs
CHANGED
|
@@ -1,42 +1,465 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// packages/config-tools/src/index.ts
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
ColorConfigSchema: () => ColorConfigSchema,
|
|
33
|
+
DefaultColorConfig: () => DefaultColorConfig,
|
|
34
|
+
DefaultStormConfig: () => DefaultStormConfig,
|
|
35
|
+
LogLevel: () => LogLevel,
|
|
36
|
+
LogLevelLabel: () => LogLevelLabel,
|
|
37
|
+
StormConfigSchema: () => StormConfigSchema,
|
|
38
|
+
createConfigExtension: () => createConfigExtension,
|
|
39
|
+
createStormConfig: () => createStormConfig,
|
|
40
|
+
getConfigEnv: () => getConfigEnv,
|
|
41
|
+
getConfigFile: () => getConfigFile,
|
|
42
|
+
getDefaultConfig: () => getDefaultConfig,
|
|
43
|
+
getExtensionEnv: () => getExtensionEnv,
|
|
44
|
+
getLogLevel: () => getLogLevel,
|
|
45
|
+
getLogLevelLabel: () => getLogLevelLabel,
|
|
46
|
+
setConfigEnv: () => setConfigEnv,
|
|
47
|
+
setExtensionEnv: () => setExtensionEnv
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(src_exports);
|
|
50
|
+
|
|
51
|
+
// packages/config-tools/src/config-file/get-config-file.ts
|
|
52
|
+
var import_cosmiconfig = require("cosmiconfig");
|
|
53
|
+
var _static_cache = void 0;
|
|
54
|
+
var getConfigFileName = (fileName) => (0, import_cosmiconfig.cosmiconfig)(fileName, { cache: true }).search();
|
|
55
|
+
var getConfigFile = async () => {
|
|
56
|
+
if (_static_cache) {
|
|
57
|
+
return _static_cache;
|
|
58
|
+
}
|
|
59
|
+
let cosmiconfigResult = await getConfigFileName("storm");
|
|
60
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
61
|
+
cosmiconfigResult = await getConfigFileName("storm-software");
|
|
62
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
63
|
+
cosmiconfigResult = await getConfigFileName("storm-stack");
|
|
64
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
65
|
+
cosmiconfigResult = await getConfigFileName("storm-cloud");
|
|
66
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
67
|
+
cosmiconfigResult = await getConfigFileName("acidic");
|
|
68
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
69
|
+
cosmiconfigResult = await getConfigFileName("acid");
|
|
70
|
+
}
|
|
24
71
|
}
|
|
25
72
|
}
|
|
26
73
|
}
|
|
27
74
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
75
|
+
if (!cosmiconfigResult || Object.keys(cosmiconfigResult).length === 0 || cosmiconfigResult.isEmpty || !cosmiconfigResult.filepath) {
|
|
76
|
+
console.warn(
|
|
77
|
+
"No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.config.js` file to the root of your workspace if it is not."
|
|
78
|
+
);
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
const config = cosmiconfigResult.config ?? {};
|
|
82
|
+
cosmiconfigResult.filepath && (config.configFile = cosmiconfigResult.filepath);
|
|
83
|
+
config.runtimeVersion = "0.0.1";
|
|
84
|
+
_static_cache = config;
|
|
85
|
+
return config;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// packages/config-tools/src/types.ts
|
|
89
|
+
var LogLevel = {
|
|
90
|
+
SILENT: 0,
|
|
91
|
+
FATAL: 10,
|
|
92
|
+
ERROR: 20,
|
|
93
|
+
WARN: 30,
|
|
94
|
+
INFO: 40,
|
|
95
|
+
DEBUG: 60,
|
|
96
|
+
TRACE: 70
|
|
97
|
+
};
|
|
98
|
+
var LogLevelLabel = {
|
|
99
|
+
SILENT: "silent",
|
|
100
|
+
FATAL: "fatal",
|
|
101
|
+
ERROR: "error",
|
|
102
|
+
WARN: "warn",
|
|
103
|
+
INFO: "info",
|
|
104
|
+
DEBUG: "debug",
|
|
105
|
+
TRACE: "trace"
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// packages/config-tools/src/utilities/get-default-config.ts
|
|
109
|
+
var import_fs = require("fs");
|
|
110
|
+
var import_find_workspace_root = require("nx/src/utils/find-workspace-root.js");
|
|
111
|
+
var import_path = require("path");
|
|
112
|
+
|
|
113
|
+
// packages/config-tools/src/schema.ts
|
|
114
|
+
var z = __toESM(require("zod"));
|
|
115
|
+
var ColorConfigSchema = z.object({
|
|
116
|
+
primary: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The primary color of the workspace"),
|
|
117
|
+
background: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d232a").describe("The background color of the workspace"),
|
|
118
|
+
success: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#087f5b").describe("The success color of the workspace"),
|
|
119
|
+
info: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The informational color of the workspace"),
|
|
120
|
+
warning: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace"),
|
|
121
|
+
error: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#990000").describe("The error color of the workspace"),
|
|
122
|
+
fatal: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#7d1a1a").describe("The fatal color of the workspace")
|
|
123
|
+
}).describe("Colors used for various workspace elements");
|
|
124
|
+
var StormConfigSchema = z.object({
|
|
125
|
+
name: z.string().trim().toLowerCase().describe("The name of the package"),
|
|
126
|
+
namespace: z.string().trim().toLowerCase().default("storm-software").describe("The namespace of the package"),
|
|
127
|
+
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
128
|
+
repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
129
|
+
license: z.string().trim().default("Apache License 2.0").describe("The root directory of the package"),
|
|
130
|
+
homepage: z.string().trim().url().default("https://stormsoftware.org").describe("The homepage of the workspace"),
|
|
131
|
+
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
132
|
+
preMajor: z.boolean().default(false).describe(
|
|
133
|
+
"An indicator specifying if the package is still in it's pre-major version"
|
|
134
|
+
),
|
|
135
|
+
owner: z.string().trim().default("@storm-software/development").describe("The owner of the package"),
|
|
136
|
+
worker: z.string().trim().default("stormie-bot").describe(
|
|
137
|
+
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
138
|
+
),
|
|
139
|
+
env: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment of the package"),
|
|
140
|
+
ci: z.boolean().default(true).describe(
|
|
141
|
+
"An indicator specifying if the current environment is a CI environment"
|
|
142
|
+
),
|
|
143
|
+
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
144
|
+
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
145
|
+
buildDirectory: z.string().trim().default("dist").describe("The build directory for the workspace"),
|
|
146
|
+
runtimeDirectory: z.string().trim().default("node_modules/.storm").describe("The runtime directory of Storm"),
|
|
147
|
+
runtimeVersion: z.string().trim().regex(
|
|
148
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
149
|
+
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
150
|
+
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
151
|
+
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
152
|
+
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
153
|
+
"The log level used to filter out lower priority log messages. If not provided, this is defaulted using the `environment` config value (if `environment` is set to `production` then `level` is `error`, else `level` is `debug`)."
|
|
154
|
+
),
|
|
155
|
+
configFile: z.string().trim().nullable().default(null).describe(
|
|
156
|
+
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
157
|
+
),
|
|
158
|
+
colors: ColorConfigSchema.describe(
|
|
159
|
+
"Storm theme config values used for styling various package elements"
|
|
160
|
+
),
|
|
161
|
+
extensions: z.record(z.any()).default({}).describe("Configuration of each used extension")
|
|
162
|
+
}).describe(
|
|
163
|
+
"Storm Workspace config values used during various dev-ops processes. This type is a combination of the StormPackageConfig and StormProject types. It represents the config of the entire monorepo."
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// packages/config-tools/src/utilities/get-default-config.ts
|
|
167
|
+
var DefaultColorConfig = {
|
|
168
|
+
primary: "#1fb2a6",
|
|
169
|
+
background: "#1d232a",
|
|
170
|
+
success: "#087f5b",
|
|
171
|
+
info: "#0ea5e9",
|
|
172
|
+
warning: "#fcc419",
|
|
173
|
+
error: "#990000",
|
|
174
|
+
fatal: "#7d1a1a"
|
|
175
|
+
};
|
|
176
|
+
var DefaultStormConfig = {
|
|
177
|
+
namespace: "storm-software",
|
|
178
|
+
license: "Apache License 2.0",
|
|
179
|
+
homepage: "https://stormsoftware.org",
|
|
180
|
+
preMajor: false,
|
|
181
|
+
owner: "@storm-software/development",
|
|
182
|
+
worker: "stormie-bot",
|
|
183
|
+
runtimeDirectory: "node_modules/.storm",
|
|
184
|
+
timezone: "America/New_York",
|
|
185
|
+
locale: "en-US",
|
|
186
|
+
env: "production",
|
|
187
|
+
branch: "main",
|
|
188
|
+
organization: "storm-software",
|
|
189
|
+
ci: true,
|
|
190
|
+
configFile: null,
|
|
191
|
+
runtimeVersion: "1.0.0",
|
|
192
|
+
colors: { ...DefaultColorConfig },
|
|
193
|
+
extensions: {}
|
|
194
|
+
};
|
|
195
|
+
var getDefaultConfig = (config = {}) => {
|
|
196
|
+
let name = "storm-workspace";
|
|
197
|
+
let namespace = "storm-software";
|
|
198
|
+
let repository = "https://github.com/storm-software/storm-stack";
|
|
199
|
+
let license = DefaultStormConfig.license;
|
|
200
|
+
let homepage = DefaultStormConfig.homepage;
|
|
201
|
+
const workspaceRoot = getWorkspaceRoot() ?? process.cwd();
|
|
202
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(workspaceRoot, "package.json"))) {
|
|
203
|
+
const file = (0, import_fs.readFileSync)((0, import_path.join)(workspaceRoot, "package.json"), {
|
|
204
|
+
encoding: "utf-8"
|
|
205
|
+
});
|
|
206
|
+
if (file) {
|
|
207
|
+
const packageJson = JSON.parse(file);
|
|
208
|
+
packageJson.name && (name = packageJson.name);
|
|
209
|
+
packageJson.namespace && (namespace = packageJson.namespace);
|
|
210
|
+
packageJson.repository?.url && (repository = packageJson.repository?.url);
|
|
211
|
+
packageJson.license && (license = packageJson.license);
|
|
212
|
+
packageJson.homepage && (homepage = packageJson.homepage);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return StormConfigSchema.parse(
|
|
216
|
+
Object.assign(config, {
|
|
217
|
+
...DefaultStormConfig,
|
|
218
|
+
colors: { ...DefaultColorConfig },
|
|
219
|
+
workspaceRoot,
|
|
220
|
+
name,
|
|
221
|
+
namespace,
|
|
222
|
+
repository,
|
|
223
|
+
license: license ?? DefaultStormConfig.license,
|
|
224
|
+
homepage: homepage ?? DefaultStormConfig.homepage,
|
|
225
|
+
extensions: {}
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
var getWorkspaceRoot = () => {
|
|
230
|
+
const root = (0, import_find_workspace_root.findWorkspaceRoot)(process.cwd());
|
|
231
|
+
process.env.STORM_WORKSPACE_ROOT ??= root?.dir;
|
|
232
|
+
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir;
|
|
233
|
+
return root?.dir;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// packages/config-tools/src/utilities/get-log-level.ts
|
|
237
|
+
var getLogLevel = (label) => {
|
|
238
|
+
switch (label) {
|
|
239
|
+
case "trace":
|
|
240
|
+
return LogLevel.TRACE;
|
|
241
|
+
case "debug":
|
|
242
|
+
return LogLevel.DEBUG;
|
|
243
|
+
case "info":
|
|
244
|
+
return LogLevel.INFO;
|
|
245
|
+
case "warn":
|
|
246
|
+
return LogLevel.WARN;
|
|
247
|
+
case "error":
|
|
248
|
+
return LogLevel.ERROR;
|
|
249
|
+
case "fatal":
|
|
250
|
+
return LogLevel.FATAL;
|
|
251
|
+
case "silent":
|
|
252
|
+
return LogLevel.SILENT;
|
|
253
|
+
default:
|
|
254
|
+
return LogLevel.INFO;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var getLogLevelLabel = (logLevel) => {
|
|
258
|
+
if (logLevel >= LogLevel.TRACE) {
|
|
259
|
+
return LogLevelLabel.TRACE;
|
|
260
|
+
} else if (logLevel >= LogLevel.DEBUG) {
|
|
261
|
+
return LogLevelLabel.DEBUG;
|
|
262
|
+
} else if (logLevel >= LogLevel.INFO) {
|
|
263
|
+
return LogLevelLabel.INFO;
|
|
264
|
+
} else if (logLevel >= LogLevel.WARN) {
|
|
265
|
+
return LogLevelLabel.WARN;
|
|
266
|
+
} else if (logLevel >= LogLevel.ERROR) {
|
|
267
|
+
return LogLevelLabel.ERROR;
|
|
268
|
+
} else if (logLevel >= LogLevel.FATAL) {
|
|
269
|
+
return LogLevelLabel.FATAL;
|
|
270
|
+
} else if (logLevel <= LogLevel.SILENT) {
|
|
271
|
+
return LogLevelLabel.SILENT;
|
|
31
272
|
} else {
|
|
32
|
-
return
|
|
273
|
+
return LogLevelLabel.INFO;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// packages/config-tools/src/env/get-env.ts
|
|
278
|
+
var getExtensionEnv = (extensionName) => {
|
|
279
|
+
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
280
|
+
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
281
|
+
const name = key.replace(prefix, "").split("_").map(
|
|
282
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
283
|
+
).join("");
|
|
284
|
+
name && (ret[name] = process.env[key]);
|
|
285
|
+
return ret;
|
|
286
|
+
}, {});
|
|
287
|
+
};
|
|
288
|
+
var getConfigEnv = () => {
|
|
289
|
+
const prefix = `STORM_`;
|
|
290
|
+
let config = {
|
|
291
|
+
name: process.env[`${prefix}NAME`],
|
|
292
|
+
namespace: process.env[`${prefix}NAMESPACE`],
|
|
293
|
+
owner: process.env[`${prefix}OWNER`],
|
|
294
|
+
worker: process.env[`${prefix}WORKER`],
|
|
295
|
+
organization: process.env[`${prefix}ORGANIZATION`],
|
|
296
|
+
license: process.env[`${prefix}LICENSE`],
|
|
297
|
+
homepage: process.env[`${prefix}HOMEPAGE`],
|
|
298
|
+
timezone: process.env[`${prefix}TIMEZONE`] ?? process.env.TZ,
|
|
299
|
+
locale: process.env[`${prefix}LOCALE`] ?? process.env.LOCALE,
|
|
300
|
+
configFile: process.env[`${prefix}CONFIG_FILE`],
|
|
301
|
+
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`],
|
|
302
|
+
packageDirectory: process.env[`${prefix}PACKAGE_DIRECTORY`],
|
|
303
|
+
buildDirectory: process.env[`${prefix}BUILD_DIRECTORY`],
|
|
304
|
+
runtimeVersion: process.env[`${prefix}RUNTIME_VERSION`],
|
|
305
|
+
runtimeDirectory: process.env[`${prefix}RUNTIME_DIRECTORY`],
|
|
306
|
+
env: process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT,
|
|
307
|
+
ci: Boolean(
|
|
308
|
+
process.env[`${prefix}CI`] ?? process.env.CI ?? process.env.CONTINUOUS_INTEGRATION
|
|
309
|
+
),
|
|
310
|
+
colors: {
|
|
311
|
+
primary: process.env[`${prefix}COLOR_PRIMARY`],
|
|
312
|
+
background: process.env[`${prefix}COLOR_BACKGROUND`],
|
|
313
|
+
success: process.env[`${prefix}COLOR_SUCCESS`],
|
|
314
|
+
info: process.env[`${prefix}COLOR_INFO`],
|
|
315
|
+
warning: process.env[`${prefix}COLOR_WARNING`],
|
|
316
|
+
error: process.env[`${prefix}COLOR_ERROR`],
|
|
317
|
+
fatal: process.env[`${prefix}COLOR_FATAL`]
|
|
318
|
+
},
|
|
319
|
+
repository: process.env[`${prefix}REPOSITORY`],
|
|
320
|
+
branch: process.env[`${prefix}BRANCH`],
|
|
321
|
+
preMajor: Boolean(process.env[`${prefix}PRE_MAJOR`]),
|
|
322
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? Number.isSafeInteger(
|
|
323
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
324
|
+
) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : LogLevelLabel.INFO,
|
|
325
|
+
extensions: {}
|
|
326
|
+
};
|
|
327
|
+
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
328
|
+
if (serializedConfig) {
|
|
329
|
+
config = Object.assign(config, JSON.parse(serializedConfig));
|
|
33
330
|
}
|
|
331
|
+
const extensionPrefix = `${prefix}EXTENSION_`;
|
|
332
|
+
return Object.keys(process.env).filter((key) => key.startsWith(extensionPrefix)).reduce((ret, key) => {
|
|
333
|
+
const extensionName = key.substring(prefix.length, key.indexOf("_", prefix.length)).split("_").map(
|
|
334
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
335
|
+
).join("");
|
|
336
|
+
extensionName && (ret.extensions[extensionName] = getExtensionEnv(extensionName));
|
|
337
|
+
return ret;
|
|
338
|
+
}, config);
|
|
34
339
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
340
|
+
|
|
341
|
+
// packages/config-tools/src/create-storm-config.ts
|
|
342
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
343
|
+
var _static_cache2 = void 0;
|
|
344
|
+
var createStormConfig = (extensionName, schema) => {
|
|
345
|
+
let result;
|
|
346
|
+
if (!_static_cache2) {
|
|
347
|
+
let config = getConfigEnv();
|
|
348
|
+
result = StormConfigSchema.parse(config);
|
|
349
|
+
} else {
|
|
350
|
+
result = _static_cache2;
|
|
40
351
|
}
|
|
41
|
-
|
|
42
|
-
|
|
352
|
+
if (schema && extensionName) {
|
|
353
|
+
result.extensions = {
|
|
354
|
+
...result.extensions,
|
|
355
|
+
[extensionName]: createConfigExtension(extensionName, schema)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
_static_cache2 = result;
|
|
359
|
+
return result;
|
|
360
|
+
};
|
|
361
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
362
|
+
const extension_cache_key = { extensionName };
|
|
363
|
+
if (_extension_cache.has(extension_cache_key)) {
|
|
364
|
+
return _extension_cache.get(extension_cache_key);
|
|
365
|
+
}
|
|
366
|
+
let extension = getExtensionEnv(extensionName);
|
|
367
|
+
if (schema) {
|
|
368
|
+
extension = schema.parse(extension);
|
|
369
|
+
}
|
|
370
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
371
|
+
return extension;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// packages/config-tools/src/env/set-env.ts
|
|
375
|
+
var setExtensionEnv = (extensionName, extension) => {
|
|
376
|
+
Object.keys(extension ?? {}).forEach((key) => {
|
|
377
|
+
if (extension[key]) {
|
|
378
|
+
let result = key?.replace(
|
|
379
|
+
/([A-Z])+/g,
|
|
380
|
+
(input) => input ? input[0].toUpperCase() + input.slice(1) : ""
|
|
381
|
+
).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
382
|
+
let extensionKey;
|
|
383
|
+
if (result.length === 0) {
|
|
384
|
+
return;
|
|
385
|
+
} else if (result.length === 1) {
|
|
386
|
+
extensionKey = result[0].toUpperCase();
|
|
387
|
+
} else {
|
|
388
|
+
extensionKey = result.reduce((ret, part) => {
|
|
389
|
+
return `${ret}_${part.toLowerCase()}`;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
var setConfigEnv = (config) => {
|
|
397
|
+
const prefix = `STORM_`;
|
|
398
|
+
process.env[`${prefix}NAME`] = config.name;
|
|
399
|
+
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
400
|
+
process.env[`${prefix}OWNER`] = config.owner;
|
|
401
|
+
process.env[`${prefix}WORKER`] = config.worker;
|
|
402
|
+
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
403
|
+
process.env[`${prefix}LICENSE`] = config.license;
|
|
404
|
+
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
405
|
+
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
406
|
+
process.env.TZ = config.timezone;
|
|
407
|
+
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
408
|
+
process.env[`${prefix}LOCALE`] = config.locale;
|
|
409
|
+
process.env.LOCALE = config.locale;
|
|
410
|
+
process.env.DEFAULT_LOCALE = config.locale;
|
|
411
|
+
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
412
|
+
process.env[`${prefix}CONFIG_FILE`] = config.configFile;
|
|
413
|
+
process.env[`${prefix}WORKSPACE_ROOT`] = config.workspaceRoot;
|
|
414
|
+
process.env.NX_WORKSPACE_ROOT = config.workspaceRoot;
|
|
415
|
+
process.env.NX_WORKSPACE_ROOT_PATH = config.workspaceRoot;
|
|
416
|
+
process.env[`${prefix}PACKAGE_DIRECTORY`] = config.packageDirectory;
|
|
417
|
+
process.env[`${prefix}BUILD_DIRECTORY`] = config.buildDirectory;
|
|
418
|
+
process.env[`${prefix}RUNTIME_VERSION`] = config.runtimeVersion;
|
|
419
|
+
process.env[`${prefix}RUNTIME_DIRECTORY`] = config.runtimeDirectory;
|
|
420
|
+
process.env[`${prefix}ENV`] = config.env;
|
|
421
|
+
process.env.NODE_ENV = config.env;
|
|
422
|
+
process.env.ENVIRONMENT = config.env;
|
|
423
|
+
process.env[`${prefix}CI`] = String(config.ci);
|
|
424
|
+
process.env.CI = String(config.ci);
|
|
425
|
+
process.env.CONTINUOUS_INTEGRATION = String(config.ci);
|
|
426
|
+
process.env[`${prefix}COLOR_PRIMARY`] = config.colors.primary;
|
|
427
|
+
process.env[`${prefix}COLOR_BACKGROUND`] = config.colors.background;
|
|
428
|
+
process.env[`${prefix}COLOR_SUCCESS`] = config.colors.success;
|
|
429
|
+
process.env[`${prefix}COLOR_INFO`] = config.colors.info;
|
|
430
|
+
process.env[`${prefix}COLOR_WARNING`] = config.colors.warning;
|
|
431
|
+
process.env[`${prefix}COLOR_ERROR`] = config.colors.error;
|
|
432
|
+
process.env[`${prefix}COLOR_FATAL`] = config.colors.fatal;
|
|
433
|
+
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
434
|
+
process.env[`${prefix}BRANCH`] = config.branch;
|
|
435
|
+
process.env[`${prefix}PRE_MAJOR`] = String(config.preMajor);
|
|
436
|
+
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
437
|
+
process.env.LOG_LEVEL = String(config.logLevel);
|
|
438
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
439
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
440
|
+
);
|
|
441
|
+
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
442
|
+
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
443
|
+
Object.keys(config.extensions ?? {}).forEach((key) => {
|
|
444
|
+
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
ColorConfigSchema,
|
|
450
|
+
DefaultColorConfig,
|
|
451
|
+
DefaultStormConfig,
|
|
452
|
+
LogLevel,
|
|
453
|
+
LogLevelLabel,
|
|
454
|
+
StormConfigSchema,
|
|
455
|
+
createConfigExtension,
|
|
456
|
+
createStormConfig,
|
|
457
|
+
getConfigEnv,
|
|
458
|
+
getConfigFile,
|
|
459
|
+
getDefaultConfig,
|
|
460
|
+
getExtensionEnv,
|
|
461
|
+
getLogLevel,
|
|
462
|
+
getLogLevelLabel,
|
|
463
|
+
setConfigEnv,
|
|
464
|
+
setExtensionEnv
|
|
465
|
+
});
|