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