@storm-software/config-tools 1.190.58 → 1.190.59

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.
@@ -0,0 +1,395 @@
1
+ import {
2
+ getLogLevel
3
+ } from "./chunk-SXPH7ILL.js";
4
+ import {
5
+ correctPaths
6
+ } from "./chunk-V3GMJ4TX.js";
7
+ import {
8
+ LogLevel
9
+ } from "./chunk-RALMUN5C.js";
10
+
11
+ // src/env/set-env.ts
12
+ var setExtensionEnv = (extensionName, extension) => {
13
+ for (const key of Object.keys(extension ?? {})) {
14
+ if (extension[key]) {
15
+ const result = key?.replace(
16
+ /([A-Z])+/g,
17
+ (input) => input ? input[0]?.toUpperCase() + input.slice(1) : ""
18
+ ).split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
19
+ let extensionKey;
20
+ if (result.length === 0) {
21
+ return;
22
+ }
23
+ if (result.length === 1) {
24
+ extensionKey = result[0]?.toUpperCase() ?? "";
25
+ } else {
26
+ extensionKey = result.reduce((ret, part) => {
27
+ return `${ret}_${part.toLowerCase()}`;
28
+ });
29
+ }
30
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
31
+ }
32
+ }
33
+ };
34
+ var setConfigEnv = (config) => {
35
+ const prefix = "STORM_";
36
+ if (config.extends) {
37
+ process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
38
+ }
39
+ if (config.name) {
40
+ process.env[`${prefix}NAME`] = config.name;
41
+ }
42
+ if (config.variant) {
43
+ process.env[`${prefix}VARIANT`] = config.variant;
44
+ }
45
+ if (config.namespace) {
46
+ process.env[`${prefix}NAMESPACE`] = config.namespace;
47
+ }
48
+ if (config.owner) {
49
+ process.env[`${prefix}OWNER`] = config.owner;
50
+ }
51
+ if (config.bot) {
52
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
53
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
54
+ }
55
+ if (config.error) {
56
+ process.env[`${prefix}ERROR_CODES_FILE`] = config.error.codesFile;
57
+ process.env[`${prefix}ERROR_URL`] = config.error.url;
58
+ }
59
+ if (config.release) {
60
+ if (config.release.banner) {
61
+ if (typeof config.release.banner === "string") {
62
+ process.env[`${prefix}RELEASE_BANNER`] = config.release.banner;
63
+ process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner;
64
+ } else {
65
+ process.env[`${prefix}RELEASE_BANNER`] = config.release.banner.url;
66
+ process.env[`${prefix}RELEASE_BANNER_URL`] = config.release.banner.url;
67
+ process.env[`${prefix}RELEASE_BANNER_ALT`] = config.release.banner.alt;
68
+ }
69
+ }
70
+ process.env[`${prefix}RELEASE_HEADER`] = config.release.header;
71
+ process.env[`${prefix}RELEASE_FOOTER`] = config.release.footer;
72
+ }
73
+ if (config.socials) {
74
+ if (config.socials.twitter) {
75
+ process.env[`${prefix}SOCIAL_TWITTER`] = config.socials.twitter;
76
+ }
77
+ if (config.socials.discord) {
78
+ process.env[`${prefix}SOCIAL_DISCORD`] = config.socials.discord;
79
+ }
80
+ if (config.socials.telegram) {
81
+ process.env[`${prefix}SOCIAL_TELEGRAM`] = config.socials.telegram;
82
+ }
83
+ if (config.socials.slack) {
84
+ process.env[`${prefix}SOCIAL_SLACK`] = config.socials.slack;
85
+ }
86
+ if (config.socials.medium) {
87
+ process.env[`${prefix}SOCIAL_MEDIUM`] = config.socials.medium;
88
+ }
89
+ if (config.socials.github) {
90
+ process.env[`${prefix}SOCIAL_GITHUB`] = config.socials.github;
91
+ }
92
+ }
93
+ if (config.organization) {
94
+ if (typeof config.organization === "string") {
95
+ process.env[`${prefix}ORG`] = config.organization;
96
+ process.env[`${prefix}ORG_NAME`] = config.organization;
97
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
98
+ process.env[`${prefix}ORGANIZATION_NAME`] = config.organization;
99
+ } else {
100
+ process.env[`${prefix}ORG`] = config.organization.name;
101
+ process.env[`${prefix}ORG_NAME`] = config.organization.name;
102
+ process.env[`${prefix}ORGANIZATION`] = config.organization.name;
103
+ process.env[`${prefix}ORGANIZATION_NAME`] = config.organization.name;
104
+ if (config.organization.url) {
105
+ process.env[`${prefix}ORG_URL`] = config.organization.url;
106
+ process.env[`${prefix}ORGANIZATION_URL`] = config.organization.url;
107
+ }
108
+ if (config.organization.description) {
109
+ process.env[`${prefix}ORG_DESCRIPTION`] = config.organization.description;
110
+ process.env[`${prefix}ORGANIZATION_DESCRIPTION`] = config.organization.description;
111
+ }
112
+ if (config.organization.logo) {
113
+ process.env[`${prefix}ORG_LOGO`] = config.organization.logo;
114
+ process.env[`${prefix}ORGANIZATION_LOGO`] = config.organization.logo;
115
+ }
116
+ if (config.organization.icon) {
117
+ process.env[`${prefix}ORG_ICON`] = config.organization.icon;
118
+ process.env[`${prefix}ORGANIZATION_ICON`] = config.organization.icon;
119
+ }
120
+ }
121
+ }
122
+ if (config.packageManager) {
123
+ process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
124
+ }
125
+ if (config.license) {
126
+ process.env[`${prefix}LICENSE`] = config.license;
127
+ }
128
+ if (config.homepage) {
129
+ process.env[`${prefix}HOMEPAGE`] = config.homepage;
130
+ }
131
+ if (config.docs) {
132
+ process.env[`${prefix}DOCS`] = config.docs;
133
+ }
134
+ if (config.portal) {
135
+ process.env[`${prefix}PORTAL`] = config.portal;
136
+ }
137
+ if (config.licensing) {
138
+ process.env[`${prefix}LICENSING`] = config.licensing;
139
+ }
140
+ if (config.contact) {
141
+ process.env[`${prefix}CONTACT`] = config.contact;
142
+ }
143
+ if (config.support) {
144
+ process.env[`${prefix}SUPPORT`] = config.support;
145
+ }
146
+ if (config.timezone) {
147
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
148
+ process.env.TZ = config.timezone;
149
+ process.env.DEFAULT_TIMEZONE = config.timezone;
150
+ process.env.TIMEZONE = config.timezone;
151
+ }
152
+ if (config.locale) {
153
+ process.env[`${prefix}LOCALE`] = config.locale;
154
+ process.env.DEFAULT_LOCALE = config.locale;
155
+ process.env.LOCALE = config.locale;
156
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
157
+ }
158
+ if (config.configFile) {
159
+ process.env[`${prefix}WORKSPACE_CONFIG_FILE`] = correctPaths(
160
+ config.configFile
161
+ );
162
+ }
163
+ if (config.workspaceRoot) {
164
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
165
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
166
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
167
+ }
168
+ if (config.directories) {
169
+ if (!config.skipCache && config.directories.cache) {
170
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(
171
+ config.directories.cache
172
+ );
173
+ process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
174
+ }
175
+ if (config.directories.data) {
176
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
177
+ process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
178
+ }
179
+ if (config.directories.config) {
180
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(
181
+ config.directories.config
182
+ );
183
+ process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
184
+ }
185
+ if (config.directories.temp) {
186
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
187
+ process.env[`${prefix}TEMP_DIRECTORY`] = process.env[`${prefix}TEMP_DIR`];
188
+ }
189
+ if (config.directories.log) {
190
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
191
+ process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
192
+ }
193
+ if (config.directories.build) {
194
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(
195
+ config.directories.build
196
+ );
197
+ process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
198
+ }
199
+ }
200
+ if (config.skipCache !== void 0) {
201
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
202
+ if (config.skipCache) {
203
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
204
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
205
+ }
206
+ }
207
+ if (config.mode) {
208
+ process.env[`${prefix}MODE`] = config.mode;
209
+ process.env.NODE_ENV = config.mode;
210
+ process.env.ENVIRONMENT = config.mode;
211
+ }
212
+ if (config.colors?.base?.light || config.colors?.base?.dark) {
213
+ for (const key of Object.keys(config.colors)) {
214
+ setThemeColorsEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
215
+ }
216
+ } else {
217
+ setThemeColorsEnv(
218
+ `${prefix}COLOR_`,
219
+ config.colors
220
+ );
221
+ }
222
+ if (config.repository) {
223
+ process.env[`${prefix}REPOSITORY`] = config.repository;
224
+ }
225
+ if (config.branch) {
226
+ process.env[`${prefix}BRANCH`] = config.branch;
227
+ }
228
+ if (config.preid) {
229
+ process.env[`${prefix}PRE_ID`] = String(config.preid);
230
+ }
231
+ if (config.registry) {
232
+ if (config.registry.github) {
233
+ process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
234
+ }
235
+ if (config.registry.npm) {
236
+ process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
237
+ }
238
+ if (config.registry.cargo) {
239
+ process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
240
+ }
241
+ if (config.registry.cyclone) {
242
+ process.env[`${prefix}REGISTRY_CYCLONE`] = String(
243
+ config.registry.cyclone
244
+ );
245
+ }
246
+ if (config.registry.container) {
247
+ process.env[`${prefix}REGISTRY_CONTAINER`] = String(
248
+ config.registry.container
249
+ );
250
+ }
251
+ }
252
+ if (config.logLevel) {
253
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
254
+ process.env.LOG_LEVEL = String(config.logLevel);
255
+ process.env.NX_VERBOSE_LOGGING = String(
256
+ getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
257
+ );
258
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
259
+ }
260
+ if (config.skipConfigLogging !== void 0) {
261
+ process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
262
+ config.skipConfigLogging
263
+ );
264
+ }
265
+ process.env[`${prefix}WORKSPACE_CONFIG`] = JSON.stringify(config);
266
+ for (const key of Object.keys(config.extensions ?? {})) {
267
+ if (config.extensions[key] && Object.keys(config.extensions[key])) {
268
+ setExtensionEnv(key, config.extensions[key]);
269
+ }
270
+ }
271
+ };
272
+ var setThemeColorsEnv = (prefix, config) => {
273
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorsEnv(prefix, config) : setSingleThemeColorsEnv(prefix, config);
274
+ };
275
+ var setSingleThemeColorsEnv = (prefix, config) => {
276
+ if (config.dark) {
277
+ process.env[`${prefix}DARK`] = config.dark;
278
+ }
279
+ if (config.light) {
280
+ process.env[`${prefix}LIGHT`] = config.light;
281
+ }
282
+ if (config.brand) {
283
+ process.env[`${prefix}BRAND`] = config.brand;
284
+ }
285
+ if (config.alternate) {
286
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
287
+ }
288
+ if (config.accent) {
289
+ process.env[`${prefix}ACCENT`] = config.accent;
290
+ }
291
+ if (config.link) {
292
+ process.env[`${prefix}LINK`] = config.link;
293
+ }
294
+ if (config.help) {
295
+ process.env[`${prefix}HELP`] = config.help;
296
+ }
297
+ if (config.success) {
298
+ process.env[`${prefix}SUCCESS`] = config.success;
299
+ }
300
+ if (config.info) {
301
+ process.env[`${prefix}INFO`] = config.info;
302
+ }
303
+ if (config.debug) {
304
+ process.env[`${prefix}DEBUG`] = config.debug;
305
+ }
306
+ if (config.warning) {
307
+ process.env[`${prefix}WARNING`] = config.warning;
308
+ }
309
+ if (config.danger) {
310
+ process.env[`${prefix}DANGER`] = config.danger;
311
+ }
312
+ if (config.fatal) {
313
+ process.env[`${prefix}FATAL`] = config.fatal;
314
+ }
315
+ if (config.performance) {
316
+ process.env[`${prefix}PERFORMANCE`] = config.performance;
317
+ }
318
+ if (config.positive) {
319
+ process.env[`${prefix}POSITIVE`] = config.positive;
320
+ }
321
+ if (config.negative) {
322
+ process.env[`${prefix}NEGATIVE`] = config.negative;
323
+ }
324
+ if (config.gradient) {
325
+ for (let i = 0; i < config.gradient.length; i++) {
326
+ process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
327
+ }
328
+ }
329
+ };
330
+ var setMultiThemeColorsEnv = (prefix, config) => {
331
+ return {
332
+ light: setBaseThemeColorsEnv(`${prefix}LIGHT_`, config.light),
333
+ dark: setBaseThemeColorsEnv(`${prefix}DARK_`, config.dark)
334
+ };
335
+ };
336
+ var setBaseThemeColorsEnv = (prefix, config) => {
337
+ if (config.foreground) {
338
+ process.env[`${prefix}FOREGROUND`] = config.foreground;
339
+ }
340
+ if (config.background) {
341
+ process.env[`${prefix}BACKGROUND`] = config.background;
342
+ }
343
+ if (config.brand) {
344
+ process.env[`${prefix}BRAND`] = config.brand;
345
+ }
346
+ if (config.alternate) {
347
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
348
+ }
349
+ if (config.accent) {
350
+ process.env[`${prefix}ACCENT`] = config.accent;
351
+ }
352
+ if (config.link) {
353
+ process.env[`${prefix}LINK`] = config.link;
354
+ }
355
+ if (config.help) {
356
+ process.env[`${prefix}HELP`] = config.help;
357
+ }
358
+ if (config.success) {
359
+ process.env[`${prefix}SUCCESS`] = config.success;
360
+ }
361
+ if (config.info) {
362
+ process.env[`${prefix}INFO`] = config.info;
363
+ }
364
+ if (config.debug) {
365
+ process.env[`${prefix}DEBUG`] = config.debug;
366
+ }
367
+ if (config.warning) {
368
+ process.env[`${prefix}WARNING`] = config.warning;
369
+ }
370
+ if (config.danger) {
371
+ process.env[`${prefix}DANGER`] = config.danger;
372
+ }
373
+ if (config.fatal) {
374
+ process.env[`${prefix}FATAL`] = config.fatal;
375
+ }
376
+ if (config.performance) {
377
+ process.env[`${prefix}PERFORMANCE`] = config.performance;
378
+ }
379
+ if (config.positive) {
380
+ process.env[`${prefix}POSITIVE`] = config.positive;
381
+ }
382
+ if (config.negative) {
383
+ process.env[`${prefix}NEGATIVE`] = config.negative;
384
+ }
385
+ if (config.gradient) {
386
+ for (let i = 0; i < config.gradient.length; i++) {
387
+ process.env[`${prefix}GRADIENT_${i}`] = config.gradient[i];
388
+ }
389
+ }
390
+ };
391
+
392
+ export {
393
+ setExtensionEnv,
394
+ setConfigEnv
395
+ };
@@ -0,0 +1,82 @@
1
+ import {
2
+ correctPaths
3
+ } from "./chunk-V3GMJ4TX.js";
4
+ import {
5
+ findFolderUp
6
+ } from "./chunk-RUKM6FCF.js";
7
+
8
+ // src/utilities/find-workspace-root.ts
9
+ var rootFiles = [
10
+ "storm-workspace.json",
11
+ "storm-workspace.yaml",
12
+ "storm-workspace.yml",
13
+ "storm-workspace.js",
14
+ "storm-workspace.ts",
15
+ ".storm-workspace.json",
16
+ ".storm-workspace.yaml",
17
+ ".storm-workspace.yml",
18
+ ".storm-workspace.js",
19
+ ".storm-workspace.ts",
20
+ "lerna.json",
21
+ "nx.json",
22
+ "turbo.json",
23
+ "npm-workspace.json",
24
+ "yarn-workspace.json",
25
+ "pnpm-workspace.json",
26
+ "npm-workspace.yaml",
27
+ "yarn-workspace.yaml",
28
+ "pnpm-workspace.yaml",
29
+ "npm-workspace.yml",
30
+ "yarn-workspace.yml",
31
+ "pnpm-workspace.yml",
32
+ "npm-lock.json",
33
+ "yarn-lock.json",
34
+ "pnpm-lock.json",
35
+ "npm-lock.yaml",
36
+ "yarn-lock.yaml",
37
+ "pnpm-lock.yaml",
38
+ "npm-lock.yml",
39
+ "yarn-lock.yml",
40
+ "pnpm-lock.yml",
41
+ "bun.lockb"
42
+ ];
43
+ var rootDirectories = [
44
+ ".storm-workspace",
45
+ ".nx",
46
+ ".git",
47
+ ".github",
48
+ ".vscode",
49
+ ".verdaccio"
50
+ ];
51
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
52
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
53
+ return correctPaths(
54
+ process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
55
+ );
56
+ }
57
+ return correctPaths(
58
+ findFolderUp(
59
+ pathInsideMonorepo ?? process.cwd(),
60
+ rootFiles,
61
+ rootDirectories
62
+ )
63
+ );
64
+ }
65
+ function findWorkspaceRoot(pathInsideMonorepo) {
66
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
67
+ if (!result) {
68
+ throw new Error(
69
+ `Cannot find workspace root upwards from known path. Files search list includes:
70
+ ${rootFiles.join(
71
+ "\n"
72
+ )}
73
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
74
+ );
75
+ }
76
+ return result;
77
+ }
78
+
79
+ export {
80
+ findWorkspaceRootSafe,
81
+ findWorkspaceRoot
82
+ };