@storm-software/cloudflare-tools 0.48.0 → 0.49.1

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