@storm-software/untyped 0.0.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/bin/untyped.js ADDED
@@ -0,0 +1,1343 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // ../config/src/schema.ts
27
+ var import_zod = __toESM(require("zod"));
28
+
29
+ // ../config/src/constants.ts
30
+ var STORM_DEFAULT_DOCS = "https://docs.stormsoftware.com";
31
+ var STORM_DEFAULT_HOMEPAGE = "https://stormsoftware.com";
32
+ var STORM_DEFAULT_LICENSING = "https://license.stormsoftware.com";
33
+ var STORM_DEFAULT_LICENSE = "Apache-2.0";
34
+
35
+ // ../config/src/schema.ts
36
+ var DarkColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d1e22").describe("The dark background color of the workspace");
37
+ var LightColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#f4f4f5").describe("The light background color of the workspace");
38
+ var BrandColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1fb2a6").describe("The primary brand specific color of the workspace");
39
+ var AlternateColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The alternate brand specific color of the workspace");
40
+ var AccentColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The secondary brand specific color of the workspace");
41
+ var LinkColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The color used to display hyperlink text");
42
+ var HelpColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#8256D0").describe("The second brand specific color of the workspace");
43
+ var SuccessColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#12B66A").describe("The success color of the workspace");
44
+ var InfoColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0070E0").describe("The informational color of the workspace");
45
+ var WarningColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace");
46
+ var DangerColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#D8314A").describe("The danger color of the workspace");
47
+ var FatalColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The fatal color of the workspace");
48
+ var PositiveColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#4ade80").describe("The positive number color of the workspace");
49
+ var NegativeColorSchema = import_zod.default.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#ef4444").describe("The negative number color of the workspace");
50
+ var DarkThemeColorConfigSchema = import_zod.default.object({
51
+ foreground: LightColorSchema,
52
+ background: DarkColorSchema,
53
+ brand: BrandColorSchema,
54
+ alternate: AlternateColorSchema,
55
+ accent: AccentColorSchema,
56
+ link: LinkColorSchema,
57
+ help: HelpColorSchema,
58
+ success: SuccessColorSchema,
59
+ info: InfoColorSchema,
60
+ warning: WarningColorSchema,
61
+ danger: DangerColorSchema,
62
+ fatal: FatalColorSchema,
63
+ positive: PositiveColorSchema,
64
+ negative: NegativeColorSchema
65
+ });
66
+ var LightThemeColorConfigSchema = import_zod.default.object({
67
+ foreground: DarkColorSchema,
68
+ background: LightColorSchema,
69
+ brand: BrandColorSchema,
70
+ alternate: AlternateColorSchema,
71
+ accent: AccentColorSchema,
72
+ link: LinkColorSchema,
73
+ help: HelpColorSchema,
74
+ success: SuccessColorSchema,
75
+ info: InfoColorSchema,
76
+ warning: WarningColorSchema,
77
+ danger: DangerColorSchema,
78
+ fatal: FatalColorSchema,
79
+ positive: PositiveColorSchema,
80
+ negative: NegativeColorSchema
81
+ });
82
+ var MultiThemeColorConfigSchema = import_zod.default.object({
83
+ dark: DarkThemeColorConfigSchema,
84
+ light: LightThemeColorConfigSchema
85
+ });
86
+ var SingleThemeColorConfigSchema = import_zod.default.object({
87
+ dark: DarkColorSchema,
88
+ light: LightColorSchema,
89
+ brand: BrandColorSchema,
90
+ alternate: AlternateColorSchema,
91
+ accent: AccentColorSchema,
92
+ link: LinkColorSchema,
93
+ help: HelpColorSchema,
94
+ success: SuccessColorSchema,
95
+ info: InfoColorSchema,
96
+ warning: WarningColorSchema,
97
+ danger: DangerColorSchema,
98
+ fatal: FatalColorSchema,
99
+ positive: PositiveColorSchema,
100
+ negative: NegativeColorSchema
101
+ });
102
+ var RegistryUrlConfigSchema = import_zod.default.string().trim().toLowerCase().url().optional().describe("A remote registry URL used to publish distributable packages");
103
+ var RegistryConfigSchema = import_zod.default.object({
104
+ github: RegistryUrlConfigSchema,
105
+ npm: RegistryUrlConfigSchema,
106
+ cargo: RegistryUrlConfigSchema,
107
+ cyclone: RegistryUrlConfigSchema,
108
+ container: RegistryUrlConfigSchema
109
+ }).default({}).describe("A list of remote registry URLs used by Storm Software");
110
+ var ColorConfigSchema = SingleThemeColorConfigSchema.or(MultiThemeColorConfigSchema).describe("Colors used for various workspace elements");
111
+ var ColorConfigMapSchema = import_zod.default.union([
112
+ import_zod.default.object({
113
+ "base": ColorConfigSchema
114
+ }),
115
+ import_zod.default.record(import_zod.default.string(), ColorConfigSchema)
116
+ ]);
117
+ var WorkspaceBotConfigSchema = import_zod.default.object({
118
+ name: import_zod.default.string().trim().default("Stormie-Bot").describe("The workspace bot user's name (this is the bot that will be used to perform various tasks)"),
119
+ email: import_zod.default.string().trim().email().default("bot@stormsoftware.com").describe("The email of the workspace bot")
120
+ }).describe("The workspace's bot user's config used to automated various operations tasks");
121
+ var WorkspaceDirectoryConfigSchema = import_zod.default.object({
122
+ cache: import_zod.default.string().trim().optional().describe("The directory used to store the environment's cached file data"),
123
+ data: import_zod.default.string().trim().optional().describe("The directory used to store the environment's data files"),
124
+ config: import_zod.default.string().trim().optional().describe("The directory used to store the environment's configuration files"),
125
+ temp: import_zod.default.string().trim().optional().describe("The directory used to store the environment's temp files"),
126
+ log: import_zod.default.string().trim().optional().describe("The directory used to store the environment's temp files"),
127
+ build: import_zod.default.string().trim().default("dist").describe("The directory used to store the workspace's distributable files after a build (relative to the workspace root)")
128
+ }).describe("Various directories used by the workspace to store data, cache, and configuration files");
129
+ var StormConfigSchema = import_zod.default.object({
130
+ $schema: import_zod.default.string().trim().default("https://cdn.jsdelivr.net/npm/@storm-software/config/schemas/storm.schema.json").optional().nullish().describe("The URL to the JSON schema file that describes the Storm configuration file"),
131
+ extends: import_zod.default.string().trim().optional().describe("The path to a base JSON file to use as a configuration preset file"),
132
+ name: import_zod.default.string().trim().toLowerCase().optional().describe("The name of the service/package/scope using this configuration"),
133
+ namespace: import_zod.default.string().trim().toLowerCase().optional().describe("The namespace of the package"),
134
+ organization: import_zod.default.string().trim().default("storm-software").describe("The organization of the workspace"),
135
+ repository: import_zod.default.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
136
+ license: import_zod.default.string().trim().default("Apache-2.0").describe("The license type of the package"),
137
+ homepage: import_zod.default.string().trim().url().default(STORM_DEFAULT_HOMEPAGE).describe("The homepage of the workspace"),
138
+ docs: import_zod.default.string().trim().url().default(STORM_DEFAULT_DOCS).describe("The base documentation site for the workspace"),
139
+ licensing: import_zod.default.string().trim().url().default(STORM_DEFAULT_LICENSING).describe("The base licensing site for the workspace"),
140
+ branch: import_zod.default.string().trim().default("main").describe("The branch of the workspace"),
141
+ preid: import_zod.default.string().optional().describe("A tag specifying the version pre-release identifier"),
142
+ owner: import_zod.default.string().trim().default("@storm-software/admin").describe("The owner of the package"),
143
+ bot: WorkspaceBotConfigSchema,
144
+ env: import_zod.default.enum([
145
+ "development",
146
+ "staging",
147
+ "production"
148
+ ]).default("production").describe("The current runtime environment name for the package"),
149
+ workspaceRoot: import_zod.default.string().trim().default("").describe("The root directory of the workspace"),
150
+ externalPackagePatterns: import_zod.default.array(import_zod.default.string()).default([]).describe("The build will use these package patterns to determine if they should be external to the bundle"),
151
+ skipCache: import_zod.default.boolean().default(false).describe("Should all known types of workspace caching be skipped?"),
152
+ directories: WorkspaceDirectoryConfigSchema,
153
+ packageManager: import_zod.default.enum([
154
+ "npm",
155
+ "yarn",
156
+ "pnpm",
157
+ "bun"
158
+ ]).default("npm").describe("The JavaScript/TypeScript package manager used by the repository"),
159
+ timezone: import_zod.default.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
160
+ locale: import_zod.default.string().trim().default("en-US").describe("The default locale of the workspace"),
161
+ logLevel: import_zod.default.enum([
162
+ "silent",
163
+ "fatal",
164
+ "error",
165
+ "warn",
166
+ "success",
167
+ "info",
168
+ "debug",
169
+ "trace",
170
+ "all"
171
+ ]).default("info").describe("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`)."),
172
+ registry: RegistryConfigSchema,
173
+ configFile: import_zod.default.string().trim().nullable().default(null).describe("The filepath of the Storm config. When this field is null, no config file was found in the current workspace."),
174
+ colors: ColorConfigSchema.or(ColorConfigMapSchema).describe("Storm theme config values used for styling various package elements"),
175
+ extensions: import_zod.default.record(import_zod.default.any()).optional().default({}).describe("Configuration of each used extension")
176
+ }).describe("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.");
177
+
178
+ // ../config-tools/src/create-storm-config.ts
179
+ var import_defu2 = __toESM(require("defu"));
180
+
181
+ // ../config-tools/src/config-file/get-config-file.ts
182
+ var import_c12 = require("c12");
183
+ var import_defu = __toESM(require("defu"));
184
+
185
+ // ../config-tools/src/types.ts
186
+ var LogLevel = {
187
+ SILENT: 0,
188
+ FATAL: 10,
189
+ ERROR: 20,
190
+ WARN: 30,
191
+ SUCCESS: 35,
192
+ INFO: 40,
193
+ DEBUG: 60,
194
+ TRACE: 70,
195
+ ALL: 100
196
+ };
197
+ var LogLevelLabel = {
198
+ SILENT: "silent",
199
+ FATAL: "fatal",
200
+ ERROR: "error",
201
+ WARN: "warn",
202
+ SUCCESS: "success",
203
+ INFO: "info",
204
+ DEBUG: "debug",
205
+ TRACE: "trace",
206
+ ALL: "all"
207
+ };
208
+
209
+ // ../config/src/types.ts
210
+ var COLOR_KEYS = [
211
+ "dark",
212
+ "light",
213
+ "base",
214
+ "brand",
215
+ "alternate",
216
+ "accent",
217
+ "link",
218
+ "success",
219
+ "help",
220
+ "info",
221
+ "warning",
222
+ "danger",
223
+ "fatal",
224
+ "positive",
225
+ "negative"
226
+ ];
227
+
228
+ // ../config-tools/src/utilities/get-default-config.ts
229
+ var import_node_fs2 = require("fs");
230
+ var import_node_path2 = require("path");
231
+
232
+ // ../config-tools/src/utilities/correct-paths.ts
233
+ var import_devkit = require("@nx/devkit");
234
+ var correctPaths = /* @__PURE__ */ __name((path) => {
235
+ if (!path) {
236
+ return "";
237
+ }
238
+ if (!path.toUpperCase().startsWith("C:") && path.includes("\\")) {
239
+ path = `C:${path}`;
240
+ }
241
+ return path.replaceAll("\\", "/");
242
+ }, "correctPaths");
243
+ var joinPaths = /* @__PURE__ */ __name((...paths) => {
244
+ if (!paths || paths.length === 0) {
245
+ return "";
246
+ }
247
+ return correctPaths((0, import_devkit.joinPathFragments)(...paths.map((path) => correctPaths(path))));
248
+ }, "joinPaths");
249
+
250
+ // ../config-tools/src/utilities/find-up.ts
251
+ var import_node_fs = require("fs");
252
+ var import_node_path = require("path");
253
+ var MAX_PATH_SEARCH_DEPTH = 30;
254
+ var depth = 0;
255
+ function findFolderUp(startPath, endFileNames) {
256
+ const _startPath = startPath ?? process.cwd();
257
+ if (endFileNames.some((endFileName) => (0, import_node_fs.existsSync)((0, import_node_path.join)(_startPath, endFileName)))) {
258
+ return _startPath;
259
+ }
260
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
261
+ const parent = (0, import_node_path.join)(_startPath, "..");
262
+ return findFolderUp(parent, endFileNames);
263
+ }
264
+ return void 0;
265
+ }
266
+ __name(findFolderUp, "findFolderUp");
267
+
268
+ // ../config-tools/src/utilities/find-workspace-root.ts
269
+ var rootFiles = [
270
+ "storm.json",
271
+ "storm.json",
272
+ "storm.yaml",
273
+ "storm.yml",
274
+ "storm.js",
275
+ "storm.ts",
276
+ ".storm.json",
277
+ ".storm.yaml",
278
+ ".storm.yml",
279
+ ".storm.js",
280
+ ".storm.ts",
281
+ "lerna.json",
282
+ "nx.json",
283
+ "turbo.json",
284
+ "npm-workspace.json",
285
+ "yarn-workspace.json",
286
+ "pnpm-workspace.json",
287
+ "npm-workspace.yaml",
288
+ "yarn-workspace.yaml",
289
+ "pnpm-workspace.yaml",
290
+ "npm-workspace.yml",
291
+ "yarn-workspace.yml",
292
+ "pnpm-workspace.yml",
293
+ "npm-lock.json",
294
+ "yarn-lock.json",
295
+ "pnpm-lock.json",
296
+ "npm-lock.yaml",
297
+ "yarn-lock.yaml",
298
+ "pnpm-lock.yaml",
299
+ "npm-lock.yml",
300
+ "yarn-lock.yml",
301
+ "pnpm-lock.yml",
302
+ "bun.lockb"
303
+ ];
304
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
305
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
306
+ return correctPaths(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
307
+ }
308
+ return correctPaths(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles));
309
+ }
310
+ __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
311
+ function findWorkspaceRoot(pathInsideMonorepo) {
312
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
313
+ if (!result) {
314
+ throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
315
+ ${rootFiles.join("\n")}
316
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
317
+ }
318
+ return result;
319
+ }
320
+ __name(findWorkspaceRoot, "findWorkspaceRoot");
321
+
322
+ // ../config-tools/src/utilities/get-default-config.ts
323
+ var DEFAULT_COLOR_CONFIG = {
324
+ "light": {
325
+ "background": "#fafafa",
326
+ "foreground": "#1d1e22",
327
+ "brand": "#1fb2a6",
328
+ "alternate": "#db2777",
329
+ "help": "#5C4EE5",
330
+ "success": "#087f5b",
331
+ "info": "#0550ae",
332
+ "warning": "#e3b341",
333
+ "danger": "#D8314A",
334
+ "positive": "#22c55e",
335
+ "negative": "#dc2626"
336
+ },
337
+ "dark": {
338
+ "background": "#1d1e22",
339
+ "foreground": "#cbd5e1",
340
+ "brand": "#2dd4bf",
341
+ "alternate": "#db2777",
342
+ "help": "#818cf8",
343
+ "success": "#10b981",
344
+ "info": "#58a6ff",
345
+ "warning": "#f3d371",
346
+ "danger": "#D8314A",
347
+ "positive": "#22c55e",
348
+ "negative": "#dc2626"
349
+ }
350
+ };
351
+ var getDefaultConfig = /* @__PURE__ */ __name((root) => {
352
+ let license = STORM_DEFAULT_LICENSE;
353
+ let homepage = STORM_DEFAULT_HOMEPAGE;
354
+ let name;
355
+ let namespace;
356
+ let repository;
357
+ const workspaceRoot = findWorkspaceRoot(root);
358
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(workspaceRoot, "package.json"))) {
359
+ const file = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(workspaceRoot, "package.json"), {
360
+ encoding: "utf8"
361
+ });
362
+ if (file) {
363
+ const packageJson = JSON.parse(file);
364
+ if (packageJson.name) {
365
+ name = packageJson.name;
366
+ }
367
+ if (packageJson.namespace) {
368
+ namespace = packageJson.namespace;
369
+ }
370
+ if (packageJson.repository?.url) {
371
+ repository = packageJson.repository?.url;
372
+ }
373
+ if (packageJson.license) {
374
+ license = packageJson.license;
375
+ }
376
+ if (packageJson.homepage) {
377
+ homepage = packageJson.homepage;
378
+ }
379
+ }
380
+ }
381
+ return {
382
+ workspaceRoot,
383
+ name,
384
+ namespace,
385
+ repository,
386
+ license,
387
+ homepage,
388
+ docs: `${homepage || STORM_DEFAULT_HOMEPAGE}/docs`,
389
+ licensing: `${homepage || STORM_DEFAULT_HOMEPAGE}/license`
390
+ };
391
+ }, "getDefaultConfig");
392
+
393
+ // ../config-tools/src/logger/chalk.ts
394
+ var import_chalk = __toESM(require("chalk"));
395
+ var chalkDefault = {
396
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
397
+ bgHex: /* @__PURE__ */ __name((_) => ({
398
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
399
+ }), "bgHex"),
400
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright"),
401
+ gray: /* @__PURE__ */ __name((message) => message, "gray"),
402
+ bold: {
403
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
404
+ bgHex: /* @__PURE__ */ __name((_) => ({
405
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
406
+ }), "bgHex"),
407
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
408
+ },
409
+ dim: {
410
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
411
+ gray: /* @__PURE__ */ __name((message) => message, "gray")
412
+ }
413
+ };
414
+ var getChalk = /* @__PURE__ */ __name(() => {
415
+ let _chalk = import_chalk.default;
416
+ if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
417
+ _chalk = chalkDefault;
418
+ }
419
+ return _chalk;
420
+ }, "getChalk");
421
+
422
+ // ../config-tools/src/logger/is-unicode-supported.ts
423
+ var import_node_process = __toESM(require("process"));
424
+ function isUnicodeSupported() {
425
+ const { env } = import_node_process.default;
426
+ const { TERM, TERM_PROGRAM } = env;
427
+ if (import_node_process.default.platform !== "win32") {
428
+ return TERM !== "linux";
429
+ }
430
+ return Boolean(env.WT_SESSION) || // Windows Terminal
431
+ Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
432
+ env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
433
+ TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
434
+ }
435
+ __name(isUnicodeSupported, "isUnicodeSupported");
436
+
437
+ // ../config-tools/src/logger/console-icons.ts
438
+ var useIcon = /* @__PURE__ */ __name((c, fallback) => isUnicodeSupported() ? c : fallback, "useIcon");
439
+ var CONSOLE_ICONS = {
440
+ [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
441
+ [LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
442
+ [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
443
+ [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
444
+ [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
445
+ [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
446
+ [LogLevelLabel.TRACE]: useIcon("\u2709", "\u2192")
447
+ };
448
+
449
+ // ../config-tools/src/logger/format-timestamp.ts
450
+ var formatTimestamp = /* @__PURE__ */ __name((date = /* @__PURE__ */ new Date()) => {
451
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
452
+ }, "formatTimestamp");
453
+
454
+ // ../config-tools/src/logger/get-log-level.ts
455
+ var getLogLevel = /* @__PURE__ */ __name((label) => {
456
+ switch (label) {
457
+ case "all":
458
+ return LogLevel.ALL;
459
+ case "trace":
460
+ return LogLevel.TRACE;
461
+ case "debug":
462
+ return LogLevel.DEBUG;
463
+ case "info":
464
+ return LogLevel.INFO;
465
+ case "warn":
466
+ return LogLevel.WARN;
467
+ case "error":
468
+ return LogLevel.ERROR;
469
+ case "fatal":
470
+ return LogLevel.FATAL;
471
+ case "silent":
472
+ return LogLevel.SILENT;
473
+ default:
474
+ return LogLevel.INFO;
475
+ }
476
+ }, "getLogLevel");
477
+ var getLogLevelLabel = /* @__PURE__ */ __name((logLevel = LogLevel.INFO) => {
478
+ if (logLevel >= LogLevel.ALL) {
479
+ return LogLevelLabel.ALL;
480
+ }
481
+ if (logLevel >= LogLevel.TRACE) {
482
+ return LogLevelLabel.TRACE;
483
+ }
484
+ if (logLevel >= LogLevel.DEBUG) {
485
+ return LogLevelLabel.DEBUG;
486
+ }
487
+ if (logLevel >= LogLevel.INFO) {
488
+ return LogLevelLabel.INFO;
489
+ }
490
+ if (logLevel >= LogLevel.WARN) {
491
+ return LogLevelLabel.WARN;
492
+ }
493
+ if (logLevel >= LogLevel.ERROR) {
494
+ return LogLevelLabel.ERROR;
495
+ }
496
+ if (logLevel >= LogLevel.FATAL) {
497
+ return LogLevelLabel.FATAL;
498
+ }
499
+ if (logLevel <= LogLevel.SILENT) {
500
+ return LogLevelLabel.SILENT;
501
+ }
502
+ return LogLevelLabel.INFO;
503
+ }, "getLogLevelLabel");
504
+ var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
505
+ const logLevel = typeof label === "string" ? getLogLevel(label) : label;
506
+ return logLevel >= LogLevel.DEBUG;
507
+ }, "isVerbose");
508
+
509
+ // ../config-tools/src/logger/console.ts
510
+ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) => {
511
+ const _chalk = getChalk();
512
+ const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
513
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
514
+ if (typeof logLevel === "number" && (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel)) {
515
+ return (_) => {
516
+ };
517
+ }
518
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
519
+ return (message) => {
520
+ console.error(`
521
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(formatLogMessage(message))}
522
+ `);
523
+ };
524
+ }
525
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
526
+ return (message) => {
527
+ console.error(`
528
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error]`)} ${_chalk.hex(colors.danger ?? "#f85149")(formatLogMessage(message))}
529
+ `);
530
+ };
531
+ }
532
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
533
+ return (message) => {
534
+ console.warn(`
535
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn]`)} ${_chalk.hex(colors.warning ?? "#e3b341")(formatLogMessage(message))}
536
+ `);
537
+ };
538
+ }
539
+ if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel || typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel)) {
540
+ return (message) => {
541
+ console.info(`
542
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.hex(colors.success ?? "#56d364")(formatLogMessage(message))}
543
+ `);
544
+ };
545
+ }
546
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
547
+ return (message) => {
548
+ console.info(`
549
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info]`)} ${_chalk.hex(colors.info ?? "#58a6ff")(formatLogMessage(message))}
550
+ `);
551
+ };
552
+ }
553
+ if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel || typeof logLevel === "string" && LogLevel.TRACE >= getLogLevel(logLevel)) {
554
+ return (message) => {
555
+ console.debug(`
556
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Debug]`)} ${_chalk.hex(colors.brand ?? "#1fb2a6")(formatLogMessage(message))}
557
+ `);
558
+ };
559
+ }
560
+ return (message) => {
561
+ console.log(`
562
+ ${_chalk.gray(formatTimestamp())} ${_chalk.bold.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.hex(colors.brand ?? "#1fb2a6")(formatLogMessage(message))}
563
+ `);
564
+ };
565
+ }, "getLogFn");
566
+ var writeFatal = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.FATAL, config)(message), "writeFatal");
567
+ var writeError = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ERROR, config)(message), "writeError");
568
+ var writeWarning = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.WARN, config)(message), "writeWarning");
569
+ var writeInfo = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.INFO, config)(message), "writeInfo");
570
+ var writeSuccess = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.SUCCESS, config)(message), "writeSuccess");
571
+ var writeTrace = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.TRACE, config)(message), "writeTrace");
572
+ var writeSystem = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ALL, config)(message), "writeSystem");
573
+ var getStopwatch = /* @__PURE__ */ __name((name) => {
574
+ const start = process.hrtime();
575
+ return () => {
576
+ const end = process.hrtime(start);
577
+ console.info(`
578
+ > \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(end[0] * 1e3 + end[1] / 1e6)}ms to complete
579
+
580
+ `);
581
+ };
582
+ }, "getStopwatch");
583
+ var MAX_DEPTH = 4;
584
+ var formatLogMessage = /* @__PURE__ */ __name((message, options = {}, depth2 = 0) => {
585
+ if (depth2 > MAX_DEPTH) {
586
+ return "<max depth>";
587
+ }
588
+ const prefix = options.prefix ?? "-";
589
+ const skip = options.skip ?? [];
590
+ return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
591
+ ${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
592
+ prefix: `${prefix}-`,
593
+ skip
594
+ }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
595
+ ${Object.keys(message).filter((key) => !skip.includes(key)).map((key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(message[key], {
596
+ prefix: `${prefix}-`,
597
+ skip
598
+ }, depth2 + 1) : message[key]}`).join("\n")}` : message;
599
+ }, "formatLogMessage");
600
+ var _isFunction = /* @__PURE__ */ __name((value) => {
601
+ try {
602
+ return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
603
+ } catch (e) {
604
+ return false;
605
+ }
606
+ }, "_isFunction");
607
+
608
+ // ../config-tools/src/utilities/process-handler.ts
609
+ var exitWithError = /* @__PURE__ */ __name((config) => {
610
+ writeFatal("Exiting script with an error status...", config);
611
+ process.exit(1);
612
+ }, "exitWithError");
613
+ var exitWithSuccess = /* @__PURE__ */ __name((config) => {
614
+ writeSuccess("Script completed successfully. Exiting...", config);
615
+ process.exit(0);
616
+ }, "exitWithSuccess");
617
+ var handleProcess = /* @__PURE__ */ __name((config) => {
618
+ writeTrace(`Using the following arguments to process the script: ${process.argv.join(", ")}`, config);
619
+ process.on("unhandledRejection", (error) => {
620
+ writeError(`An Unhandled Rejection occurred while running the program: ${error}`, config);
621
+ exitWithError(config);
622
+ });
623
+ process.on("uncaughtException", (error) => {
624
+ writeError(`An Uncaught Exception occurred while running the program: ${error.message}
625
+ Stacktrace: ${error.stack}`, config);
626
+ exitWithError(config);
627
+ });
628
+ process.on("SIGTERM", (signal) => {
629
+ writeError(`The program terminated with signal code: ${signal}`, config);
630
+ exitWithError(config);
631
+ });
632
+ process.on("SIGINT", (signal) => {
633
+ writeError(`The program terminated with signal code: ${signal}`, config);
634
+ exitWithError(config);
635
+ });
636
+ process.on("SIGHUP", (signal) => {
637
+ writeError(`The program terminated with signal code: ${signal}`, config);
638
+ exitWithError(config);
639
+ });
640
+ }, "handleProcess");
641
+
642
+ // ../config-tools/src/config-file/get-config-file.ts
643
+ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
644
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
645
+ let config = (0, import_c12.loadConfig)({
646
+ cwd: workspacePath,
647
+ packageJson: true,
648
+ name: fileName,
649
+ envName: fileName?.toUpperCase(),
650
+ jitiOptions: {
651
+ debug: false,
652
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
653
+ },
654
+ ...options
655
+ });
656
+ if (!config || Object.keys(config).length === 0) {
657
+ config = (0, import_c12.loadConfig)({
658
+ cwd: workspacePath,
659
+ packageJson: true,
660
+ name: fileName,
661
+ envName: fileName?.toUpperCase(),
662
+ jitiOptions: {
663
+ debug: false,
664
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
665
+ },
666
+ configFile: fileName,
667
+ ...options
668
+ });
669
+ }
670
+ return config;
671
+ }, "getConfigFileByName");
672
+ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
673
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
674
+ const result = await getConfigFileByName("storm", workspacePath);
675
+ let config = result.config;
676
+ const configFile = result.configFile;
677
+ if (config && configFile && Object.keys(config).length > 0) {
678
+ writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
679
+ logLevel: "all"
680
+ });
681
+ }
682
+ if (additionalFileNames && additionalFileNames.length > 0) {
683
+ const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
684
+ for (const result2 of results) {
685
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
686
+ writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
687
+ logLevel: "all"
688
+ });
689
+ config = (0, import_defu.default)(result2.config ?? {}, config ?? {});
690
+ }
691
+ }
692
+ }
693
+ if (!config) {
694
+ return void 0;
695
+ }
696
+ config.configFile = configFile;
697
+ return config;
698
+ }, "getConfigFile");
699
+
700
+ // ../config-tools/src/env/get-env.ts
701
+ var getConfigEnv = /* @__PURE__ */ __name(() => {
702
+ const prefix = "STORM_";
703
+ let config = {
704
+ extends: process.env[`${prefix}EXTENDS`] || void 0,
705
+ name: process.env[`${prefix}NAME`] || void 0,
706
+ namespace: process.env[`${prefix}NAMESPACE`] || void 0,
707
+ owner: process.env[`${prefix}OWNER`] || void 0,
708
+ bot: {
709
+ name: process.env[`${prefix}BOT_NAME`] || void 0,
710
+ email: process.env[`${prefix}BOT_EMAIL`] || void 0
711
+ },
712
+ organization: process.env[`${prefix}ORGANIZATION`] || void 0,
713
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
714
+ license: process.env[`${prefix}LICENSE`] || void 0,
715
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
716
+ docs: process.env[`${prefix}DOCS`] || void 0,
717
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
718
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
719
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
720
+ configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
721
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
722
+ directories: {
723
+ cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
724
+ data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
725
+ config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
726
+ temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
727
+ log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
728
+ build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
729
+ },
730
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
731
+ env: (process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
732
+ // ci:
733
+ // process.env[`${prefix}CI`] !== undefined
734
+ // ? Boolean(
735
+ // process.env[`${prefix}CI`] ??
736
+ // process.env.CI ??
737
+ // process.env.CONTINUOUS_INTEGRATION
738
+ // )
739
+ // : undefined,
740
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
741
+ branch: process.env[`${prefix}BRANCH`] || void 0,
742
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
743
+ externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
744
+ registry: {
745
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
746
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
747
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
748
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
749
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
750
+ },
751
+ logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0
752
+ };
753
+ const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
754
+ config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
755
+ ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
756
+ return ret;
757
+ }, {}) : getThemeColorConfigEnv(prefix);
758
+ if (config.docs === STORM_DEFAULT_DOCS) {
759
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
760
+ config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
761
+ } else {
762
+ config.docs = `${config.homepage}/docs`;
763
+ }
764
+ }
765
+ if (config.licensing === STORM_DEFAULT_LICENSING) {
766
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
767
+ config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
768
+ } else {
769
+ config.licensing = `${config.homepage}/docs`;
770
+ }
771
+ }
772
+ const serializedConfig = process.env[`${prefix}CONFIG`];
773
+ if (serializedConfig) {
774
+ const parsed = JSON.parse(serializedConfig);
775
+ config = {
776
+ ...config,
777
+ ...parsed,
778
+ colors: {
779
+ ...config.colors,
780
+ ...parsed.colors
781
+ },
782
+ extensions: {
783
+ ...config.extensions,
784
+ ...parsed.extensions
785
+ }
786
+ };
787
+ }
788
+ return config;
789
+ }, "getConfigEnv");
790
+ var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
791
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
792
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
793
+ }, "getThemeColorConfigEnv");
794
+ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
795
+ return {
796
+ dark: process.env[`${prefix}DARK`],
797
+ light: process.env[`${prefix}LIGHT`],
798
+ brand: process.env[`${prefix}BRAND`],
799
+ alternate: process.env[`${prefix}ALTERNATE`],
800
+ accent: process.env[`${prefix}ACCENT`],
801
+ link: process.env[`${prefix}LINK`],
802
+ help: process.env[`${prefix}HELP`],
803
+ success: process.env[`${prefix}SUCCESS`],
804
+ info: process.env[`${prefix}INFO`],
805
+ warning: process.env[`${prefix}WARNING`],
806
+ danger: process.env[`${prefix}DANGER`],
807
+ fatal: process.env[`${prefix}FATAL`],
808
+ positive: process.env[`${prefix}POSITIVE`],
809
+ negative: process.env[`${prefix}NEGATIVE`]
810
+ };
811
+ }, "getSingleThemeColorConfigEnv");
812
+ var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
813
+ return {
814
+ light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
815
+ dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
816
+ };
817
+ }, "getMultiThemeColorConfigEnv");
818
+ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
819
+ return {
820
+ foreground: process.env[`${prefix}FOREGROUND`],
821
+ background: process.env[`${prefix}BACKGROUND`],
822
+ brand: process.env[`${prefix}BRAND`],
823
+ alternate: process.env[`${prefix}ALTERNATE`],
824
+ accent: process.env[`${prefix}ACCENT`],
825
+ link: process.env[`${prefix}LINK`],
826
+ help: process.env[`${prefix}HELP`],
827
+ success: process.env[`${prefix}SUCCESS`],
828
+ info: process.env[`${prefix}INFO`],
829
+ warning: process.env[`${prefix}WARNING`],
830
+ danger: process.env[`${prefix}DANGER`],
831
+ fatal: process.env[`${prefix}FATAL`],
832
+ positive: process.env[`${prefix}POSITIVE`],
833
+ negative: process.env[`${prefix}NEGATIVE`]
834
+ };
835
+ }, "getBaseThemeColorConfigEnv");
836
+
837
+ // ../config-tools/src/env/set-env.ts
838
+ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
839
+ for (const key of Object.keys(extension ?? {})) {
840
+ if (extension[key]) {
841
+ const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
842
+ let extensionKey;
843
+ if (result.length === 0) {
844
+ return;
845
+ }
846
+ if (result.length === 1) {
847
+ extensionKey = result[0]?.toUpperCase() ?? "";
848
+ } else {
849
+ extensionKey = result.reduce((ret, part) => {
850
+ return `${ret}_${part.toLowerCase()}`;
851
+ });
852
+ }
853
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
854
+ }
855
+ }
856
+ }, "setExtensionEnv");
857
+ var setConfigEnv = /* @__PURE__ */ __name((config) => {
858
+ const prefix = "STORM_";
859
+ if (config.extends) {
860
+ process.env[`${prefix}EXTENDS`] = config.extends;
861
+ }
862
+ if (config.name) {
863
+ process.env[`${prefix}NAME`] = config.name;
864
+ }
865
+ if (config.namespace) {
866
+ process.env[`${prefix}NAMESPACE`] = config.namespace;
867
+ }
868
+ if (config.owner) {
869
+ process.env[`${prefix}OWNER`] = config.owner;
870
+ }
871
+ if (config.bot) {
872
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
873
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
874
+ }
875
+ if (config.organization) {
876
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
877
+ }
878
+ if (config.packageManager) {
879
+ process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
880
+ }
881
+ if (config.license) {
882
+ process.env[`${prefix}LICENSE`] = config.license;
883
+ }
884
+ if (config.homepage) {
885
+ process.env[`${prefix}HOMEPAGE`] = config.homepage;
886
+ }
887
+ if (config.docs) {
888
+ process.env[`${prefix}DOCS`] = config.docs;
889
+ }
890
+ if (config.licensing) {
891
+ process.env[`${prefix}LICENSING`] = config.licensing;
892
+ }
893
+ if (config.timezone) {
894
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
895
+ process.env.TZ = config.timezone;
896
+ process.env.DEFAULT_TIMEZONE = config.timezone;
897
+ }
898
+ if (config.locale) {
899
+ process.env[`${prefix}LOCALE`] = config.locale;
900
+ process.env.LOCALE = config.locale;
901
+ process.env.DEFAULT_LOCALE = config.locale;
902
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
903
+ }
904
+ if (config.configFile) {
905
+ process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
906
+ }
907
+ if (config.workspaceRoot) {
908
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
909
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
910
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
911
+ }
912
+ if (config.directories) {
913
+ if (!config.skipCache && config.directories.cache) {
914
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
915
+ }
916
+ if (config.directories.data) {
917
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
918
+ }
919
+ if (config.directories.config) {
920
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
921
+ }
922
+ if (config.directories.temp) {
923
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
924
+ }
925
+ if (config.directories.log) {
926
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
927
+ }
928
+ if (config.directories.build) {
929
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
930
+ }
931
+ }
932
+ if (config.skipCache !== void 0) {
933
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
934
+ if (config.skipCache) {
935
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
936
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
937
+ }
938
+ }
939
+ if (config.env) {
940
+ process.env[`${prefix}ENV`] = config.env;
941
+ process.env.NODE_ENV = config.env;
942
+ process.env.ENVIRONMENT = config.env;
943
+ }
944
+ if (config.colors?.base?.light || config.colors?.base?.dark) {
945
+ for (const key of Object.keys(config.colors)) {
946
+ setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
947
+ }
948
+ } else {
949
+ setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
950
+ }
951
+ if (config.repository) {
952
+ process.env[`${prefix}REPOSITORY`] = config.repository;
953
+ }
954
+ if (config.branch) {
955
+ process.env[`${prefix}BRANCH`] = config.branch;
956
+ }
957
+ if (config.preid) {
958
+ process.env[`${prefix}PRE_ID`] = String(config.preid);
959
+ }
960
+ if (config.externalPackagePatterns) {
961
+ process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
962
+ }
963
+ if (config.registry) {
964
+ if (config.registry.github) {
965
+ process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
966
+ }
967
+ if (config.registry.npm) {
968
+ process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
969
+ }
970
+ if (config.registry.cargo) {
971
+ process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
972
+ }
973
+ if (config.registry.cyclone) {
974
+ process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
975
+ }
976
+ if (config.registry.container) {
977
+ process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
978
+ }
979
+ }
980
+ if (config.logLevel) {
981
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
982
+ process.env.LOG_LEVEL = String(config.logLevel);
983
+ process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
984
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
985
+ }
986
+ process.env[`${prefix}CONFIG`] = JSON.stringify(config);
987
+ for (const key of Object.keys(config.extensions ?? {})) {
988
+ config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
989
+ }
990
+ }, "setConfigEnv");
991
+ var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
992
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
993
+ }, "setThemeColorConfigEnv");
994
+ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
995
+ if (config.dark) {
996
+ process.env[`${prefix}DARK`] = config.dark;
997
+ }
998
+ if (config.light) {
999
+ process.env[`${prefix}LIGHT`] = config.light;
1000
+ }
1001
+ if (config.brand) {
1002
+ process.env[`${prefix}BRAND`] = config.brand;
1003
+ }
1004
+ if (config.alternate) {
1005
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
1006
+ }
1007
+ if (config.accent) {
1008
+ process.env[`${prefix}ACCENT`] = config.accent;
1009
+ }
1010
+ if (config.link) {
1011
+ process.env[`${prefix}LINK`] = config.link;
1012
+ }
1013
+ if (config.help) {
1014
+ process.env[`${prefix}HELP`] = config.help;
1015
+ }
1016
+ if (config.success) {
1017
+ process.env[`${prefix}SUCCESS`] = config.success;
1018
+ }
1019
+ if (config.info) {
1020
+ process.env[`${prefix}INFO`] = config.info;
1021
+ }
1022
+ if (config.warning) {
1023
+ process.env[`${prefix}WARNING`] = config.warning;
1024
+ }
1025
+ if (config.danger) {
1026
+ process.env[`${prefix}DANGER`] = config.danger;
1027
+ }
1028
+ if (config.fatal) {
1029
+ process.env[`${prefix}FATAL`] = config.fatal;
1030
+ }
1031
+ if (config.positive) {
1032
+ process.env[`${prefix}POSITIVE`] = config.positive;
1033
+ }
1034
+ if (config.negative) {
1035
+ process.env[`${prefix}NEGATIVE`] = config.negative;
1036
+ }
1037
+ }, "setSingleThemeColorConfigEnv");
1038
+ var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1039
+ return {
1040
+ light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
1041
+ dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
1042
+ };
1043
+ }, "setMultiThemeColorConfigEnv");
1044
+ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1045
+ if (config.foreground) {
1046
+ process.env[`${prefix}FOREGROUND`] = config.foreground;
1047
+ }
1048
+ if (config.background) {
1049
+ process.env[`${prefix}BACKGROUND`] = config.background;
1050
+ }
1051
+ if (config.brand) {
1052
+ process.env[`${prefix}BRAND`] = config.brand;
1053
+ }
1054
+ if (config.alternate) {
1055
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
1056
+ }
1057
+ if (config.accent) {
1058
+ process.env[`${prefix}ACCENT`] = config.accent;
1059
+ }
1060
+ if (config.link) {
1061
+ process.env[`${prefix}LINK`] = config.link;
1062
+ }
1063
+ if (config.help) {
1064
+ process.env[`${prefix}HELP`] = config.help;
1065
+ }
1066
+ if (config.success) {
1067
+ process.env[`${prefix}SUCCESS`] = config.success;
1068
+ }
1069
+ if (config.info) {
1070
+ process.env[`${prefix}INFO`] = config.info;
1071
+ }
1072
+ if (config.warning) {
1073
+ process.env[`${prefix}WARNING`] = config.warning;
1074
+ }
1075
+ if (config.danger) {
1076
+ process.env[`${prefix}DANGER`] = config.danger;
1077
+ }
1078
+ if (config.fatal) {
1079
+ process.env[`${prefix}FATAL`] = config.fatal;
1080
+ }
1081
+ if (config.positive) {
1082
+ process.env[`${prefix}POSITIVE`] = config.positive;
1083
+ }
1084
+ if (config.negative) {
1085
+ process.env[`${prefix}NEGATIVE`] = config.negative;
1086
+ }
1087
+ }, "setBaseThemeColorConfigEnv");
1088
+
1089
+ // ../config-tools/src/create-storm-config.ts
1090
+ var _static_cache = void 0;
1091
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
1092
+ let config = {};
1093
+ if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
1094
+ writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
1095
+ return _static_cache.data;
1096
+ }
1097
+ let _workspaceRoot = workspaceRoot;
1098
+ if (!_workspaceRoot) {
1099
+ _workspaceRoot = findWorkspaceRoot();
1100
+ }
1101
+ const configFile = await getConfigFile(_workspaceRoot);
1102
+ if (!configFile) {
1103
+ writeWarning("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
1104
+ logLevel: "all"
1105
+ });
1106
+ }
1107
+ config = (0, import_defu2.default)(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
1108
+ setConfigEnv(config);
1109
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
1110
+ ${formatLogMessage(config)}`, config);
1111
+ return config;
1112
+ }, "loadStormConfig");
1113
+
1114
+ // bin/untyped.ts
1115
+ var import_commander = require("commander");
1116
+
1117
+ // src/generate.ts
1118
+ var import_glob = require("glob");
1119
+ var import_loader = require("untyped/loader");
1120
+
1121
+ // src/generators/dts.ts
1122
+ var import_promises = require("fs/promises");
1123
+ var import_untyped = require("untyped");
1124
+
1125
+ // src/utilities.ts
1126
+ var getOutputFile = /* @__PURE__ */ __name((file, extension) => {
1127
+ let fileName = file.name.slice(0, file.name.lastIndexOf(".")).replace(".schema", "").replace("schema", "");
1128
+ if (!fileName) {
1129
+ fileName = "schema";
1130
+ }
1131
+ if (extension === "json" && fileName !== "schema") {
1132
+ fileName = `${fileName}.schema`;
1133
+ }
1134
+ return joinPaths(file.parentPath, `${fileName}.${extension}`);
1135
+ }, "getOutputFile");
1136
+
1137
+ // src/generators/dts.ts
1138
+ function generateDeclaration(schema) {
1139
+ return `
1140
+ // Generated by @storm-software/untyped
1141
+ // Do not edit this file directly
1142
+
1143
+ ${(0, import_untyped.generateTypes)(schema, {
1144
+ addExport: true,
1145
+ partial: true,
1146
+ interfaceName: `${schema.title?.replaceAll(" ", "") || "Type"}Schema`
1147
+ })}
1148
+
1149
+ `;
1150
+ }
1151
+ __name(generateDeclaration, "generateDeclaration");
1152
+ function generateDeclarationFile(schema, file, config) {
1153
+ try {
1154
+ const declarations = getOutputFile(file, "d.ts");
1155
+ writeTrace(`Writing type declaration file ${declarations}`, config);
1156
+ return (0, import_promises.writeFile)(declarations, generateDeclaration(schema));
1157
+ } catch (error) {
1158
+ writeError(`Error writing declaration file for ${file.name}
1159
+
1160
+ Error:
1161
+ ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
1162
+ Stack Trace: ${error.stack}` : ""}
1163
+
1164
+ Parsed schema:
1165
+ ${JSON.stringify(schema)}
1166
+ `, config);
1167
+ throw error;
1168
+ }
1169
+ }
1170
+ __name(generateDeclarationFile, "generateDeclarationFile");
1171
+
1172
+ // src/generators/json-schema.ts
1173
+ var import_promises2 = require("fs/promises");
1174
+ function generateJsonSchemaFile(schema, file, config) {
1175
+ try {
1176
+ const jsonSchema = getOutputFile(file, "json");
1177
+ writeTrace(`Writing JSON schema file ${jsonSchema}`, config);
1178
+ return (0, import_promises2.writeFile)(jsonSchema, JSON.stringify(schema, null, 2));
1179
+ } catch (error) {
1180
+ writeError(`Error writing JSON schema file for ${file.name}
1181
+
1182
+ Error:
1183
+ ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
1184
+ Stack Trace: ${error.stack}` : ""}
1185
+
1186
+ Parsed schema:
1187
+ ${JSON.stringify(schema)}
1188
+ `, config);
1189
+ throw error;
1190
+ }
1191
+ }
1192
+ __name(generateJsonSchemaFile, "generateJsonSchemaFile");
1193
+
1194
+ // src/generators/markdown.ts
1195
+ var import_promises3 = require("fs/promises");
1196
+ function generateMarkdown(schema) {
1197
+ return `
1198
+ <!-- Generated by @storm-software/untyped -->
1199
+ <!-- Do not edit this file directly -->
1200
+
1201
+ ${generateMarkdownLevel(schema, schema.title || "", "#").join("\n")}
1202
+
1203
+ `;
1204
+ }
1205
+ __name(generateMarkdown, "generateMarkdown");
1206
+ function generateMarkdownLevel(schema, title, level) {
1207
+ const lines = [];
1208
+ lines.push(`${level} ${title}`);
1209
+ if (schema.type === "object") {
1210
+ for (const key in schema.properties) {
1211
+ const val = schema.properties[key];
1212
+ lines.push("", ...generateMarkdownLevel(val, `\`${key}\``, level + "#"));
1213
+ }
1214
+ return lines;
1215
+ }
1216
+ lines.push(`- **Type**: \`${schema.markdownType || schema.tsType || schema.type}\``);
1217
+ if ("default" in schema) {
1218
+ lines.push(`- **Default**: \`${JSON.stringify(schema.default)}\``);
1219
+ }
1220
+ lines.push("");
1221
+ if (schema.title) {
1222
+ lines.push("> " + schema.title, "");
1223
+ }
1224
+ if (schema.description) {
1225
+ lines.push("", schema.description, "");
1226
+ }
1227
+ return lines;
1228
+ }
1229
+ __name(generateMarkdownLevel, "generateMarkdownLevel");
1230
+ function generateMarkdownFile(schema, file, config) {
1231
+ try {
1232
+ const declarations = getOutputFile(file, "md");
1233
+ writeTrace(`Writing type markdown file ${declarations}`, config);
1234
+ return (0, import_promises3.writeFile)(declarations, generateMarkdown(schema));
1235
+ } catch (error) {
1236
+ writeError(`Error writing markdown file for ${file.name}
1237
+
1238
+ Error:
1239
+ ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
1240
+ Stack Trace: ${error.stack}` : ""}
1241
+
1242
+ Parsed schema:
1243
+ ${JSON.stringify(schema)}
1244
+ `, config);
1245
+ throw error;
1246
+ }
1247
+ }
1248
+ __name(generateMarkdownFile, "generateMarkdownFile");
1249
+
1250
+ // src/generate.ts
1251
+ var getGenerateAction = /* @__PURE__ */ __name((config) => async (options) => {
1252
+ const files = await (0, import_glob.glob)(options.entry, {
1253
+ ignore: [
1254
+ "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}",
1255
+ "**/dist/**",
1256
+ "**/tmp/**",
1257
+ "**/node_modules/**",
1258
+ "**/.git/**",
1259
+ "**/.cache/**",
1260
+ "**/.nx/**"
1261
+ ],
1262
+ withFileTypes: true,
1263
+ cwd: config.workspaceRoot
1264
+ });
1265
+ const cache = !Boolean(process.env.CI) && !Boolean(process.env.STORM_CI) && !config.skipCache;
1266
+ writeTrace(cache ? `Skipping jiti cache because ${Boolean(process.env.CI) ? '`process.env.CI` is set to "true"' : Boolean(process.env.STORM_CI) ? '`process.env.STORM_CI` is set to "true"' : config.skipCache ? "`skipCache` in the Storm configuration file is set to `true`" : "<INVALID REASON>"}` : "Will use jiti cache while parsing schema files", config);
1267
+ await Promise.all(files.map(async (file) => {
1268
+ writeTrace(`Generating files for schema file: ${joinPaths(file.parentPath, file.name)}`, config);
1269
+ let schema;
1270
+ try {
1271
+ schema = await (0, import_loader.loadSchema)(joinPaths(file.parentPath, file.name), {
1272
+ jiti: {
1273
+ debug: isVerbose(config.logLevel),
1274
+ fsCache: cache && joinPaths(config.directories.cache || "node_modules/.cache", "storm", "untyped"),
1275
+ moduleCache: cache,
1276
+ interopDefault: true
1277
+ }
1278
+ });
1279
+ } catch (error) {
1280
+ writeError(`Error while parsing schema file: ${joinPaths(file.parentPath, file.name)}
1281
+
1282
+ Error:
1283
+ ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
1284
+ Stack Trace: ${error.stack}` : ""}
1285
+
1286
+ Parsed schema:
1287
+ ${JSON.stringify(schema)}
1288
+ `, config);
1289
+ throw error;
1290
+ }
1291
+ const promises = [];
1292
+ promises.push(generateDeclarationFile(schema, file, config));
1293
+ promises.push(generateMarkdownFile(schema, file, config));
1294
+ promises.push(generateJsonSchemaFile(schema, file, config));
1295
+ return Promise.all(promises);
1296
+ }));
1297
+ }, "getGenerateAction");
1298
+
1299
+ // bin/untyped.ts
1300
+ async function createProgram(config) {
1301
+ try {
1302
+ writeInfo("\u26A1 Running Storm Untyped codegen utility", config);
1303
+ const root = findWorkspaceRootSafe();
1304
+ process.env.STORM_WORKSPACE_ROOT ??= root;
1305
+ process.env.NX_WORKSPACE_ROOT_PATH ??= root;
1306
+ root && process.chdir(root);
1307
+ const program = new import_commander.Command("storm-untyped");
1308
+ program.version("1.0.0", "-v --version", "display CLI version");
1309
+ program.description("\u26A1 Run the Storm untyped codegen utility").showHelpAfterError().showSuggestionAfterError();
1310
+ const entryOption = new import_commander.Option("-e --entry <path>", "The path to the entry file to generate types for. This can be a file or a directory. Globs are supported.").argParser((val) => val.split(",")).default([
1311
+ "**/schema.ts",
1312
+ "**/*.schema.ts"
1313
+ ]);
1314
+ const outputPathOption = new import_commander.Option("-o --output-path <path>", "The path of the project's source folder to build");
1315
+ program.command("generate", {
1316
+ isDefault: true
1317
+ }).alias("bundle").description("Run a TypeScript build using Untyped, API-Extractor, and TSC (for type generation).").addOption(entryOption).addOption(outputPathOption).action(getGenerateAction(config));
1318
+ return program;
1319
+ } catch (e) {
1320
+ writeFatal(`A fatal error occurred while running the program: ${e.message}`, config);
1321
+ process.exit(1);
1322
+ }
1323
+ }
1324
+ __name(createProgram, "createProgram");
1325
+ void (async () => {
1326
+ const config = await loadStormConfig();
1327
+ const stopwatch = getStopwatch("Storm Untyped executable");
1328
+ try {
1329
+ handleProcess(config);
1330
+ const program = await createProgram(config);
1331
+ await program.parseAsync(process.argv);
1332
+ writeSuccess(`\u{1F389} Storm Untyped executable has completed successfully!`, config);
1333
+ exitWithSuccess(config);
1334
+ } catch (error) {
1335
+ writeFatal(`A fatal error occurred while running Storm Untyped executable:
1336
+
1337
+ ${error.message}`, config);
1338
+ exitWithError(config);
1339
+ process.exit(1);
1340
+ } finally {
1341
+ stopwatch();
1342
+ }
1343
+ })();