@storm-software/pulumi-tools 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/chunk-23KFTIT2.mjs +0 -0
  3. package/dist/chunk-3GQAWCBQ.js +13 -0
  4. package/dist/chunk-3I666OI5.js +17 -0
  5. package/dist/chunk-4BDVESFO.mjs +109 -0
  6. package/dist/chunk-53MF6VMZ.js +18 -0
  7. package/dist/chunk-A6SQY5H3.js +16 -0
  8. package/dist/chunk-AJZ5SHGR.js +15 -0
  9. package/dist/chunk-ANLNSAGB.mjs +16 -0
  10. package/dist/chunk-CA7S5MOH.mjs +0 -0
  11. package/dist/chunk-CFSEZM76.js +13 -0
  12. package/dist/chunk-DBLK3NPE.js +20 -0
  13. package/dist/chunk-DFO7BOCT.js +35 -0
  14. package/dist/chunk-F6BX5YBK.mjs +15 -0
  15. package/dist/chunk-FLIBLJZ5.mjs +4586 -0
  16. package/dist/chunk-GTCRGRK2.mjs +20 -0
  17. package/dist/chunk-GUQOEBFW.js +1 -0
  18. package/dist/chunk-LZVNTYR3.js +109 -0
  19. package/dist/chunk-N2YKXZ5R.js +1 -0
  20. package/dist/chunk-QWZKKPML.mjs +18 -0
  21. package/dist/chunk-U64WWLJ7.mjs +35 -0
  22. package/dist/chunk-UV4HQO3Y.mjs +0 -0
  23. package/dist/chunk-XO62WWX4.js +1 -0
  24. package/dist/chunk-XUV4U54K.mjs +21 -0
  25. package/dist/chunk-XVKT7UGE.mjs +13 -0
  26. package/dist/chunk-Z2BSLIJ7.js +4585 -0
  27. package/dist/chunk-Z7XF6QIZ.mjs +17 -0
  28. package/dist/executors.d.mts +10 -0
  29. package/dist/executors.d.ts +10 -0
  30. package/dist/executors.js +9 -0
  31. package/dist/executors.mjs +9 -0
  32. package/dist/generators-Bk-gnn2s.d.ts +30 -0
  33. package/dist/generators-kdwvS-eX.d.mts +30 -0
  34. package/dist/generators.d.mts +5 -0
  35. package/dist/generators.d.ts +5 -0
  36. package/dist/generators.js +10 -0
  37. package/dist/generators.mjs +10 -0
  38. package/dist/index.d.mts +12 -0
  39. package/dist/index.d.ts +12 -0
  40. package/dist/index.js +26 -0
  41. package/dist/index.mjs +26 -0
  42. package/dist/schema.d-0Y4jyHfI.d.ts +11 -0
  43. package/dist/schema.d-BBpw11tM.d.ts +8 -0
  44. package/dist/schema.d-BCkJFwHO.d.mts +11 -0
  45. package/dist/schema.d-BTpgEb0Q.d.mts +8 -0
  46. package/dist/schema.d-C3zluSfr.d.mts +7 -0
  47. package/dist/schema.d-CWp7y_9i.d.mts +8 -0
  48. package/dist/schema.d-D2EQU5UL.d.mts +11 -0
  49. package/dist/schema.d-DhkOAnzb.d.ts +8 -0
  50. package/dist/schema.d-Dri9rCeV.d.ts +11 -0
  51. package/dist/schema.d-i8onVGak.d.ts +7 -0
  52. package/dist/src/base/base-executor.d.mts +44 -0
  53. package/dist/src/base/base-executor.d.ts +44 -0
  54. package/dist/src/base/base-executor.js +8 -0
  55. package/dist/src/base/base-executor.mjs +8 -0
  56. package/dist/src/base/index.d.mts +6 -0
  57. package/dist/src/base/index.d.ts +6 -0
  58. package/dist/src/base/index.js +15 -0
  59. package/dist/src/base/index.mjs +15 -0
  60. package/dist/src/base/providers.d.mts +8 -0
  61. package/dist/src/base/providers.d.ts +8 -0
  62. package/dist/src/base/providers.js +9 -0
  63. package/dist/src/base/providers.mjs +9 -0
  64. package/dist/src/executors/config/executor.d.mts +12 -0
  65. package/dist/src/executors/config/executor.d.ts +12 -0
  66. package/dist/src/executors/config/executor.js +9 -0
  67. package/dist/src/executors/config/executor.mjs +9 -0
  68. package/dist/src/executors/import/executor.d.mts +12 -0
  69. package/dist/src/executors/import/executor.d.ts +12 -0
  70. package/dist/src/executors/import/executor.js +9 -0
  71. package/dist/src/executors/import/executor.mjs +9 -0
  72. package/dist/src/executors/preview/executor.d.mts +12 -0
  73. package/dist/src/executors/preview/executor.d.ts +12 -0
  74. package/dist/src/executors/preview/executor.js +9 -0
  75. package/dist/src/executors/preview/executor.mjs +9 -0
  76. package/dist/src/executors/refresh/executor.d.mts +12 -0
  77. package/dist/src/executors/refresh/executor.d.ts +12 -0
  78. package/dist/src/executors/refresh/executor.js +9 -0
  79. package/dist/src/executors/refresh/executor.mjs +9 -0
  80. package/dist/src/executors/up/executor.d.mts +12 -0
  81. package/dist/src/executors/up/executor.d.ts +12 -0
  82. package/dist/src/executors/up/executor.js +9 -0
  83. package/dist/src/executors/up/executor.mjs +9 -0
  84. package/dist/src/generators/init/generator.d.mts +5 -0
  85. package/dist/src/generators/init/generator.d.ts +5 -0
  86. package/dist/src/generators/init/generator.js +11 -0
  87. package/dist/src/generators/init/generator.mjs +11 -0
  88. package/dist/src/generators/init/schema.d.ts +1 -1
  89. package/dist/tsup.config.d.mts +5 -0
  90. package/dist/tsup.config.d.ts +5 -0
  91. package/dist/tsup.config.js +34 -0
  92. package/dist/tsup.config.mjs +34 -0
  93. package/dist/types-CIJRaFHD.d.mts +1185 -0
  94. package/dist/types-CIJRaFHD.d.ts +1185 -0
  95. package/package.json +1 -1
