@storm-software/config-tools 1.1.2 → 1.2.0

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 CHANGED
@@ -1,3 +1,18 @@
1
+ ## [1.1.3](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.2...config-tools-v1.1.3) (2023-12-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **workspace-tools:** Resolved issue with `esbuildPluginPino` plugin for neutral build ([dba1022](https://github.com/storm-software/storm-ops/commit/dba102278281102a359c1c7cff087b9969b58c7c))
7
+
8
+ ## [1.1.2](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.1...config-tools-v1.1.2) (2023-12-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **config-tools:** Resolved issue with updated `createStormConfig` schema ([cbc6941](https://github.com/storm-software/storm-ops/commit/cbc69413e1ebbf5521c638401a34c604f25c2854))
14
+ * **config-tools:** Updated the config schema's default values ([42fc718](https://github.com/storm-software/storm-ops/commit/42fc7183f2725e435d006897fb349c02f7454ff9))
15
+
1
16
  ## [1.1.1](https://github.com/storm-software/storm-ops/compare/config-tools-v1.1.0...config-tools-v1.1.1) (2023-12-02)
2
17
 
3
18
 
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
- [![Version](https://img.shields.io/badge/version-1.1.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
19
+ [![Version](https://img.shields.io/badge/version-1.1.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
20
20
  [![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with docusaurus](https://img.shields.io/badge/documented_with-docusaurus-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://docusaurus.io/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
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 />
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
- modules: {}
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
- modules: {},
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 moduleConfig = await createConfigExtension(extensionName, schema);
246
- result.modules[extensionName] = moduleConfig;
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.2",
3
+ "version": "1.2.0",
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": {