@storm-software/config-tools 1.1.3 → 1.2.1
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 +14 -0
- package/README.md +25 -2
- package/index.cjs +472 -0
- package/index.js +140 -62
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.3...config-tools-v1.2.0) (2023-12-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **config-tools:** Added `logLevel` configuration value ([edcd12a](https://github.com/storm-software/storm-ops/commit/edcd12a215cc1f6ec7c8ee3b1521a847a5a1e44f))
|
|
7
|
+
|
|
8
|
+
## [1.1.3](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.2...config-tools-v1.1.3) (2023-12-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **workspace-tools:** Resolved issue with `esbuildPluginPino` plugin for neutral build ([dba1022](https://github.com/storm-software/storm-ops/commit/dba102278281102a359c1c7cff087b9969b58c7c))
|
|
14
|
+
|
|
1
15
|
## [1.1.2](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.1...config-tools-v1.1.2) (2023-12-02)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
16
16
|
|
|
17
17
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.org" target="_blank">stormsoftware.org</a> to stay up to date with this developer</h3><br />
|
|
18
18
|
|
|
19
|
-
[](https://prettier.io/)
|
|
20
20
|
[](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://docusaurus.io/) 
|
|
21
21
|
|
|
22
22
|
<h3 align="center" bold="true">⚠️ <b>Attention</b> ⚠️ This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be availible through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.</h3><br />
|
|
@@ -27,10 +27,33 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
27
27
|
|
|
28
28
|
<!-- END header -->
|
|
29
29
|
|
|
30
|
-
#
|
|
30
|
+
# Storm Configuration Tools
|
|
31
31
|
|
|
32
32
|
A package containing various utilities to support custom workspace configurations
|
|
33
33
|
|
|
34
|
+
Below is a list of the available configuration values that can be set through environment variables:
|
|
35
|
+
|
|
36
|
+
| Name | Description | Default |
|
|
37
|
+
| ----------------------- | -------------------------------------------------------------------------------------- | --------------------------- |
|
|
38
|
+
| STORM_COLOR_BACKGROUND | The workspace's background theme color | `#1d232a` |
|
|
39
|
+
| STORM_COLOR_ERROR | The workspace's error theme color | `#990000` |
|
|
40
|
+
| STORM_COLOR_FATAL | The workspace's fatal theme color | `#7d1a1a` |
|
|
41
|
+
| STORM_COLOR_INFO | The workspace's info theme color | `#0ea5e9` |
|
|
42
|
+
| STORM_COLOR_PRIMARY | The workspace's primary theme color | `#1fb2a6` |
|
|
43
|
+
| STORM_COLOR_SUCCESS | The workspace's success theme color | `#087f5b` |
|
|
44
|
+
| STORM_COLOR_WARNING | The workspace's warning theme color | `#fcc419` |
|
|
45
|
+
| STORM_ENV | The current runtime environment of the package | "production" |
|
|
46
|
+
| STORM_HOMEPAGE | The homepage URL for the workspace | <https://stormsoftware.org> |
|
|
47
|
+
| STORM_LICENSE | The license used by the workspace | "Apache License 2.0" |
|
|
48
|
+
| STORM_LOCALE | The default locale of the workspace | "en-US" |
|
|
49
|
+
| STORM_LOG_LEVEL | The current maximum level of messages to write to the logs | "info" |
|
|
50
|
+
| STORM_ORGANIZATION | The organization of the workspace | "storm-software" |
|
|
51
|
+
| STORM_REPOSITORY | The repo URL of the workspace (i.e. GitHub URL) |
|
|
52
|
+
| STORM_RUNTIME_DIRECTORY | The default directory of the storm runtime for storage/generation | "node_modules/.storm" |
|
|
53
|
+
| STORM_RUNTIME_VERSION | The global version of the Storm runtime | "1.0.0" |
|
|
54
|
+
| STORM_TIMEZONE | The default timezone of the workspace | "America/New_York" |
|
|
55
|
+
| STORM_WORKER | The worker of the package (this is the bot that will be used to perform various tasks) | "stormie-bot" |
|
|
56
|
+
|
|
34
57
|
<!-- START doctoc -->
|
|
35
58
|
<!-- END doctoc -->
|
|
36
59
|
|
package/index.cjs
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
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
|
+
wrapped_ColorConfig: () => wrapped_ColorConfig,
|
|
49
|
+
wrapped_StormConfig: () => wrapped_StormConfig
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(src_exports);
|
|
52
|
+
|
|
53
|
+
// packages/config-tools/src/config-file/get-config-file.ts
|
|
54
|
+
var import_cosmiconfig = require("cosmiconfig");
|
|
55
|
+
var _static_cache = void 0;
|
|
56
|
+
var getConfigFileName = (fileName) => (0, import_cosmiconfig.cosmiconfig)(fileName, { cache: true }).search();
|
|
57
|
+
var getConfigFile = async () => {
|
|
58
|
+
if (_static_cache) {
|
|
59
|
+
return _static_cache;
|
|
60
|
+
}
|
|
61
|
+
let cosmiconfigResult = await getConfigFileName("storm");
|
|
62
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
63
|
+
cosmiconfigResult = await getConfigFileName("storm-software");
|
|
64
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
65
|
+
cosmiconfigResult = await getConfigFileName("storm-stack");
|
|
66
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
67
|
+
cosmiconfigResult = await getConfigFileName("storm-cloud");
|
|
68
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
69
|
+
cosmiconfigResult = await getConfigFileName("acidic");
|
|
70
|
+
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
71
|
+
cosmiconfigResult = await getConfigFileName("acid");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!cosmiconfigResult || Object.keys(cosmiconfigResult).length === 0 || cosmiconfigResult.isEmpty || !cosmiconfigResult.filepath) {
|
|
78
|
+
console.warn(
|
|
79
|
+
"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."
|
|
80
|
+
);
|
|
81
|
+
return void 0;
|
|
82
|
+
}
|
|
83
|
+
const config = cosmiconfigResult.config ?? {};
|
|
84
|
+
cosmiconfigResult.filepath && (config.configFile = cosmiconfigResult.filepath);
|
|
85
|
+
config.runtimeVersion = "0.0.1";
|
|
86
|
+
_static_cache = config;
|
|
87
|
+
return config;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// packages/config-tools/src/create-storm-config.ts
|
|
91
|
+
var import_typeschema2 = require("@decs/typeschema");
|
|
92
|
+
|
|
93
|
+
// packages/config-tools/src/types.ts
|
|
94
|
+
var import_typeschema = require("@decs/typeschema");
|
|
95
|
+
|
|
96
|
+
// packages/config-tools/src/schema.ts
|
|
97
|
+
var z = __toESM(require("zod"), 1);
|
|
98
|
+
var ColorConfigSchema = z.object({
|
|
99
|
+
primary: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The primary color of the workspace"),
|
|
100
|
+
background: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d232a").describe("The background color of the workspace"),
|
|
101
|
+
success: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#087f5b").describe("The success color of the workspace"),
|
|
102
|
+
info: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The informational color of the workspace"),
|
|
103
|
+
warning: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace"),
|
|
104
|
+
error: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#990000").describe("The error color of the workspace"),
|
|
105
|
+
fatal: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#7d1a1a").describe("The fatal color of the workspace")
|
|
106
|
+
}).describe("Colors used for various workspace elements");
|
|
107
|
+
var StormConfigSchema = z.object({
|
|
108
|
+
name: z.string().trim().toLowerCase().describe("The name of the package"),
|
|
109
|
+
namespace: z.string().trim().toLowerCase().default("storm-software").describe("The namespace of the package"),
|
|
110
|
+
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
111
|
+
repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
112
|
+
license: z.string().trim().default("Apache License 2.0").describe("The root directory of the package"),
|
|
113
|
+
homepage: z.string().trim().url().default("https://stormsoftware.org").describe("The homepage of the workspace"),
|
|
114
|
+
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
115
|
+
preMajor: z.boolean().default(false).describe(
|
|
116
|
+
"An indicator specifying if the package is still in it's pre-major version"
|
|
117
|
+
),
|
|
118
|
+
owner: z.string().trim().default("@storm-software/development").describe("The owner of the package"),
|
|
119
|
+
worker: z.string().trim().default("stormie-bot").describe(
|
|
120
|
+
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
121
|
+
),
|
|
122
|
+
env: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment of the package"),
|
|
123
|
+
ci: z.boolean().default(true).describe(
|
|
124
|
+
"An indicator specifying if the current environment is a CI environment"
|
|
125
|
+
),
|
|
126
|
+
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
127
|
+
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
128
|
+
buildDirectory: z.string().trim().default("dist").describe("The build directory for the workspace"),
|
|
129
|
+
runtimeDirectory: z.string().trim().default("node_modules/.storm").describe("The runtime directory of Storm"),
|
|
130
|
+
runtimeVersion: z.string().trim().regex(
|
|
131
|
+
/^(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-]+)*))?$/
|
|
132
|
+
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
133
|
+
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
134
|
+
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
135
|
+
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
136
|
+
"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`)."
|
|
137
|
+
),
|
|
138
|
+
configFile: z.string().trim().nullable().default(null).describe(
|
|
139
|
+
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
140
|
+
),
|
|
141
|
+
colors: ColorConfigSchema.describe(
|
|
142
|
+
"Storm theme config values used for styling various package elements"
|
|
143
|
+
),
|
|
144
|
+
extensions: z.record(z.any()).describe("Configuration of each used extension")
|
|
145
|
+
}).describe(
|
|
146
|
+
"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."
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
// packages/config-tools/src/types.ts
|
|
150
|
+
var wrapped_ColorConfig = (0, import_typeschema.wrap)(ColorConfigSchema);
|
|
151
|
+
var wrapped_StormConfig = (0, import_typeschema.wrap)(StormConfigSchema);
|
|
152
|
+
var LogLevel = {
|
|
153
|
+
SILENT: 0,
|
|
154
|
+
FATAL: 10,
|
|
155
|
+
ERROR: 20,
|
|
156
|
+
WARN: 30,
|
|
157
|
+
INFO: 40,
|
|
158
|
+
DEBUG: 60,
|
|
159
|
+
TRACE: 70
|
|
160
|
+
};
|
|
161
|
+
var LogLevelLabel = {
|
|
162
|
+
SILENT: "silent",
|
|
163
|
+
FATAL: "fatal",
|
|
164
|
+
ERROR: "error",
|
|
165
|
+
WARN: "warn",
|
|
166
|
+
INFO: "info",
|
|
167
|
+
DEBUG: "debug",
|
|
168
|
+
TRACE: "trace"
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// packages/config-tools/src/utilities/get-default-config.ts
|
|
172
|
+
var import_fs = require("fs");
|
|
173
|
+
var import_promises = require("fs/promises");
|
|
174
|
+
var import_find_workspace_root = require("nx/src/utils/find-workspace-root.js");
|
|
175
|
+
var import_path = require("path");
|
|
176
|
+
var DefaultColorConfig = {
|
|
177
|
+
primary: "#1fb2a6",
|
|
178
|
+
background: "#1d232a",
|
|
179
|
+
success: "#087f5b",
|
|
180
|
+
info: "#0ea5e9",
|
|
181
|
+
warning: "#fcc419",
|
|
182
|
+
error: "#990000",
|
|
183
|
+
fatal: "#7d1a1a"
|
|
184
|
+
};
|
|
185
|
+
var DefaultStormConfig = {
|
|
186
|
+
namespace: "storm-software",
|
|
187
|
+
license: "Apache License 2.0",
|
|
188
|
+
homepage: "https://stormsoftware.org",
|
|
189
|
+
preMajor: false,
|
|
190
|
+
owner: "@storm-software/development",
|
|
191
|
+
worker: "stormie-bot",
|
|
192
|
+
runtimeDirectory: "node_modules/.storm",
|
|
193
|
+
colors: { ...DefaultColorConfig },
|
|
194
|
+
extensions: {}
|
|
195
|
+
};
|
|
196
|
+
var getDefaultConfig = async (config = {}) => {
|
|
197
|
+
let name = "storm-workspace";
|
|
198
|
+
let namespace = "storm-software";
|
|
199
|
+
let repository = "https://github.com/storm-software/storm-stack";
|
|
200
|
+
let license = DefaultStormConfig.license;
|
|
201
|
+
let homepage = DefaultStormConfig.homepage;
|
|
202
|
+
const workspaceRoot = getWorkspaceRoot() ?? process.cwd();
|
|
203
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(workspaceRoot, "package.json"))) {
|
|
204
|
+
const file = await (0, import_promises.readFile)((0, import_path.join)(workspaceRoot, "package.json"), {
|
|
205
|
+
encoding: "utf-8"
|
|
206
|
+
});
|
|
207
|
+
if (file) {
|
|
208
|
+
const packageJson = JSON.parse(file);
|
|
209
|
+
packageJson.name && (name = packageJson.name);
|
|
210
|
+
packageJson.namespace && (namespace = packageJson.namespace);
|
|
211
|
+
packageJson.repository?.url && (repository = packageJson.repository?.url);
|
|
212
|
+
packageJson.license && (license = packageJson.license);
|
|
213
|
+
packageJson.homepage && (homepage = packageJson.homepage);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...DefaultStormConfig,
|
|
218
|
+
colors: { ...DefaultColorConfig, ...config },
|
|
219
|
+
workspaceRoot,
|
|
220
|
+
name,
|
|
221
|
+
namespace,
|
|
222
|
+
repository,
|
|
223
|
+
license: license ?? DefaultStormConfig.license,
|
|
224
|
+
homepage: homepage ?? DefaultStormConfig.homepage,
|
|
225
|
+
timezone: "America/New_York",
|
|
226
|
+
locale: "en-US",
|
|
227
|
+
env: "production",
|
|
228
|
+
branch: "main",
|
|
229
|
+
organization: "storm-software",
|
|
230
|
+
extensions: {},
|
|
231
|
+
ci: true,
|
|
232
|
+
configFile: (0, import_path.join)(workspaceRoot, "storm.config.js"),
|
|
233
|
+
runtimeVersion: "1.0.0",
|
|
234
|
+
...config
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
var getWorkspaceRoot = () => {
|
|
238
|
+
const root = (0, import_find_workspace_root.findWorkspaceRoot)(process.cwd());
|
|
239
|
+
process.env.STORM_REPO_ROOT ??= root?.dir;
|
|
240
|
+
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir;
|
|
241
|
+
return root?.dir;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// packages/config-tools/src/utilities/get-log-level.ts
|
|
245
|
+
var getLogLevel = (label) => {
|
|
246
|
+
switch (label) {
|
|
247
|
+
case "trace":
|
|
248
|
+
return LogLevel.TRACE;
|
|
249
|
+
case "debug":
|
|
250
|
+
return LogLevel.DEBUG;
|
|
251
|
+
case "info":
|
|
252
|
+
return LogLevel.INFO;
|
|
253
|
+
case "warn":
|
|
254
|
+
return LogLevel.WARN;
|
|
255
|
+
case "error":
|
|
256
|
+
return LogLevel.ERROR;
|
|
257
|
+
case "fatal":
|
|
258
|
+
return LogLevel.FATAL;
|
|
259
|
+
case "silent":
|
|
260
|
+
return LogLevel.SILENT;
|
|
261
|
+
default:
|
|
262
|
+
return LogLevel.INFO;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
var getLogLevelLabel = (logLevel) => {
|
|
266
|
+
if (logLevel >= LogLevel.TRACE) {
|
|
267
|
+
return LogLevelLabel.TRACE;
|
|
268
|
+
} else if (logLevel >= LogLevel.DEBUG) {
|
|
269
|
+
return LogLevelLabel.DEBUG;
|
|
270
|
+
} else if (logLevel >= LogLevel.INFO) {
|
|
271
|
+
return LogLevelLabel.INFO;
|
|
272
|
+
} else if (logLevel >= LogLevel.WARN) {
|
|
273
|
+
return LogLevelLabel.WARN;
|
|
274
|
+
} else if (logLevel >= LogLevel.ERROR) {
|
|
275
|
+
return LogLevelLabel.ERROR;
|
|
276
|
+
} else if (logLevel >= LogLevel.FATAL) {
|
|
277
|
+
return LogLevelLabel.FATAL;
|
|
278
|
+
} else if (logLevel <= LogLevel.SILENT) {
|
|
279
|
+
return LogLevelLabel.SILENT;
|
|
280
|
+
} else {
|
|
281
|
+
return LogLevelLabel.INFO;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// packages/config-tools/src/env/get-env.ts
|
|
286
|
+
var getExtensionEnv = (extensionName) => {
|
|
287
|
+
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
288
|
+
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
289
|
+
const name = key.replace(prefix, "").split("_").map(
|
|
290
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
291
|
+
).join("");
|
|
292
|
+
name && (ret[name] = process.env[key]);
|
|
293
|
+
return ret;
|
|
294
|
+
}, {});
|
|
295
|
+
};
|
|
296
|
+
var getConfigEnv = () => {
|
|
297
|
+
const prefix = `STORM_`;
|
|
298
|
+
let config = {
|
|
299
|
+
name: process.env[`${prefix}NAME`],
|
|
300
|
+
namespace: process.env[`${prefix}NAMESPACE`],
|
|
301
|
+
owner: process.env[`${prefix}OWNER`],
|
|
302
|
+
worker: process.env[`${prefix}WORKER`],
|
|
303
|
+
organization: process.env[`${prefix}ORGANIZATION`],
|
|
304
|
+
license: process.env[`${prefix}LICENSE`],
|
|
305
|
+
homepage: process.env[`${prefix}HOMEPAGE`],
|
|
306
|
+
timezone: process.env[`${prefix}TIMEZONE`] ?? process.env.TZ,
|
|
307
|
+
locale: process.env[`${prefix}LOCALE`] ?? process.env.LOCALE,
|
|
308
|
+
configFile: process.env[`${prefix}CONFIG_FILE`],
|
|
309
|
+
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`],
|
|
310
|
+
packageDirectory: process.env[`${prefix}PACKAGE_DIRECTORY`],
|
|
311
|
+
buildDirectory: process.env[`${prefix}BUILD_DIRECTORY`],
|
|
312
|
+
runtimeVersion: process.env[`${prefix}RUNTIME_VERSION`],
|
|
313
|
+
runtimeDirectory: process.env[`${prefix}RUNTIME_DIRECTORY`],
|
|
314
|
+
env: process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT,
|
|
315
|
+
ci: Boolean(
|
|
316
|
+
process.env[`${prefix}CI`] ?? process.env.CI ?? process.env.CONTINUOUS_INTEGRATION
|
|
317
|
+
),
|
|
318
|
+
colors: {
|
|
319
|
+
primary: process.env[`${prefix}COLOR_PRIMARY`],
|
|
320
|
+
background: process.env[`${prefix}COLOR_BACKGROUND`],
|
|
321
|
+
success: process.env[`${prefix}COLOR_SUCCESS`],
|
|
322
|
+
info: process.env[`${prefix}COLOR_INFO`],
|
|
323
|
+
warning: process.env[`${prefix}COLOR_WARNING`],
|
|
324
|
+
error: process.env[`${prefix}COLOR_ERROR`],
|
|
325
|
+
fatal: process.env[`${prefix}COLOR_FATAL`]
|
|
326
|
+
},
|
|
327
|
+
repository: process.env[`${prefix}REPOSITORY`],
|
|
328
|
+
branch: process.env[`${prefix}BRANCH`],
|
|
329
|
+
preMajor: Boolean(process.env[`${prefix}PRE_MAJOR`]),
|
|
330
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? Number.isSafeInteger(
|
|
331
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
332
|
+
) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : LogLevelLabel.INFO,
|
|
333
|
+
extensions: {}
|
|
334
|
+
};
|
|
335
|
+
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
336
|
+
if (serializedConfig) {
|
|
337
|
+
config = Object.assign(config, JSON.parse(serializedConfig));
|
|
338
|
+
}
|
|
339
|
+
const extensionPrefix = `${prefix}EXTENSION_`;
|
|
340
|
+
return Object.keys(process.env).filter((key) => key.startsWith(extensionPrefix)).reduce((ret, key) => {
|
|
341
|
+
const extensionName = key.substring(prefix.length, key.indexOf("_", prefix.length)).split("_").map(
|
|
342
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
343
|
+
).join("");
|
|
344
|
+
extensionName && (ret.extensions[extensionName] = getExtensionEnv(extensionName));
|
|
345
|
+
return ret;
|
|
346
|
+
}, config);
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// packages/config-tools/src/create-storm-config.ts
|
|
350
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
351
|
+
var _static_cache2 = void 0;
|
|
352
|
+
var createStormConfig = async (extensionName, schema) => {
|
|
353
|
+
let result;
|
|
354
|
+
if (!_static_cache2) {
|
|
355
|
+
let config = getConfigEnv();
|
|
356
|
+
result = await wrapped_StormConfig.parse(config);
|
|
357
|
+
} else {
|
|
358
|
+
result = _static_cache2;
|
|
359
|
+
}
|
|
360
|
+
if (schema && extensionName) {
|
|
361
|
+
const extensionConfig = await createConfigExtension(extensionName, schema);
|
|
362
|
+
result.extensions[extensionName] = extensionConfig;
|
|
363
|
+
}
|
|
364
|
+
_static_cache2 = result;
|
|
365
|
+
return result;
|
|
366
|
+
};
|
|
367
|
+
var createConfigExtension = async (extensionName, schema) => {
|
|
368
|
+
const extension_cache_key = { extensionName };
|
|
369
|
+
if (_extension_cache.has(extension_cache_key)) {
|
|
370
|
+
return _extension_cache.get(extension_cache_key);
|
|
371
|
+
}
|
|
372
|
+
let extension = getExtensionEnv(extensionName);
|
|
373
|
+
if (schema) {
|
|
374
|
+
extension = await (0, import_typeschema2.wrap)(schema).parse(extension);
|
|
375
|
+
}
|
|
376
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
377
|
+
return extension;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// packages/config-tools/src/env/set-env.ts
|
|
381
|
+
var setExtensionEnv = (extensionName, extension) => {
|
|
382
|
+
Object.keys(extension ?? {}).forEach((key) => {
|
|
383
|
+
if (extension[key]) {
|
|
384
|
+
let result = key?.replace(
|
|
385
|
+
/([A-Z])+/g,
|
|
386
|
+
(input) => input ? input[0].toUpperCase() + input.slice(1) : ""
|
|
387
|
+
).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
388
|
+
let extensionKey;
|
|
389
|
+
if (result.length === 0) {
|
|
390
|
+
return;
|
|
391
|
+
} else if (result.length === 1) {
|
|
392
|
+
extensionKey = result[0].toUpperCase();
|
|
393
|
+
} else {
|
|
394
|
+
extensionKey = result.reduce((ret, part) => {
|
|
395
|
+
return `${ret}_${part.toLowerCase()}`;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
var setConfigEnv = (config) => {
|
|
403
|
+
const prefix = `STORM_`;
|
|
404
|
+
process.env[`${prefix}NAME`] = config.name;
|
|
405
|
+
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
406
|
+
process.env[`${prefix}OWNER`] = config.owner;
|
|
407
|
+
process.env[`${prefix}WORKER`] = config.worker;
|
|
408
|
+
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
409
|
+
process.env[`${prefix}LICENSE`] = config.license;
|
|
410
|
+
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
411
|
+
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
412
|
+
process.env.TZ = config.timezone;
|
|
413
|
+
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
414
|
+
process.env[`${prefix}LOCALE`] = config.locale;
|
|
415
|
+
process.env.LOCALE = config.locale;
|
|
416
|
+
process.env.DEFAULT_LOCALE = config.locale;
|
|
417
|
+
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
418
|
+
process.env[`${prefix}CONFIG_FILE`] = config.configFile;
|
|
419
|
+
process.env[`${prefix}WORKSPACE_ROOT`] = config.workspaceRoot;
|
|
420
|
+
process.env.NX_WORKSPACE_ROOT = config.workspaceRoot;
|
|
421
|
+
process.env.NX_WORKSPACE_ROOT_PATH = config.workspaceRoot;
|
|
422
|
+
process.env[`${prefix}PACKAGE_DIRECTORY`] = config.packageDirectory;
|
|
423
|
+
process.env[`${prefix}BUILD_DIRECTORY`] = config.buildDirectory;
|
|
424
|
+
process.env[`${prefix}RUNTIME_VERSION`] = config.runtimeVersion;
|
|
425
|
+
process.env[`${prefix}RUNTIME_DIRECTORY`] = config.runtimeDirectory;
|
|
426
|
+
process.env[`${prefix}ENV`] = config.env;
|
|
427
|
+
process.env.NODE_ENV = config.env;
|
|
428
|
+
process.env.ENVIRONMENT = config.env;
|
|
429
|
+
process.env[`${prefix}CI`] = String(config.ci);
|
|
430
|
+
process.env.CI = String(config.ci);
|
|
431
|
+
process.env.CONTINUOUS_INTEGRATION = String(config.ci);
|
|
432
|
+
process.env[`${prefix}COLOR_PRIMARY`] = config.colors.primary;
|
|
433
|
+
process.env[`${prefix}COLOR_BACKGROUND`] = config.colors.background;
|
|
434
|
+
process.env[`${prefix}COLOR_SUCCESS`] = config.colors.success;
|
|
435
|
+
process.env[`${prefix}COLOR_INFO`] = config.colors.info;
|
|
436
|
+
process.env[`${prefix}COLOR_WARNING`] = config.colors.warning;
|
|
437
|
+
process.env[`${prefix}COLOR_ERROR`] = config.colors.error;
|
|
438
|
+
process.env[`${prefix}COLOR_FATAL`] = config.colors.fatal;
|
|
439
|
+
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
440
|
+
process.env[`${prefix}BRANCH`] = config.branch;
|
|
441
|
+
process.env[`${prefix}PRE_MAJOR`] = String(config.preMajor);
|
|
442
|
+
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
443
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
444
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
445
|
+
);
|
|
446
|
+
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
447
|
+
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
448
|
+
Object.keys(config.extensions ?? {}).forEach((key) => {
|
|
449
|
+
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
453
|
+
0 && (module.exports = {
|
|
454
|
+
ColorConfigSchema,
|
|
455
|
+
DefaultColorConfig,
|
|
456
|
+
DefaultStormConfig,
|
|
457
|
+
LogLevel,
|
|
458
|
+
LogLevelLabel,
|
|
459
|
+
StormConfigSchema,
|
|
460
|
+
createConfigExtension,
|
|
461
|
+
createStormConfig,
|
|
462
|
+
getConfigEnv,
|
|
463
|
+
getConfigFile,
|
|
464
|
+
getDefaultConfig,
|
|
465
|
+
getExtensionEnv,
|
|
466
|
+
getLogLevel,
|
|
467
|
+
getLogLevelLabel,
|
|
468
|
+
setConfigEnv,
|
|
469
|
+
setExtensionEnv,
|
|
470
|
+
wrapped_ColorConfig,
|
|
471
|
+
wrapped_StormConfig
|
|
472
|
+
});
|
package/index.js
CHANGED
|
@@ -38,6 +38,84 @@ var getConfigFile = async () => {
|
|
|
38
38
|
// packages/config-tools/src/create-storm-config.ts
|
|
39
39
|
import { wrap as wrap2 } from "@decs/typeschema";
|
|
40
40
|
|
|
41
|
+
// packages/config-tools/src/types.ts
|
|
42
|
+
import { wrap } from "@decs/typeschema";
|
|
43
|
+
|
|
44
|
+
// packages/config-tools/src/schema.ts
|
|
45
|
+
import * as z from "zod";
|
|
46
|
+
var ColorConfigSchema = z.object({
|
|
47
|
+
primary: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The primary color of the workspace"),
|
|
48
|
+
background: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d232a").describe("The background color of the workspace"),
|
|
49
|
+
success: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#087f5b").describe("The success color of the workspace"),
|
|
50
|
+
info: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The informational color of the workspace"),
|
|
51
|
+
warning: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace"),
|
|
52
|
+
error: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#990000").describe("The error color of the workspace"),
|
|
53
|
+
fatal: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#7d1a1a").describe("The fatal color of the workspace")
|
|
54
|
+
}).describe("Colors used for various workspace elements");
|
|
55
|
+
var StormConfigSchema = z.object({
|
|
56
|
+
name: z.string().trim().toLowerCase().describe("The name of the package"),
|
|
57
|
+
namespace: z.string().trim().toLowerCase().default("storm-software").describe("The namespace of the package"),
|
|
58
|
+
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
59
|
+
repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
60
|
+
license: z.string().trim().default("Apache License 2.0").describe("The root directory of the package"),
|
|
61
|
+
homepage: z.string().trim().url().default("https://stormsoftware.org").describe("The homepage of the workspace"),
|
|
62
|
+
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
63
|
+
preMajor: z.boolean().default(false).describe(
|
|
64
|
+
"An indicator specifying if the package is still in it's pre-major version"
|
|
65
|
+
),
|
|
66
|
+
owner: z.string().trim().default("@storm-software/development").describe("The owner of the package"),
|
|
67
|
+
worker: z.string().trim().default("stormie-bot").describe(
|
|
68
|
+
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
69
|
+
),
|
|
70
|
+
env: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment of the package"),
|
|
71
|
+
ci: z.boolean().default(true).describe(
|
|
72
|
+
"An indicator specifying if the current environment is a CI environment"
|
|
73
|
+
),
|
|
74
|
+
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
75
|
+
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
76
|
+
buildDirectory: z.string().trim().default("dist").describe("The build directory for the workspace"),
|
|
77
|
+
runtimeDirectory: z.string().trim().default("node_modules/.storm").describe("The runtime directory of Storm"),
|
|
78
|
+
runtimeVersion: z.string().trim().regex(
|
|
79
|
+
/^(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-]+)*))?$/
|
|
80
|
+
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
81
|
+
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
82
|
+
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
83
|
+
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
84
|
+
"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`)."
|
|
85
|
+
),
|
|
86
|
+
configFile: z.string().trim().nullable().default(null).describe(
|
|
87
|
+
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
88
|
+
),
|
|
89
|
+
colors: ColorConfigSchema.describe(
|
|
90
|
+
"Storm theme config values used for styling various package elements"
|
|
91
|
+
),
|
|
92
|
+
extensions: z.record(z.any()).describe("Configuration of each used extension")
|
|
93
|
+
}).describe(
|
|
94
|
+
"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."
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// packages/config-tools/src/types.ts
|
|
98
|
+
var wrapped_ColorConfig = wrap(ColorConfigSchema);
|
|
99
|
+
var wrapped_StormConfig = wrap(StormConfigSchema);
|
|
100
|
+
var LogLevel = {
|
|
101
|
+
SILENT: 0,
|
|
102
|
+
FATAL: 10,
|
|
103
|
+
ERROR: 20,
|
|
104
|
+
WARN: 30,
|
|
105
|
+
INFO: 40,
|
|
106
|
+
DEBUG: 60,
|
|
107
|
+
TRACE: 70
|
|
108
|
+
};
|
|
109
|
+
var LogLevelLabel = {
|
|
110
|
+
SILENT: "silent",
|
|
111
|
+
FATAL: "fatal",
|
|
112
|
+
ERROR: "error",
|
|
113
|
+
WARN: "warn",
|
|
114
|
+
INFO: "info",
|
|
115
|
+
DEBUG: "debug",
|
|
116
|
+
TRACE: "trace"
|
|
117
|
+
};
|
|
118
|
+
|
|
41
119
|
// packages/config-tools/src/utilities/get-default-config.ts
|
|
42
120
|
import { existsSync } from "fs";
|
|
43
121
|
import { readFile } from "fs/promises";
|
|
@@ -61,7 +139,7 @@ var DefaultStormConfig = {
|
|
|
61
139
|
worker: "stormie-bot",
|
|
62
140
|
runtimeDirectory: "node_modules/.storm",
|
|
63
141
|
colors: { ...DefaultColorConfig },
|
|
64
|
-
|
|
142
|
+
extensions: {}
|
|
65
143
|
};
|
|
66
144
|
var getDefaultConfig = async (config = {}) => {
|
|
67
145
|
let name = "storm-workspace";
|
|
@@ -97,7 +175,7 @@ var getDefaultConfig = async (config = {}) => {
|
|
|
97
175
|
env: "production",
|
|
98
176
|
branch: "main",
|
|
99
177
|
organization: "storm-software",
|
|
100
|
-
|
|
178
|
+
extensions: {},
|
|
101
179
|
ci: true,
|
|
102
180
|
configFile: join(workspaceRoot, "storm.config.js"),
|
|
103
181
|
runtimeVersion: "1.0.0",
|
|
@@ -111,6 +189,47 @@ var getWorkspaceRoot = () => {
|
|
|
111
189
|
return root?.dir;
|
|
112
190
|
};
|
|
113
191
|
|
|
192
|
+
// packages/config-tools/src/utilities/get-log-level.ts
|
|
193
|
+
var getLogLevel = (label) => {
|
|
194
|
+
switch (label) {
|
|
195
|
+
case "trace":
|
|
196
|
+
return LogLevel.TRACE;
|
|
197
|
+
case "debug":
|
|
198
|
+
return LogLevel.DEBUG;
|
|
199
|
+
case "info":
|
|
200
|
+
return LogLevel.INFO;
|
|
201
|
+
case "warn":
|
|
202
|
+
return LogLevel.WARN;
|
|
203
|
+
case "error":
|
|
204
|
+
return LogLevel.ERROR;
|
|
205
|
+
case "fatal":
|
|
206
|
+
return LogLevel.FATAL;
|
|
207
|
+
case "silent":
|
|
208
|
+
return LogLevel.SILENT;
|
|
209
|
+
default:
|
|
210
|
+
return LogLevel.INFO;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var getLogLevelLabel = (logLevel) => {
|
|
214
|
+
if (logLevel >= LogLevel.TRACE) {
|
|
215
|
+
return LogLevelLabel.TRACE;
|
|
216
|
+
} else if (logLevel >= LogLevel.DEBUG) {
|
|
217
|
+
return LogLevelLabel.DEBUG;
|
|
218
|
+
} else if (logLevel >= LogLevel.INFO) {
|
|
219
|
+
return LogLevelLabel.INFO;
|
|
220
|
+
} else if (logLevel >= LogLevel.WARN) {
|
|
221
|
+
return LogLevelLabel.WARN;
|
|
222
|
+
} else if (logLevel >= LogLevel.ERROR) {
|
|
223
|
+
return LogLevelLabel.ERROR;
|
|
224
|
+
} else if (logLevel >= LogLevel.FATAL) {
|
|
225
|
+
return LogLevelLabel.FATAL;
|
|
226
|
+
} else if (logLevel <= LogLevel.SILENT) {
|
|
227
|
+
return LogLevelLabel.SILENT;
|
|
228
|
+
} else {
|
|
229
|
+
return LogLevelLabel.INFO;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
114
233
|
// packages/config-tools/src/env/get-env.ts
|
|
115
234
|
var getExtensionEnv = (extensionName) => {
|
|
116
235
|
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
@@ -124,7 +243,6 @@ var getExtensionEnv = (extensionName) => {
|
|
|
124
243
|
};
|
|
125
244
|
var getConfigEnv = () => {
|
|
126
245
|
const prefix = `STORM_`;
|
|
127
|
-
const defaultConfig = getDefaultConfig();
|
|
128
246
|
let config = {
|
|
129
247
|
name: process.env[`${prefix}NAME`],
|
|
130
248
|
namespace: process.env[`${prefix}NAMESPACE`],
|
|
@@ -157,6 +275,9 @@ var getConfigEnv = () => {
|
|
|
157
275
|
repository: process.env[`${prefix}REPOSITORY`],
|
|
158
276
|
branch: process.env[`${prefix}BRANCH`],
|
|
159
277
|
preMajor: Boolean(process.env[`${prefix}PRE_MAJOR`]),
|
|
278
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? Number.isSafeInteger(
|
|
279
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
280
|
+
) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : LogLevelLabel.INFO,
|
|
160
281
|
extensions: {}
|
|
161
282
|
};
|
|
162
283
|
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
@@ -173,63 +294,6 @@ var getConfigEnv = () => {
|
|
|
173
294
|
}, config);
|
|
174
295
|
};
|
|
175
296
|
|
|
176
|
-
// packages/config-tools/src/types.ts
|
|
177
|
-
import { wrap } from "@decs/typeschema";
|
|
178
|
-
|
|
179
|
-
// packages/config-tools/src/schema.ts
|
|
180
|
-
import * as z from "zod";
|
|
181
|
-
var ColorConfigSchema = z.object({
|
|
182
|
-
primary: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The primary color of the workspace"),
|
|
183
|
-
background: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d232a").describe("The background color of the workspace"),
|
|
184
|
-
success: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#087f5b").describe("The success color of the workspace"),
|
|
185
|
-
info: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The informational color of the workspace"),
|
|
186
|
-
warning: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace"),
|
|
187
|
-
error: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#990000").describe("The error color of the workspace"),
|
|
188
|
-
fatal: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#7d1a1a").describe("The fatal color of the workspace")
|
|
189
|
-
}).describe("Colors used for various workspace elements");
|
|
190
|
-
var StormConfigSchema = z.object({
|
|
191
|
-
name: z.string().trim().toLowerCase().describe("The name of the package"),
|
|
192
|
-
namespace: z.string().trim().toLowerCase().default("storm-software").describe("The namespace of the package"),
|
|
193
|
-
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
194
|
-
repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
195
|
-
license: z.string().trim().default("Apache License 2.0").describe("The root directory of the package"),
|
|
196
|
-
homepage: z.string().trim().url().default("https://stormsoftware.org").describe("The homepage of the workspace"),
|
|
197
|
-
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
198
|
-
preMajor: z.boolean().default(false).describe(
|
|
199
|
-
"An indicator specifying if the package is still in it's pre-major version"
|
|
200
|
-
),
|
|
201
|
-
owner: z.string().trim().default("@storm-software/development").describe("The owner of the package"),
|
|
202
|
-
worker: z.string().trim().default("stormie-bot").describe(
|
|
203
|
-
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
204
|
-
),
|
|
205
|
-
env: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment of the package"),
|
|
206
|
-
ci: z.boolean().default(true).describe(
|
|
207
|
-
"An indicator specifying if the current environment is a CI environment"
|
|
208
|
-
),
|
|
209
|
-
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
210
|
-
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
211
|
-
buildDirectory: z.string().trim().default("dist").describe("The build directory for the workspace"),
|
|
212
|
-
runtimeDirectory: z.string().trim().default("node_modules/.storm").describe("The runtime directory of Storm"),
|
|
213
|
-
runtimeVersion: z.string().trim().regex(
|
|
214
|
-
/^(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-]+)*))?$/
|
|
215
|
-
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
216
|
-
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
217
|
-
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
218
|
-
configFile: z.string().trim().nullable().default(null).describe(
|
|
219
|
-
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
220
|
-
),
|
|
221
|
-
colors: ColorConfigSchema.describe(
|
|
222
|
-
"Storm theme config values used for styling various package elements"
|
|
223
|
-
),
|
|
224
|
-
extensions: z.record(z.any()).describe("Configuration of each used extension")
|
|
225
|
-
}).describe(
|
|
226
|
-
"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."
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
// packages/config-tools/src/types.ts
|
|
230
|
-
var wrapped_ColorConfig = wrap(ColorConfigSchema);
|
|
231
|
-
var wrapped_StormConfig = wrap(StormConfigSchema);
|
|
232
|
-
|
|
233
297
|
// packages/config-tools/src/create-storm-config.ts
|
|
234
298
|
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
235
299
|
var _static_cache2 = void 0;
|
|
@@ -242,8 +306,8 @@ var createStormConfig = async (extensionName, schema) => {
|
|
|
242
306
|
result = _static_cache2;
|
|
243
307
|
}
|
|
244
308
|
if (schema && extensionName) {
|
|
245
|
-
const
|
|
246
|
-
result.
|
|
309
|
+
const extensionConfig = await createConfigExtension(extensionName, schema);
|
|
310
|
+
result.extensions[extensionName] = extensionConfig;
|
|
247
311
|
}
|
|
248
312
|
_static_cache2 = result;
|
|
249
313
|
return result;
|
|
@@ -294,10 +358,15 @@ var setConfigEnv = (config) => {
|
|
|
294
358
|
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
295
359
|
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
296
360
|
process.env.TZ = config.timezone;
|
|
361
|
+
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
297
362
|
process.env[`${prefix}LOCALE`] = config.locale;
|
|
298
363
|
process.env.LOCALE = config.locale;
|
|
364
|
+
process.env.DEFAULT_LOCALE = config.locale;
|
|
365
|
+
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
299
366
|
process.env[`${prefix}CONFIG_FILE`] = config.configFile;
|
|
300
367
|
process.env[`${prefix}WORKSPACE_ROOT`] = config.workspaceRoot;
|
|
368
|
+
process.env.NX_WORKSPACE_ROOT = config.workspaceRoot;
|
|
369
|
+
process.env.NX_WORKSPACE_ROOT_PATH = config.workspaceRoot;
|
|
301
370
|
process.env[`${prefix}PACKAGE_DIRECTORY`] = config.packageDirectory;
|
|
302
371
|
process.env[`${prefix}BUILD_DIRECTORY`] = config.buildDirectory;
|
|
303
372
|
process.env[`${prefix}RUNTIME_VERSION`] = config.runtimeVersion;
|
|
@@ -318,6 +387,11 @@ var setConfigEnv = (config) => {
|
|
|
318
387
|
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
319
388
|
process.env[`${prefix}BRANCH`] = config.branch;
|
|
320
389
|
process.env[`${prefix}PRE_MAJOR`] = String(config.preMajor);
|
|
390
|
+
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
391
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
392
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
393
|
+
);
|
|
394
|
+
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
321
395
|
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
322
396
|
Object.keys(config.extensions ?? {}).forEach((key) => {
|
|
323
397
|
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
@@ -327,6 +401,8 @@ export {
|
|
|
327
401
|
ColorConfigSchema,
|
|
328
402
|
DefaultColorConfig,
|
|
329
403
|
DefaultStormConfig,
|
|
404
|
+
LogLevel,
|
|
405
|
+
LogLevelLabel,
|
|
330
406
|
StormConfigSchema,
|
|
331
407
|
createConfigExtension,
|
|
332
408
|
createStormConfig,
|
|
@@ -334,6 +410,8 @@ export {
|
|
|
334
410
|
getConfigFile,
|
|
335
411
|
getDefaultConfig,
|
|
336
412
|
getExtensionEnv,
|
|
413
|
+
getLogLevel,
|
|
414
|
+
getLogLevelLabel,
|
|
337
415
|
setConfigEnv,
|
|
338
416
|
setExtensionEnv,
|
|
339
417
|
wrapped_ColorConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/config-tools",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
|
|
6
6
|
"repository": {
|