@@ -0,0 +1,4586 @@
1
+ import {
2
+ __dirname,
3
+ __name,
4
+ __require
5
+ } from "./chunk-XUV4U54K.mjs";
6
+
7
+ // ../config-tools/src/utilities/run.ts
8
+ import { exec, execSync } from "node:child_process";
9
+ var LARGE_BUFFER = 1024 * 1e6;
10
+ var run = /* @__PURE__ */ __name((config, command, cwd = config.workspaceRoot ?? process.cwd(), stdio = "inherit", env = process.env) => {
11
+ return execSync(command, {
12
+ cwd,
13
+ env: {
14
+ ...process.env,
15
+ ...env,
16
+ CLICOLOR: "true",
17
+ FORCE_COLOR: "true"
18
+ },
19
+ windowsHide: true,
20
+ stdio,
21
+ maxBuffer: LARGE_BUFFER,
22
+ killSignal: "SIGTERM"
23
+ });
24
+ }, "run");
25
+
26
+ // ../config-tools/src/config-file/get-config-file.ts
27
+ import { loadConfig } from "c12";
28
+ import defu from "defu";
29
+
30
+ // ../config-tools/src/types.ts
31
+ var LogLevel = {
32
+ SILENT: 0,
33
+ FATAL: 10,
34
+ ERROR: 20,
35
+ WARN: 30,
36
+ SUCCESS: 35,
37
+ INFO: 40,
38
+ DEBUG: 60,
39
+ TRACE: 70,
40
+ ALL: 100
41
+ };
42
+ var LogLevelLabel = {
43
+ SILENT: "silent",
44
+ FATAL: "fatal",
45
+ ERROR: "error",
46
+ WARN: "warn",
47
+ SUCCESS: "success",
48
+ INFO: "info",
49
+ DEBUG: "debug",
50
+ TRACE: "trace",
51
+ ALL: "all"
52
+ };
53
+
54
+ // ../config/src/constants.ts
55
+ var STORM_DEFAULT_DOCS = "https://docs.stormsoftware.com";
56
+ var STORM_DEFAULT_HOMEPAGE = "https://stormsoftware.com";
57
+ var STORM_DEFAULT_LICENSING = "https://license.stormsoftware.com";
58
+ var STORM_DEFAULT_LICENSE = "Apache-2.0";
59
+
60
+ // ../config/src/schema.ts
61
+ import z from "zod";
62
+ 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");
63
+ 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");
64
+ 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");
65
+ 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");
66
+ 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");
67
+ 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");
68
+ 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");
69
+ 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");
70
+ 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");
71
+ 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");
72
+ 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");
73
+ var FatalColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The fatal color of the workspace");
74
+ 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");
75
+ 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");
76
+ var DarkThemeColorConfigSchema = z.object({
77
+ foreground: LightColorSchema,
78
+ background: DarkColorSchema,
79
+ brand: BrandColorSchema,
80
+ alternate: AlternateColorSchema,
81
+ accent: AccentColorSchema,
82
+ link: LinkColorSchema,
83
+ help: HelpColorSchema,
84
+ success: SuccessColorSchema,
85
+ info: InfoColorSchema,
86
+ warning: WarningColorSchema,
87
+ danger: DangerColorSchema,
88
+ fatal: FatalColorSchema,
89
+ positive: PositiveColorSchema,
90
+ negative: NegativeColorSchema
91
+ });
92
+ var LightThemeColorConfigSchema = z.object({
93
+ foreground: DarkColorSchema,
94
+ background: LightColorSchema,
95
+ brand: BrandColorSchema,
96
+ alternate: AlternateColorSchema,
97
+ accent: AccentColorSchema,
98
+ link: LinkColorSchema,
99
+ help: HelpColorSchema,
100
+ success: SuccessColorSchema,
101
+ info: InfoColorSchema,
102
+ warning: WarningColorSchema,
103
+ danger: DangerColorSchema,
104
+ fatal: FatalColorSchema,
105
+ positive: PositiveColorSchema,
106
+ negative: NegativeColorSchema
107
+ });
108
+ var MultiThemeColorConfigSchema = z.object({
109
+ dark: DarkThemeColorConfigSchema,
110
+ light: LightThemeColorConfigSchema
111
+ });
112
+ var SingleThemeColorConfigSchema = z.object({
113
+ dark: DarkColorSchema,
114
+ light: LightColorSchema,
115
+ brand: BrandColorSchema,
116
+ alternate: AlternateColorSchema,
117
+ accent: AccentColorSchema,
118
+ link: LinkColorSchema,
119
+ help: HelpColorSchema,
120
+ success: SuccessColorSchema,
121
+ info: InfoColorSchema,
122
+ warning: WarningColorSchema,
123
+ danger: DangerColorSchema,
124
+ fatal: FatalColorSchema,
125
+ positive: PositiveColorSchema,
126
+ negative: NegativeColorSchema
127
+ });
128
+ var RegistryUrlConfigSchema = z.string().trim().toLowerCase().url().optional().describe("A remote registry URL used to publish distributable packages");
129
+ var RegistryConfigSchema = z.object({
130
+ github: RegistryUrlConfigSchema,
131
+ npm: RegistryUrlConfigSchema,
132
+ cargo: RegistryUrlConfigSchema,
133
+ cyclone: RegistryUrlConfigSchema,
134
+ container: RegistryUrlConfigSchema
135
+ }).default({}).describe("A list of remote registry URLs used by Storm Software");
136
+ var ColorConfigSchema = SingleThemeColorConfigSchema.or(MultiThemeColorConfigSchema).describe("Colors used for various workspace elements");
137
+ var ColorConfigMapSchema = z.union([
138
+ z.object({
139
+ "base": ColorConfigSchema
140
+ }),
141
+ z.record(z.string(), ColorConfigSchema)
142
+ ]);
143
+ var WorkspaceBotConfigSchema = z.object({
144
+ 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)"),
145
+ email: z.string().trim().email().default("bot@stormsoftware.com").describe("The email of the workspace bot")
146
+ }).describe("The workspace's bot user's config used to automated various operations tasks");
147
+ var WorkspaceDirectoryConfigSchema = z.object({
148
+ cache: z.string().trim().optional().describe("The directory used to store the environment's cached file data"),
149
+ data: z.string().trim().optional().describe("The directory used to store the environment's data files"),
150
+ config: z.string().trim().optional().describe("The directory used to store the environment's configuration files"),
151
+ temp: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
152
+ log: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
153
+ 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)")
154
+ }).describe("Various directories used by the workspace to store data, cache, and configuration files");
155
+ var StormConfigSchema = z.object({
156
+ $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"),
157
+ extends: z.string().trim().optional().describe("The path to a base JSON file to use as a configuration preset file"),
158
+ name: z.string().trim().toLowerCase().optional().describe("The name of the service/package/scope using this configuration"),
159
+ namespace: z.string().trim().toLowerCase().optional().describe("The namespace of the package"),
160
+ organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
161
+ repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
162
+ license: z.string().trim().default("Apache-2.0").describe("The license type of the package"),
163
+ homepage: z.string().trim().url().default(STORM_DEFAULT_HOMEPAGE).describe("The homepage of the workspace"),
164
+ docs: z.string().trim().url().default(STORM_DEFAULT_DOCS).describe("The base documentation site for the workspace"),
165
+ licensing: z.string().trim().url().default(STORM_DEFAULT_LICENSING).describe("The base licensing site for the workspace"),
166
+ branch: z.string().trim().default("main").describe("The branch of the workspace"),
167
+ preid: z.string().optional().describe("A tag specifying the version pre-release identifier"),
168
+ owner: z.string().trim().default("@storm-software/admin").describe("The owner of the package"),
169
+ bot: WorkspaceBotConfigSchema,
170
+ env: z.enum([
171
+ "development",
172
+ "staging",
173
+ "production"
174
+ ]).default("production").describe("The current runtime environment name for the package"),
175
+ workspaceRoot: z.string().trim().default("").describe("The root directory of the workspace"),
176
+ externalPackagePatterns: z.array(z.string()).default([]).describe("The build will use these package patterns to determine if they should be external to the bundle"),
177
+ skipCache: z.boolean().default(false).describe("Should all known types of workspace caching be skipped?"),
178
+ directories: WorkspaceDirectoryConfigSchema,
179
+ packageManager: z.enum([
180
+ "npm",
181
+ "yarn",
182
+ "pnpm",
183
+ "bun"
184
+ ]).default("npm").describe("The JavaScript/TypeScript package manager used by the repository"),
185
+ timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
186
+ locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
187
+ logLevel: z.enum([
188
+ "silent",
189
+ "fatal",
190
+ "error",
191
+ "warn",
192
+ "success",
193
+ "info",
194
+ "debug",
195
+ "trace",
196
+ "all"
197
+ ]).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`)."),
198
+ registry: RegistryConfigSchema,
199
+ 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."),
200
+ colors: ColorConfigSchema.or(ColorConfigMapSchema).describe("Storm theme config values used for styling various package elements"),
201
+ extensions: z.record(z.any()).optional().default({}).describe("Configuration of each used extension")
202
+ }).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.");
203
+
204
+ // ../config/src/types.ts
205
+ var COLOR_KEYS = [
206
+ "dark",
207
+ "light",
208
+ "base",
209
+ "brand",
210
+ "alternate",
211
+ "accent",
212
+ "link",
213
+ "success",
214
+ "help",
215
+ "info",
216
+ "warning",
217
+ "danger",
218
+ "fatal",
219
+ "positive",
220
+ "negative"
221
+ ];
222
+
223
+ // ../config-tools/src/utilities/get-default-config.ts
224
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
225
+ import { join as join2 } from "node:path";
226
+
227
+ // ../config-tools/src/utilities/correct-paths.ts
228
+ import { joinPathFragments } from "@nx/devkit";
229
+ var correctPaths = /* @__PURE__ */ __name((path7) => {
230
+ if (!path7) {
231
+ return "";
232
+ }
233
+ if (!path7.toUpperCase().startsWith("C:") && path7.includes("\\")) {
234
+ path7 = `C:${path7}`;
235
+ }
236
+ return path7.replaceAll("\\", "/");
237
+ }, "correctPaths");
238
+ var joinPaths = /* @__PURE__ */ __name((...paths) => {
239
+ if (!paths || paths.length === 0) {
240
+ return "";
241
+ }
242
+ return correctPaths(joinPathFragments(...paths.map((path7) => correctPaths(path7))));
243
+ }, "joinPaths");
244
+
245
+ // ../config-tools/src/utilities/find-up.ts
246
+ import { existsSync } from "node:fs";
247
+ import { join } from "node:path";
248
+ var MAX_PATH_SEARCH_DEPTH = 30;
249
+ var depth = 0;
250
+ function findFolderUp(startPath, endFileNames) {
251
+ const _startPath = startPath ?? process.cwd();
252
+ if (endFileNames.some((endFileName) => existsSync(join(_startPath, endFileName)))) {
253
+ return _startPath;
254
+ }
255
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
256
+ const parent = join(_startPath, "..");
257
+ return findFolderUp(parent, endFileNames);
258
+ }
259
+ return void 0;
260
+ }
261
+ __name(findFolderUp, "findFolderUp");
262
+
263
+ // ../config-tools/src/utilities/find-workspace-root.ts
264
+ var rootFiles = [
265
+ "storm.json",
266
+ "storm.json",
267
+ "storm.yaml",
268
+ "storm.yml",
269
+ "storm.js",
270
+ "storm.ts",
271
+ ".storm.json",
272
+ ".storm.yaml",
273
+ ".storm.yml",
274
+ ".storm.js",
275
+ ".storm.ts",
276
+ "lerna.json",
277
+ "nx.json",
278
+ "turbo.json",
279
+ "npm-workspace.json",
280
+ "yarn-workspace.json",
281
+ "pnpm-workspace.json",
282
+ "npm-workspace.yaml",
283
+ "yarn-workspace.yaml",
284
+ "pnpm-workspace.yaml",
285
+ "npm-workspace.yml",
286
+ "yarn-workspace.yml",
287
+ "pnpm-workspace.yml",
288
+ "npm-lock.json",
289
+ "yarn-lock.json",
290
+ "pnpm-lock.json",
291
+ "npm-lock.yaml",
292
+ "yarn-lock.yaml",
293
+ "pnpm-lock.yaml",
294
+ "npm-lock.yml",
295
+ "yarn-lock.yml",
296
+ "pnpm-lock.yml",
297
+ "bun.lockb"
298
+ ];
299
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
300
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
301
+ return correctPaths(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
302
+ }
303
+ return correctPaths(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles));
304
+ }
305
+ __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
306
+ function findWorkspaceRoot(pathInsideMonorepo) {
307
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
308
+ if (!result) {
309
+ throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
310
+ ${rootFiles.join("\n")}
311
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
312
+ }
313
+ return result;
314
+ }
315
+ __name(findWorkspaceRoot, "findWorkspaceRoot");
316
+
317
+ // ../config-tools/src/utilities/get-default-config.ts
318
+ var DEFAULT_COLOR_CONFIG = {
319
+ "light": {
320
+ "background": "#fafafa",
321
+ "foreground": "#1d1e22",
322
+ "brand": "#1fb2a6",
323
+ "alternate": "#db2777",
324
+ "help": "#5C4EE5",
325
+ "success": "#087f5b",
326
+ "info": "#0550ae",
327
+ "warning": "#e3b341",
328
+ "danger": "#D8314A",
329
+ "positive": "#22c55e",
330
+ "negative": "#dc2626"
331
+ },
332
+ "dark": {
333
+ "background": "#1d1e22",
334
+ "foreground": "#cbd5e1",
335
+ "brand": "#2dd4bf",
336
+ "alternate": "#db2777",
337
+ "help": "#818cf8",
338
+ "success": "#10b981",
339
+ "info": "#58a6ff",
340
+ "warning": "#f3d371",
341
+ "danger": "#D8314A",
342
+ "positive": "#22c55e",
343
+ "negative": "#dc2626"
344
+ }
345
+ };
346
+ var getDefaultConfig = /* @__PURE__ */ __name((root) => {
347
+ let license = STORM_DEFAULT_LICENSE;
348
+ let homepage = STORM_DEFAULT_HOMEPAGE;
349
+ let name;
350
+ let namespace;
351
+ let repository;
352
+ const workspaceRoot3 = findWorkspaceRoot(root);
353
+ if (existsSync2(join2(workspaceRoot3, "package.json"))) {
354
+ const file = readFileSync(join2(workspaceRoot3, "package.json"), {
355
+ encoding: "utf8"
356
+ });
357
+ if (file) {
358
+ const packageJson = JSON.parse(file);
359
+ if (packageJson.name) {
360
+ name = packageJson.name;
361
+ }
362
+ if (packageJson.namespace) {
363
+ namespace = packageJson.namespace;
364
+ }
365
+ if (packageJson.repository?.url) {
366
+ repository = packageJson.repository?.url;
367
+ }
368
+ if (packageJson.license) {
369
+ license = packageJson.license;
370
+ }
371
+ if (packageJson.homepage) {
372
+ homepage = packageJson.homepage;
373
+ }
374
+ }
375
+ }
376
+ return {
377
+ workspaceRoot: workspaceRoot3,
378
+ name,
379
+ namespace,
380
+ repository,
381
+ license,
382
+ homepage,
383
+ docs: `${homepage || STORM_DEFAULT_HOMEPAGE}/docs`,
384
+ licensing: `${homepage || STORM_DEFAULT_HOMEPAGE}/license`
385
+ };
386
+ }, "getDefaultConfig");
387
+
388
+ // ../config-tools/src/logger/chalk.ts
389
+ import chalk from "chalk";
390
+ var chalkDefault = {
391
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
392
+ bgHex: /* @__PURE__ */ __name((_) => ({
393
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
394
+ }), "bgHex"),
395
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright"),
396
+ gray: /* @__PURE__ */ __name((message) => message, "gray"),
397
+ bold: {
398
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
399
+ bgHex: /* @__PURE__ */ __name((_) => ({
400
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
401
+ }), "bgHex"),
402
+ whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
403
+ },
404
+ dim: {
405
+ hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
406
+ gray: /* @__PURE__ */ __name((message) => message, "gray")
407
+ }
408
+ };
409
+ var getChalk = /* @__PURE__ */ __name(() => {
410
+ let _chalk = chalk;
411
+ if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
412
+ _chalk = chalkDefault;
413
+ }
414
+ return _chalk;
415
+ }, "getChalk");
416
+
417
+ // ../config-tools/src/logger/is-unicode-supported.ts
418
+ import process2 from "node:process";
419
+ function isUnicodeSupported() {
420
+ const { env } = process2;
421
+ const { TERM, TERM_PROGRAM } = env;
422
+ if (process2.platform !== "win32") {
423
+ return TERM !== "linux";
424
+ }
425
+ return Boolean(env.WT_SESSION) || // Windows Terminal
426
+ Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
427
+ env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
428
+ TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
429
+ }
430
+ __name(isUnicodeSupported, "isUnicodeSupported");
431
+
432
+ // ../config-tools/src/logger/console-icons.ts
433
+ var useIcon = /* @__PURE__ */ __name((c, fallback) => isUnicodeSupported() ? c : fallback, "useIcon");
434
+ var CONSOLE_ICONS = {
435
+ [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
436
+ [LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
437
+ [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
438
+ [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
439
+ [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
440
+ [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
441
+ [LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
442
+ [LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
443
+ };
444
+
445
+ // ../config-tools/src/logger/format-timestamp.ts
446
+ var formatTimestamp = /* @__PURE__ */ __name((date = /* @__PURE__ */ new Date()) => {
447
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
448
+ }, "formatTimestamp");
449
+
450
+ // ../config-tools/src/logger/get-log-level.ts
451
+ var getLogLevel = /* @__PURE__ */ __name((label) => {
452
+ switch (label) {
453
+ case "all":
454
+ return LogLevel.ALL;
455
+ case "trace":
456
+ return LogLevel.TRACE;
457
+ case "debug":
458
+ return LogLevel.DEBUG;
459
+ case "info":
460
+ return LogLevel.INFO;
461
+ case "warn":
462
+ return LogLevel.WARN;
463
+ case "error":
464
+ return LogLevel.ERROR;
465
+ case "fatal":
466
+ return LogLevel.FATAL;
467
+ case "silent":
468
+ return LogLevel.SILENT;
469
+ default:
470
+ return LogLevel.INFO;
471
+ }
472
+ }, "getLogLevel");
473
+ var getLogLevelLabel = /* @__PURE__ */ __name((logLevel = LogLevel.INFO) => {
474
+ if (logLevel >= LogLevel.ALL) {
475
+ return LogLevelLabel.ALL;
476
+ }
477
+ if (logLevel >= LogLevel.TRACE) {
478
+ return LogLevelLabel.TRACE;
479
+ }
480
+ if (logLevel >= LogLevel.DEBUG) {
481
+ return LogLevelLabel.DEBUG;
482
+ }
483
+ if (logLevel >= LogLevel.INFO) {
484
+ return LogLevelLabel.INFO;
485
+ }
486
+ if (logLevel >= LogLevel.WARN) {
487
+ return LogLevelLabel.WARN;
488
+ }
489
+ if (logLevel >= LogLevel.ERROR) {
490
+ return LogLevelLabel.ERROR;
491
+ }
492
+ if (logLevel >= LogLevel.FATAL) {
493
+ return LogLevelLabel.FATAL;
494
+ }
495
+ if (logLevel <= LogLevel.SILENT) {
496
+ return LogLevelLabel.SILENT;
497
+ }
498
+ return LogLevelLabel.INFO;
499
+ }, "getLogLevelLabel");
500
+ var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
501
+ const logLevel = typeof label === "string" ? getLogLevel(label) : label;
502
+ return logLevel >= LogLevel.DEBUG;
503
+ }, "isVerbose");
504
+
505
+ // ../config-tools/src/logger/console.ts
506
+ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) => {
507
+ const _chalk = getChalk();
508
+ 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;
509
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
510
+ if (typeof logLevel === "number" && (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel)) {
511
+ return (_) => {
512
+ };
513
+ }
514
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
515
+ return (message) => {
516
+ console.error(`
517
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
518
+ `);
519
+ };
520
+ }
521
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
522
+ return (message) => {
523
+ console.error(`
524
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
525
+ `);
526
+ };
527
+ }
528
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
529
+ return (message) => {
530
+ console.warn(`
531
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
532
+ `);
533
+ };
534
+ }
535
+ if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel || typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel)) {
536
+ return (message) => {
537
+ console.info(`
538
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
539
+ `);
540
+ };
541
+ }
542
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
543
+ return (message) => {
544
+ console.info(`
545
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
546
+ `);
547
+ };
548
+ }
549
+ if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel || typeof logLevel === "string" && LogLevel.TRACE >= getLogLevel(logLevel)) {
550
+ return (message) => {
551
+ console.debug(`
552
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
553
+ `);
554
+ };
555
+ }
556
+ return (message) => {
557
+ console.log(`
558
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
559
+ `);
560
+ };
561
+ }, "getLogFn");
562
+ var writeFatal = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.FATAL, config)(message), "writeFatal");
563
+ var writeError = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ERROR, config)(message), "writeError");
564
+ var writeWarning = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.WARN, config)(message), "writeWarning");
565
+ var writeInfo = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.INFO, config)(message), "writeInfo");
566
+ var writeSuccess = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.SUCCESS, config)(message), "writeSuccess");
567
+ var writeDebug = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.DEBUG, config)(message), "writeDebug");
568
+ var writeTrace = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.TRACE, config)(message), "writeTrace");
569
+ var writeSystem = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ALL, config)(message), "writeSystem");
570
+ var getStopwatch = /* @__PURE__ */ __name((name) => {
571
+ const start = process.hrtime();
572
+ return () => {
573
+ const end = process.hrtime(start);
574
+ console.info(`
575
+ > \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(end[0] * 1e3 + end[1] / 1e6)}ms to complete
576
+
577
+ `);
578
+ };
579
+ }, "getStopwatch");
580
+ var MAX_DEPTH = 4;
581
+ var formatLogMessage = /* @__PURE__ */ __name((message, options = {}, depth2 = 0) => {
582
+ if (depth2 > MAX_DEPTH) {
583
+ return "<max depth>";
584
+ }
585
+ const prefix = options.prefix ?? "-";
586
+ const skip2 = options.skip ?? [];
587
+ return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
588
+ ${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
589
+ prefix: `${prefix}-`,
590
+ skip: skip2
591
+ }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
592
+ ${Object.keys(message).filter((key) => !skip2.includes(key)).map((key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(message[key], {
593
+ prefix: `${prefix}-`,
594
+ skip: skip2
595
+ }, depth2 + 1) : message[key]}`).join("\n")}` : message;
596
+ }, "formatLogMessage");
597
+ var _isFunction = /* @__PURE__ */ __name((value) => {
598
+ try {
599
+ return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
600
+ } catch (e) {
601
+ return false;
602
+ }
603
+ }, "_isFunction");
604
+
605
+ // ../config-tools/src/utilities/apply-workspace-tokens.ts
606
+ var applyWorkspaceBaseTokens = /* @__PURE__ */ __name(async (option, tokenizerOptions) => {
607
+ let result = option;
608
+ if (!result) {
609
+ return result;
610
+ }
611
+ if (tokenizerOptions) {
612
+ const optionKeys = Object.keys(tokenizerOptions);
613
+ if (optionKeys.some((optionKey) => result.includes(`{${optionKey}}`))) {
614
+ for (const optionKey of optionKeys) {
615
+ if (result.includes(`{${optionKey}}`)) {
616
+ result = result.replaceAll(`{${optionKey}}`, tokenizerOptions.config?.[optionKey] ?? "");
617
+ }
618
+ }
619
+ }
620
+ }
621
+ if (tokenizerOptions.config) {
622
+ const configKeys = Object.keys(tokenizerOptions.config);
623
+ if (configKeys.some((configKey) => result.includes(`{${configKey}}`))) {
624
+ for (const configKey of configKeys) {
625
+ if (result.includes(`{${configKey}}`)) {
626
+ result = result.replaceAll(`{${configKey}}`, tokenizerOptions.config[configKey]);
627
+ }
628
+ }
629
+ }
630
+ }
631
+ if (result.includes("{workspaceRoot}")) {
632
+ result = result.replaceAll("{workspaceRoot}", tokenizerOptions.workspaceRoot ?? tokenizerOptions.config?.workspaceRoot ?? findWorkspaceRoot());
633
+ }
634
+ return result;
635
+ }, "applyWorkspaceBaseTokens");
636
+ var applyWorkspaceTokens = /* @__PURE__ */ __name(async (options, config, tokenizerFn) => {
637
+ if (!options) {
638
+ return {};
639
+ }
640
+ const result = {};
641
+ for (const option of Object.keys(options)) {
642
+ if (typeof options[option] === "string") {
643
+ result[option] = await Promise.resolve(tokenizerFn(options[option], config));
644
+ } else if (Array.isArray(options[option])) {
645
+ result[option] = await Promise.all(options[option].map(async (item) => typeof item === "string" ? await Promise.resolve(tokenizerFn(item, config)) : item));
646
+ } else if (typeof options[option] === "object") {
647
+ result[option] = await applyWorkspaceTokens(options[option], config, tokenizerFn);
648
+ } else {
649
+ result[option] = options[option];
650
+ }
651
+ }
652
+ return result;
653
+ }, "applyWorkspaceTokens");
654
+
655
+ // ../config-tools/src/config-file/get-config-file.ts
656
+ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
657
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
658
+ let config = loadConfig({
659
+ cwd: workspacePath,
660
+ packageJson: true,
661
+ name: fileName,
662
+ envName: fileName?.toUpperCase(),
663
+ jitiOptions: {
664
+ debug: false,
665
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
666
+ },
667
+ ...options
668
+ });
669
+ if (!config || Object.keys(config).length === 0) {
670
+ config = loadConfig({
671
+ cwd: workspacePath,
672
+ packageJson: true,
673
+ name: fileName,
674
+ envName: fileName?.toUpperCase(),
675
+ jitiOptions: {
676
+ debug: false,
677
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
678
+ },
679
+ configFile: fileName,
680
+ ...options
681
+ });
682
+ }
683
+ return config;
684
+ }, "getConfigFileByName");
685
+ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
686
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
687
+ const result = await getConfigFileByName("storm", workspacePath);
688
+ let config = result.config;
689
+ const configFile = result.configFile;
690
+ if (config && configFile && Object.keys(config).length > 0) {
691
+ writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
692
+ logLevel: "all"
693
+ });
694
+ }
695
+ if (additionalFileNames && additionalFileNames.length > 0) {
696
+ const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
697
+ for (const result2 of results) {
698
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
699
+ writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
700
+ logLevel: "all"
701
+ });
702
+ config = defu(result2.config ?? {}, config ?? {});
703
+ }
704
+ }
705
+ }
706
+ if (!config) {
707
+ return void 0;
708
+ }
709
+ config.configFile = configFile;
710
+ return config;
711
+ }, "getConfigFile");
712
+
713
+ // ../config-tools/src/create-storm-config.ts
714
+ import defu2 from "defu";
715
+
716
+ // ../config-tools/src/env/get-env.ts
717
+ var getConfigEnv = /* @__PURE__ */ __name(() => {
718
+ const prefix = "STORM_";
719
+ let config = {
720
+ extends: process.env[`${prefix}EXTENDS`] || void 0,
721
+ name: process.env[`${prefix}NAME`] || void 0,
722
+ namespace: process.env[`${prefix}NAMESPACE`] || void 0,
723
+ owner: process.env[`${prefix}OWNER`] || void 0,
724
+ bot: {
725
+ name: process.env[`${prefix}BOT_NAME`] || void 0,
726
+ email: process.env[`${prefix}BOT_EMAIL`] || void 0
727
+ },
728
+ organization: process.env[`${prefix}ORGANIZATION`] || void 0,
729
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
730
+ license: process.env[`${prefix}LICENSE`] || void 0,
731
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
732
+ docs: process.env[`${prefix}DOCS`] || void 0,
733
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
734
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
735
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
736
+ configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
737
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
738
+ directories: {
739
+ cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
740
+ data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
741
+ config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
742
+ temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
743
+ log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
744
+ build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
745
+ },
746
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
747
+ env: (process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
748
+ // ci:
749
+ // process.env[`${prefix}CI`] !== undefined
750
+ // ? Boolean(
751
+ // process.env[`${prefix}CI`] ??
752
+ // process.env.CI ??
753
+ // process.env.CONTINUOUS_INTEGRATION
754
+ // )
755
+ // : undefined,
756
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
757
+ branch: process.env[`${prefix}BRANCH`] || void 0,
758
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
759
+ externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
760
+ registry: {
761
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
762
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
763
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
764
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
765
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
766
+ },
767
+ 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
768
+ };
769
+ 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}`)));
770
+ config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
771
+ ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
772
+ return ret;
773
+ }, {}) : getThemeColorConfigEnv(prefix);
774
+ if (config.docs === STORM_DEFAULT_DOCS) {
775
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
776
+ config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
777
+ } else {
778
+ config.docs = `${config.homepage}/docs`;
779
+ }
780
+ }
781
+ if (config.licensing === STORM_DEFAULT_LICENSING) {
782
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
783
+ config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
784
+ } else {
785
+ config.licensing = `${config.homepage}/docs`;
786
+ }
787
+ }
788
+ const serializedConfig = process.env[`${prefix}CONFIG`];
789
+ if (serializedConfig) {
790
+ const parsed = JSON.parse(serializedConfig);
791
+ config = {
792
+ ...config,
793
+ ...parsed,
794
+ colors: {
795
+ ...config.colors,
796
+ ...parsed.colors
797
+ },
798
+ extensions: {
799
+ ...config.extensions,
800
+ ...parsed.extensions
801
+ }
802
+ };
803
+ }
804
+ return config;
805
+ }, "getConfigEnv");
806
+ var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
807
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
808
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
809
+ }, "getThemeColorConfigEnv");
810
+ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
811
+ return {
812
+ dark: process.env[`${prefix}DARK`],
813
+ light: process.env[`${prefix}LIGHT`],
814
+ brand: process.env[`${prefix}BRAND`],
815
+ alternate: process.env[`${prefix}ALTERNATE`],
816
+ accent: process.env[`${prefix}ACCENT`],
817
+ link: process.env[`${prefix}LINK`],
818
+ help: process.env[`${prefix}HELP`],
819
+ success: process.env[`${prefix}SUCCESS`],
820
+ info: process.env[`${prefix}INFO`],
821
+ warning: process.env[`${prefix}WARNING`],
822
+ danger: process.env[`${prefix}DANGER`],
823
+ fatal: process.env[`${prefix}FATAL`],
824
+ positive: process.env[`${prefix}POSITIVE`],
825
+ negative: process.env[`${prefix}NEGATIVE`]
826
+ };
827
+ }, "getSingleThemeColorConfigEnv");
828
+ var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
829
+ return {
830
+ light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
831
+ dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
832
+ };
833
+ }, "getMultiThemeColorConfigEnv");
834
+ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
835
+ return {
836
+ foreground: process.env[`${prefix}FOREGROUND`],
837
+ background: process.env[`${prefix}BACKGROUND`],
838
+ brand: process.env[`${prefix}BRAND`],
839
+ alternate: process.env[`${prefix}ALTERNATE`],
840
+ accent: process.env[`${prefix}ACCENT`],
841
+ link: process.env[`${prefix}LINK`],
842
+ help: process.env[`${prefix}HELP`],
843
+ success: process.env[`${prefix}SUCCESS`],
844
+ info: process.env[`${prefix}INFO`],
845
+ warning: process.env[`${prefix}WARNING`],
846
+ danger: process.env[`${prefix}DANGER`],
847
+ fatal: process.env[`${prefix}FATAL`],
848
+ positive: process.env[`${prefix}POSITIVE`],
849
+ negative: process.env[`${prefix}NEGATIVE`]
850
+ };
851
+ }, "getBaseThemeColorConfigEnv");
852
+
853
+ // ../config-tools/src/env/set-env.ts
854
+ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
855
+ for (const key of Object.keys(extension ?? {})) {
856
+ if (extension[key]) {
857
+ const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
858
+ let extensionKey;
859
+ if (result.length === 0) {
860
+ return;
861
+ }
862
+ if (result.length === 1) {
863
+ extensionKey = result[0]?.toUpperCase() ?? "";
864
+ } else {
865
+ extensionKey = result.reduce((ret, part) => {
866
+ return `${ret}_${part.toLowerCase()}`;
867
+ });
868
+ }
869
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
870
+ }
871
+ }
872
+ }, "setExtensionEnv");
873
+ var setConfigEnv = /* @__PURE__ */ __name((config) => {
874
+ const prefix = "STORM_";
875
+ if (config.extends) {
876
+ process.env[`${prefix}EXTENDS`] = config.extends;
877
+ }
878
+ if (config.name) {
879
+ process.env[`${prefix}NAME`] = config.name;
880
+ }
881
+ if (config.namespace) {
882
+ process.env[`${prefix}NAMESPACE`] = config.namespace;
883
+ }
884
+ if (config.owner) {
885
+ process.env[`${prefix}OWNER`] = config.owner;
886
+ }
887
+ if (config.bot) {
888
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
889
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
890
+ }
891
+ if (config.organization) {
892
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
893
+ }
894
+ if (config.packageManager) {
895
+ process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
896
+ }
897
+ if (config.license) {
898
+ process.env[`${prefix}LICENSE`] = config.license;
899
+ }
900
+ if (config.homepage) {
901
+ process.env[`${prefix}HOMEPAGE`] = config.homepage;
902
+ }
903
+ if (config.docs) {
904
+ process.env[`${prefix}DOCS`] = config.docs;
905
+ }
906
+ if (config.licensing) {
907
+ process.env[`${prefix}LICENSING`] = config.licensing;
908
+ }
909
+ if (config.timezone) {
910
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
911
+ process.env.TZ = config.timezone;
912
+ process.env.DEFAULT_TIMEZONE = config.timezone;
913
+ }
914
+ if (config.locale) {
915
+ process.env[`${prefix}LOCALE`] = config.locale;
916
+ process.env.LOCALE = config.locale;
917
+ process.env.DEFAULT_LOCALE = config.locale;
918
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
919
+ }
920
+ if (config.configFile) {
921
+ process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
922
+ }
923
+ if (config.workspaceRoot) {
924
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
925
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
926
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
927
+ }
928
+ if (config.directories) {
929
+ if (!config.skipCache && config.directories.cache) {
930
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
931
+ }
932
+ if (config.directories.data) {
933
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
934
+ }
935
+ if (config.directories.config) {
936
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
937
+ }
938
+ if (config.directories.temp) {
939
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
940
+ }
941
+ if (config.directories.log) {
942
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
943
+ }
944
+ if (config.directories.build) {
945
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
946
+ }
947
+ }
948
+ if (config.skipCache !== void 0) {
949
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
950
+ if (config.skipCache) {
951
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
952
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
953
+ }
954
+ }
955
+ if (config.env) {
956
+ process.env[`${prefix}ENV`] = config.env;
957
+ process.env.NODE_ENV = config.env;
958
+ process.env.ENVIRONMENT = config.env;
959
+ }
960
+ if (config.colors?.base?.light || config.colors?.base?.dark) {
961
+ for (const key of Object.keys(config.colors)) {
962
+ setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
963
+ }
964
+ } else {
965
+ setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
966
+ }
967
+ if (config.repository) {
968
+ process.env[`${prefix}REPOSITORY`] = config.repository;
969
+ }
970
+ if (config.branch) {
971
+ process.env[`${prefix}BRANCH`] = config.branch;
972
+ }
973
+ if (config.preid) {
974
+ process.env[`${prefix}PRE_ID`] = String(config.preid);
975
+ }
976
+ if (config.externalPackagePatterns) {
977
+ process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
978
+ }
979
+ if (config.registry) {
980
+ if (config.registry.github) {
981
+ process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
982
+ }
983
+ if (config.registry.npm) {
984
+ process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
985
+ }
986
+ if (config.registry.cargo) {
987
+ process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
988
+ }
989
+ if (config.registry.cyclone) {
990
+ process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
991
+ }
992
+ if (config.registry.container) {
993
+ process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
994
+ }
995
+ }
996
+ if (config.logLevel) {
997
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
998
+ process.env.LOG_LEVEL = String(config.logLevel);
999
+ process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
1000
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
1001
+ }
1002
+ process.env[`${prefix}CONFIG`] = JSON.stringify(config);
1003
+ for (const key of Object.keys(config.extensions ?? {})) {
1004
+ config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
1005
+ }
1006
+ }, "setConfigEnv");
1007
+ var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1008
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
1009
+ }, "setThemeColorConfigEnv");
1010
+ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1011
+ if (config.dark) {
1012
+ process.env[`${prefix}DARK`] = config.dark;
1013
+ }
1014
+ if (config.light) {
1015
+ process.env[`${prefix}LIGHT`] = config.light;
1016
+ }
1017
+ if (config.brand) {
1018
+ process.env[`${prefix}BRAND`] = config.brand;
1019
+ }
1020
+ if (config.alternate) {
1021
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
1022
+ }
1023
+ if (config.accent) {
1024
+ process.env[`${prefix}ACCENT`] = config.accent;
1025
+ }
1026
+ if (config.link) {
1027
+ process.env[`${prefix}LINK`] = config.link;
1028
+ }
1029
+ if (config.help) {
1030
+ process.env[`${prefix}HELP`] = config.help;
1031
+ }
1032
+ if (config.success) {
1033
+ process.env[`${prefix}SUCCESS`] = config.success;
1034
+ }
1035
+ if (config.info) {
1036
+ process.env[`${prefix}INFO`] = config.info;
1037
+ }
1038
+ if (config.warning) {
1039
+ process.env[`${prefix}WARNING`] = config.warning;
1040
+ }
1041
+ if (config.danger) {
1042
+ process.env[`${prefix}DANGER`] = config.danger;
1043
+ }
1044
+ if (config.fatal) {
1045
+ process.env[`${prefix}FATAL`] = config.fatal;
1046
+ }
1047
+ if (config.positive) {
1048
+ process.env[`${prefix}POSITIVE`] = config.positive;
1049
+ }
1050
+ if (config.negative) {
1051
+ process.env[`${prefix}NEGATIVE`] = config.negative;
1052
+ }
1053
+ }, "setSingleThemeColorConfigEnv");
1054
+ var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1055
+ return {
1056
+ light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
1057
+ dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
1058
+ };
1059
+ }, "setMultiThemeColorConfigEnv");
1060
+ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
1061
+ if (config.foreground) {
1062
+ process.env[`${prefix}FOREGROUND`] = config.foreground;
1063
+ }
1064
+ if (config.background) {
1065
+ process.env[`${prefix}BACKGROUND`] = config.background;
1066
+ }
1067
+ if (config.brand) {
1068
+ process.env[`${prefix}BRAND`] = config.brand;
1069
+ }
1070
+ if (config.alternate) {
1071
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
1072
+ }
1073
+ if (config.accent) {
1074
+ process.env[`${prefix}ACCENT`] = config.accent;
1075
+ }
1076
+ if (config.link) {
1077
+ process.env[`${prefix}LINK`] = config.link;
1078
+ }
1079
+ if (config.help) {
1080
+ process.env[`${prefix}HELP`] = config.help;
1081
+ }
1082
+ if (config.success) {
1083
+ process.env[`${prefix}SUCCESS`] = config.success;
1084
+ }
1085
+ if (config.info) {
1086
+ process.env[`${prefix}INFO`] = config.info;
1087
+ }
1088
+ if (config.warning) {
1089
+ process.env[`${prefix}WARNING`] = config.warning;
1090
+ }
1091
+ if (config.danger) {
1092
+ process.env[`${prefix}DANGER`] = config.danger;
1093
+ }
1094
+ if (config.fatal) {
1095
+ process.env[`${prefix}FATAL`] = config.fatal;
1096
+ }
1097
+ if (config.positive) {
1098
+ process.env[`${prefix}POSITIVE`] = config.positive;
1099
+ }
1100
+ if (config.negative) {
1101
+ process.env[`${prefix}NEGATIVE`] = config.negative;
1102
+ }
1103
+ }, "setBaseThemeColorConfigEnv");
1104
+
1105
+ // ../config-tools/src/create-storm-config.ts
1106
+ var _static_cache = void 0;
1107
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot3) => {
1108
+ let config = {};
1109
+ if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
1110
+ writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
1111
+ return _static_cache.data;
1112
+ }
1113
+ let _workspaceRoot = workspaceRoot3;
1114
+ if (!_workspaceRoot) {
1115
+ _workspaceRoot = findWorkspaceRoot();
1116
+ }
1117
+ const configFile = await getConfigFile(_workspaceRoot);
1118
+ if (!configFile) {
1119
+ 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", {
1120
+ logLevel: "all"
1121
+ });
1122
+ }
1123
+ config = defu2(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
1124
+ setConfigEnv(config);
1125
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
1126
+ ${formatLogMessage(config)}`, config);
1127
+ return config;
1128
+ }, "loadStormConfig");
1129
+
1130
+ // ../workspace-tools/src/utils/apply-workspace-tokens.ts
1131
+ var applyWorkspaceExecutorTokens = /* @__PURE__ */ __name(async (option, tokenizerOptions) => {
1132
+ let result = option;
1133
+ if (!result) {
1134
+ return result;
1135
+ }
1136
+ let projectName;
1137
+ let projectRoot;
1138
+ let sourceRoot;
1139
+ if (tokenizerOptions?.projectName) {
1140
+ const context2 = tokenizerOptions;
1141
+ projectName = context2.projectName;
1142
+ projectRoot = context2.root;
1143
+ sourceRoot = context2.sourceRoot;
1144
+ } else {
1145
+ const projectConfig = tokenizerOptions;
1146
+ projectRoot = projectConfig.root;
1147
+ if (projectConfig.name) {
1148
+ projectName = projectConfig.name;
1149
+ }
1150
+ if (projectConfig.sourceRoot) {
1151
+ sourceRoot = projectConfig.sourceRoot;
1152
+ }
1153
+ }
1154
+ if (tokenizerOptions.config) {
1155
+ const configKeys = Object.keys(tokenizerOptions.config);
1156
+ if (configKeys.some((configKey) => result.includes(`{${configKey}}`))) {
1157
+ for (const configKey of configKeys) {
1158
+ if (result.includes(`{${configKey}}`)) {
1159
+ result = result.replaceAll(`{${configKey}}`, tokenizerOptions.config[configKey]);
1160
+ }
1161
+ }
1162
+ }
1163
+ }
1164
+ if (result.includes("{projectName}")) {
1165
+ result = result.replaceAll("{projectName}", projectName);
1166
+ }
1167
+ if (result.includes("{projectRoot}")) {
1168
+ result = result.replaceAll("{projectRoot}", projectRoot);
1169
+ }
1170
+ if (result.includes("{sourceRoot}")) {
1171
+ result = result.replaceAll("{sourceRoot}", sourceRoot);
1172
+ }
1173
+ if (result.includes("{workspaceRoot}")) {
1174
+ result = result.replaceAll("{workspaceRoot}", tokenizerOptions.workspaceRoot ?? findWorkspaceRoot());
1175
+ }
1176
+ return result;
1177
+ }, "applyWorkspaceExecutorTokens");
1178
+
1179
+ // ../workspace-tools/src/base/base-executor.ts
1180
+ var withRunExecutor = /* @__PURE__ */ __name((name, executorFn, executorOptions = {}) => async (_options, context2) => {
1181
+ const stopwatch = getStopwatch(name);
1182
+ let options = _options;
1183
+ let config = {};
1184
+ try {
1185
+ writeInfo(`\u26A1 Running the ${name} executor...
1186
+ `, config);
1187
+ if (!context2.projectsConfigurations?.projects || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName]) {
1188
+ throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace.");
1189
+ }
1190
+ const workspaceRoot3 = findWorkspaceRoot();
1191
+ const projectRoot = context2.projectsConfigurations.projects[context2.projectName]?.root ?? workspaceRoot3;
1192
+ const sourceRoot = context2.projectsConfigurations.projects[context2.projectName]?.sourceRoot ?? workspaceRoot3;
1193
+ const projectName = context2.projectsConfigurations.projects[context2.projectName]?.name ?? context2.projectName;
1194
+ config.workspaceRoot = workspaceRoot3;
1195
+ if (!executorOptions.skipReadingConfig) {
1196
+ writeTrace(`Loading the Storm Config from environment variables and storm.config.js file...
1197
+ - workspaceRoot: ${workspaceRoot3}
1198
+ - projectRoot: ${projectRoot}
1199
+ - sourceRoot: ${sourceRoot}
1200
+ - projectName: ${projectName}
1201
+ `, config);
1202
+ config = await loadStormConfig(workspaceRoot3);
1203
+ }
1204
+ if (executorOptions?.hooks?.applyDefaultOptions) {
1205
+ writeDebug("Running the applyDefaultOptions hook...", config);
1206
+ options = await Promise.resolve(executorOptions.hooks.applyDefaultOptions(options, config));
1207
+ writeDebug("Completed the applyDefaultOptions hook", config);
1208
+ }
1209
+ writeTrace(`Executor schema options \u2699\uFE0F
1210
+ ${Object.keys(options).map((key) => ` - ${key}=${_isFunction2(options[key]) ? "<function>" : JSON.stringify(options[key])}`).join("\n")}`, config);
1211
+ const tokenized = await applyWorkspaceTokens(options, {
1212
+ config,
1213
+ workspaceRoot: workspaceRoot3,
1214
+ projectRoot,
1215
+ sourceRoot,
1216
+ projectName,
1217
+ ...context2.projectsConfigurations.projects[context2.projectName],
1218
+ ...executorOptions
1219
+ }, applyWorkspaceExecutorTokens);
1220
+ if (executorOptions?.hooks?.preProcess) {
1221
+ writeDebug("Running the preProcess hook...", config);
1222
+ await Promise.resolve(executorOptions.hooks.preProcess(tokenized, config));
1223
+ writeDebug("Completed the preProcess hook", config);
1224
+ }
1225
+ const ret = executorFn(tokenized, context2, config);
1226
+ if (_isFunction2(ret?.next)) {
1227
+ const asyncGen = ret;
1228
+ for await (const iter of asyncGen) {
1229
+ }
1230
+ }
1231
+ const result = await Promise.resolve(ret);
1232
+ if (result && (!result.success || result.error && result?.error?.message && typeof result?.error?.message === "string" && result?.error?.name && typeof result?.error?.name === "string")) {
1233
+ writeTrace(`Failure determined by the ${name} executor
1234
+ ${formatLogMessage(result)}`, config);
1235
+ console.error(result);
1236
+ throw new Error(`The ${name} executor failed to run`, {
1237
+ cause: result?.error
1238
+ });
1239
+ }
1240
+ if (executorOptions?.hooks?.postProcess) {
1241
+ writeDebug("Running the postProcess hook...", config);
1242
+ await Promise.resolve(executorOptions.hooks.postProcess(config));
1243
+ writeDebug("Completed the postProcess hook", config);
1244
+ }
1245
+ writeSuccess(`Completed running the ${name} task executor!
1246
+ `, config);
1247
+ return {
1248
+ success: true
1249
+ };
1250
+ } catch (error) {
1251
+ writeFatal("A fatal error occurred while running the executor - the process was forced to terminate", config);
1252
+ writeError(`An exception was thrown in the executor's process
1253
+ - Details: ${error.message}
1254
+ - Stacktrace: ${error.stack}`, config);
1255
+ return {
1256
+ success: false
1257
+ };
1258
+ } finally {
1259
+ stopwatch();
1260
+ }
1261
+ }, "withRunExecutor");
1262
+ var _isFunction2 = /* @__PURE__ */ __name((value) => {
1263
+ try {
1264
+ return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
1265
+ } catch (e) {
1266
+ return false;
1267
+ }
1268
+ }, "_isFunction");
1269
+
1270
+ // ../workspace-tools/src/base/base-generator.ts
1271
+ var withRunGenerator = /* @__PURE__ */ __name((name, generatorFn, generatorOptions = {
1272
+ skipReadingConfig: false
1273
+ }) => async (tree, _options) => {
1274
+ const stopwatch = getStopwatch(name);
1275
+ let options = _options;
1276
+ let config;
1277
+ try {
1278
+ writeInfo(`\u26A1 Running the ${name} generator...
1279
+
1280
+ `, config);
1281
+ const workspaceRoot3 = findWorkspaceRoot();
1282
+ if (!generatorOptions.skipReadingConfig) {
1283
+ writeDebug(`Loading the Storm Config from environment variables and storm.config.js file...
1284
+ - workspaceRoot: ${workspaceRoot3}`, config);
1285
+ config = await loadStormConfig(workspaceRoot3);
1286
+ }
1287
+ if (generatorOptions?.hooks?.applyDefaultOptions) {
1288
+ writeDebug("Running the applyDefaultOptions hook...", config);
1289
+ options = await Promise.resolve(generatorOptions.hooks.applyDefaultOptions(options, config));
1290
+ writeDebug("Completed the applyDefaultOptions hook", config);
1291
+ }
1292
+ writeTrace(`Generator schema options \u2699\uFE0F
1293
+ ${Object.keys(options ?? {}).map((key) => ` - ${key}=${JSON.stringify(options[key])}`).join("\n")}`, config);
1294
+ const tokenized = await applyWorkspaceTokens(options, {
1295
+ workspaceRoot: tree.root,
1296
+ config
1297
+ }, applyWorkspaceBaseTokens);
1298
+ if (generatorOptions?.hooks?.preProcess) {
1299
+ writeDebug("Running the preProcess hook...", config);
1300
+ await Promise.resolve(generatorOptions.hooks.preProcess(tokenized, config));
1301
+ writeDebug("Completed the preProcess hook", config);
1302
+ }
1303
+ const result = await Promise.resolve(generatorFn(tree, tokenized, config));
1304
+ if (result) {
1305
+ if (result.success === false || result.error && result?.error?.message && typeof result?.error?.message === "string" && result?.error?.name && typeof result?.error?.name === "string") {
1306
+ throw new Error(`The ${name} generator failed to run`, {
1307
+ cause: result?.error
1308
+ });
1309
+ } else if (result.success && result.data) {
1310
+ return result;
1311
+ }
1312
+ }
1313
+ if (generatorOptions?.hooks?.postProcess) {
1314
+ writeDebug("Running the postProcess hook...", config);
1315
+ await Promise.resolve(generatorOptions.hooks.postProcess(config));
1316
+ writeDebug("Completed the postProcess hook", config);
1317
+ }
1318
+ return () => {
1319
+ writeSuccess(`Completed running the ${name} generator!
1320
+ `, config);
1321
+ };
1322
+ } catch (error) {
1323
+ return () => {
1324
+ writeFatal("A fatal error occurred while running the generator - the process was forced to terminate", config);
1325
+ writeError(`An exception was thrown in the generator's process
1326
+ - Details: ${error.message}
1327
+ - Stacktrace: ${error.stack}`, config);
1328
+ };
1329
+ } finally {
1330
+ stopwatch();
1331
+ }
1332
+ }, "withRunGenerator");
1333
+
1334
+ // ../workspace-tools/src/generators/init/init.ts
1335
+ import { addDependenciesToPackageJson, formatFiles } from "@nx/devkit";
1336
+ async function initGenerator(tree, schema) {
1337
+ const task = addDependenciesToPackageJson(tree, {
1338
+ nx: "^19.6.2",
1339
+ "@nx/workspace": "^19.6.2",
1340
+ "@nx/js": "^19.6.2",
1341
+ "@storm-software/eslint": "latest",
1342
+ "@storm-software/prettier": "latest",
1343
+ "@storm-software/config-tools": "latest",
1344
+ "@storm-software/testing-tools": "latest",
1345
+ "@storm-software/git-tools": "latest",
1346
+ "@storm-software/linting-tools": "latest"
1347
+ }, {});
1348
+ if (!schema.skipFormat) {
1349
+ await formatFiles(tree);
1350
+ }
1351
+ return task;
1352
+ }
1353
+ __name(initGenerator, "initGenerator");
1354
+
1355
+ // ../workspace-tools/src/utils/cargo.ts
1356
+ import { joinPathFragments as joinPathFragments2, workspaceRoot } from "@nx/devkit";
1357
+ import { execSync as execSync2, spawn } from "node:child_process";
1358
+ import { relative } from "node:path";
1359
+ var INVALID_CARGO_ARGS = [
1360
+ "allFeatures",
1361
+ "allTargets",
1362
+ "main",
1363
+ "outputPath",
1364
+ "package",
1365
+ "tsConfig"
1366
+ ];
1367
+ var buildCargoCommand = /* @__PURE__ */ __name((baseCommand, options, context2) => {
1368
+ const args = [];
1369
+ if (options.toolchain && options.toolchain !== "stable") {
1370
+ args.push(`+${options.toolchain}`);
1371
+ }
1372
+ args.push(baseCommand);
1373
+ for (const [key, value] of Object.entries(options)) {
1374
+ if (key === "toolchain" || key === "release" || INVALID_CARGO_ARGS.includes(key)) {
1375
+ continue;
1376
+ }
1377
+ if (typeof value === "boolean") {
1378
+ if (value) {
1379
+ args.push(`--${key}`);
1380
+ }
1381
+ } else if (Array.isArray(value)) {
1382
+ for (const item of value) {
1383
+ args.push(`--${key}`, item);
1384
+ }
1385
+ } else {
1386
+ args.push(`--${key}`, String(value));
1387
+ }
1388
+ }
1389
+ if (context2.projectName) {
1390
+ args.push("-p", context2.projectName);
1391
+ }
1392
+ if (options.allFeatures && !args.includes("--all-features")) {
1393
+ args.push("--all-features");
1394
+ }
1395
+ if (options.allTargets && !args.includes("--all-targets")) {
1396
+ args.push("--all-targets");
1397
+ }
1398
+ if (options.release && !args.includes("--profile")) {
1399
+ args.push("--release");
1400
+ }
1401
+ if (options.outputPath && !args.includes("--target-dir")) {
1402
+ args.push("--target-dir", options.outputPath);
1403
+ }
1404
+ return args;
1405
+ }, "buildCargoCommand");
1406
+ async function cargoCommand(...args) {
1407
+ console.log(`> cargo ${args.join(" ")}`);
1408
+ args.push("--color", "always");
1409
+ return await Promise.resolve(runProcess("cargo", ...args));
1410
+ }
1411
+ __name(cargoCommand, "cargoCommand");
1412
+ function cargoCommandSync(args = "", options) {
1413
+ const normalizedOptions = {
1414
+ stdio: options?.stdio ?? "inherit",
1415
+ env: {
1416
+ ...process.env,
1417
+ ...options?.env
1418
+ }
1419
+ };
1420
+ try {
1421
+ return {
1422
+ output: execSync2(`cargo ${args}`, {
1423
+ encoding: "utf8",
1424
+ windowsHide: true,
1425
+ stdio: normalizedOptions.stdio,
1426
+ env: normalizedOptions.env,
1427
+ maxBuffer: 1024 * 1024 * 10
1428
+ }),
1429
+ success: true
1430
+ };
1431
+ } catch (e) {
1432
+ return {
1433
+ output: e,
1434
+ success: false
1435
+ };
1436
+ }
1437
+ }
1438
+ __name(cargoCommandSync, "cargoCommandSync");
1439
+ function cargoMetadata() {
1440
+ const output3 = cargoCommandSync("metadata --format-version=1", {
1441
+ stdio: "pipe"
1442
+ });
1443
+ if (!output3.success) {
1444
+ console.error("Failed to get cargo metadata");
1445
+ return null;
1446
+ }
1447
+ return JSON.parse(output3.output);
1448
+ }
1449
+ __name(cargoMetadata, "cargoMetadata");
1450
+ function runProcess(processCmd, ...args) {
1451
+ const metadata = cargoMetadata();
1452
+ const targetDir = metadata?.target_directory ?? joinPathFragments2(workspaceRoot, "dist", "cargo");
1453
+ return new Promise((resolve) => {
1454
+ if (process.env.VERCEL) {
1455
+ return resolve({
1456
+ success: true
1457
+ });
1458
+ }
1459
+ execSync2(`${processCmd} ${args.join(" ")}`, {
1460
+ cwd: process.cwd(),
1461
+ env: {
1462
+ ...process.env,
1463
+ RUSTC_WRAPPER: "",
1464
+ CARGO_TARGET_DIR: targetDir,
1465
+ CARGO_BUILD_TARGET_DIR: targetDir
1466
+ },
1467
+ windowsHide: true,
1468
+ stdio: [
1469
+ "inherit",
1470
+ "inherit",
1471
+ "inherit"
1472
+ ]
1473
+ });
1474
+ resolve({
1475
+ success: true
1476
+ });
1477
+ });
1478
+ }
1479
+ __name(runProcess, "runProcess");
1480
+
1481
+ // ../workspace-tools/src/executors/cargo-build/executor.ts
1482
+ async function cargoBuildExecutor(options, context2) {
1483
+ const command = buildCargoCommand("build", options, context2);
1484
+ return await cargoCommand(...command);
1485
+ }
1486
+ __name(cargoBuildExecutor, "cargoBuildExecutor");
1487
+ var executor_default = withRunExecutor("Cargo Build", cargoBuildExecutor, {
1488
+ skipReadingConfig: false,
1489
+ hooks: {
1490
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
1491
+ options.outputPath ??= "dist/target/{projectRoot}";
1492
+ options.toolchain ??= "stable";
1493
+ return options;
1494
+ }, "applyDefaultOptions")
1495
+ }
1496
+ });
1497
+
1498
+ // ../workspace-tools/src/executors/cargo-check/executor.ts
1499
+ async function cargoCheckExecutor(options, context2) {
1500
+ const command = buildCargoCommand("check", options, context2);
1501
+ return await cargoCommand(...command);
1502
+ }
1503
+ __name(cargoCheckExecutor, "cargoCheckExecutor");
1504
+ var executor_default2 = withRunExecutor("Cargo Check", cargoCheckExecutor, {
1505
+ skipReadingConfig: false,
1506
+ hooks: {
1507
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
1508
+ options.toolchain ??= "stable";
1509
+ return options;
1510
+ }, "applyDefaultOptions")
1511
+ }
1512
+ });
1513
+
1514
+ // ../workspace-tools/src/executors/cargo-clippy/executor.ts
1515
+ async function cargoClippyExecutor(options, context2) {
1516
+ const command = buildCargoCommand("clippy", options, context2);
1517
+ return await cargoCommand(...command);
1518
+ }
1519
+ __name(cargoClippyExecutor, "cargoClippyExecutor");
1520
+ var executor_default3 = withRunExecutor("Cargo Clippy", cargoClippyExecutor, {
1521
+ skipReadingConfig: false,
1522
+ hooks: {
1523
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
1524
+ options.toolchain ??= "stable";
1525
+ options.fix ??= false;
1526
+ return options;
1527
+ }, "applyDefaultOptions")
1528
+ }
1529
+ });
1530
+
1531
+ // ../workspace-tools/src/executors/cargo-doc/executor.ts
1532
+ import deepClone from "deep-clone";
1533
+ async function cargoDocExecutor(options, context2) {
1534
+ const opts = deepClone(options);
1535
+ opts["no-deps"] = opts.noDeps;
1536
+ delete opts.noDeps;
1537
+ const command = buildCargoCommand("doc", options, context2);
1538
+ return await cargoCommand(...command);
1539
+ }
1540
+ __name(cargoDocExecutor, "cargoDocExecutor");
1541
+ var executor_default4 = withRunExecutor("Cargo Doc", cargoDocExecutor, {
1542
+ skipReadingConfig: false,
1543
+ hooks: {
1544
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
1545
+ options.outputPath ??= "dist/docs/{projectRoot}";
1546
+ options.toolchain ??= "stable";
1547
+ options.release ??= options.profile ? false : true;
1548
+ options.allFeatures ??= true;
1549
+ options.lib ??= true;
1550
+ options.bins ??= true;
1551
+ options.examples ??= true;
1552
+ options.noDeps ??= false;
1553
+ return options;
1554
+ }, "applyDefaultOptions")
1555
+ }
1556
+ });
1557
+
1558
+ // ../workspace-tools/src/executors/cargo-format/executor.ts
1559
+ async function cargoFormatExecutor(options, context2) {
1560
+ const command = buildCargoCommand("fmt", options, context2);
1561
+ return await cargoCommand(...command);
1562
+ }
1563
+ __name(cargoFormatExecutor, "cargoFormatExecutor");
1564
+ var executor_default5 = withRunExecutor("Cargo Format", cargoFormatExecutor, {
1565
+ skipReadingConfig: false,
1566
+ hooks: {
1567
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
1568
+ options.outputPath ??= "dist/target/{projectRoot}";
1569
+ options.toolchain ??= "stable";
1570
+ return options;
1571
+ }, "applyDefaultOptions")
1572
+ }
1573
+ });
1574
+
1575
+ // ../workspace-tools/src/executors/cargo-publish/executor.ts
1576
+ import { joinPathFragments as joinPathFragments3 } from "@nx/devkit";
1577
+ import { execSync as execSync3 } from "node:child_process";
1578
+ import { readFileSync as readFileSync2 } from "node:fs";
1579
+ import https from "node:https";
1580
+
1581
+ // ../workspace-tools/src/utils/toml.ts
1582
+ import TOML from "@ltd/j-toml";
1583
+ import { logger } from "@nx/devkit";
1584
+
1585
+ // ../workspace-tools/src/executors/cargo-publish/executor.ts
1586
+ var LARGE_BUFFER2 = 1024 * 1e6;
1587
+
1588
+ // ../esbuild/src/build.ts
1589
+ import { hfs as hfs6 } from "@humanfs/node";
1590
+ import { createProjectGraphAsync as createProjectGraphAsync3, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph3, writeJsonFile } from "@nx/devkit";
1591
+
1592
+ // ../build-tools/src/config.ts
1593
+ var DEFAULT_COMPILED_BANNER = `
1594
+ /**
1595
+ * \u26A1 Built by Storm Software
1596
+ */
1597
+
1598
+ `;
1599
+ var DEFAULT_ENVIRONMENT = "production";
1600
+ var DEFAULT_TARGET = "esnext";
1601
+ var DEFAULT_ORGANIZATION = "storm-software";
1602
+
1603
+ // ../build-tools/src/plugins/swc.ts
1604
+ import { transform } from "@swc/core";
1605
+
1606
+ // ../build-tools/src/plugins/ts-resolve.ts
1607
+ import fs from "node:fs";
1608
+ import { builtinModules } from "node:module";
1609
+ import path from "node:path";
1610
+ import _resolve from "resolve";
1611
+
1612
+ // ../build-tools/src/plugins/type-definitions.ts
1613
+ import { stripIndents } from "@nx/devkit";
1614
+ import { relative as relative2 } from "path";
1615
+
1616
+ // ../build-tools/src/utilities/copy-assets.ts
1617
+ import { hfs as hfs2 } from "@humanfs/node";
1618
+ import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
1619
+ import { copyAssets as copyAssetsBase } from "@nx/js";
1620
+ import { glob } from "glob";
1621
+
1622
+ // ../build-tools/src/utilities/read-nx-config.ts
1623
+ import { hfs } from "@humanfs/node";
1624
+ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot3) => {
1625
+ let rootDir = workspaceRoot3;
1626
+ if (!rootDir) {
1627
+ const config = await loadStormConfig();
1628
+ rootDir = config.workspaceRoot;
1629
+ }
1630
+ const nxJsonPath = joinPaths(rootDir, "nx.json");
1631
+ if (!await hfs.isFile(nxJsonPath)) {
1632
+ throw new Error("Cannot find project.json configuration");
1633
+ }
1634
+ return hfs.json(nxJsonPath);
1635
+ }, "readNxConfig");
1636
+
1637
+ // ../build-tools/src/utilities/copy-assets.ts
1638
+ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson4 = true, includeSrc = false, banner, footer) => {
1639
+ const pendingAssets = Array.from(assets ?? []);
1640
+ if (!pendingAssets?.some((asset) => asset?.glob === "*.md")) {
1641
+ pendingAssets.push({
1642
+ input: projectRoot,
1643
+ glob: "*.md",
1644
+ output: "/"
1645
+ });
1646
+ }
1647
+ if (generatePackageJson4 === false) {
1648
+ pendingAssets.push({
1649
+ input: sourceRoot,
1650
+ glob: "package.json",
1651
+ output: "."
1652
+ });
1653
+ }
1654
+ if (!pendingAssets?.some((asset) => asset?.glob === "LICENSE")) {
1655
+ pendingAssets.push({
1656
+ input: "",
1657
+ glob: "LICENSE",
1658
+ output: "."
1659
+ });
1660
+ }
1661
+ if (includeSrc === true) {
1662
+ pendingAssets.push({
1663
+ input: sourceRoot,
1664
+ glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
1665
+ output: "src/"
1666
+ });
1667
+ }
1668
+ const nxJson = readNxConfig(config.workspaceRoot);
1669
+ const projectGraph = await createProjectGraphAsync({
1670
+ exitOnError: true
1671
+ });
1672
+ const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
1673
+ if (!projectsConfigurations?.projects?.[projectName]) {
1674
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
1675
+ }
1676
+ const buildTarget = projectsConfigurations.projects[projectName]?.targets?.build;
1677
+ if (!buildTarget) {
1678
+ throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
1679
+ }
1680
+ const result = await copyAssetsBase({
1681
+ assets,
1682
+ watch: false,
1683
+ outputPath
1684
+ }, {
1685
+ root: config.workspaceRoot,
1686
+ targetName: "build",
1687
+ target: buildTarget,
1688
+ projectName,
1689
+ projectGraph,
1690
+ projectsConfigurations,
1691
+ nxJsonConfiguration: nxJson,
1692
+ cwd: config.workspaceRoot,
1693
+ isVerbose: isVerbose(config.logLevel)
1694
+ });
1695
+ if (!result.success) {
1696
+ throw new Error("The Build process failed trying to copy assets");
1697
+ }
1698
+ if (includeSrc === true) {
1699
+ writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
1700
+ const files = await glob([
1701
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
1702
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
1703
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
1704
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
1705
+ ]);
1706
+ await Promise.allSettled(files.map(async (file) => hfs2.write(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
1707
+
1708
+ ${await hfs2.text(file)}
1709
+
1710
+ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
1711
+ }
1712
+ }, "copyAssets");
1713
+
1714
+ // ../build-tools/src/utilities/generate-package-json.ts
1715
+ import { hfs as hfs3 } from "@humanfs/node";
1716
+ import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
1717
+ import { Glob } from "glob";
1718
+ import { createProjectGraphAsync as createProjectGraphAsync2, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2 } from "nx/src/project-graph/project-graph";
1719
+ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot3, projectRoot, projectName, packageJson) => {
1720
+ const projectGraph = await createProjectGraphAsync2({
1721
+ exitOnError: true
1722
+ });
1723
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
1724
+ if (!projectConfigurations?.projects?.[projectName]) {
1725
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
1726
+ }
1727
+ const projectJsonPath = joinPaths(workspaceRoot3, projectRoot, "project.json");
1728
+ if (!await hfs3.isFile(projectJsonPath)) {
1729
+ throw new Error("Cannot find project.json configuration");
1730
+ }
1731
+ if (!projectConfigurations?.projects?.[projectName]) {
1732
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
1733
+ }
1734
+ const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot3, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
1735
+ const localPackages = [];
1736
+ for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot3)) {
1737
+ const projectNode = project.node;
1738
+ if (projectNode.data.root) {
1739
+ const projectPackageJsonPath = joinPaths(workspaceRoot3, projectNode.data.root, "package.json");
1740
+ if (await hfs3.isFile(projectPackageJsonPath)) {
1741
+ const projectPackageJson = await hfs3.json(projectPackageJsonPath);
1742
+ if (projectPackageJson.private !== false) {
1743
+ localPackages.push(projectPackageJson);
1744
+ }
1745
+ }
1746
+ }
1747
+ }
1748
+ if (localPackages.length > 0) {
1749
+ writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
1750
+ packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
1751
+ if (!ret[localPackage.name]) {
1752
+ ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
1753
+ }
1754
+ return ret;
1755
+ }, packageJson.peerDependencies ?? {});
1756
+ packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
1757
+ if (!ret[localPackage.name]) {
1758
+ ret[localPackage.name] = {
1759
+ optional: false
1760
+ };
1761
+ }
1762
+ return ret;
1763
+ }, packageJson.peerDependenciesMeta ?? {});
1764
+ packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
1765
+ if (!ret[localPackage.name]) {
1766
+ ret[localPackage.name] = localPackage.version || "0.0.1";
1767
+ }
1768
+ return ret;
1769
+ }, packageJson.peerDependencies ?? {});
1770
+ } else {
1771
+ writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
1772
+ }
1773
+ return packageJson;
1774
+ }, "addPackageDependencies");
1775
+ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
1776
+ const workspaceRoot3 = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
1777
+ const workspacePackageJson = await hfs3.json(joinPaths(workspaceRoot3, "package.json"));
1778
+ packageJson.type ??= "module";
1779
+ packageJson.sideEffects ??= false;
1780
+ if (includeSrc === true) {
1781
+ let distSrc = sourceRoot.replace(projectRoot, "");
1782
+ if (distSrc.startsWith("/")) {
1783
+ distSrc = distSrc.substring(1);
1784
+ }
1785
+ packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
1786
+ }
1787
+ packageJson.files ??= [
1788
+ "dist/**/*"
1789
+ ];
1790
+ if (includeSrc === true && !packageJson.files.includes("src")) {
1791
+ packageJson.files.push("src/**/*");
1792
+ }
1793
+ packageJson.publishConfig ??= {
1794
+ access: "public"
1795
+ };
1796
+ packageJson.description ??= workspacePackageJson.description;
1797
+ packageJson.homepage ??= workspacePackageJson.homepage;
1798
+ packageJson.bugs ??= workspacePackageJson.bugs;
1799
+ packageJson.license ??= workspacePackageJson.license;
1800
+ packageJson.keywords ??= workspacePackageJson.keywords;
1801
+ packageJson.funding ??= workspacePackageJson.funding;
1802
+ packageJson.author ??= workspacePackageJson.author;
1803
+ packageJson.maintainers ??= workspacePackageJson.maintainers;
1804
+ if (!packageJson.maintainers && packageJson.author) {
1805
+ packageJson.maintainers = [
1806
+ packageJson.author
1807
+ ];
1808
+ }
1809
+ packageJson.contributors ??= workspacePackageJson.contributors;
1810
+ if (!packageJson.contributors && packageJson.author) {
1811
+ packageJson.contributors = [
1812
+ packageJson.author
1813
+ ];
1814
+ }
1815
+ packageJson.repository ??= workspacePackageJson.repository;
1816
+ packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
1817
+ return packageJson;
1818
+ }, "addWorkspacePackageJsonFields");
1819
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
1820
+ let entry = file.replaceAll("\\", "/");
1821
+ if (sourceRoot) {
1822
+ entry = entry.replace(sourceRoot, "");
1823
+ }
1824
+ return {
1825
+ "import": {
1826
+ "types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
1827
+ "default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
1828
+ },
1829
+ "require": {
1830
+ "types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
1831
+ "default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
1832
+ },
1833
+ "default": {
1834
+ "types": `./dist/${entry}.d.ts`,
1835
+ "default": `./dist/${entry}.js`
1836
+ }
1837
+ };
1838
+ }, "addPackageJsonExport");
1839
+ var addPackageJsonExports = /* @__PURE__ */ __name(async (sourceRoot, packageJson) => {
1840
+ packageJson.exports ??= {};
1841
+ const files = await new Glob("**/*.{ts,tsx}", {
1842
+ absolute: false,
1843
+ cwd: sourceRoot,
1844
+ root: sourceRoot
1845
+ }).walk();
1846
+ files.forEach((file) => {
1847
+ addPackageJsonExport(file, packageJson.type, sourceRoot);
1848
+ const split = file.split(".");
1849
+ split.pop();
1850
+ const entry = split.join(".").replaceAll("\\", "/");
1851
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
1852
+ });
1853
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
1854
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
1855
+ packageJson.types = "./dist/index.d.ts";
1856
+ packageJson.exports ??= {};
1857
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
1858
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
1859
+ ret[key.replace("/index", "")] = packageJson.exports[key];
1860
+ }
1861
+ return ret;
1862
+ }, packageJson.exports);
1863
+ packageJson.exports["./package.json"] ??= "./package.json";
1864
+ packageJson.exports["."] = packageJson.exports["."] ?? addPackageJsonExport("index", packageJson.type, sourceRoot);
1865
+ return packageJson;
1866
+ }, "addPackageJsonExports");
1867
+
1868
+ // ../build-tools/src/utilities/get-entry-points.ts
1869
+ import { glob as glob2 } from "glob";
1870
+ var getEntryPoints = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, entry, emitOnAll = false) => {
1871
+ const workspaceRoot3 = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
1872
+ const entryPoints = [];
1873
+ if (entry) {
1874
+ if (Array.isArray(entry)) {
1875
+ entryPoints.push(...entry);
1876
+ } else if (typeof entry === "string") {
1877
+ entryPoints.push(entry);
1878
+ } else {
1879
+ entryPoints.push(...Object.values(entry));
1880
+ }
1881
+ }
1882
+ if (emitOnAll) {
1883
+ entryPoints.push(joinPaths(workspaceRoot3, sourceRoot || projectRoot, "**/*.{ts,tsx}"));
1884
+ }
1885
+ const results = [];
1886
+ for (const entryPoint in entryPoints) {
1887
+ if (entryPoint.includes("*")) {
1888
+ const files = await glob2(entryPoint, {
1889
+ withFileTypes: true
1890
+ });
1891
+ results.push(...files.reduce((ret, filePath) => {
1892
+ const result = correctPaths(joinPaths(filePath.path, filePath.name).replaceAll(correctPaths(workspaceRoot3), "").replaceAll(correctPaths(projectRoot), ""));
1893
+ if (result) {
1894
+ writeDebug(`Trying to add entry point ${result} at "${joinPaths(filePath.path, filePath.name)}"`, config);
1895
+ if (!results.includes(result)) {
1896
+ results.push(result);
1897
+ }
1898
+ }
1899
+ return ret;
1900
+ }, []));
1901
+ } else {
1902
+ results.push(entryPoint);
1903
+ }
1904
+ }
1905
+ return results;
1906
+ }, "getEntryPoints");
1907
+
1908
+ // ../build-tools/src/utilities/get-env.ts
1909
+ var getEnv = /* @__PURE__ */ __name((builder, options) => {
1910
+ return {
1911
+ STORM_BUILD: builder,
1912
+ STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
1913
+ STORM_NAME: options.name,
1914
+ STORM_ENV: options.envName || DEFAULT_ENVIRONMENT,
1915
+ STORM_PLATFORM: options.platform,
1916
+ STORM_FORMAT: JSON.stringify(options.format),
1917
+ STORM_TARGET: JSON.stringify(options.target),
1918
+ ...options.env
1919
+ };
1920
+ }, "getEnv");
1921
+
1922
+ // ../build-tools/src/utilities/get-out-extension.ts
1923
+ function getOutExtension(format, pkgType) {
1924
+ let jsExtension = ".js";
1925
+ let dtsExtension = ".d.ts";
1926
+ if (pkgType === "module" && format === "cjs") {
1927
+ jsExtension = ".cjs";
1928
+ dtsExtension = ".d.cts";
1929
+ }
1930
+ if (pkgType !== "module" && format === "esm") {
1931
+ jsExtension = ".mjs";
1932
+ dtsExtension = ".d.mts";
1933
+ }
1934
+ if (format === "iife") {
1935
+ jsExtension = ".global.js";
1936
+ }
1937
+ return {
1938
+ js: jsExtension,
1939
+ dts: dtsExtension
1940
+ };
1941
+ }
1942
+ __name(getOutExtension, "getOutExtension");
1943
+
1944
+ // ../build-tools/src/utilities/task-graph.ts
1945
+ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
1946
+
1947
+ // ../esbuild/src/build.ts
1948
+ import { watch as createWatcher } from "chokidar";
1949
+ import defu3 from "defu";
1950
+ import { debounce, flatten } from "es-toolkit";
1951
+ import { map } from "es-toolkit/compat";
1952
+ import * as esbuild2 from "esbuild";
1953
+ import { globbySync } from "globby";
1954
+ import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
1955
+
1956
+ // ../esbuild/src/base/renderer-engine.ts
1957
+ import path3 from "node:path";
1958
+ import { SourceMapConsumer, SourceMapGenerator } from "source-map";
1959
+
1960
+ // ../esbuild/src/utilities/output-file.ts
1961
+ import fs2 from "node:fs";
1962
+ import path2 from "node:path";
1963
+ var outputFile = /* @__PURE__ */ __name(async (filepath, data, options) => {
1964
+ await fs2.promises.mkdir(path2.dirname(filepath), {
1965
+ recursive: true
1966
+ });
1967
+ await fs2.promises.writeFile(filepath, data, options);
1968
+ }, "outputFile");
1969
+
1970
+ // ../esbuild/src/base/renderer-engine.ts
1971
+ var parseSourceMap = /* @__PURE__ */ __name((map2) => {
1972
+ return typeof map2 === "string" ? JSON.parse(map2) : map2;
1973
+ }, "parseSourceMap");
1974
+ var isJS = /* @__PURE__ */ __name((path7) => /\.(js|mjs|cjs)$/.test(path7), "isJS");
1975
+ var isCSS = /* @__PURE__ */ __name((path7) => /\.css$/.test(path7), "isCSS");
1976
+ var getSourcemapComment = /* @__PURE__ */ __name((inline, map2, filepath, isCssFile) => {
1977
+ if (!map2) return "";
1978
+ const prefix = isCssFile ? "/*" : "//";
1979
+ const suffix = isCssFile ? " */" : "";
1980
+ const url = inline ? `data:application/json;base64,${Buffer.from(typeof map2 === "string" ? map2 : JSON.stringify(map2)).toString("base64")}` : `${path3.basename(filepath)}.map`;
1981
+ return `${prefix}# sourceMappingURL=${url}${suffix}`;
1982
+ }, "getSourcemapComment");
1983
+ var RendererEngine = class {
1984
+ static {
1985
+ __name(this, "RendererEngine");
1986
+ }
1987
+ #renderers;
1988
+ #options;
1989
+ constructor(renderers) {
1990
+ this.#renderers = renderers;
1991
+ }
1992
+ setOptions(options) {
1993
+ this.#options = options;
1994
+ }
1995
+ getOptions() {
1996
+ if (!this.#options) {
1997
+ throw new Error(`Renderer options is not set`);
1998
+ }
1999
+ return this.#options;
2000
+ }
2001
+ modifyEsbuildOptions(options) {
2002
+ for (const renderer of this.#renderers) {
2003
+ if (renderer.esbuildOptions) {
2004
+ renderer.esbuildOptions.call(this.getOptions(), options);
2005
+ }
2006
+ }
2007
+ }
2008
+ async buildStarted() {
2009
+ for (const renderer of this.#renderers) {
2010
+ if (renderer.buildStart) {
2011
+ await renderer.buildStart.call(this.getOptions());
2012
+ }
2013
+ }
2014
+ }
2015
+ async buildFinished({ outputFiles, metafile }) {
2016
+ const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
2017
+ if (isJS(file.path) || isCSS(file.path)) {
2018
+ let relativePath = path3.relative(this.getOptions().config.workspaceRoot, file.path);
2019
+ if (!relativePath.startsWith("\\\\?\\")) {
2020
+ relativePath = relativePath.replace(/\\/g, "/");
2021
+ }
2022
+ const meta = metafile?.outputs[relativePath];
2023
+ return {
2024
+ type: "chunk",
2025
+ path: file.path,
2026
+ code: file.text,
2027
+ map: outputFiles.find((f) => f.path === `${file.path}.map`)?.text,
2028
+ entryPoint: meta?.entryPoint,
2029
+ exports: meta?.exports,
2030
+ imports: meta?.imports
2031
+ };
2032
+ } else {
2033
+ return {
2034
+ type: "asset",
2035
+ path: file.path,
2036
+ contents: file.contents
2037
+ };
2038
+ }
2039
+ });
2040
+ const writtenFiles = [];
2041
+ await Promise.all(files.map(async (info) => {
2042
+ for (const renderer of this.#renderers) {
2043
+ if (info.type === "chunk" && renderer.renderChunk) {
2044
+ const result = await renderer.renderChunk.call(this.getOptions(), info.code, info);
2045
+ if (result) {
2046
+ info.code = result.code;
2047
+ if (result.map) {
2048
+ const originalConsumer = await new SourceMapConsumer(parseSourceMap(info.map));
2049
+ const newConsumer = await new SourceMapConsumer(parseSourceMap(result.map));
2050
+ const generator = SourceMapGenerator.fromSourceMap(newConsumer);
2051
+ generator.applySourceMap(originalConsumer, info.path);
2052
+ info.map = generator.toJSON();
2053
+ originalConsumer.destroy();
2054
+ newConsumer.destroy();
2055
+ }
2056
+ }
2057
+ }
2058
+ }
2059
+ const inlineSourceMap = this.#options.sourcemap === "inline";
2060
+ const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents;
2061
+ await outputFile(info.path, contents, {
2062
+ mode: info.type === "chunk" ? info.mode : void 0
2063
+ });
2064
+ writtenFiles.push({
2065
+ get name() {
2066
+ return path3.relative(process.cwd(), info.path);
2067
+ },
2068
+ get size() {
2069
+ return contents.length;
2070
+ }
2071
+ });
2072
+ if (info.type === "chunk" && info.map && !inlineSourceMap) {
2073
+ const map2 = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
2074
+ const outPath = `${info.path}.map`;
2075
+ const contents2 = JSON.stringify(map2);
2076
+ await outputFile(outPath, contents2);
2077
+ writtenFiles.push({
2078
+ get name() {
2079
+ return path3.relative(process.cwd(), outPath);
2080
+ },
2081
+ get size() {
2082
+ return contents2.length;
2083
+ }
2084
+ });
2085
+ }
2086
+ }));
2087
+ for (const renderer of this.#renderers) {
2088
+ if (renderer.buildEnd) {
2089
+ await renderer.buildEnd.call(this.getOptions(), {
2090
+ writtenFiles
2091
+ });
2092
+ }
2093
+ }
2094
+ }
2095
+ };
2096
+
2097
+ // ../esbuild/src/clean.ts
2098
+ import { hfs as hfs4 } from "@humanfs/node";
2099
+ async function clean(name = "ESBuild", directory, config) {
2100
+ writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
2101
+ const stopwatch = getStopwatch(`${name} output clean`);
2102
+ await hfs4.deleteAll(directory);
2103
+ stopwatch();
2104
+ }
2105
+ __name(clean, "clean");
2106
+
2107
+ // ../esbuild/src/plugins/esm-split-code-to-cjs.ts
2108
+ import * as esbuild from "esbuild";
2109
+ var esmSplitCodeToCjsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2110
+ name: "storm:esm-split-code-to-cjs",
2111
+ setup(build6) {
2112
+ build6.onEnd(async (result) => {
2113
+ const outFiles = Object.keys(result.metafile?.outputs ?? {});
2114
+ const jsFiles = outFiles.filter((f) => f.endsWith("js"));
2115
+ await esbuild.build({
2116
+ outdir: resolvedOptions.outdir,
2117
+ entryPoints: jsFiles,
2118
+ allowOverwrite: true,
2119
+ format: "cjs",
2120
+ logLevel: "error",
2121
+ packages: "external"
2122
+ });
2123
+ });
2124
+ }
2125
+ }), "esmSplitCodeToCjsPlugin");
2126
+
2127
+ // ../esbuild/src/plugins/fix-imports.ts
2128
+ var fixImportsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2129
+ name: "storm:fix-imports",
2130
+ setup(build6) {
2131
+ build6.onResolve({
2132
+ filter: /^spdx-exceptions/
2133
+ }, () => {
2134
+ return {
2135
+ path: __require.resolve("spdx-exceptions")
2136
+ };
2137
+ });
2138
+ build6.onResolve({
2139
+ filter: /^spdx-license-ids/
2140
+ }, () => {
2141
+ return {
2142
+ path: __require.resolve("spdx-license-ids")
2143
+ };
2144
+ });
2145
+ }
2146
+ }), "fixImportsPlugin");
2147
+
2148
+ // ../esbuild/src/plugins/native-node-module.ts
2149
+ import { dirname } from "node:path";
2150
+ var nativeNodeModulesPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
2151
+ return {
2152
+ name: "native-node-modules",
2153
+ setup(build6) {
2154
+ build6.onResolve({
2155
+ filter: /\.node$/,
2156
+ namespace: "file"
2157
+ }, (args) => {
2158
+ const resolvedId = __require.resolve(args.path, {
2159
+ paths: [
2160
+ args.resolveDir
2161
+ ]
2162
+ });
2163
+ if (resolvedId.endsWith(".node")) {
2164
+ return {
2165
+ path: resolvedId,
2166
+ namespace: "node-file"
2167
+ };
2168
+ }
2169
+ return {
2170
+ path: resolvedId
2171
+ };
2172
+ });
2173
+ build6.onLoad({
2174
+ filter: /.*/,
2175
+ namespace: "node-file"
2176
+ }, (args) => {
2177
+ return {
2178
+ contents: `
2179
+ import path from ${JSON.stringify(args.path)}
2180
+ try { module.exports = require(path) }
2181
+ catch {}
2182
+ `,
2183
+ resolveDir: dirname(args.path)
2184
+ };
2185
+ });
2186
+ build6.onResolve({
2187
+ filter: /\.node$/,
2188
+ namespace: "node-file"
2189
+ }, (args) => ({
2190
+ path: args.path,
2191
+ namespace: "file"
2192
+ }));
2193
+ const opts = build6.initialOptions;
2194
+ opts.loader = opts.loader || {};
2195
+ opts.loader[".node"] = "file";
2196
+ }
2197
+ };
2198
+ }, "nativeNodeModulesPlugin");
2199
+
2200
+ // ../esbuild/src/plugins/node-protocol.ts
2201
+ var nodeProtocolPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
2202
+ const nodeProtocol = "node:";
2203
+ return {
2204
+ name: "node-protocol-plugin",
2205
+ setup({ onResolve }) {
2206
+ onResolve({
2207
+ filter: /^node:/
2208
+ }, ({ path: path7 }) => ({
2209
+ path: path7.slice(nodeProtocol.length),
2210
+ external: true
2211
+ }));
2212
+ }
2213
+ };
2214
+ }, "nodeProtocolPlugin");
2215
+
2216
+ // ../esbuild/src/plugins/on-error.ts
2217
+ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2218
+ name: "storm:on-error",
2219
+ setup(build6) {
2220
+ build6.onEnd((result) => {
2221
+ if (result.errors.length > 0 && process.env.WATCH !== "true") {
2222
+ writeError(`The following errors occurred during the build:
2223
+ ${result.errors.map((error) => error.text).join("\n")}
2224
+
2225
+ `, resolvedOptions.config);
2226
+ throw new Error("Storm esbuild process failed with errors.");
2227
+ }
2228
+ });
2229
+ }
2230
+ }), "onErrorPlugin");
2231
+
2232
+ // ../esbuild/src/plugins/resolve-paths.ts
2233
+ import path4 from "node:path";
2234
+ function resolvePathsConfig(options, cwd) {
2235
+ if (options?.compilerOptions?.paths) {
2236
+ const paths = Object.entries(options.compilerOptions.paths);
2237
+ const resolvedPaths = paths.map(([key, paths2]) => {
2238
+ return [
2239
+ key,
2240
+ paths2.map((v) => path4.resolve(cwd, v))
2241
+ ];
2242
+ });
2243
+ return Object.fromEntries(resolvedPaths);
2244
+ }
2245
+ if (options.extends) {
2246
+ const extendsPath = path4.resolve(cwd, options.extends);
2247
+ const extendsDir = path4.dirname(extendsPath);
2248
+ const extendsConfig = __require(extendsPath);
2249
+ return resolvePathsConfig(extendsConfig, extendsDir);
2250
+ }
2251
+ return [];
2252
+ }
2253
+ __name(resolvePathsConfig, "resolvePathsConfig");
2254
+ var resolvePathsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2255
+ name: "storm:resolve-paths",
2256
+ setup(build6) {
2257
+ const parentTsConfig = build6.initialOptions.tsconfig ? __require(joinPaths(resolvedOptions.config.workspaceRoot, build6.initialOptions.tsconfig)) : __require(joinPaths(resolvedOptions.config.workspaceRoot, "tsconfig.json"));
2258
+ const resolvedTsPaths = resolvePathsConfig(parentTsConfig, options.projectRoot);
2259
+ const packagesRegex = new RegExp(`^(${Object.keys(resolvedTsPaths).join("|")})$`);
2260
+ build6.onResolve({
2261
+ filter: packagesRegex
2262
+ }, (args) => {
2263
+ if (build6.initialOptions.external?.includes(args.path)) {
2264
+ return {
2265
+ path: args.path,
2266
+ external: true
2267
+ };
2268
+ }
2269
+ return {
2270
+ path: `${resolvedTsPaths[args.path][0]}/index.ts`
2271
+ };
2272
+ });
2273
+ }
2274
+ }), "resolvePathsPlugin");
2275
+
2276
+ // ../esbuild/src/plugins/tsc.ts
2277
+ import { hfs as hfs5 } from "@humanfs/node";
2278
+ import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
2279
+ function bundleTypeDefinitions(filename, outfile, externals, options) {
2280
+ const { dependencies, peerDependencies, devDependencies } = __require(joinPaths(options.projectRoot, "package.json"));
2281
+ const dependenciesKeys = Object.keys(dependencies ?? {}).flatMap((p) => [
2282
+ p,
2283
+ getTypeDependencyPackageName(p)
2284
+ ]);
2285
+ const peerDependenciesKeys = Object.keys(peerDependencies ?? {}).flatMap((p) => [
2286
+ p,
2287
+ getTypeDependencyPackageName(p)
2288
+ ]);
2289
+ const devDependenciesKeys = Object.keys(devDependencies ?? {}).flatMap((p) => [
2290
+ p,
2291
+ getTypeDependencyPackageName(p)
2292
+ ]);
2293
+ const includeDeps = devDependenciesKeys;
2294
+ const excludeDeps = /* @__PURE__ */ new Set([
2295
+ ...dependenciesKeys,
2296
+ ...peerDependenciesKeys,
2297
+ ...externals
2298
+ ]);
2299
+ const bundledPackages = includeDeps.filter((dep) => !excludeDeps.has(dep));
2300
+ const extractorConfig = ExtractorConfig.prepare({
2301
+ configObject: {
2302
+ projectFolder: options.projectRoot,
2303
+ mainEntryPointFilePath: filename,
2304
+ bundledPackages,
2305
+ compiler: {
2306
+ tsconfigFilePath: options.tsconfig,
2307
+ overrideTsconfig: {
2308
+ compilerOptions: {
2309
+ paths: {}
2310
+ // bug with api extract + paths
2311
+ }
2312
+ }
2313
+ },
2314
+ dtsRollup: {
2315
+ enabled: true,
2316
+ untrimmedFilePath: joinPaths(options.outdir, `${outfile}.d.ts`)
2317
+ },
2318
+ tsdocMetadata: {
2319
+ enabled: false
2320
+ }
2321
+ },
2322
+ packageJsonFullPath: joinPaths(options.projectRoot, "package.json"),
2323
+ configObjectFullPath: void 0
2324
+ });
2325
+ const extractorResult = Extractor.invoke(extractorConfig, {
2326
+ showVerboseMessages: true,
2327
+ localBuild: true
2328
+ });
2329
+ if (extractorResult.succeeded === false) {
2330
+ writeError(`API Extractor completed with ${extractorResult.errorCount} ${extractorResult.errorCount === 1 ? "error" : "errors"}`);
2331
+ throw new Error("API Extractor completed with errors");
2332
+ }
2333
+ }
2334
+ __name(bundleTypeDefinitions, "bundleTypeDefinitions");
2335
+ var tscPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
2336
+ name: "storm:tsc",
2337
+ setup(build6) {
2338
+ if (options.emitTypes === false) {
2339
+ return;
2340
+ }
2341
+ build6.onStart(async () => {
2342
+ if (process.env.WATCH !== "true" && process.env.DEV !== "true") {
2343
+ await run(resolvedOptions.config, `pnpm exec tsc --project ${resolvedOptions.tsconfig}`, resolvedOptions.config.workspaceRoot);
2344
+ }
2345
+ if (resolvedOptions.bundle && resolvedOptions.entryPoints && resolvedOptions.entryPoints.length > 0 && resolvedOptions.entryPoints[0] && resolvedOptions.entryPoints[0].endsWith(".ts")) {
2346
+ const sourceRoot = resolvedOptions.sourceRoot.replaceAll(resolvedOptions.projectRoot, "");
2347
+ const typeOutDir = resolvedOptions.outdir;
2348
+ const entryPoint = resolvedOptions.entryPoints[0].replace(sourceRoot, "").replace(/\.ts$/, "");
2349
+ const bundlePath = joinPaths(resolvedOptions.outdir, entryPoint);
2350
+ let dtsPath;
2351
+ if (await hfs5.isFile(joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`))) {
2352
+ dtsPath = joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`);
2353
+ } else if (await hfs5.isFile(joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`))) {
2354
+ dtsPath = joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`);
2355
+ }
2356
+ const ext = resolvedOptions.outExtension.dts || resolvedOptions.format === "esm" ? "d.mts" : "d.ts";
2357
+ if (process.env.WATCH !== "true" && process.env.DEV !== "true") {
2358
+ bundleTypeDefinitions(dtsPath, bundlePath, resolvedOptions.external ?? [], resolvedOptions);
2359
+ const dtsContents = await hfs5.text(`${bundlePath}.d.ts`);
2360
+ await hfs5.write(`${bundlePath}.${ext}`, dtsContents);
2361
+ } else {
2362
+ await hfs5.write(`${bundlePath}.${ext}`, `export * from './${entryPoint}'`);
2363
+ }
2364
+ }
2365
+ });
2366
+ }
2367
+ }), "tscPlugin");
2368
+ function getTypeDependencyPackageName(npmPackage) {
2369
+ if (npmPackage.startsWith("@")) {
2370
+ const [scope, name] = npmPackage.split("/");
2371
+ return `@types/${scope?.slice(1)}__${name}`;
2372
+ }
2373
+ return `@types/${npmPackage}`;
2374
+ }
2375
+ __name(getTypeDependencyPackageName, "getTypeDependencyPackageName");
2376
+
2377
+ // ../esbuild/src/config.ts
2378
+ var getOutputExtensionMap = /* @__PURE__ */ __name((options, pkgType) => {
2379
+ return options.outExtension ? options.outExtension(options.format, pkgType) : getOutExtension(options.format, pkgType);
2380
+ }, "getOutputExtensionMap");
2381
+ var getDefaultBuildPlugins = /* @__PURE__ */ __name((options, resolvedOptions) => [
2382
+ nodeProtocolPlugin(options, resolvedOptions),
2383
+ resolvePathsPlugin(options, resolvedOptions),
2384
+ fixImportsPlugin(options, resolvedOptions),
2385
+ nativeNodeModulesPlugin(options, resolvedOptions),
2386
+ esmSplitCodeToCjsPlugin(options, resolvedOptions),
2387
+ tscPlugin(options, resolvedOptions),
2388
+ onErrorPlugin(options, resolvedOptions)
2389
+ ], "getDefaultBuildPlugins");
2390
+ var DEFAULT_BUILD_OPTIONS = {
2391
+ platform: "node",
2392
+ target: "node22",
2393
+ format: "cjs",
2394
+ external: [],
2395
+ logLevel: "error",
2396
+ tsconfig: "tsconfig.json",
2397
+ envName: "production",
2398
+ keepNames: true,
2399
+ metafile: true,
2400
+ injectShims: true,
2401
+ color: true,
2402
+ watch: false,
2403
+ bundle: true,
2404
+ clean: true,
2405
+ debug: false,
2406
+ loader: {
2407
+ ".aac": "file",
2408
+ ".css": "file",
2409
+ ".eot": "file",
2410
+ ".flac": "file",
2411
+ ".gif": "file",
2412
+ ".jpeg": "file",
2413
+ ".jpg": "file",
2414
+ ".mp3": "file",
2415
+ ".mp4": "file",
2416
+ ".ogg": "file",
2417
+ ".otf": "file",
2418
+ ".png": "file",
2419
+ ".svg": "file",
2420
+ ".ttf": "file",
2421
+ ".wav": "file",
2422
+ ".webm": "file",
2423
+ ".webp": "file",
2424
+ ".woff": "file",
2425
+ ".woff2": "file"
2426
+ },
2427
+ banner: DEFAULT_COMPILED_BANNER
2428
+ };
2429
+
2430
+ // ../esbuild/src/plugins/deps-check.ts
2431
+ import { builtinModules as builtinModules2 } from "node:module";
2432
+ import path5 from "node:path";
2433
+ var unusedIgnore = [
2434
+ // these are our dev dependencies
2435
+ /@types\/.*?/,
2436
+ /@typescript-eslint.*?/,
2437
+ /eslint.*?/,
2438
+ "esbuild",
2439
+ "husky",
2440
+ "is-ci",
2441
+ "lint-staged",
2442
+ "prettier",
2443
+ "typescript",
2444
+ "ts-node",
2445
+ "ts-jest",
2446
+ "@swc/core",
2447
+ "@swc/jest",
2448
+ "jest",
2449
+ // these are missing 3rd party deps
2450
+ "spdx-exceptions",
2451
+ "spdx-license-ids",
2452
+ // type-only, so it is not detected
2453
+ "ts-toolbelt",
2454
+ // these are indirectly used by build
2455
+ "buffer"
2456
+ ];
2457
+ var missingIgnore = [
2458
+ ".prisma",
2459
+ "@prisma/client",
2460
+ "ts-toolbelt"
2461
+ ];
2462
+ var depsCheckPlugin = /* @__PURE__ */ __name((bundle) => ({
2463
+ name: "storm:deps-check",
2464
+ setup(build6) {
2465
+ const pkgJsonPath = path5.join(process.cwd(), "package.json");
2466
+ const pkgContents = __require(pkgJsonPath);
2467
+ const regDependencies = Object.keys(pkgContents["dependencies"] ?? {});
2468
+ const devDependencies = Object.keys(pkgContents["devDependencies"] ?? {});
2469
+ const peerDependencies = Object.keys(pkgContents["peerDependencies"] ?? {});
2470
+ const dependencies = [
2471
+ ...regDependencies,
2472
+ ...bundle ? devDependencies : []
2473
+ ];
2474
+ const collectedDependencies = /* @__PURE__ */ new Set();
2475
+ const onlyPackages = /^[^./](?!:)|^\.[^./]|^\.\.[^/]/;
2476
+ build6.onResolve({
2477
+ filter: onlyPackages
2478
+ }, (args) => {
2479
+ if (args.importer.includes(process.cwd())) {
2480
+ if (args.path[0] === "@") {
2481
+ const [org, pkg] = args.path.split("/");
2482
+ collectedDependencies.add(`${org}/${pkg}`);
2483
+ } else {
2484
+ const [pkg] = args.path.split("/");
2485
+ collectedDependencies.add(pkg);
2486
+ }
2487
+ }
2488
+ return {
2489
+ external: true
2490
+ };
2491
+ });
2492
+ build6.onEnd(() => {
2493
+ const unusedDependencies = [
2494
+ ...dependencies
2495
+ ].filter((dep) => {
2496
+ return !collectedDependencies.has(dep) || builtinModules2.includes(dep);
2497
+ });
2498
+ const missingDependencies = [
2499
+ ...collectedDependencies
2500
+ ].filter((dep) => {
2501
+ return !dependencies.includes(dep) && !builtinModules2.includes(dep);
2502
+ });
2503
+ const filteredUnusedDeps = unusedDependencies.filter((dep) => {
2504
+ return !unusedIgnore.some((pattern) => dep.match(pattern));
2505
+ });
2506
+ const filteredMissingDeps = missingDependencies.filter((dep) => {
2507
+ return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep);
2508
+ });
2509
+ writeWarning(`Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`);
2510
+ writeError(`Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`);
2511
+ if (filteredMissingDeps.length > 0) {
2512
+ throw new Error(`Missing dependencies detected - please install them:
2513
+ ${JSON.stringify(filteredMissingDeps)}
2514
+ `);
2515
+ }
2516
+ });
2517
+ }
2518
+ }), "depsCheckPlugin");
2519
+
2520
+ // ../esbuild/src/renderers/shebang.ts
2521
+ var shebangRenderer = {
2522
+ name: "shebang",
2523
+ renderChunk(_, __, info) {
2524
+ if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) {
2525
+ info.mode = 493;
2526
+ }
2527
+ }
2528
+ };
2529
+
2530
+ // ../esbuild/src/utilities/helpers.ts
2531
+ function handleSync(fn) {
2532
+ try {
2533
+ return fn();
2534
+ } catch (error_) {
2535
+ return error_;
2536
+ }
2537
+ }
2538
+ __name(handleSync, "handleSync");
2539
+ async function handleAsync(fn) {
2540
+ try {
2541
+ return await fn();
2542
+ } catch (error_) {
2543
+ return error_;
2544
+ }
2545
+ }
2546
+ __name(handleAsync, "handleAsync");
2547
+ var handle = handleSync;
2548
+ handle.async = handleAsync;
2549
+ var skip = Symbol("skip");
2550
+ function transduceSync(list, transformer) {
2551
+ const transduced = [];
2552
+ for (const [i, element_] of list.entries()) {
2553
+ const transformed = transformer(element_, i);
2554
+ if (transformed !== skip) {
2555
+ transduced[transduced.length] = transformed;
2556
+ }
2557
+ }
2558
+ return transduced;
2559
+ }
2560
+ __name(transduceSync, "transduceSync");
2561
+ async function transduceAsync(list, transformer) {
2562
+ const transduced = [];
2563
+ await Promise.all(list.entries().map(async ([i, element_]) => {
2564
+ const transformed = await transformer(element_, i);
2565
+ if (transformed !== skip) {
2566
+ transduced[transduced.length] = transformed;
2567
+ }
2568
+ }));
2569
+ return transduced;
2570
+ }
2571
+ __name(transduceAsync, "transduceAsync");
2572
+ var transduce = transduceSync;
2573
+ transduce.async = transduceAsync;
2574
+ function pipeSync(fn, ...fns) {
2575
+ return (...args) => {
2576
+ let result = fn(...args);
2577
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
2578
+ result = fns[i]?.(result);
2579
+ }
2580
+ return result;
2581
+ };
2582
+ }
2583
+ __name(pipeSync, "pipeSync");
2584
+ function pipeAsync(fn, ...fns) {
2585
+ return async (...args) => {
2586
+ let result = await fn(...args);
2587
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
2588
+ result = await fns[i]?.(result);
2589
+ }
2590
+ return result;
2591
+ };
2592
+ }
2593
+ __name(pipeAsync, "pipeAsync");
2594
+ var pipe = pipeSync;
2595
+ pipe.async = pipeAsync;
2596
+
2597
+ // ../esbuild/src/build.ts
2598
+ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
2599
+ const projectRoot = userOptions.projectRoot;
2600
+ const workspaceRoot3 = findWorkspaceRoot2(projectRoot);
2601
+ if (!workspaceRoot3) {
2602
+ throw new Error("Cannot find Nx workspace root");
2603
+ }
2604
+ const config = await loadStormConfig(workspaceRoot3.dir);
2605
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
2606
+ const stopwatch = getStopwatch("Build options resolution");
2607
+ const projectGraph = await createProjectGraphAsync3({
2608
+ exitOnError: true
2609
+ });
2610
+ const projectJsonPath = joinPaths(workspaceRoot3.dir, projectRoot, "project.json");
2611
+ if (!await hfs6.isFile(projectJsonPath)) {
2612
+ throw new Error("Cannot find project.json configuration");
2613
+ }
2614
+ const projectJson = await hfs6.json(projectJsonPath);
2615
+ const projectName = projectJson.name;
2616
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph3(projectGraph);
2617
+ if (!projectConfigurations?.projects?.[projectName]) {
2618
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
2619
+ }
2620
+ const options = defu3(userOptions, DEFAULT_BUILD_OPTIONS);
2621
+ options.name ??= `${projectName}-${options.format}`;
2622
+ options.target ??= DEFAULT_TARGET;
2623
+ const packageJsonPath = joinPaths(workspaceRoot3.dir, options.projectRoot, "package.json");
2624
+ if (!await hfs6.isFile(packageJsonPath)) {
2625
+ throw new Error("Cannot find package.json configuration");
2626
+ }
2627
+ const packageJson = await hfs6.json(packageJsonPath);
2628
+ const outExtension = getOutputExtensionMap(options, packageJson.type);
2629
+ const env = getEnv("esbuild", options);
2630
+ const result = {
2631
+ ...options,
2632
+ config,
2633
+ mainFields: options.platform === "node" ? [
2634
+ "module",
2635
+ "main"
2636
+ ] : [
2637
+ "browser",
2638
+ "module",
2639
+ "main"
2640
+ ],
2641
+ resolveExtensions: [
2642
+ ".ts",
2643
+ ".js",
2644
+ ".node"
2645
+ ],
2646
+ ...userOptions,
2647
+ tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
2648
+ format: options.format || "cjs",
2649
+ entryPoints: await getEntryPoints(config, projectRoot, projectJson.sourceRoot, userOptions.entry || [
2650
+ "./src/index.ts"
2651
+ ], userOptions.emitOnAll),
2652
+ outdir: userOptions.outputPath || joinPaths("dist", projectRoot),
2653
+ plugins: [],
2654
+ name: userOptions.name || projectName,
2655
+ projectConfigurations,
2656
+ projectName,
2657
+ projectGraph,
2658
+ sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || joinPaths(projectRoot, "src"),
2659
+ minify: userOptions.minify || !userOptions.debug,
2660
+ verbose: userOptions.verbose || isVerbose() || userOptions.debug === true,
2661
+ includeSrc: userOptions.includeSrc === true,
2662
+ metafile: userOptions.metafile !== false,
2663
+ generatePackageJson: userOptions.generatePackageJson !== false,
2664
+ clean: userOptions.clean !== false,
2665
+ emitOnAll: userOptions.emitOnAll === true,
2666
+ assets: userOptions.assets ?? [],
2667
+ injectShims: userOptions.injectShims !== true,
2668
+ bundle: userOptions.bundle !== false,
2669
+ keepNames: true,
2670
+ watch: userOptions.watch === true,
2671
+ outExtension,
2672
+ footer: userOptions.footer,
2673
+ banner: {
2674
+ js: options.banner || DEFAULT_COMPILED_BANNER,
2675
+ css: options.banner || DEFAULT_COMPILED_BANNER
2676
+ },
2677
+ splitting: options.format === "iife" ? false : typeof options.splitting === "boolean" ? options.splitting : options.format === "esm",
2678
+ treeShaking: options.format === "esm",
2679
+ env,
2680
+ define: {
2681
+ STORM_FORMAT: JSON.stringify(options.format || "cjs"),
2682
+ ...options.format === "cjs" && options.injectShims ? {
2683
+ "import.meta.url": "importMetaUrl"
2684
+ } : {},
2685
+ ...options.define,
2686
+ ...Object.keys(env || {}).reduce((res, key) => {
2687
+ const value = JSON.stringify(env[key]);
2688
+ return {
2689
+ ...res,
2690
+ [`process.env.${key}`]: value,
2691
+ [`import.meta.env.${key}`]: value
2692
+ };
2693
+ }, {})
2694
+ },
2695
+ inject: [
2696
+ options.format === "cjs" && options.injectShims ? joinPaths(__dirname, "../assets/cjs_shims.js") : "",
2697
+ options.format === "esm" && options.injectShims && options.platform === "node" ? joinPaths(__dirname, "../assets/esm_shims.js") : "",
2698
+ ...options.inject ?? []
2699
+ ].filter(Boolean)
2700
+ };
2701
+ result.plugins = userOptions.plugins ?? getDefaultBuildPlugins(userOptions, result);
2702
+ stopwatch();
2703
+ return result;
2704
+ }, "resolveOptions");
2705
+ async function generatePackageJson(context2) {
2706
+ if (context2.options.generatePackageJson !== false && await hfs6.isFile(joinPaths(context2.options.projectRoot, "package.json"))) {
2707
+ writeDebug(" \u270D\uFE0F Writing package.json file", context2.options.config);
2708
+ const stopwatch = getStopwatch("Write package.json file");
2709
+ const packageJsonPath = joinPaths(context2.options.projectRoot, "project.json");
2710
+ if (!await hfs6.isFile(packageJsonPath)) {
2711
+ throw new Error("Cannot find package.json configuration");
2712
+ }
2713
+ let packageJson = await hfs6.json(joinPaths(context2.options.config.workspaceRoot, context2.options.projectRoot, "package.json"));
2714
+ if (!packageJson) {
2715
+ throw new Error("Cannot find package.json configuration file");
2716
+ }
2717
+ packageJson = await addPackageDependencies(context2.options.config.workspaceRoot, context2.options.projectRoot, context2.options.projectName, packageJson);
2718
+ packageJson = await addWorkspacePackageJsonFields(context2.options.config, context2.options.projectRoot, context2.options.sourceRoot, context2.options.projectName, false, packageJson);
2719
+ packageJson.exports ??= {};
2720
+ packageJson.exports["./package.json"] ??= "./package.json";
2721
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, context2.options.sourceRoot);
2722
+ let entryPoints = [
2723
+ {
2724
+ in: "./src/index.ts",
2725
+ out: "./src/index.ts"
2726
+ }
2727
+ ];
2728
+ if (context2.options.entryPoints) {
2729
+ if (Array.isArray(context2.options.entryPoints)) {
2730
+ entryPoints = context2.options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
2731
+ in: entryPoint,
2732
+ out: entryPoint
2733
+ } : entryPoint);
2734
+ }
2735
+ for (const entryPoint of entryPoints) {
2736
+ const split = entryPoint.out.split(".");
2737
+ split.pop();
2738
+ const entry = split.join(".").replaceAll("\\", "/");
2739
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, context2.options.sourceRoot);
2740
+ }
2741
+ }
2742
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
2743
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
2744
+ packageJson.types = "./dist/index.d.ts";
2745
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
2746
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
2747
+ ret[key.replace("/index", "")] = packageJson.exports[key];
2748
+ }
2749
+ return ret;
2750
+ }, packageJson.exports);
2751
+ await writeJsonFile(joinPaths(context2.options.outdir, "package.json"), packageJson);
2752
+ stopwatch();
2753
+ }
2754
+ return context2;
2755
+ }
2756
+ __name(generatePackageJson, "generatePackageJson");
2757
+ async function createOptions(options) {
2758
+ return flatten(await Promise.all(map(options, (opt) => [
2759
+ // we defer it so that we don't trigger glob immediately
2760
+ () => resolveOptions(opt)
2761
+ ])));
2762
+ }
2763
+ __name(createOptions, "createOptions");
2764
+ async function generateContext(getOptions) {
2765
+ const options = await getOptions();
2766
+ const rendererEngine = new RendererEngine([
2767
+ shebangRenderer,
2768
+ ...options.renderers || []
2769
+ ]);
2770
+ return {
2771
+ options,
2772
+ rendererEngine
2773
+ };
2774
+ }
2775
+ __name(generateContext, "generateContext");
2776
+ async function executeEsBuild(context2) {
2777
+ writeDebug(` \u{1F680} Running ${context2.options.name} build`, context2.options.config);
2778
+ const stopwatch = getStopwatch(`${context2.options.name} build`);
2779
+ if (process.env.WATCH === "true") {
2780
+ const ctx = await esbuild2.context(context2.options);
2781
+ watch(ctx, context2.options);
2782
+ }
2783
+ const result = await esbuild2.build(context2.options);
2784
+ if (result.metafile) {
2785
+ const metafilePath = `${context2.options.outdir}/${context2.options.name}.meta.json`;
2786
+ await hfs6.write(metafilePath, JSON.stringify(result.metafile));
2787
+ }
2788
+ stopwatch();
2789
+ return context2;
2790
+ }
2791
+ __name(executeEsBuild, "executeEsBuild");
2792
+ async function copyBuildAssets(context2) {
2793
+ if (context2.result?.errors.length === 0) {
2794
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context2.options.outdir}`, context2.options.config);
2795
+ const stopwatch = getStopwatch(`${context2.options.name} asset copy`);
2796
+ await copyAssets(context2.options.config, context2.options.assets ?? [], context2.options.outdir, context2.options.projectRoot, context2.options.projectName, context2.options.sourceRoot, true, false);
2797
+ stopwatch();
2798
+ }
2799
+ return context2;
2800
+ }
2801
+ __name(copyBuildAssets, "copyBuildAssets");
2802
+ async function reportResults(context2) {
2803
+ if (context2.result?.errors.length === 0) {
2804
+ if (context2.result.warnings.length > 0) {
2805
+ writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context2.result.warnings.map((warning) => warning.text).join("\n")}`, context2.options.config);
2806
+ }
2807
+ writeSuccess(` \u{1F4E6} The ${context2.options.name} build completed successfully`, context2.options.config);
2808
+ }
2809
+ }
2810
+ __name(reportResults, "reportResults");
2811
+ async function dependencyCheck(options) {
2812
+ if (process.env.DEV === "true") {
2813
+ return void 0;
2814
+ }
2815
+ if (process.env.CI && !process.env.BUILDKITE) {
2816
+ return void 0;
2817
+ }
2818
+ const buildPromise = esbuild2.build({
2819
+ entryPoints: globbySync("**/*.{j,t}s", {
2820
+ // We don't check dependencies in ecosystem tests because tests are isolated from the build.
2821
+ ignore: [
2822
+ "./src/__tests__/**/*",
2823
+ "./tests/e2e/**/*",
2824
+ "./dist/**/*"
2825
+ ],
2826
+ gitignore: true
2827
+ }),
2828
+ logLevel: "silent",
2829
+ bundle: true,
2830
+ write: false,
2831
+ outdir: "out",
2832
+ plugins: [
2833
+ depsCheckPlugin(options.bundle)
2834
+ ]
2835
+ });
2836
+ await buildPromise.catch(() => {
2837
+ });
2838
+ return void 0;
2839
+ }
2840
+ __name(dependencyCheck, "dependencyCheck");
2841
+ async function cleanOutputPath(context2) {
2842
+ if (context2.options.clean !== false && context2.options.outdir) {
2843
+ await clean(context2.options.name, context2.options.outdir, context2.options.config);
2844
+ }
2845
+ return context2;
2846
+ }
2847
+ __name(cleanOutputPath, "cleanOutputPath");
2848
+ async function build3(options) {
2849
+ writeDebug(` \u26A1 Executing Storm ESBuild pipeline`);
2850
+ const stopwatch = getStopwatch("ESBuild pipeline");
2851
+ try {
2852
+ const opts = Array.isArray(options) ? options : [
2853
+ options
2854
+ ];
2855
+ if (opts.length === 0) {
2856
+ throw new Error("No build options were provided");
2857
+ }
2858
+ void transduce.async(opts, dependencyCheck);
2859
+ await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
2860
+ writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
2861
+ } catch (error) {
2862
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
2863
+ throw error;
2864
+ } finally {
2865
+ stopwatch();
2866
+ }
2867
+ }
2868
+ __name(build3, "build");
2869
+ var watch = /* @__PURE__ */ __name((context2, options) => {
2870
+ if (!options.watch) {
2871
+ return context2;
2872
+ }
2873
+ const config = {
2874
+ ignoreInitial: true,
2875
+ useFsEvents: true,
2876
+ ignored: [
2877
+ "./src/__tests__/**/*",
2878
+ "./package.json"
2879
+ ]
2880
+ };
2881
+ const changeWatcher = createWatcher([
2882
+ "./src/**/*"
2883
+ ], config);
2884
+ const fastRebuild = debounce(async () => {
2885
+ const timeBefore = Date.now();
2886
+ const rebuildResult = await handle.async(() => {
2887
+ return context2.rebuild();
2888
+ });
2889
+ if (rebuildResult instanceof Error) {
2890
+ writeError(rebuildResult.message);
2891
+ }
2892
+ writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
2893
+ }, 10);
2894
+ changeWatcher.on("change", fastRebuild);
2895
+ return void 0;
2896
+ }, "watch");
2897
+
2898
+ // ../workspace-tools/src/executors/esbuild/executor.ts
2899
+ async function esbuildExecutorFn(options, context2, config) {
2900
+ writeInfo("\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
2901
+ if (!context2.projectsConfigurations?.projects || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName] || !context2.projectsConfigurations.projects[context2.projectName]?.root) {
2902
+ throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace.");
2903
+ }
2904
+ await build3({
2905
+ ...options,
2906
+ projectRoot: context2.projectsConfigurations.projects?.[context2.projectName].root,
2907
+ projectName: context2.projectName,
2908
+ sourceRoot: context2.projectsConfigurations.projects?.[context2.projectName]?.sourceRoot,
2909
+ format: options.format,
2910
+ platform: options.format
2911
+ });
2912
+ return {
2913
+ success: true
2914
+ };
2915
+ }
2916
+ __name(esbuildExecutorFn, "esbuildExecutorFn");
2917
+ var executor_default6 = withRunExecutor("Storm ESBuild build", esbuildExecutorFn, {
2918
+ skipReadingConfig: false,
2919
+ hooks: {
2920
+ applyDefaultOptions: /* @__PURE__ */ __name(async (options, config) => {
2921
+ options.entry ??= [
2922
+ "src/index.ts"
2923
+ ];
2924
+ options.outputPath ??= "dist/{projectRoot}";
2925
+ options.tsconfig ??= "{projectRoot}/tsconfig.json";
2926
+ return options;
2927
+ }, "applyDefaultOptions")
2928
+ }
2929
+ });
2930
+
2931
+ // ../workspace-tools/src/executors/npm-publish/executor.ts
2932
+ import { execSync as execSync4 } from "node:child_process";
2933
+ import fs3 from "node:fs/promises";
2934
+
2935
+ // ../workspace-tools/src/utils/pnpm-deps-update.ts
2936
+ import { existsSync as existsSync3 } from "node:fs";
2937
+ import { readFile, writeFile } from "node:fs/promises";
2938
+ import readYamlFile from "read-yaml-file";
2939
+
2940
+ // ../workspace-tools/src/executors/npm-publish/executor.ts
2941
+ var LARGE_BUFFER3 = 1024 * 1e6;
2942
+
2943
+ // ../workspace-tools/src/executors/size-limit/executor.ts
2944
+ import { joinPathFragments as joinPathFragments4 } from "@nx/devkit";
2945
+ import esBuildPlugin from "@size-limit/esbuild";
2946
+ import esBuildWhyPlugin from "@size-limit/esbuild-why";
2947
+ import filePlugin from "@size-limit/file";
2948
+ import sizeLimit from "size-limit";
2949
+ async function sizeLimitExecutorFn(options, context2, config) {
2950
+ if (!context2?.projectName || !context2.projectsConfigurations?.projects || !context2.projectsConfigurations.projects[context2.projectName]) {
2951
+ throw new Error("The Size-Limit process failed because the context is not valid. Please run this command from a workspace.");
2952
+ }
2953
+ writeInfo(`\u{1F4CF} Running Size-Limit on ${context2.projectName}`, config);
2954
+ sizeLimit([
2955
+ filePlugin,
2956
+ esBuildPlugin,
2957
+ esBuildWhyPlugin
2958
+ ], {
2959
+ checks: options.entry ?? context2.projectsConfigurations.projects[context2.projectName]?.sourceRoot ?? joinPathFragments4(context2.projectsConfigurations.projects[context2.projectName]?.root ?? "./", "src")
2960
+ }).then((result) => {
2961
+ writeInfo(`\u{1F4CF} ${context2.projectName} Size-Limit result: ${JSON.stringify(result)}`, config);
2962
+ });
2963
+ return {
2964
+ success: true
2965
+ };
2966
+ }
2967
+ __name(sizeLimitExecutorFn, "sizeLimitExecutorFn");
2968
+ var executor_default7 = withRunExecutor("Size-Limit Performance Test Executor", sizeLimitExecutorFn, {
2969
+ skipReadingConfig: false,
2970
+ hooks: {
2971
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
2972
+ return options;
2973
+ }, "applyDefaultOptions")
2974
+ }
2975
+ });
2976
+
2977
+ // ../tsdown/src/build.ts
2978
+ import { hfs as hfs8 } from "@humanfs/node";
2979
+ import { createProjectGraphAsync as createProjectGraphAsync4, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph4, writeJsonFile as writeJsonFile2 } from "@nx/devkit";
2980
+ import defu4 from "defu";
2981
+ import { findWorkspaceRoot as findWorkspaceRoot3 } from "nx/src/utils/find-workspace-root";
2982
+ import { build as tsdown } from "tsdown";
2983
+
2984
+ // ../tsdown/src/clean.ts
2985
+ import { hfs as hfs7 } from "@humanfs/node";
2986
+ async function clean2(name = "ESBuild", directory, config) {
2987
+ writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
2988
+ const stopwatch = getStopwatch(`${name} output clean`);
2989
+ await hfs7.deleteAll(directory);
2990
+ stopwatch();
2991
+ }
2992
+ __name(clean2, "clean");
2993
+
2994
+ // ../tsdown/src/config.ts
2995
+ var DEFAULT_BUILD_OPTIONS2 = {
2996
+ platform: "node",
2997
+ target: "node22",
2998
+ format: [
2999
+ "esm",
3000
+ "cjs"
3001
+ ],
3002
+ tsconfig: "tsconfig.json",
3003
+ envName: "production",
3004
+ globalName: "globalThis",
3005
+ unused: {
3006
+ level: "error"
3007
+ },
3008
+ injectShims: true,
3009
+ watch: false,
3010
+ bundle: true,
3011
+ treeshake: true,
3012
+ clean: true,
3013
+ debug: false
3014
+ };
3015
+
3016
+ // ../tsdown/src/build.ts
3017
+ var resolveOptions2 = /* @__PURE__ */ __name(async (userOptions) => {
3018
+ const projectRoot = userOptions.projectRoot;
3019
+ const workspaceRoot3 = findWorkspaceRoot3(projectRoot);
3020
+ if (!workspaceRoot3) {
3021
+ throw new Error("Cannot find Nx workspace root");
3022
+ }
3023
+ const config = await loadStormConfig(workspaceRoot3.dir);
3024
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
3025
+ const stopwatch = getStopwatch("Build options resolution");
3026
+ const projectGraph = await createProjectGraphAsync4({
3027
+ exitOnError: true
3028
+ });
3029
+ const projectJsonPath = joinPaths(workspaceRoot3.dir, projectRoot, "project.json");
3030
+ if (!await hfs8.isFile(projectJsonPath)) {
3031
+ throw new Error("Cannot find project.json configuration");
3032
+ }
3033
+ const projectJson = await hfs8.json(projectJsonPath);
3034
+ const projectName = projectJson.name;
3035
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph4(projectGraph);
3036
+ if (!projectConfigurations?.projects?.[projectName]) {
3037
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
3038
+ }
3039
+ const options = defu4(userOptions, DEFAULT_BUILD_OPTIONS2);
3040
+ options.name ??= `${projectName}-${options.format}`;
3041
+ options.target ??= DEFAULT_TARGET;
3042
+ const packageJsonPath = joinPaths(workspaceRoot3.dir, options.projectRoot, "package.json");
3043
+ if (!await hfs8.isFile(packageJsonPath)) {
3044
+ throw new Error("Cannot find package.json configuration");
3045
+ }
3046
+ const env = getEnv("tsdown", options);
3047
+ const result = {
3048
+ ...options,
3049
+ config,
3050
+ ...userOptions,
3051
+ tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
3052
+ format: options.format || "cjs",
3053
+ entryPoints: await getEntryPoints(config, projectRoot, projectJson.sourceRoot, userOptions.entry || [
3054
+ "./src/index.ts"
3055
+ ], userOptions.emitOnAll),
3056
+ outdir: userOptions.outputPath || joinPaths("dist", projectRoot),
3057
+ plugins: [],
3058
+ name: userOptions.name || projectName,
3059
+ projectConfigurations,
3060
+ projectName,
3061
+ projectGraph,
3062
+ sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || joinPaths(projectRoot, "src"),
3063
+ minify: userOptions.minify || !userOptions.debug,
3064
+ verbose: userOptions.verbose || isVerbose() || userOptions.debug === true,
3065
+ includeSrc: userOptions.includeSrc === true,
3066
+ metafile: userOptions.metafile !== false,
3067
+ generatePackageJson: userOptions.generatePackageJson !== false,
3068
+ clean: userOptions.clean !== false,
3069
+ emitOnAll: userOptions.emitOnAll === true,
3070
+ dts: userOptions.emitTypes === true ? {
3071
+ transformer: "oxc"
3072
+ } : userOptions.emitTypes,
3073
+ bundleDts: userOptions.emitTypes,
3074
+ assets: userOptions.assets ?? [],
3075
+ shims: userOptions.injectShims !== true,
3076
+ bundle: userOptions.bundle !== false,
3077
+ watch: userOptions.watch === true,
3078
+ define: {
3079
+ STORM_FORMAT: JSON.stringify(options.format || "cjs"),
3080
+ ...options.format === "cjs" && options.injectShims ? {
3081
+ "import.meta.url": "importMetaUrl"
3082
+ } : {},
3083
+ ...Object.keys(env || {}).reduce((res, key) => {
3084
+ const value = JSON.stringify(env[key]);
3085
+ return {
3086
+ ...res,
3087
+ [`process.env.${key}`]: value,
3088
+ [`import.meta.env.${key}`]: value
3089
+ };
3090
+ }, {}),
3091
+ ...options.define
3092
+ }
3093
+ };
3094
+ stopwatch();
3095
+ return result;
3096
+ }, "resolveOptions");
3097
+ async function generatePackageJson2(options) {
3098
+ if (options.generatePackageJson !== false && await hfs8.isFile(joinPaths(options.projectRoot, "package.json"))) {
3099
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
3100
+ const stopwatch = getStopwatch("Write package.json file");
3101
+ const packageJsonPath = joinPaths(options.projectRoot, "project.json");
3102
+ if (!await hfs8.isFile(packageJsonPath)) {
3103
+ throw new Error("Cannot find package.json configuration");
3104
+ }
3105
+ let packageJson = await hfs8.json(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"));
3106
+ if (!packageJson) {
3107
+ throw new Error("Cannot find package.json configuration file");
3108
+ }
3109
+ packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
3110
+ packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
3111
+ packageJson.exports ??= {};
3112
+ packageJson.exports["./package.json"] ??= "./package.json";
3113
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
3114
+ let entryPoints = [
3115
+ {
3116
+ in: "./src/index.ts",
3117
+ out: "./src/index.ts"
3118
+ }
3119
+ ];
3120
+ if (options.entryPoints) {
3121
+ if (Array.isArray(options.entryPoints)) {
3122
+ entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
3123
+ in: entryPoint,
3124
+ out: entryPoint
3125
+ } : entryPoint);
3126
+ }
3127
+ for (const entryPoint of entryPoints) {
3128
+ const split = entryPoint.out.split(".");
3129
+ split.pop();
3130
+ const entry = split.join(".").replaceAll("\\", "/");
3131
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
3132
+ }
3133
+ }
3134
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
3135
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
3136
+ packageJson.types = "./dist/index.d.ts";
3137
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
3138
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
3139
+ ret[key.replace("/index", "")] = packageJson.exports[key];
3140
+ }
3141
+ return ret;
3142
+ }, packageJson.exports);
3143
+ await writeJsonFile2(joinPaths(options.outdir, "package.json"), packageJson);
3144
+ stopwatch();
3145
+ }
3146
+ return options;
3147
+ }
3148
+ __name(generatePackageJson2, "generatePackageJson");
3149
+ async function executeTSDown(options) {
3150
+ writeDebug(` \u{1F680} Running ${options.name} build`, options.config);
3151
+ const stopwatch = getStopwatch(`${options.name} build`);
3152
+ await tsdown({
3153
+ ...options,
3154
+ entry: options.entryPoints,
3155
+ outDir: options.outdir,
3156
+ config: false
3157
+ });
3158
+ stopwatch();
3159
+ return options;
3160
+ }
3161
+ __name(executeTSDown, "executeTSDown");
3162
+ async function copyBuildAssets2(options) {
3163
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`, options.config);
3164
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
3165
+ await copyAssets(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.projectName, options.sourceRoot, true, false);
3166
+ stopwatch();
3167
+ return options;
3168
+ }
3169
+ __name(copyBuildAssets2, "copyBuildAssets");
3170
+ async function reportResults2(options) {
3171
+ writeSuccess(` \u{1F4E6} The ${options.name} build completed successfully`, options.config);
3172
+ }
3173
+ __name(reportResults2, "reportResults");
3174
+ async function cleanOutputPath2(options) {
3175
+ if (options.clean !== false && options.outdir) {
3176
+ await clean2(options.name, options.outdir, options.config);
3177
+ }
3178
+ return options;
3179
+ }
3180
+ __name(cleanOutputPath2, "cleanOutputPath");
3181
+ async function build4(options) {
3182
+ writeDebug(` \u26A1 Executing Storm TSDown pipeline`);
3183
+ const stopwatch = getStopwatch("TSDown pipeline");
3184
+ try {
3185
+ const opts = Array.isArray(options) ? options : [
3186
+ options
3187
+ ];
3188
+ if (opts.length === 0) {
3189
+ throw new Error("No build options were provided");
3190
+ }
3191
+ const resolved = await Promise.all(opts.map(async (opt) => await resolveOptions2(opt)));
3192
+ if (resolved.length > 0) {
3193
+ await cleanOutputPath2(resolved[0]);
3194
+ await generatePackageJson2(resolved[0]);
3195
+ await Promise.all(resolved.map(async (opt) => {
3196
+ await executeTSDown(opt);
3197
+ await copyBuildAssets2(opt);
3198
+ await reportResults2(opt);
3199
+ }));
3200
+ } else {
3201
+ writeWarning(" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function.");
3202
+ }
3203
+ writeSuccess(" \u{1F3C1} TSDown pipeline build completed successfully");
3204
+ } catch (error) {
3205
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
3206
+ throw error;
3207
+ } finally {
3208
+ stopwatch();
3209
+ }
3210
+ }
3211
+ __name(build4, "build");
3212
+
3213
+ // ../workspace-tools/src/executors/tsdown/executor.ts
3214
+ async function tsdownExecutorFn(options, context2, config) {
3215
+ writeInfo("\u{1F4E6} Running Storm TSDown build executor on the workspace", config);
3216
+ if (!context2.projectsConfigurations?.projects || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName] || !context2.projectsConfigurations.projects[context2.projectName]?.root) {
3217
+ throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace.");
3218
+ }
3219
+ await build4({
3220
+ ...options,
3221
+ projectRoot: context2.projectsConfigurations.projects?.[context2.projectName].root,
3222
+ projectName: context2.projectName,
3223
+ sourceRoot: context2.projectsConfigurations.projects?.[context2.projectName]?.sourceRoot,
3224
+ format: options.format,
3225
+ platform: options.platform
3226
+ });
3227
+ return {
3228
+ success: true
3229
+ };
3230
+ }
3231
+ __name(tsdownExecutorFn, "tsdownExecutorFn");
3232
+ var executor_default8 = withRunExecutor("Storm TSDown build executor", tsdownExecutorFn, {
3233
+ skipReadingConfig: false,
3234
+ hooks: {
3235
+ applyDefaultOptions: /* @__PURE__ */ __name(async (options, config) => {
3236
+ options.entry ??= [
3237
+ "src/index.ts"
3238
+ ];
3239
+ options.outputPath ??= "dist/{projectRoot}";
3240
+ options.tsconfig ??= "{projectRoot}/tsconfig.json";
3241
+ return options;
3242
+ }, "applyDefaultOptions")
3243
+ }
3244
+ });
3245
+
3246
+ // ../workspace-tools/src/executors/typia/executor.ts
3247
+ import { removeSync } from "fs-extra";
3248
+ import { TypiaProgrammer } from "typia/lib/programmers/TypiaProgrammer.js";
3249
+ async function typiaExecutorFn(options, _, config) {
3250
+ if (options.clean !== false) {
3251
+ writeInfo(`\u{1F9F9} Cleaning output path: ${options.outputPath}`, config);
3252
+ removeSync(options.outputPath);
3253
+ }
3254
+ await Promise.all(options.entry.map((entry) => {
3255
+ writeInfo(`\u{1F680} Running Typia on entry: ${entry}`, config);
3256
+ return TypiaProgrammer.build({
3257
+ input: entry,
3258
+ output: options.outputPath,
3259
+ project: options.tsconfig
3260
+ });
3261
+ }));
3262
+ return {
3263
+ success: true
3264
+ };
3265
+ }
3266
+ __name(typiaExecutorFn, "typiaExecutorFn");
3267
+ var executor_default9 = withRunExecutor("Typia runtime validation generator", typiaExecutorFn, {
3268
+ skipReadingConfig: false,
3269
+ hooks: {
3270
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
3271
+ options.entry ??= [
3272
+ "{sourceRoot}/index.ts"
3273
+ ];
3274
+ options.outputPath ??= "{sourceRoot}/__generated__/typia";
3275
+ options.tsconfig ??= "{projectRoot}/tsconfig.json";
3276
+ options.clean ??= true;
3277
+ return options;
3278
+ }, "applyDefaultOptions")
3279
+ }
3280
+ });
3281
+
3282
+ // ../unbuild/src/build.ts
3283
+ import { hfs as hfs10 } from "@humanfs/node";
3284
+ import { createProjectGraphAsync as createProjectGraphAsync6, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph5, writeJsonFile as writeJsonFile3 } from "@nx/devkit";
3285
+ import { getHelperDependency as getHelperDependency2, HelperDependency as HelperDependency2 } from "@nx/js";
3286
+ import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies3 } from "@nx/js/src/utils/buildable-libs-utils";
3287
+ import defu5 from "defu";
3288
+ import { relative as relative4 } from "node:path";
3289
+ import { findWorkspaceRoot as findWorkspaceRoot4 } from "nx/src/utils/find-workspace-root";
3290
+ import { build as unbuild } from "unbuild";
3291
+
3292
+ // ../unbuild/src/clean.ts
3293
+ import { hfs as hfs9 } from "@humanfs/node";
3294
+ async function clean3(name = "Unbuild", directory, config) {
3295
+ writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
3296
+ const stopwatch = getStopwatch(`${name} output clean`);
3297
+ await hfs9.deleteAll(directory);
3298
+ stopwatch();
3299
+ }
3300
+ __name(clean3, "clean");
3301
+
3302
+ // ../unbuild/src/plugins/analyze.ts
3303
+ var formatBytes = /* @__PURE__ */ __name((bytes) => {
3304
+ if (bytes === 0) return "0 Byte";
3305
+ const k = 1e3;
3306
+ const dm = 3;
3307
+ const sizes = [
3308
+ "Bytes",
3309
+ "KB",
3310
+ "MB",
3311
+ "GB"
3312
+ ];
3313
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
3314
+ return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
3315
+ }, "formatBytes");
3316
+ var analyzePlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
3317
+ return {
3318
+ name: "storm:analyzer",
3319
+ renderChunk(source, chunk) {
3320
+ const sourceBytes = formatBytes(source.length);
3321
+ const fileName = chunk.fileName;
3322
+ writeInfo(` - ${fileName} ${sourceBytes}`, resolvedOptions.config);
3323
+ }
3324
+ };
3325
+ }, "analyzePlugin");
3326
+
3327
+ // ../unbuild/src/plugins/on-error.ts
3328
+ var onErrorPlugin2 = /* @__PURE__ */ __name((options, resolvedOptions) => ({
3329
+ name: "storm:on-error",
3330
+ buildEnd(error) {
3331
+ if (error) {
3332
+ writeError(`The following errors occurred during the build:
3333
+ ${error ? error.message : "Unknown build error"}
3334
+
3335
+ `, resolvedOptions.config);
3336
+ throw new Error("Storm unbuild process failed with errors.");
3337
+ }
3338
+ },
3339
+ renderError(error) {
3340
+ writeError(`The following errors occurred during the build:
3341
+ ${error ? error.message : "Unknown build error"}
3342
+
3343
+ `, resolvedOptions.config);
3344
+ throw new Error("Storm unbuild process failed with errors.");
3345
+ }
3346
+ }), "onErrorPlugin");
3347
+
3348
+ // ../unbuild/src/plugins/swc.ts
3349
+ var swcPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
3350
+ const { transform: transform3 } = __require("@swc/core");
3351
+ return {
3352
+ name: "storm:swc",
3353
+ transform(code, filename) {
3354
+ return transform3(code, {
3355
+ filename,
3356
+ jsc: {
3357
+ transform: {
3358
+ react: {
3359
+ runtime: "automatic"
3360
+ }
3361
+ }
3362
+ }
3363
+ });
3364
+ }
3365
+ };
3366
+ }, "swcPlugin");
3367
+
3368
+ // ../unbuild/src/plugins/tsc.ts
3369
+ import { createProjectGraphAsync as createProjectGraphAsync5 } from "@nx/devkit";
3370
+ import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
3371
+ import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
3372
+ import ts2Plugin from "rollup-plugin-typescript2";
3373
+
3374
+ // ../unbuild/src/utilities/helpers.ts
3375
+ import { joinPathFragments as joinPathFragments5 } from "@nx/devkit";
3376
+ import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
3377
+ import { dirname as dirname2, extname } from "node:path";
3378
+ import { pathToFileURL } from "node:url";
3379
+ import ts from "typescript";
3380
+ async function loadConfig2(configPath) {
3381
+ if (!/\.(js|mjs)$/.test(extname(configPath))) {
3382
+ throw new Error("Unsupported config file format");
3383
+ }
3384
+ return import(pathToFileURL(configPath).toString()).then((config) => config.default);
3385
+ }
3386
+ __name(loadConfig2, "loadConfig");
3387
+ async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
3388
+ const tsConfigFile = ts.readConfigFile(joinPathFragments5(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
3389
+ const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname2(joinPathFragments5(config.workspaceRoot, projectRoot, tsConfigPath)));
3390
+ const compilerOptions = {
3391
+ rootDir: projectRoot,
3392
+ declaration: true,
3393
+ paths: computeCompilerOptionsPaths(tsConfig, dependencies ?? [])
3394
+ };
3395
+ writeTrace(compilerOptions, config);
3396
+ return compilerOptions;
3397
+ }
3398
+ __name(createTsCompilerOptions, "createTsCompilerOptions");
3399
+
3400
+ // ../unbuild/src/plugins/tsc.ts
3401
+ var tscPlugin2 = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
3402
+ const projectGraph = await createProjectGraphAsync5({
3403
+ exitOnError: true
3404
+ });
3405
+ const result = calculateProjectBuildableDependencies2(void 0, projectGraph, resolvedOptions.config.workspaceRoot, resolvedOptions.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
3406
+ let dependencies = result.dependencies;
3407
+ const tsLibDependency = getHelperDependency(HelperDependency.tsc, resolvedOptions.tsconfig, dependencies, projectGraph, true);
3408
+ if (tsLibDependency) {
3409
+ dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
3410
+ dependencies.push(tsLibDependency);
3411
+ }
3412
+ return ts2Plugin({
3413
+ check: options.emitTypes !== false,
3414
+ tsconfig: resolvedOptions.tsconfig,
3415
+ tsconfigOverride: {
3416
+ compilerOptions: await createTsCompilerOptions(resolvedOptions.config, resolvedOptions.tsconfig, resolvedOptions.projectRoot, dependencies)
3417
+ }
3418
+ });
3419
+ }, "tscPlugin");
3420
+
3421
+ // ../unbuild/src/plugins/type-definitions.ts
3422
+ import { relative as relative3 } from "node:path";
3423
+ var typeDefinitions = /* @__PURE__ */ __name((options, resolvedOptions) => ({
3424
+ name: "storm:dts-bundle",
3425
+ async generateBundle(_opts, bundle) {
3426
+ for (const file of Object.values(bundle)) {
3427
+ if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
3428
+ continue;
3429
+ }
3430
+ const hasDefaultExport = file.exports.includes("default");
3431
+ const entrySourceFileName = relative3(options.projectRoot, file.facadeModuleId);
3432
+ const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
3433
+ const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
3434
+ const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
3435
+ const dtsFileSource = hasDefaultExport ? `
3436
+ export * from ${relativeSourceDtsName};
3437
+ export { default } from ${relativeSourceDtsName};
3438
+ ` : `export * from ${relativeSourceDtsName};
3439
+ `;
3440
+ this.emitFile({
3441
+ type: "asset",
3442
+ fileName: dtsFileName,
3443
+ source: dtsFileSource
3444
+ });
3445
+ }
3446
+ }
3447
+ }), "typeDefinitions");
3448
+
3449
+ // ../unbuild/src/config.ts
3450
+ var getDefaultBuildPlugins2 = /* @__PURE__ */ __name(async (options, resolvedOptions) => Promise.all([
3451
+ analyzePlugin(options, resolvedOptions),
3452
+ swcPlugin(options, resolvedOptions),
3453
+ typeDefinitions(options, resolvedOptions),
3454
+ tscPlugin2(options, resolvedOptions),
3455
+ onErrorPlugin2(options, resolvedOptions)
3456
+ ].map((plugin) => Promise.resolve(plugin))), "getDefaultBuildPlugins");
3457
+
3458
+ // ../unbuild/src/build.ts
3459
+ async function resolveOptions3(options) {
3460
+ const projectRoot = options.projectRoot;
3461
+ if (!projectRoot) {
3462
+ throw new Error("Cannot find project root");
3463
+ }
3464
+ const outputPath = options.outputPath || joinPaths("dist", projectRoot);
3465
+ const workspaceRoot3 = findWorkspaceRoot4(projectRoot);
3466
+ if (!workspaceRoot3) {
3467
+ throw new Error("Cannot find workspace root");
3468
+ }
3469
+ const config = await loadStormConfig(workspaceRoot3.dir);
3470
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
3471
+ const stopwatch = getStopwatch("Build options resolution");
3472
+ if (options.configPath) {
3473
+ const configFile = await loadConfig2(options.configPath);
3474
+ if (configFile) {
3475
+ options = defu5(options, configFile);
3476
+ }
3477
+ }
3478
+ const projectGraph = await createProjectGraphAsync6({
3479
+ exitOnError: true
3480
+ });
3481
+ const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
3482
+ if (!await hfs10.isFile(projectJsonPath)) {
3483
+ throw new Error("Cannot find project.json configuration");
3484
+ }
3485
+ const projectJson = await hfs10.json(projectJsonPath);
3486
+ const projectName = projectJson.name;
3487
+ const packageJsonPath = joinPaths(workspaceRoot3.dir, projectRoot, "package.json");
3488
+ if (!await hfs10.isFile(packageJsonPath)) {
3489
+ throw new Error("Cannot find package.json configuration");
3490
+ }
3491
+ const packageJson = await hfs10.json(packageJsonPath);
3492
+ let tsconfig = options.tsconfig;
3493
+ if (!tsconfig) {
3494
+ tsconfig = joinPaths(workspaceRoot3.dir, projectRoot, "tsconfig.json");
3495
+ }
3496
+ if (!await hfs10.isFile(tsconfig)) {
3497
+ throw new Error("Cannot find tsconfig.json configuration");
3498
+ }
3499
+ let sourceRoot = projectJson.sourceRoot;
3500
+ if (!sourceRoot) {
3501
+ sourceRoot = joinPaths(projectRoot, "src");
3502
+ }
3503
+ if (!await hfs10.isDirectory(sourceRoot)) {
3504
+ throw new Error("Cannot find sourceRoot directory");
3505
+ }
3506
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph5(projectGraph);
3507
+ if (!projectConfigurations?.projects?.[projectName]) {
3508
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
3509
+ }
3510
+ const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot3.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
3511
+ let dependencies = result.dependencies;
3512
+ const tsLibDependency = getHelperDependency2(HelperDependency2.tsc, tsconfig, dependencies, projectGraph, true);
3513
+ if (tsLibDependency) {
3514
+ dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
3515
+ dependencies.push(tsLibDependency);
3516
+ }
3517
+ const resolvedOptions = {
3518
+ name: projectName,
3519
+ config,
3520
+ projectRoot,
3521
+ sourceRoot,
3522
+ projectName,
3523
+ tsconfig,
3524
+ clean: false,
3525
+ entries: [
3526
+ {
3527
+ builder: "mkdist",
3528
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
3529
+ outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3530
+ declaration: options.emitTypes !== false,
3531
+ format: "esm"
3532
+ },
3533
+ {
3534
+ builder: "mkdist",
3535
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
3536
+ outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
3537
+ declaration: options.emitTypes !== false,
3538
+ format: "cjs",
3539
+ ext: "cjs"
3540
+ }
3541
+ ],
3542
+ declaration: options.emitTypes !== false ? "compatible" : false,
3543
+ failOnWarn: false,
3544
+ sourcemap: options.sourcemap ?? !!options.debug,
3545
+ outDir: outputPath,
3546
+ parallel: true,
3547
+ stub: false,
3548
+ stubOptions: {
3549
+ jiti: {}
3550
+ },
3551
+ externals: options.external ?? [],
3552
+ dependencies: [],
3553
+ peerDependencies: [],
3554
+ devDependencies: [],
3555
+ hooks: {},
3556
+ alias: {},
3557
+ replace: {},
3558
+ rollup: {
3559
+ replace: {},
3560
+ alias: {},
3561
+ json: {},
3562
+ commonjs: {
3563
+ sourceMap: options.sourcemap ?? true
3564
+ },
3565
+ emitCJS: true,
3566
+ cjsBridge: true,
3567
+ dts: {
3568
+ respectExternal: true,
3569
+ tsconfig
3570
+ },
3571
+ output: {
3572
+ banner: options.banner || `
3573
+ // \u26A1 Built by Storm Software
3574
+ `,
3575
+ footer: options.footer
3576
+ },
3577
+ resolve: {
3578
+ preferBuiltins: true,
3579
+ extensions: [
3580
+ ".cjs",
3581
+ ".mjs",
3582
+ ".js",
3583
+ ".jsx",
3584
+ ".ts",
3585
+ ".tsx",
3586
+ ".json"
3587
+ ]
3588
+ },
3589
+ esbuild: {
3590
+ minify: !!options.minify,
3591
+ splitting: options.splitting !== false,
3592
+ treeShaking: options.treeShaking !== false,
3593
+ color: true,
3594
+ logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
3595
+ }
3596
+ }
3597
+ };
3598
+ dependencies = dependencies.filter((dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app");
3599
+ if (dependencies.length > 0) {
3600
+ resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
3601
+ }
3602
+ if (packageJson.devDependencies) {
3603
+ resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
3604
+ }
3605
+ if (packageJson.peerDependencies) {
3606
+ resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
3607
+ }
3608
+ if (options.rollup) {
3609
+ let rollup = {};
3610
+ if (typeof options.rollup === "string") {
3611
+ const rollupFile = await loadConfig2(options.rollup);
3612
+ if (rollupFile) {
3613
+ rollup = rollupFile;
3614
+ }
3615
+ } else {
3616
+ rollup = options.rollup;
3617
+ }
3618
+ resolvedOptions.rollup = defu5(resolvedOptions.rollup ?? {}, rollup);
3619
+ }
3620
+ resolvedOptions.hooks = {
3621
+ "rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
3622
+ opts.plugins = options.plugins ?? await getDefaultBuildPlugins2(options, resolvedOptions);
3623
+ }, "rollup:options")
3624
+ };
3625
+ stopwatch();
3626
+ return resolvedOptions;
3627
+ }
3628
+ __name(resolveOptions3, "resolveOptions");
3629
+ async function generatePackageJson3(options) {
3630
+ if (options.generatePackageJson !== false && await hfs10.isFile(joinPaths(options.projectRoot, "package.json"))) {
3631
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
3632
+ const stopwatch = getStopwatch("Write package.json file");
3633
+ const packageJsonPath = joinPaths(options.projectRoot, "project.json");
3634
+ if (!await hfs10.isFile(packageJsonPath)) {
3635
+ throw new Error("Cannot find package.json configuration");
3636
+ }
3637
+ let packageJson = await hfs10.json(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"));
3638
+ if (!packageJson) {
3639
+ throw new Error("Cannot find package.json configuration file");
3640
+ }
3641
+ packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
3642
+ packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
3643
+ packageJson = await addPackageJsonExports(options.sourceRoot, packageJson);
3644
+ await writeJsonFile3(joinPaths(options.outDir, "package.json"), packageJson);
3645
+ stopwatch();
3646
+ }
3647
+ return options;
3648
+ }
3649
+ __name(generatePackageJson3, "generatePackageJson");
3650
+ async function executeUnbuild(options) {
3651
+ writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
3652
+ const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
3653
+ try {
3654
+ await unbuild(options.projectRoot, false, {
3655
+ ...options,
3656
+ rootDir: options.projectRoot
3657
+ });
3658
+ } finally {
3659
+ stopwatch();
3660
+ }
3661
+ return options;
3662
+ }
3663
+ __name(executeUnbuild, "executeUnbuild");
3664
+ async function copyBuildAssets3(options) {
3665
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
3666
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
3667
+ await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
3668
+ stopwatch();
3669
+ return options;
3670
+ }
3671
+ __name(copyBuildAssets3, "copyBuildAssets");
3672
+ async function cleanOutputPath3(options) {
3673
+ if (options.clean !== false && options.outDir) {
3674
+ await clean3(options.name, options.outDir, options.config);
3675
+ }
3676
+ return options;
3677
+ }
3678
+ __name(cleanOutputPath3, "cleanOutputPath");
3679
+ async function build5(options) {
3680
+ writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
3681
+ const stopwatch = getStopwatch("Unbuild pipeline");
3682
+ try {
3683
+ const resolvedOptions = await resolveOptions3(options);
3684
+ await cleanOutputPath3(resolvedOptions);
3685
+ await generatePackageJson3(resolvedOptions);
3686
+ await executeUnbuild(resolvedOptions);
3687
+ await copyBuildAssets3(resolvedOptions);
3688
+ writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, resolvedOptions.config);
3689
+ } catch (error) {
3690
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
3691
+ throw error;
3692
+ } finally {
3693
+ stopwatch();
3694
+ }
3695
+ }
3696
+ __name(build5, "build");
3697
+
3698
+ // ../workspace-tools/src/executors/unbuild/executor.ts
3699
+ import { defu as defu6 } from "defu";
3700
+ async function unbuildExecutorFn(options, context2, config) {
3701
+ writeInfo("\u{1F4E6} Running Storm Unbuild executor on the workspace", config);
3702
+ if (!context2.projectsConfigurations?.projects || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName] || !context2.projectsConfigurations.projects[context2.projectName]?.root) {
3703
+ throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace.");
3704
+ }
3705
+ await build5(defu6({
3706
+ ...options,
3707
+ projectRoot: context2.projectsConfigurations.projects?.[context2.projectName].root,
3708
+ projectName: context2.projectName,
3709
+ sourceRoot: context2.projectsConfigurations.projects?.[context2.projectName]?.sourceRoot,
3710
+ platform: options.platform,
3711
+ name: context2.projectName
3712
+ }, {
3713
+ stubOptions: {
3714
+ jiti: {
3715
+ cache: "node_modules/.cache/storm"
3716
+ }
3717
+ },
3718
+ rollup: {
3719
+ emitCJS: true,
3720
+ watch: false,
3721
+ cjsBridge: false,
3722
+ dts: {
3723
+ respectExternal: true
3724
+ },
3725
+ replace: {},
3726
+ alias: {},
3727
+ resolve: {},
3728
+ json: {},
3729
+ commonjs: {},
3730
+ esbuild: {
3731
+ target: options.target,
3732
+ format: "esm",
3733
+ platform: options.platform,
3734
+ minify: options.minify,
3735
+ treeShaking: options.treeShaking
3736
+ }
3737
+ }
3738
+ }));
3739
+ return {
3740
+ success: true
3741
+ };
3742
+ }
3743
+ __name(unbuildExecutorFn, "unbuildExecutorFn");
3744
+ var executor_default10 = withRunExecutor("TypeScript Unbuild build", unbuildExecutorFn, {
3745
+ skipReadingConfig: false,
3746
+ hooks: {
3747
+ applyDefaultOptions: /* @__PURE__ */ __name(async (options, config) => {
3748
+ options.entry ??= [
3749
+ "{sourceRoot}"
3750
+ ];
3751
+ options.outputPath ??= "dist/{projectRoot}";
3752
+ options.tsconfig ??= "{projectRoot}/tsconfig.json";
3753
+ return options;
3754
+ }, "applyDefaultOptions")
3755
+ }
3756
+ });
3757
+
3758
+ // ../workspace-tools/src/generators/browser-library/generator.ts
3759
+ import { formatFiles as formatFiles3, generateFiles, joinPathFragments as joinPathFragments6, names as names2, offsetFromRoot as offsetFromRoot2 } from "@nx/devkit";
3760
+
3761
+ // ../workspace-tools/src/base/typescript-library-generator.ts
3762
+ import { addDependenciesToPackageJson as addDependenciesToPackageJson2, addProjectConfiguration, ensurePackage, formatFiles as formatFiles2, names, offsetFromRoot, readJson, updateJson, writeJson } from "@nx/devkit";
3763
+ import { determineProjectNameAndRootOptions } from "@nx/devkit/src/generators/project-name-and-root-utils";
3764
+ import { addTsConfigPath, getRelativePathToRootTsConfig, tsConfigBaseOptions } from "@nx/js";
3765
+ import jsInitGenerator from "@nx/js/src/generators/init/init";
3766
+ import setupVerdaccio from "@nx/js/src/generators/setup-verdaccio/generator";
3767
+
3768
+ // ../workspace-tools/src/utils/project-tags.ts
3769
+ var ProjectTagConstants = {
3770
+ Language: {
3771
+ TAG_ID: "language",
3772
+ TYPESCRIPT: "typescript",
3773
+ RUST: "rust"
3774
+ },
3775
+ ProjectType: {
3776
+ TAG_ID: "type",
3777
+ LIBRARY: "library",
3778
+ APPLICATION: "application"
3779
+ },
3780
+ DistStyle: {
3781
+ TAG_ID: "dist-style",
3782
+ NORMAL: "normal",
3783
+ CLEAN: "clean"
3784
+ },
3785
+ Provider: {
3786
+ TAG_ID: "provider"
3787
+ },
3788
+ Platform: {
3789
+ TAG_ID: "platform",
3790
+ NODE: "node",
3791
+ BROWSER: "browser",
3792
+ NEUTRAL: "neutral",
3793
+ WORKER: "worker"
3794
+ },
3795
+ Registry: {
3796
+ TAG_ID: "registry",
3797
+ CARGO: "cargo",
3798
+ NPM: "npm",
3799
+ CONTAINER: "container",
3800
+ CYCLONE: "cyclone"
3801
+ },
3802
+ Plugin: {
3803
+ TAG_ID: "plugin"
3804
+ }
3805
+ };
3806
+ var formatProjectTag = /* @__PURE__ */ __name((variant, value) => {
3807
+ return `${variant}:${value}`;
3808
+ }, "formatProjectTag");
3809
+ var hasProjectTag = /* @__PURE__ */ __name((project, variant) => {
3810
+ project.tags = project.tags ?? [];
3811
+ const prefix = formatProjectTag(variant, "");
3812
+ return project.tags.some((tag) => tag.startsWith(prefix) && tag.length > prefix.length);
3813
+ }, "hasProjectTag");
3814
+ var addProjectTag = /* @__PURE__ */ __name((project, variant, value, options = {
3815
+ overwrite: false
3816
+ }) => {
3817
+ project.tags = project.tags ?? [];
3818
+ if (options.overwrite || !hasProjectTag(project, variant)) {
3819
+ project.tags = project.tags.filter((tag) => !tag.startsWith(formatProjectTag(variant, "")));
3820
+ project.tags.push(formatProjectTag(variant, value));
3821
+ }
3822
+ }, "addProjectTag");
3823
+
3824
+ // ../workspace-tools/src/utils/versions.ts
3825
+ var typesNodeVersion = "20.9.0";
3826
+ var nxVersion = "^18.0.4";
3827
+ var nodeVersion = "20.11.0";
3828
+ var pnpmVersion = "8.10.2";
3829
+
3830
+ // ../workspace-tools/src/base/typescript-library-generator.ts
3831
+ async function typeScriptLibraryGeneratorFn(tree, schema, config) {
3832
+ const options = await normalizeOptions(tree, {
3833
+ ...schema
3834
+ });
3835
+ const tasks = [];
3836
+ tasks.push(await jsInitGenerator(tree, {
3837
+ ...options,
3838
+ tsConfigName: options.rootProject ? "tsconfig.json" : "tsconfig.base.json"
3839
+ }));
3840
+ tasks.push(addDependenciesToPackageJson2(tree, {}, {
3841
+ "@storm-software/workspace-tools": "latest",
3842
+ "@storm-software/testing-tools": "latest",
3843
+ ...schema.devDependencies ?? {}
3844
+ }));
3845
+ if (options.publishable) {
3846
+ tasks.push(await setupVerdaccio(tree, {
3847
+ ...options,
3848
+ skipFormat: true
3849
+ }));
3850
+ }
3851
+ const projectConfig = {
3852
+ root: options.directory,
3853
+ projectType: "library",
3854
+ sourceRoot: joinPaths(options.directory ?? "", "src"),
3855
+ targets: {
3856
+ build: {
3857
+ executor: schema.buildExecutor,
3858
+ outputs: [
3859
+ "{options.outputPath}"
3860
+ ],
3861
+ options: {
3862
+ entry: [
3863
+ joinPaths(options.projectRoot, "src", "index.ts")
3864
+ ],
3865
+ outputPath: getOutputPath(options),
3866
+ tsconfig: joinPaths(options.projectRoot, "tsconfig.json"),
3867
+ project: joinPaths(options.projectRoot, "package.json"),
3868
+ defaultConfiguration: "production",
3869
+ platform: "neutral",
3870
+ assets: [
3871
+ {
3872
+ input: options.projectRoot,
3873
+ glob: "*.md",
3874
+ output: "/"
3875
+ },
3876
+ {
3877
+ input: "",
3878
+ glob: "LICENSE",
3879
+ output: "/"
3880
+ }
3881
+ ]
3882
+ },
3883
+ configurations: {
3884
+ production: {
3885
+ debug: false,
3886
+ verbose: false
3887
+ },
3888
+ development: {
3889
+ debug: true,
3890
+ verbose: true
3891
+ }
3892
+ }
3893
+ }
3894
+ }
3895
+ };
3896
+ if (schema.platform) {
3897
+ projectConfig.targets.build.options.platform = schema.platform === "worker" ? "node" : schema.platform;
3898
+ }
3899
+ addProjectTag(projectConfig, ProjectTagConstants.Platform.TAG_ID, schema.platform === "node" ? ProjectTagConstants.Platform.NODE : schema.platform === "worker" ? ProjectTagConstants.Platform.WORKER : schema.platform === "browser" ? ProjectTagConstants.Platform.BROWSER : ProjectTagConstants.Platform.NEUTRAL, {
3900
+ overwrite: false
3901
+ });
3902
+ createProjectTsConfigJson(tree, options);
3903
+ addProjectConfiguration(tree, options.name, projectConfig);
3904
+ let repository = {
3905
+ type: "github",
3906
+ url: config?.repository || `https://github.com/${config?.organization || "storm-software"}/${config?.namespace || config?.name || "repository"}.git`
3907
+ };
3908
+ let description = schema.description || "A package developed by Storm Software used to create modern, scalable web applications.";
3909
+ if (tree.exists("package.json")) {
3910
+ const packageJson = readJson(tree, "package.json");
3911
+ if (packageJson?.repository) {
3912
+ repository = packageJson.repository;
3913
+ }
3914
+ if (packageJson?.description) {
3915
+ description = packageJson.description;
3916
+ }
3917
+ }
3918
+ if (!options.importPath) {
3919
+ options.importPath = options.name;
3920
+ }
3921
+ const packageJsonPath = joinPaths(options.projectRoot, "package.json");
3922
+ if (tree.exists(packageJsonPath)) {
3923
+ updateJson(tree, packageJsonPath, (json) => {
3924
+ if (!options.importPath) {
3925
+ options.importPath = options.name;
3926
+ }
3927
+ json.name = options.importPath;
3928
+ json.version = "0.0.1";
3929
+ if (json.private && (options.publishable || options.rootProject)) {
3930
+ json.private = void 0;
3931
+ }
3932
+ return {
3933
+ ...json,
3934
+ version: "0.0.1",
3935
+ description,
3936
+ repository: {
3937
+ ...repository,
3938
+ directory: options.projectRoot
3939
+ },
3940
+ type: "module",
3941
+ dependencies: {
3942
+ ...json.dependencies
3943
+ },
3944
+ publishConfig: {
3945
+ access: "public"
3946
+ }
3947
+ };
3948
+ });
3949
+ } else {
3950
+ writeJson(tree, packageJsonPath, {
3951
+ name: options.importPath,
3952
+ version: "0.0.1",
3953
+ description,
3954
+ repository: {
3955
+ ...repository,
3956
+ directory: options.projectRoot
3957
+ },
3958
+ private: !options.publishable || options.rootProject,
3959
+ type: "module",
3960
+ publishConfig: {
3961
+ access: "public"
3962
+ }
3963
+ });
3964
+ }
3965
+ if (tree.exists("package.json") && options.importPath) {
3966
+ updateJson(tree, "package.json", (json) => ({
3967
+ ...json,
3968
+ pnpm: {
3969
+ ...json?.pnpm,
3970
+ overrides: {
3971
+ ...json?.pnpm?.overrides,
3972
+ [options.importPath ?? ""]: "workspace:*"
3973
+ }
3974
+ }
3975
+ }));
3976
+ }
3977
+ addTsConfigPath(tree, options.importPath, [
3978
+ joinPaths(options.projectRoot, "./src", `index.${options.js ? "js" : "ts"}`)
3979
+ ]);
3980
+ addTsConfigPath(tree, joinPaths(options.importPath, "/*"), [
3981
+ joinPaths(options.projectRoot, "./src", "/*")
3982
+ ]);
3983
+ if (tree.exists("package.json")) {
3984
+ const packageJson = readJson(tree, "package.json");
3985
+ if (packageJson?.repository) {
3986
+ repository = packageJson.repository;
3987
+ }
3988
+ if (packageJson?.description) {
3989
+ description = packageJson.description;
3990
+ }
3991
+ }
3992
+ const tsconfigPath = joinPaths(options.projectRoot, "tsconfig.json");
3993
+ if (tree.exists(tsconfigPath)) {
3994
+ updateJson(tree, tsconfigPath, (json) => {
3995
+ json.composite ??= true;
3996
+ return json;
3997
+ });
3998
+ } else {
3999
+ writeJson(tree, tsconfigPath, {
4000
+ extends: `${offsetFromRoot(options.projectRoot)}tsconfig.base.json`,
4001
+ composite: true,
4002
+ compilerOptions: {
4003
+ outDir: `${offsetFromRoot(options.projectRoot)}dist/out-tsc`
4004
+ },
4005
+ files: [],
4006
+ include: [
4007
+ "src/**/*.ts",
4008
+ "src/**/*.js"
4009
+ ],
4010
+ exclude: [
4011
+ "jest.config.ts",
4012
+ "src/**/*.spec.ts",
4013
+ "src/**/*.test.ts"
4014
+ ]
4015
+ });
4016
+ }
4017
+ await formatFiles2(tree);
4018
+ return null;
4019
+ }
4020
+ __name(typeScriptLibraryGeneratorFn, "typeScriptLibraryGeneratorFn");
4021
+ function getOutputPath(options) {
4022
+ const parts = [
4023
+ "dist"
4024
+ ];
4025
+ if (options.projectRoot === ".") {
4026
+ parts.push(options.name);
4027
+ } else {
4028
+ parts.push(options.projectRoot);
4029
+ }
4030
+ return joinPaths(...parts);
4031
+ }
4032
+ __name(getOutputPath, "getOutputPath");
4033
+ function createProjectTsConfigJson(tree, options) {
4034
+ const tsconfig = {
4035
+ extends: options.rootProject ? void 0 : getRelativePathToRootTsConfig(tree, options.projectRoot),
4036
+ ...options?.tsconfigOptions ?? {},
4037
+ compilerOptions: {
4038
+ ...options.rootProject ? tsConfigBaseOptions : {},
4039
+ outDir: joinPaths(offsetFromRoot(options.projectRoot), "dist/out-tsc"),
4040
+ noEmit: true,
4041
+ ...options?.tsconfigOptions?.compilerOptions ?? {}
4042
+ },
4043
+ files: [
4044
+ ...options?.tsconfigOptions?.files ?? []
4045
+ ],
4046
+ include: [
4047
+ ...options?.tsconfigOptions?.include ?? [],
4048
+ "src/**/*.ts",
4049
+ "src/**/*.js",
4050
+ "bin/**/*"
4051
+ ],
4052
+ exclude: [
4053
+ ...options?.tsconfigOptions?.exclude ?? [],
4054
+ "jest.config.ts",
4055
+ "src/**/*.spec.ts",
4056
+ "src/**/*.test.ts"
4057
+ ]
4058
+ };
4059
+ writeJson(tree, joinPaths(options.projectRoot, "tsconfig.json"), tsconfig);
4060
+ }
4061
+ __name(createProjectTsConfigJson, "createProjectTsConfigJson");
4062
+ async function normalizeOptions(tree, options) {
4063
+ if (options.publishable) {
4064
+ if (!options.importPath) {
4065
+ throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
4066
+ }
4067
+ }
4068
+ let bundler = "tsc";
4069
+ if (options.publishable === false && options.buildable === false) {
4070
+ bundler = "none";
4071
+ }
4072
+ const { Linter } = ensurePackage("@nx/eslint", nxVersion);
4073
+ const { projectName, names: projectNames, projectRoot, importPath } = await determineProjectNameAndRootOptions(tree, {
4074
+ name: options.name,
4075
+ projectType: "library",
4076
+ directory: options.directory,
4077
+ importPath: options.importPath,
4078
+ rootProject: options.rootProject
4079
+ });
4080
+ options.rootProject = projectRoot === ".";
4081
+ const normalized = names(projectNames.projectFileName);
4082
+ const fileName = normalized.fileName;
4083
+ return {
4084
+ js: false,
4085
+ pascalCaseFiles: false,
4086
+ skipFormat: false,
4087
+ skipTsConfig: false,
4088
+ includeBabelRc: false,
4089
+ unitTestRunner: "jest",
4090
+ linter: Linter.EsLint,
4091
+ testEnvironment: "node",
4092
+ config: "project",
4093
+ compiler: "tsc",
4094
+ bundler,
4095
+ skipTypeCheck: false,
4096
+ minimal: false,
4097
+ hasPlugin: false,
4098
+ isUsingTsSolutionConfig: false,
4099
+ projectPackageManagerWorkspaceState: "included",
4100
+ ...options,
4101
+ fileName,
4102
+ name: projectName,
4103
+ projectNames,
4104
+ projectRoot,
4105
+ parsedTags: options.tags ? options.tags.split(",").map((s) => s.trim()) : [],
4106
+ importPath
4107
+ };
4108
+ }
4109
+ __name(normalizeOptions, "normalizeOptions");
4110
+
4111
+ // ../workspace-tools/src/generators/browser-library/generator.ts
4112
+ async function browserLibraryGeneratorFn(tree, schema, config) {
4113
+ const filesDir = joinPathFragments6(__dirname, "./files");
4114
+ const tsLibraryGeneratorOptions = {
4115
+ buildExecutor: "@storm-software/workspace-tools:unbuild",
4116
+ platform: "browser",
4117
+ devDependencies: {
4118
+ "@types/react": "^18.3.6",
4119
+ "@types/react-dom": "^18.3.0"
4120
+ },
4121
+ peerDependencies: {
4122
+ react: "^18.3.0",
4123
+ "react-dom": "^18.3.0",
4124
+ "react-native": "*"
4125
+ },
4126
+ peerDependenciesMeta: {
4127
+ "react-dom": {
4128
+ optional: true
4129
+ },
4130
+ "react-native": {
4131
+ optional: true
4132
+ }
4133
+ },
4134
+ ...schema,
4135
+ description: schema.description,
4136
+ directory: schema.directory
4137
+ };
4138
+ const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
4139
+ const { className, name, propertyName } = names2(options.projectNames.projectFileName);
4140
+ generateFiles(tree, filesDir, options.projectRoot, {
4141
+ ...schema,
4142
+ dot: ".",
4143
+ className,
4144
+ name,
4145
+ namespace: process.env.STORM_NAMESPACE ?? "storm-software",
4146
+ description: schema.description ?? "",
4147
+ propertyName,
4148
+ js: !!options.js,
4149
+ cliCommand: "nx",
4150
+ strict: void 0,
4151
+ tmpl: "",
4152
+ offsetFromRoot: offsetFromRoot2(options.projectRoot),
4153
+ buildable: options.bundler && options.bundler !== "none",
4154
+ hasUnitTestRunner: options.unitTestRunner !== "none",
4155
+ tsConfigOptions: {
4156
+ compilerOptions: {
4157
+ jsx: "react",
4158
+ types: [
4159
+ "node",
4160
+ "@nx/react/typings/cssmodule.d.ts",
4161
+ "@nx/react/typings/image.d.ts"
4162
+ ]
4163
+ }
4164
+ }
4165
+ });
4166
+ await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
4167
+ await formatFiles3(tree);
4168
+ return null;
4169
+ }
4170
+ __name(browserLibraryGeneratorFn, "browserLibraryGeneratorFn");
4171
+ var generator_default = withRunGenerator("TypeScript Library Creator (Browser Platform)", browserLibraryGeneratorFn, {
4172
+ hooks: {
4173
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
4174
+ options.description ??= "A library used by Storm Software to support browser applications";
4175
+ options.platform ??= "browser";
4176
+ return options;
4177
+ }, "applyDefaultOptions")
4178
+ }
4179
+ });
4180
+
4181
+ // ../workspace-tools/src/generators/config-schema/generator.ts
4182
+ import { formatFiles as formatFiles4, writeJson as writeJson2 } from "@nx/devkit";
4183
+ import { zodToJsonSchema } from "zod-to-json-schema";
4184
+ async function configSchemaGeneratorFn(tree, options, config) {
4185
+ writeInfo("\u{1F4E6} Running Storm Configuration JSON Schema generator", config);
4186
+ writeTrace(`Determining the Storm Configuration JSON Schema...`, config);
4187
+ const jsonSchema = zodToJsonSchema(StormConfigSchema, {
4188
+ name: "StormWorkspaceConfiguration"
4189
+ });
4190
+ writeTrace(jsonSchema, config);
4191
+ const outputPath = options.outputFile.replaceAll("{workspaceRoot}", "").replaceAll(config?.workspaceRoot ?? findWorkspaceRoot(), options.outputFile?.startsWith("./") ? "" : "./");
4192
+ writeTrace(`\u{1F4DD} Writing Storm Configuration JSON Schema to "${outputPath}"`, config);
4193
+ writeJson2(tree, outputPath, jsonSchema, {
4194
+ spaces: 2
4195
+ });
4196
+ await formatFiles4(tree);
4197
+ writeSuccess("\u{1F680} Storm Configuration JSON Schema creation has completed successfully!", config);
4198
+ return {
4199
+ success: true
4200
+ };
4201
+ }
4202
+ __name(configSchemaGeneratorFn, "configSchemaGeneratorFn");
4203
+ var generator_default2 = withRunGenerator("Configuration Schema Creator", configSchemaGeneratorFn, {
4204
+ hooks: {
4205
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
4206
+ options.outputFile ??= "{workspaceRoot}/storm-workspace.schema.json";
4207
+ return options;
4208
+ }, "applyDefaultOptions")
4209
+ }
4210
+ });
4211
+
4212
+ // ../workspace-tools/src/generators/neutral-library/generator.ts
4213
+ import { formatFiles as formatFiles5, generateFiles as generateFiles2, joinPathFragments as joinPathFragments7, names as names3, offsetFromRoot as offsetFromRoot3 } from "@nx/devkit";
4214
+ async function neutralLibraryGeneratorFn(tree, schema, config) {
4215
+ const filesDir = joinPathFragments7(__dirname, "./files");
4216
+ const tsLibraryGeneratorOptions = {
4217
+ ...schema,
4218
+ platform: "neutral",
4219
+ devDependencies: {},
4220
+ buildExecutor: "@storm-software/workspace-tools:unbuild"
4221
+ };
4222
+ const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
4223
+ const { className, name, propertyName } = names3(options.projectNames.projectFileName);
4224
+ generateFiles2(tree, filesDir, options.projectRoot, {
4225
+ ...schema,
4226
+ dot: ".",
4227
+ className,
4228
+ name,
4229
+ namespace: process.env.STORM_NAMESPACE ?? "storm-software",
4230
+ description: schema.description ?? "",
4231
+ propertyName,
4232
+ js: !!options.js,
4233
+ cliCommand: "nx",
4234
+ strict: void 0,
4235
+ tmpl: "",
4236
+ offsetFromRoot: offsetFromRoot3(options.projectRoot),
4237
+ buildable: options.bundler && options.bundler !== "none",
4238
+ hasUnitTestRunner: options.unitTestRunner !== "none"
4239
+ });
4240
+ await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
4241
+ await formatFiles5(tree);
4242
+ return null;
4243
+ }
4244
+ __name(neutralLibraryGeneratorFn, "neutralLibraryGeneratorFn");
4245
+ var generator_default3 = withRunGenerator("TypeScript Library Creator (Neutral Platform)", neutralLibraryGeneratorFn, {
4246
+ hooks: {
4247
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
4248
+ options.description ??= "A library used by Storm Software to support either browser or NodeJs applications";
4249
+ options.platform = "neutral";
4250
+ return options;
4251
+ }, "applyDefaultOptions")
4252
+ }
4253
+ });
4254
+
4255
+ // ../workspace-tools/src/generators/node-library/generator.ts
4256
+ import { formatFiles as formatFiles6, generateFiles as generateFiles3, joinPathFragments as joinPathFragments8, names as names4, offsetFromRoot as offsetFromRoot4 } from "@nx/devkit";
4257
+ async function nodeLibraryGeneratorFn(tree, schema, config) {
4258
+ const filesDir = joinPathFragments8(__dirname, "./files");
4259
+ const tsLibraryGeneratorOptions = {
4260
+ platform: "node",
4261
+ devDependencies: {
4262
+ "@types/node": typesNodeVersion
4263
+ },
4264
+ buildExecutor: "@storm-software/workspace-tools:unbuild",
4265
+ ...schema,
4266
+ directory: schema.directory,
4267
+ description: schema.description
4268
+ };
4269
+ const options = await normalizeOptions(tree, tsLibraryGeneratorOptions);
4270
+ const { className, name, propertyName } = names4(options.name);
4271
+ generateFiles3(tree, filesDir, options.projectRoot, {
4272
+ ...schema,
4273
+ dot: ".",
4274
+ className,
4275
+ name,
4276
+ namespace: process.env.STORM_NAMESPACE ?? "storm-software",
4277
+ description: schema.description ?? "",
4278
+ propertyName,
4279
+ js: !!options.js,
4280
+ cliCommand: "nx",
4281
+ strict: void 0,
4282
+ tmpl: "",
4283
+ offsetFromRoot: offsetFromRoot4(options.projectRoot),
4284
+ buildable: options.bundler && options.bundler !== "none",
4285
+ hasUnitTestRunner: options.unitTestRunner !== "none"
4286
+ });
4287
+ await typeScriptLibraryGeneratorFn(tree, tsLibraryGeneratorOptions, config);
4288
+ await formatFiles6(tree);
4289
+ return null;
4290
+ }
4291
+ __name(nodeLibraryGeneratorFn, "nodeLibraryGeneratorFn");
4292
+ var generator_default4 = withRunGenerator("TypeScript Library Creator (NodeJs Platform)", nodeLibraryGeneratorFn, {
4293
+ hooks: {
4294
+ applyDefaultOptions: /* @__PURE__ */ __name((options) => {
4295
+ options.description ??= "A library used by Storm Software to support NodeJs applications";
4296
+ options.platform ??= "node";
4297
+ return options;
4298
+ }, "applyDefaultOptions")
4299
+ }
4300
+ });
4301
+
4302
+ // ../workspace-tools/src/generators/preset/generator.ts
4303
+ import { addDependenciesToPackageJson as addDependenciesToPackageJson3, addProjectConfiguration as addProjectConfiguration2, formatFiles as formatFiles7, generateFiles as generateFiles4, joinPathFragments as joinPathFragments9, updateJson as updateJson2 } from "@nx/devkit";
4304
+ import * as path6 from "node:path";
4305
+ async function presetGeneratorFn(tree, options) {
4306
+ const projectRoot = ".";
4307
+ options.description ??= `\u26A1The ${options.namespace ? options.namespace : options.name} monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.`;
4308
+ options.namespace ??= options.organization;
4309
+ addProjectConfiguration2(tree, `@${options.namespace}/${options.name}`, {
4310
+ root: projectRoot,
4311
+ projectType: "application",
4312
+ targets: {
4313
+ "local-registry": {
4314
+ executor: "@nx/js:verdaccio",
4315
+ options: {
4316
+ port: 4873,
4317
+ config: ".verdaccio/config.yml",
4318
+ storage: "tmp/local-registry/storage"
4319
+ }
4320
+ }
4321
+ }
4322
+ });
4323
+ updateJson2(tree, "package.json", (json) => {
4324
+ json.scripts = json.scripts || {};
4325
+ json.version = "0.0.0";
4326
+ json.triggerEmptyDevReleaseByIncrementingThisNumber = 0;
4327
+ json.private = true;
4328
+ json.keywords ??= [
4329
+ options.name,
4330
+ options.namespace,
4331
+ "storm",
4332
+ "storm-stack",
4333
+ "storm-ops",
4334
+ "acidic",
4335
+ "acidic-engine",
4336
+ "cyclone-ui",
4337
+ "rust",
4338
+ "nx",
4339
+ "graphql",
4340
+ "sullivanpj",
4341
+ "monorepo"
4342
+ ];
4343
+ json.homepage ??= "https://stormsoftware.com";
4344
+ json.bugs ??= {
4345
+ url: `https://github.com/${options.organization}/${options.name}/issues`,
4346
+ email: "support@stormsoftware.com"
4347
+ };
4348
+ json.license = "Apache-2.0";
4349
+ json.author ??= {
4350
+ name: "Storm Software",
4351
+ email: "contact@stormsoftware.com",
4352
+ url: "https://stormsoftware.com"
4353
+ };
4354
+ json.maintainers ??= [
4355
+ {
4356
+ "name": "Storm Software",
4357
+ "email": "contact@stormsoftware.com",
4358
+ "url": "https://stormsoftware.com"
4359
+ },
4360
+ {
4361
+ "name": "Pat Sullivan",
4362
+ "email": "admin@stormsoftware.com",
4363
+ "url": "https://patsullivan.org"
4364
+ }
4365
+ ];
4366
+ json.funding ??= {
4367
+ type: "github",
4368
+ url: "https://github.com/sponsors/storm-software"
4369
+ };
4370
+ json.namespace ??= `@${options.namespace}`;
4371
+ json.description ??= options.description;
4372
+ options.repositoryUrl ??= `https://github.com/${options.organization}/${options.name}`;
4373
+ json.repository ??= {
4374
+ type: "github",
4375
+ url: `${options.repositoryUrl}.git`
4376
+ };
4377
+ json.packageManager ??= "pnpm@9.15.2";
4378
+ json.engines ??= {
4379
+ "node": ">=20.11.0",
4380
+ "pnpm": ">=9.15.2"
4381
+ };
4382
+ json.prettier = "@storm-software/prettier/config.json";
4383
+ json.nx ??= {
4384
+ "includedScripts": [
4385
+ "lint-sherif",
4386
+ "lint-knip",
4387
+ "lint-ls",
4388
+ "lint",
4389
+ "format",
4390
+ "format-sherif",
4391
+ "format-readme",
4392
+ "format-prettier",
4393
+ "format-toml",
4394
+ "commit",
4395
+ "release"
4396
+ ]
4397
+ };
4398
+ json.scripts.adr = "pnpm log4brains adr new";
4399
+ json.scripts["adr-preview"] = "pnpm log4brains preview";
4400
+ json.scripts.prepare = "pnpm add lefthook -w && pnpm lefthook install";
4401
+ json.scripts.preinstall = "npx -y only-allow pnpm";
4402
+ json.scripts["install-csb"] = "corepack enable && pnpm install --no-frozen-lockfile";
4403
+ json.scripts.clean = "rimraf dist && rimraf --glob packages/**/dist && rimraf --glob tools/**/dist && rimraf --glob docs/**/dist && rimraf --glob apps/**/dist && rimraf --glob libs/**/dist";
4404
+ json.scripts.nuke = "nx clear-cache && rimraf .nx/cache && rimraf .nx/workspace-data && pnpm clean && rimraf pnpm-lock.yaml && rimraf --glob packages/**/node_modules && rimraf --glob tools/**/node_modules && rimraf node_modules";
4405
+ json.scripts.prebuild = "pnpm clean";
4406
+ json.scripts.build = "nx affected -t build --parallel=5";
4407
+ json.scripts["build-all"] = "nx run-many -t build --all --parallel=5";
4408
+ json.scripts["build-prod"] = "nx run-many -t build --all --prod --parallel=5";
4409
+ json.scripts["build-tools"] = "nx run-many -t build --projects=tools/* --parallel=5";
4410
+ json.scripts["build-docs"] = "nx run-many -t build --projects=docs/* --parallel=5";
4411
+ if (!options.includeApps) {
4412
+ json.scripts["build-packages"] = "nx run-many -t build --projects=packages/* --parallel=5";
4413
+ } else {
4414
+ json.scripts["build-apps"] = "nx run-many -t build --projects=apps/* --parallel=5";
4415
+ json.scripts["build-libs"] = "nx run-many -t build --projects=libs/* --parallel=5";
4416
+ json.scripts["build-storybook"] = "storybook build -s public";
4417
+ }
4418
+ json.scripts.nx = "nx";
4419
+ json.scripts.graph = "nx graph";
4420
+ json.scripts.lint = "pnpm storm-lint all --skip-cspell --skip-alex";
4421
+ if (options.includeApps) {
4422
+ json.scripts.start = "nx serve";
4423
+ json.scripts.storybook = "pnpm storybook dev -p 6006";
4424
+ }
4425
+ json.scripts.help = "nx help";
4426
+ json.scripts["dep-graph"] = "nx dep-graph";
4427
+ json.scripts["local-registry"] = `nx local-registry @${options.namespace}/${options.name}`;
4428
+ json.scripts.e2e = "nx e2e";
4429
+ if (options.includeApps) {
4430
+ json.scripts.test = "nx test && pnpm test-storybook";
4431
+ json.scripts["test-storybook"] = "pnpm test-storybook";
4432
+ } else {
4433
+ json.scripts.test = "nx test";
4434
+ }
4435
+ json.scripts.lint = "pnpm storm-lint all --skip-cspell --skip-alex";
4436
+ json.scripts.commit = "pnpm storm-git commit";
4437
+ json.scripts["api-extractor"] = 'pnpm storm-docs api-extractor --outputPath="docs/api-reference" --clean';
4438
+ json.scripts.release = "pnpm storm-git release";
4439
+ json.scripts.format = "nx format:write";
4440
+ json.scripts["format-sherif"] = "pnpm exec sherif -f -i typescript -i react -i react-dom";
4441
+ json.scripts["format-toml"] = 'pnpm exec taplo format --config="./node_modules/@storm-software/linting-tools/taplo/config.toml" --cache-path="./node_modules/.cache/storm/taplo"';
4442
+ json.scripts["format-readme"] = 'pnpm storm-git readme --templates="tools/readme-templates"';
4443
+ json.scripts["format-prettier"] = "pnpm exec prettier --write --ignore-unknown --no-error-on-unmatched-pattern --cache && git update-index";
4444
+ json.scripts.lint = "pnpm storm-lint all --skip-cspell";
4445
+ json.scripts["lint-knip"] = "pnpm exec knip";
4446
+ json.scripts["lint-sherif"] = "pnpm exec sherif -i typescript -i react -i react-dom";
4447
+ json.scripts["lint-ls"] = 'pnpm exec ls-lint --config="./node_modules/@storm-software/linting-tools/ls-lint/ls-lint.yml"';
4448
+ json.packageManager ??= `pnpm@${pnpmVersion}`;
4449
+ json.engines = {
4450
+ node: `>=${nodeVersion}`,
4451
+ pnpm: `>=${pnpmVersion}`
4452
+ };
4453
+ return json;
4454
+ });
4455
+ generateFiles4(tree, path6.join(__dirname, "files"), projectRoot, {
4456
+ ...options,
4457
+ pnpmVersion,
4458
+ nodeVersion
4459
+ });
4460
+ await formatFiles7(tree);
4461
+ let dependencies = {
4462
+ "@ls-lint/ls-lint": "2.2.3",
4463
+ "@ltd/j-toml": "1.38.0",
4464
+ "@nx/devkit": "^20.2.2",
4465
+ "@nx/eslint-plugin": "^20.2.2",
4466
+ "@nx/js": "^20.2.2",
4467
+ "@nx/workspace": "^20.2.2",
4468
+ "@storm-software/config": "latest",
4469
+ "@storm-software/git-tools": "latest",
4470
+ "@storm-software/linting-tools": "latest",
4471
+ "@storm-software/testing-tools": "latest",
4472
+ "@storm-software/workspace-tools": "latest",
4473
+ "@storm-software/eslint": "latest",
4474
+ "@storm-software/cspell": "latest",
4475
+ "@storm-software/prettier": "latest",
4476
+ "@taplo/cli": "0.7.0",
4477
+ "@types/node": "^20.14.10",
4478
+ "copyfiles": "2.4.1",
4479
+ "eslint": "9.5.0",
4480
+ "jest": "29.7.0",
4481
+ "jest-environment-node": "29.7.0",
4482
+ "knip": "5.25.2",
4483
+ "lefthook": "1.6.18",
4484
+ "nx": "^20.2.2",
4485
+ "prettier": "3.3.2",
4486
+ "prettier-plugin-prisma": "5.0.0",
4487
+ "rimraf": "5.0.7",
4488
+ "sherif": "0.10.0",
4489
+ "ts-jest": "29.1.5",
4490
+ "ts-node": "10.9.2",
4491
+ "tslib": "2.6.3",
4492
+ "typescript": "5.5.3",
4493
+ "verdaccio": "5.31.1"
4494
+ };
4495
+ if (options.includeApps) {
4496
+ dependencies = {
4497
+ ...dependencies,
4498
+ react: "latest",
4499
+ "react-dom": "latest",
4500
+ storybook: "latest",
4501
+ "@storybook/addons": "latest",
4502
+ "@nx/react": "latest",
4503
+ "@nx/next": "latest",
4504
+ "@nx/node": "latest",
4505
+ "@nx/storybook": "latest",
4506
+ "jest-environment-jsdom": "29.7.0"
4507
+ };
4508
+ }
4509
+ if (options.includeRust) {
4510
+ dependencies = {
4511
+ ...dependencies,
4512
+ "@monodon/rust": "1.4.0"
4513
+ };
4514
+ }
4515
+ if (options.nxCloud) {
4516
+ dependencies = {
4517
+ ...dependencies,
4518
+ "nx-cloud": "latest"
4519
+ };
4520
+ }
4521
+ await Promise.resolve(addDependenciesToPackageJson3(tree, dependencies, {}, joinPathFragments9(projectRoot, "package.json")));
4522
+ return null;
4523
+ }
4524
+ __name(presetGeneratorFn, "presetGeneratorFn");
4525
+ var generator_default5 = withRunGenerator("Storm Workspace Preset Generator", presetGeneratorFn);
4526
+
4527
+ // ../workspace-tools/src/generators/release-version/generator.ts
4528
+ import { formatFiles as formatFiles8, joinPathFragments as joinPathFragments10, output, readJson as readJson2, updateJson as updateJson3, writeJson as writeJson3 } from "@nx/devkit";
4529
+ import { resolveLocalPackageDependencies as resolveLocalPackageJsonDependencies } from "@nx/js/src/generators/release-version/utils/resolve-local-package-dependencies";
4530
+ import { updateLockFile } from "@nx/js/src/generators/release-version/utils/update-lock-file";
4531
+
4532
+ // ../git-tools/src/types.ts
4533
+ var RuleConfigSeverity;
4534
+ (function(RuleConfigSeverity2) {
4535
+ RuleConfigSeverity2[RuleConfigSeverity2["Disabled"] = 0] = "Disabled";
4536
+ RuleConfigSeverity2[RuleConfigSeverity2["Warning"] = 1] = "Warning";
4537
+ RuleConfigSeverity2[RuleConfigSeverity2["Error"] = 2] = "Error";
4538
+ })(RuleConfigSeverity || (RuleConfigSeverity = {}));
4539
+
4540
+ // ../git-tools/src/release/changelog-renderer.ts
4541
+ import ChangelogRenderer from "nx/release/changelog-renderer/index";
4542
+
4543
+ // ../workspace-tools/src/generators/release-version/generator.ts
4544
+ import { exec as exec2, execSync as execSync5 } from "node:child_process";
4545
+ import { relative as relative5 } from "node:path";
4546
+ import { IMPLICIT_DEFAULT_RELEASE_GROUP } from "nx/src/command-line/release/config/config";
4547
+ import { getFirstGitCommit, getLatestGitTagForPattern } from "nx/src/command-line/release/utils/git";
4548
+ import { resolveSemverSpecifierFromConventionalCommits, resolveSemverSpecifierFromPrompt } from "nx/src/command-line/release/utils/resolve-semver-specifier";
4549
+ import { isValidSemverSpecifier } from "nx/src/command-line/release/utils/semver";
4550
+ import { deriveNewSemverVersion, validReleaseVersionPrefixes } from "nx/src/command-line/release/version";
4551
+ import { interpolate } from "nx/src/tasks-runner/utils";
4552
+ import { prerelease } from "semver";
4553
+
4554
+ // ../workspace-tools/src/utils/create-cli-options.ts
4555
+ import { names as names5 } from "@nx/devkit";
4556
+
4557
+ // ../workspace-tools/src/utils/get-project-configurations.ts
4558
+ import { retrieveProjectConfigurationsWithoutPluginInference } from "nx/src/project-graph/utils/retrieve-workspace-files";
4559
+
4560
+ // ../workspace-tools/src/utils/lock-file.ts
4561
+ import { existsSync as existsSync4 } from "node:fs";
4562
+ import { join as join4 } from "node:path";
4563
+ import { output as output2, readJsonFile, workspaceRoot as workspaceRoot2 } from "nx/src/devkit-exports";
4564
+ import { getNpmLockfileDependencies, getNpmLockfileNodes } from "nx/src/plugins/js/lock-file/npm-parser";
4565
+ import { getPnpmLockfileDependencies, getPnpmLockfileNodes } from "nx/src/plugins/js/lock-file/pnpm-parser";
4566
+ import { getYarnLockfileDependencies, getYarnLockfileNodes } from "nx/src/plugins/js/lock-file/yarn-parser";
4567
+ var YARN_LOCK_FILE = "yarn.lock";
4568
+ var NPM_LOCK_FILE = "package-lock.json";
4569
+ var PNPM_LOCK_FILE = "pnpm-lock.yaml";
4570
+ var YARN_LOCK_PATH = join4(workspaceRoot2, YARN_LOCK_FILE);
4571
+ var NPM_LOCK_PATH = join4(workspaceRoot2, NPM_LOCK_FILE);
4572
+ var PNPM_LOCK_PATH = join4(workspaceRoot2, PNPM_LOCK_FILE);
4573
+
4574
+ // ../workspace-tools/src/utils/package-helpers.ts
4575
+ import { joinPathFragments as joinPathFragments11, readJsonFile as readJsonFile2 } from "@nx/devkit";
4576
+ import { existsSync as existsSync5 } from "node:fs";
4577
+
4578
+ // ../workspace-tools/src/utils/typia-transform.ts
4579
+ import transform2 from "typia/lib/transform";
4580
+
4581
+ export {
4582
+ run,
4583
+ withRunExecutor,
4584
+ withRunGenerator,
4585
+ initGenerator
4586
+ };