@storm-software/unbuild 0.17.0 → 0.17.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 (46) hide show
  1. package/README.md +1 -1
  2. package/dist/build.cjs +15 -0
  3. package/dist/build.d.cts +13 -0
  4. package/dist/build.d.ts +13 -0
  5. package/dist/build.js +15 -0
  6. package/dist/chunk-3GQAWCBQ.js +13 -0
  7. package/dist/chunk-3VV4SMHK.js +65 -0
  8. package/dist/chunk-425BMCFI.cjs +31 -0
  9. package/dist/chunk-5N2TOSNK.cjs +21 -0
  10. package/dist/chunk-5RCA5OSO.cjs +35 -0
  11. package/dist/chunk-6G4AZLTO.cjs +28 -0
  12. package/dist/chunk-BGYQAVKQ.cjs +13 -0
  13. package/dist/chunk-C2GKE7R5.js +35 -0
  14. package/dist/chunk-D7L56O4W.js +1039 -0
  15. package/dist/chunk-DWREBCC4.cjs +557 -0
  16. package/dist/chunk-EES2DAYR.cjs +65 -0
  17. package/dist/chunk-FYSN6ZVI.js +21 -0
  18. package/dist/chunk-GGNOJ77I.js +0 -0
  19. package/dist/chunk-KVVGB74V.js +31 -0
  20. package/dist/chunk-LGSLDHM4.cjs +31 -0
  21. package/dist/chunk-OP52W2X6.cjs +35 -0
  22. package/dist/chunk-P5CSSAMQ.js +557 -0
  23. package/dist/chunk-REG7YZIZ.js +31 -0
  24. package/dist/chunk-SFZRYJZ2.cjs +1 -0
  25. package/dist/chunk-V3TNL7N7.cjs +1039 -0
  26. package/dist/chunk-VN5I7Q45.js +28 -0
  27. package/dist/chunk-X42DGJLB.js +35 -0
  28. package/dist/clean-DgUPedep.d.cts +1194 -0
  29. package/dist/clean-DgUPedep.d.ts +1194 -0
  30. package/dist/clean.cjs +8 -0
  31. package/dist/clean.d.cts +2 -0
  32. package/dist/clean.d.ts +2 -0
  33. package/dist/clean.js +8 -0
  34. package/dist/config.cjs +13 -0
  35. package/dist/config.d.cts +8 -0
  36. package/dist/config.d.ts +8 -0
  37. package/dist/config.js +13 -0
  38. package/dist/index.cjs +27 -0
  39. package/dist/index.d.cts +23 -0
  40. package/dist/index.d.ts +23 -0
  41. package/dist/index.js +27 -0
  42. package/dist/types.cjs +1 -0
  43. package/dist/types.d.cts +30 -0
  44. package/dist/types.d.ts +30 -0
  45. package/dist/types.js +1 -0
  46. package/package.json +1 -1
@@ -0,0 +1,1039 @@
1
+ import {
2
+ clean
3
+ } from "./chunk-FYSN6ZVI.js";
4
+ import {
5
+ getDefaultBuildPlugins
6
+ } from "./chunk-KVVGB74V.js";
7
+ import {
8
+ loadConfig
9
+ } from "./chunk-3VV4SMHK.js";
10
+ import {
11
+ COLOR_KEYS,
12
+ LogLevel,
13
+ LogLevelLabel,
14
+ STORM_DEFAULT_DOCS,
15
+ STORM_DEFAULT_HOMEPAGE,
16
+ STORM_DEFAULT_LICENSING,
17
+ correctPaths,
18
+ findWorkspaceRoot,
19
+ formatLogMessage,
20
+ getDefaultConfig,
21
+ getLogLevel,
22
+ getLogLevelLabel,
23
+ getStopwatch,
24
+ isVerbose,
25
+ joinPaths,
26
+ writeDebug,
27
+ writeFatal,
28
+ writeSuccess,
29
+ writeSystem,
30
+ writeTrace,
31
+ writeWarning
32
+ } from "./chunk-P5CSSAMQ.js";
33
+ import {
34
+ __name
35
+ } from "./chunk-3GQAWCBQ.js";
36
+
37
+ // src/build.ts
38
+ import { hfs as hfs4 } from "@humanfs/node";
39
+ import { createProjectGraphAsync as createProjectGraphAsync3, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph3, writeJsonFile } from "@nx/devkit";
40
+ import { getHelperDependency, HelperDependency } from "@nx/js";
41
+ import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
42
+
43
+ // ../build-tools/src/plugins/swc.ts
44
+ import { transform } from "@swc/core";
45
+
46
+ // ../build-tools/src/plugins/ts-resolve.ts
47
+ import fs from "node:fs";
48
+ import { builtinModules } from "node:module";
49
+ import path from "node:path";
50
+ import _resolve from "resolve";
51
+
52
+ // ../build-tools/src/plugins/type-definitions.ts
53
+ import { stripIndents } from "@nx/devkit";
54
+ import { relative } from "path";
55
+
56
+ // ../build-tools/src/utilities/copy-assets.ts
57
+ import { hfs as hfs2 } from "@humanfs/node";
58
+ import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
59
+ import { copyAssets as copyAssetsBase } from "@nx/js";
60
+ import { glob } from "glob";
61
+
62
+ // ../build-tools/src/utilities/read-nx-config.ts
63
+ import { hfs } from "@humanfs/node";
64
+
65
+ // ../config-tools/src/config-file/get-config-file.ts
66
+ import { loadConfig as loadConfig2 } from "c12";
67
+ import defu from "defu";
68
+ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
69
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
70
+ let config = loadConfig2({
71
+ cwd: workspacePath,
72
+ packageJson: true,
73
+ name: fileName,
74
+ envName: fileName?.toUpperCase(),
75
+ jitiOptions: {
76
+ debug: false,
77
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
78
+ },
79
+ ...options
80
+ });
81
+ if (!config || Object.keys(config).length === 0) {
82
+ config = loadConfig2({
83
+ cwd: workspacePath,
84
+ packageJson: true,
85
+ name: fileName,
86
+ envName: fileName?.toUpperCase(),
87
+ jitiOptions: {
88
+ debug: false,
89
+ cache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache", "storm")
90
+ },
91
+ configFile: fileName,
92
+ ...options
93
+ });
94
+ }
95
+ return config;
96
+ }, "getConfigFileByName");
97
+ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
98
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
99
+ const result = await getConfigFileByName("storm", workspacePath);
100
+ let config = result.config;
101
+ const configFile = result.configFile;
102
+ if (config && configFile && Object.keys(config).length > 0) {
103
+ writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
104
+ logLevel: "all"
105
+ });
106
+ }
107
+ if (additionalFileNames && additionalFileNames.length > 0) {
108
+ const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
109
+ for (const result2 of results) {
110
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
111
+ writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
112
+ logLevel: "all"
113
+ });
114
+ config = defu(result2.config ?? {}, config ?? {});
115
+ }
116
+ }
117
+ }
118
+ if (!config) {
119
+ return void 0;
120
+ }
121
+ config.configFile = configFile;
122
+ return config;
123
+ }, "getConfigFile");
124
+
125
+ // ../config-tools/src/create-storm-config.ts
126
+ import defu2 from "defu";
127
+
128
+ // ../config-tools/src/env/get-env.ts
129
+ var getConfigEnv = /* @__PURE__ */ __name(() => {
130
+ const prefix = "STORM_";
131
+ let config = {
132
+ extends: process.env[`${prefix}EXTENDS`] || void 0,
133
+ name: process.env[`${prefix}NAME`] || void 0,
134
+ namespace: process.env[`${prefix}NAMESPACE`] || void 0,
135
+ owner: process.env[`${prefix}OWNER`] || void 0,
136
+ bot: {
137
+ name: process.env[`${prefix}BOT_NAME`] || void 0,
138
+ email: process.env[`${prefix}BOT_EMAIL`] || void 0
139
+ },
140
+ organization: process.env[`${prefix}ORGANIZATION`] || void 0,
141
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
142
+ license: process.env[`${prefix}LICENSE`] || void 0,
143
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
144
+ docs: process.env[`${prefix}DOCS`] || void 0,
145
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
146
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
147
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
148
+ configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
149
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
150
+ directories: {
151
+ cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
152
+ data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
153
+ config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
154
+ temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
155
+ log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
156
+ build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
157
+ },
158
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
159
+ env: (process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
160
+ // ci:
161
+ // process.env[`${prefix}CI`] !== undefined
162
+ // ? Boolean(
163
+ // process.env[`${prefix}CI`] ??
164
+ // process.env.CI ??
165
+ // process.env.CONTINUOUS_INTEGRATION
166
+ // )
167
+ // : undefined,
168
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
169
+ branch: process.env[`${prefix}BRANCH`] || void 0,
170
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
171
+ externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
172
+ registry: {
173
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
174
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
175
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
176
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
177
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
178
+ },
179
+ logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0
180
+ };
181
+ const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
182
+ config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
183
+ ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
184
+ return ret;
185
+ }, {}) : getThemeColorConfigEnv(prefix);
186
+ if (config.docs === STORM_DEFAULT_DOCS) {
187
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
188
+ config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
189
+ } else {
190
+ config.docs = `${config.homepage}/docs`;
191
+ }
192
+ }
193
+ if (config.licensing === STORM_DEFAULT_LICENSING) {
194
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
195
+ config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
196
+ } else {
197
+ config.licensing = `${config.homepage}/docs`;
198
+ }
199
+ }
200
+ const serializedConfig = process.env[`${prefix}CONFIG`];
201
+ if (serializedConfig) {
202
+ const parsed = JSON.parse(serializedConfig);
203
+ config = {
204
+ ...config,
205
+ ...parsed,
206
+ colors: {
207
+ ...config.colors,
208
+ ...parsed.colors
209
+ },
210
+ extensions: {
211
+ ...config.extensions,
212
+ ...parsed.extensions
213
+ }
214
+ };
215
+ }
216
+ return config;
217
+ }, "getConfigEnv");
218
+ var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
219
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
220
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
221
+ }, "getThemeColorConfigEnv");
222
+ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
223
+ return {
224
+ dark: process.env[`${prefix}DARK`],
225
+ light: process.env[`${prefix}LIGHT`],
226
+ brand: process.env[`${prefix}BRAND`],
227
+ alternate: process.env[`${prefix}ALTERNATE`],
228
+ accent: process.env[`${prefix}ACCENT`],
229
+ link: process.env[`${prefix}LINK`],
230
+ help: process.env[`${prefix}HELP`],
231
+ success: process.env[`${prefix}SUCCESS`],
232
+ info: process.env[`${prefix}INFO`],
233
+ warning: process.env[`${prefix}WARNING`],
234
+ danger: process.env[`${prefix}DANGER`],
235
+ fatal: process.env[`${prefix}FATAL`],
236
+ positive: process.env[`${prefix}POSITIVE`],
237
+ negative: process.env[`${prefix}NEGATIVE`]
238
+ };
239
+ }, "getSingleThemeColorConfigEnv");
240
+ var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
241
+ return {
242
+ light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
243
+ dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
244
+ };
245
+ }, "getMultiThemeColorConfigEnv");
246
+ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
247
+ return {
248
+ foreground: process.env[`${prefix}FOREGROUND`],
249
+ background: process.env[`${prefix}BACKGROUND`],
250
+ brand: process.env[`${prefix}BRAND`],
251
+ alternate: process.env[`${prefix}ALTERNATE`],
252
+ accent: process.env[`${prefix}ACCENT`],
253
+ link: process.env[`${prefix}LINK`],
254
+ help: process.env[`${prefix}HELP`],
255
+ success: process.env[`${prefix}SUCCESS`],
256
+ info: process.env[`${prefix}INFO`],
257
+ warning: process.env[`${prefix}WARNING`],
258
+ danger: process.env[`${prefix}DANGER`],
259
+ fatal: process.env[`${prefix}FATAL`],
260
+ positive: process.env[`${prefix}POSITIVE`],
261
+ negative: process.env[`${prefix}NEGATIVE`]
262
+ };
263
+ }, "getBaseThemeColorConfigEnv");
264
+
265
+ // ../config-tools/src/env/set-env.ts
266
+ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
267
+ for (const key of Object.keys(extension ?? {})) {
268
+ if (extension[key]) {
269
+ const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
270
+ let extensionKey;
271
+ if (result.length === 0) {
272
+ return;
273
+ }
274
+ if (result.length === 1) {
275
+ extensionKey = result[0]?.toUpperCase() ?? "";
276
+ } else {
277
+ extensionKey = result.reduce((ret, part) => {
278
+ return `${ret}_${part.toLowerCase()}`;
279
+ });
280
+ }
281
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
282
+ }
283
+ }
284
+ }, "setExtensionEnv");
285
+ var setConfigEnv = /* @__PURE__ */ __name((config) => {
286
+ const prefix = "STORM_";
287
+ if (config.extends) {
288
+ process.env[`${prefix}EXTENDS`] = config.extends;
289
+ }
290
+ if (config.name) {
291
+ process.env[`${prefix}NAME`] = config.name;
292
+ }
293
+ if (config.namespace) {
294
+ process.env[`${prefix}NAMESPACE`] = config.namespace;
295
+ }
296
+ if (config.owner) {
297
+ process.env[`${prefix}OWNER`] = config.owner;
298
+ }
299
+ if (config.bot) {
300
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
301
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
302
+ }
303
+ if (config.organization) {
304
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
305
+ }
306
+ if (config.packageManager) {
307
+ process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
308
+ }
309
+ if (config.license) {
310
+ process.env[`${prefix}LICENSE`] = config.license;
311
+ }
312
+ if (config.homepage) {
313
+ process.env[`${prefix}HOMEPAGE`] = config.homepage;
314
+ }
315
+ if (config.docs) {
316
+ process.env[`${prefix}DOCS`] = config.docs;
317
+ }
318
+ if (config.licensing) {
319
+ process.env[`${prefix}LICENSING`] = config.licensing;
320
+ }
321
+ if (config.timezone) {
322
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
323
+ process.env.TZ = config.timezone;
324
+ process.env.DEFAULT_TIMEZONE = config.timezone;
325
+ }
326
+ if (config.locale) {
327
+ process.env[`${prefix}LOCALE`] = config.locale;
328
+ process.env.LOCALE = config.locale;
329
+ process.env.DEFAULT_LOCALE = config.locale;
330
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
331
+ }
332
+ if (config.configFile) {
333
+ process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
334
+ }
335
+ if (config.workspaceRoot) {
336
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
337
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
338
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
339
+ }
340
+ if (config.directories) {
341
+ if (!config.skipCache && config.directories.cache) {
342
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
343
+ }
344
+ if (config.directories.data) {
345
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
346
+ }
347
+ if (config.directories.config) {
348
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
349
+ }
350
+ if (config.directories.temp) {
351
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
352
+ }
353
+ if (config.directories.log) {
354
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
355
+ }
356
+ if (config.directories.build) {
357
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
358
+ }
359
+ }
360
+ if (config.skipCache !== void 0) {
361
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
362
+ if (config.skipCache) {
363
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
364
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
365
+ }
366
+ }
367
+ if (config.env) {
368
+ process.env[`${prefix}ENV`] = config.env;
369
+ process.env.NODE_ENV = config.env;
370
+ process.env.ENVIRONMENT = config.env;
371
+ }
372
+ if (config.colors?.base?.light || config.colors?.base?.dark) {
373
+ for (const key of Object.keys(config.colors)) {
374
+ setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
375
+ }
376
+ } else {
377
+ setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
378
+ }
379
+ if (config.repository) {
380
+ process.env[`${prefix}REPOSITORY`] = config.repository;
381
+ }
382
+ if (config.branch) {
383
+ process.env[`${prefix}BRANCH`] = config.branch;
384
+ }
385
+ if (config.preid) {
386
+ process.env[`${prefix}PRE_ID`] = String(config.preid);
387
+ }
388
+ if (config.externalPackagePatterns) {
389
+ process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
390
+ }
391
+ if (config.registry) {
392
+ if (config.registry.github) {
393
+ process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
394
+ }
395
+ if (config.registry.npm) {
396
+ process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
397
+ }
398
+ if (config.registry.cargo) {
399
+ process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
400
+ }
401
+ if (config.registry.cyclone) {
402
+ process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
403
+ }
404
+ if (config.registry.container) {
405
+ process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
406
+ }
407
+ }
408
+ if (config.logLevel) {
409
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
410
+ process.env.LOG_LEVEL = String(config.logLevel);
411
+ process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
412
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
413
+ }
414
+ process.env[`${prefix}CONFIG`] = JSON.stringify(config);
415
+ for (const key of Object.keys(config.extensions ?? {})) {
416
+ config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
417
+ }
418
+ }, "setConfigEnv");
419
+ var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
420
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
421
+ }, "setThemeColorConfigEnv");
422
+ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
423
+ if (config.dark) {
424
+ process.env[`${prefix}DARK`] = config.dark;
425
+ }
426
+ if (config.light) {
427
+ process.env[`${prefix}LIGHT`] = config.light;
428
+ }
429
+ if (config.brand) {
430
+ process.env[`${prefix}BRAND`] = config.brand;
431
+ }
432
+ if (config.alternate) {
433
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
434
+ }
435
+ if (config.accent) {
436
+ process.env[`${prefix}ACCENT`] = config.accent;
437
+ }
438
+ if (config.link) {
439
+ process.env[`${prefix}LINK`] = config.link;
440
+ }
441
+ if (config.help) {
442
+ process.env[`${prefix}HELP`] = config.help;
443
+ }
444
+ if (config.success) {
445
+ process.env[`${prefix}SUCCESS`] = config.success;
446
+ }
447
+ if (config.info) {
448
+ process.env[`${prefix}INFO`] = config.info;
449
+ }
450
+ if (config.warning) {
451
+ process.env[`${prefix}WARNING`] = config.warning;
452
+ }
453
+ if (config.danger) {
454
+ process.env[`${prefix}DANGER`] = config.danger;
455
+ }
456
+ if (config.fatal) {
457
+ process.env[`${prefix}FATAL`] = config.fatal;
458
+ }
459
+ if (config.positive) {
460
+ process.env[`${prefix}POSITIVE`] = config.positive;
461
+ }
462
+ if (config.negative) {
463
+ process.env[`${prefix}NEGATIVE`] = config.negative;
464
+ }
465
+ }, "setSingleThemeColorConfigEnv");
466
+ var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
467
+ return {
468
+ light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
469
+ dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
470
+ };
471
+ }, "setMultiThemeColorConfigEnv");
472
+ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
473
+ if (config.foreground) {
474
+ process.env[`${prefix}FOREGROUND`] = config.foreground;
475
+ }
476
+ if (config.background) {
477
+ process.env[`${prefix}BACKGROUND`] = config.background;
478
+ }
479
+ if (config.brand) {
480
+ process.env[`${prefix}BRAND`] = config.brand;
481
+ }
482
+ if (config.alternate) {
483
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
484
+ }
485
+ if (config.accent) {
486
+ process.env[`${prefix}ACCENT`] = config.accent;
487
+ }
488
+ if (config.link) {
489
+ process.env[`${prefix}LINK`] = config.link;
490
+ }
491
+ if (config.help) {
492
+ process.env[`${prefix}HELP`] = config.help;
493
+ }
494
+ if (config.success) {
495
+ process.env[`${prefix}SUCCESS`] = config.success;
496
+ }
497
+ if (config.info) {
498
+ process.env[`${prefix}INFO`] = config.info;
499
+ }
500
+ if (config.warning) {
501
+ process.env[`${prefix}WARNING`] = config.warning;
502
+ }
503
+ if (config.danger) {
504
+ process.env[`${prefix}DANGER`] = config.danger;
505
+ }
506
+ if (config.fatal) {
507
+ process.env[`${prefix}FATAL`] = config.fatal;
508
+ }
509
+ if (config.positive) {
510
+ process.env[`${prefix}POSITIVE`] = config.positive;
511
+ }
512
+ if (config.negative) {
513
+ process.env[`${prefix}NEGATIVE`] = config.negative;
514
+ }
515
+ }, "setBaseThemeColorConfigEnv");
516
+
517
+ // ../config-tools/src/create-storm-config.ts
518
+ var _static_cache = void 0;
519
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
520
+ let config = {};
521
+ if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
522
+ writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
523
+ return _static_cache.data;
524
+ }
525
+ let _workspaceRoot = workspaceRoot;
526
+ if (!_workspaceRoot) {
527
+ _workspaceRoot = findWorkspaceRoot();
528
+ }
529
+ const configFile = await getConfigFile(_workspaceRoot);
530
+ if (!configFile) {
531
+ writeWarning("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
532
+ logLevel: "all"
533
+ });
534
+ }
535
+ config = defu2(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
536
+ setConfigEnv(config);
537
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
538
+ ${formatLogMessage(config)}`, config);
539
+ return config;
540
+ }, "loadStormConfig");
541
+
542
+ // ../build-tools/src/utilities/read-nx-config.ts
543
+ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
544
+ let rootDir = workspaceRoot;
545
+ if (!rootDir) {
546
+ const config = await loadStormConfig();
547
+ rootDir = config.workspaceRoot;
548
+ }
549
+ const nxJsonPath = joinPaths(rootDir, "nx.json");
550
+ if (!await hfs.isFile(nxJsonPath)) {
551
+ throw new Error("Cannot find project.json configuration");
552
+ }
553
+ return hfs.json(nxJsonPath);
554
+ }, "readNxConfig");
555
+
556
+ // ../build-tools/src/utilities/copy-assets.ts
557
+ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
558
+ const pendingAssets = Array.from(assets ?? []);
559
+ if (!pendingAssets?.some((asset) => asset?.glob === "*.md")) {
560
+ pendingAssets.push({
561
+ input: projectRoot,
562
+ glob: "*.md",
563
+ output: "/"
564
+ });
565
+ }
566
+ if (generatePackageJson2 === false) {
567
+ pendingAssets.push({
568
+ input: sourceRoot,
569
+ glob: "package.json",
570
+ output: "."
571
+ });
572
+ }
573
+ if (!pendingAssets?.some((asset) => asset?.glob === "LICENSE")) {
574
+ pendingAssets.push({
575
+ input: "",
576
+ glob: "LICENSE",
577
+ output: "."
578
+ });
579
+ }
580
+ if (includeSrc === true) {
581
+ pendingAssets.push({
582
+ input: sourceRoot,
583
+ glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
584
+ output: "src/"
585
+ });
586
+ }
587
+ const nxJson = readNxConfig(config.workspaceRoot);
588
+ const projectGraph = await createProjectGraphAsync({
589
+ exitOnError: true
590
+ });
591
+ const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
592
+ if (!projectsConfigurations?.projects?.[projectName]) {
593
+ 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.");
594
+ }
595
+ const buildTarget = projectsConfigurations.projects[projectName]?.targets?.build;
596
+ if (!buildTarget) {
597
+ 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")}`);
598
+ }
599
+ const result = await copyAssetsBase({
600
+ assets,
601
+ watch: false,
602
+ outputPath
603
+ }, {
604
+ root: config.workspaceRoot,
605
+ targetName: "build",
606
+ target: buildTarget,
607
+ projectName,
608
+ projectGraph,
609
+ projectsConfigurations,
610
+ nxJsonConfiguration: nxJson,
611
+ cwd: config.workspaceRoot,
612
+ isVerbose: isVerbose(config.logLevel)
613
+ });
614
+ if (!result.success) {
615
+ throw new Error("The Build process failed trying to copy assets");
616
+ }
617
+ if (includeSrc === true) {
618
+ writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
619
+ const files = await glob([
620
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
621
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
622
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
623
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
624
+ ]);
625
+ await Promise.allSettled(files.map(async (file) => hfs2.write(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
626
+
627
+ ${await hfs2.text(file)}
628
+
629
+ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
630
+ }
631
+ }, "copyAssets");
632
+
633
+ // ../build-tools/src/utilities/generate-package-json.ts
634
+ import { hfs as hfs3 } from "@humanfs/node";
635
+ import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
636
+ import { Glob } from "glob";
637
+ import { createProjectGraphAsync as createProjectGraphAsync2, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2 } from "nx/src/project-graph/project-graph";
638
+ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
639
+ const projectGraph = await createProjectGraphAsync2({
640
+ exitOnError: true
641
+ });
642
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
643
+ if (!projectConfigurations?.projects?.[projectName]) {
644
+ 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.");
645
+ }
646
+ const projectJsonPath = joinPaths(workspaceRoot, projectRoot, "project.json");
647
+ if (!await hfs3.isFile(projectJsonPath)) {
648
+ throw new Error("Cannot find project.json configuration");
649
+ }
650
+ if (!projectConfigurations?.projects?.[projectName]) {
651
+ 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.");
652
+ }
653
+ const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
654
+ const localPackages = [];
655
+ for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
656
+ const projectNode = project.node;
657
+ if (projectNode.data.root) {
658
+ const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
659
+ if (await hfs3.isFile(projectPackageJsonPath)) {
660
+ const projectPackageJson = await hfs3.json(projectPackageJsonPath);
661
+ if (projectPackageJson.private !== false) {
662
+ localPackages.push(projectPackageJson);
663
+ }
664
+ }
665
+ }
666
+ }
667
+ if (localPackages.length > 0) {
668
+ writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
669
+ packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
670
+ if (!ret[localPackage.name]) {
671
+ ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
672
+ }
673
+ return ret;
674
+ }, packageJson.peerDependencies ?? {});
675
+ packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
676
+ if (!ret[localPackage.name]) {
677
+ ret[localPackage.name] = {
678
+ optional: false
679
+ };
680
+ }
681
+ return ret;
682
+ }, packageJson.peerDependenciesMeta ?? {});
683
+ packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
684
+ if (!ret[localPackage.name]) {
685
+ ret[localPackage.name] = localPackage.version || "0.0.1";
686
+ }
687
+ return ret;
688
+ }, packageJson.peerDependencies ?? {});
689
+ } else {
690
+ writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
691
+ }
692
+ return packageJson;
693
+ }, "addPackageDependencies");
694
+ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
695
+ const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
696
+ const workspacePackageJson = await hfs3.json(joinPaths(workspaceRoot, "package.json"));
697
+ packageJson.type ??= "module";
698
+ packageJson.sideEffects ??= false;
699
+ if (includeSrc === true) {
700
+ let distSrc = sourceRoot.replace(projectRoot, "");
701
+ if (distSrc.startsWith("/")) {
702
+ distSrc = distSrc.substring(1);
703
+ }
704
+ packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
705
+ }
706
+ packageJson.files ??= [
707
+ "dist/**/*"
708
+ ];
709
+ if (includeSrc === true && !packageJson.files.includes("src")) {
710
+ packageJson.files.push("src/**/*");
711
+ }
712
+ packageJson.publishConfig ??= {
713
+ access: "public"
714
+ };
715
+ packageJson.description ??= workspacePackageJson.description;
716
+ packageJson.homepage ??= workspacePackageJson.homepage;
717
+ packageJson.bugs ??= workspacePackageJson.bugs;
718
+ packageJson.license ??= workspacePackageJson.license;
719
+ packageJson.keywords ??= workspacePackageJson.keywords;
720
+ packageJson.funding ??= workspacePackageJson.funding;
721
+ packageJson.author ??= workspacePackageJson.author;
722
+ packageJson.maintainers ??= workspacePackageJson.maintainers;
723
+ if (!packageJson.maintainers && packageJson.author) {
724
+ packageJson.maintainers = [
725
+ packageJson.author
726
+ ];
727
+ }
728
+ packageJson.contributors ??= workspacePackageJson.contributors;
729
+ if (!packageJson.contributors && packageJson.author) {
730
+ packageJson.contributors = [
731
+ packageJson.author
732
+ ];
733
+ }
734
+ packageJson.repository ??= workspacePackageJson.repository;
735
+ packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
736
+ return packageJson;
737
+ }, "addWorkspacePackageJsonFields");
738
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
739
+ let entry = file.replaceAll("\\", "/");
740
+ if (sourceRoot) {
741
+ entry = entry.replace(sourceRoot, "");
742
+ }
743
+ return {
744
+ "import": {
745
+ "types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
746
+ "default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
747
+ },
748
+ "require": {
749
+ "types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
750
+ "default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
751
+ },
752
+ "default": {
753
+ "types": `./dist/${entry}.d.ts`,
754
+ "default": `./dist/${entry}.js`
755
+ }
756
+ };
757
+ }, "addPackageJsonExport");
758
+ var addPackageJsonExports = /* @__PURE__ */ __name(async (sourceRoot, packageJson) => {
759
+ packageJson.exports ??= {};
760
+ const files = await new Glob("**/*.{ts,tsx}", {
761
+ absolute: false,
762
+ cwd: sourceRoot,
763
+ root: sourceRoot
764
+ }).walk();
765
+ files.forEach((file) => {
766
+ addPackageJsonExport(file, packageJson.type, sourceRoot);
767
+ const split = file.split(".");
768
+ split.pop();
769
+ const entry = split.join(".").replaceAll("\\", "/");
770
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, sourceRoot);
771
+ });
772
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
773
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
774
+ packageJson.types = "./dist/index.d.ts";
775
+ packageJson.exports ??= {};
776
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
777
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
778
+ ret[key.replace("/index", "")] = packageJson.exports[key];
779
+ }
780
+ return ret;
781
+ }, packageJson.exports);
782
+ packageJson.exports["./package.json"] ??= "./package.json";
783
+ packageJson.exports["."] = packageJson.exports["."] ?? addPackageJsonExport("index", packageJson.type, sourceRoot);
784
+ return packageJson;
785
+ }, "addPackageJsonExports");
786
+
787
+ // ../build-tools/src/utilities/get-entry-points.ts
788
+ import { glob as glob2 } from "glob";
789
+
790
+ // ../build-tools/src/utilities/task-graph.ts
791
+ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
792
+
793
+ // src/build.ts
794
+ import defu3 from "defu";
795
+ import { relative as relative2 } from "node:path";
796
+ import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
797
+ import { build as unbuild } from "unbuild";
798
+ async function resolveOptions(options) {
799
+ const projectRoot = options.projectRoot;
800
+ if (!projectRoot) {
801
+ throw new Error("Cannot find project root");
802
+ }
803
+ const outputPath = options.outputPath || joinPaths("dist", projectRoot);
804
+ const workspaceRoot = findWorkspaceRoot2(projectRoot);
805
+ if (!workspaceRoot) {
806
+ throw new Error("Cannot find workspace root");
807
+ }
808
+ const config = await loadStormConfig(workspaceRoot.dir);
809
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
810
+ const stopwatch = getStopwatch("Build options resolution");
811
+ if (options.configPath) {
812
+ const configFile = await loadConfig(options.configPath);
813
+ if (configFile) {
814
+ options = defu3(options, configFile);
815
+ }
816
+ }
817
+ const projectGraph = await createProjectGraphAsync3({
818
+ exitOnError: true
819
+ });
820
+ const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
821
+ if (!await hfs4.isFile(projectJsonPath)) {
822
+ throw new Error("Cannot find project.json configuration");
823
+ }
824
+ const projectJson = await hfs4.json(projectJsonPath);
825
+ const projectName = projectJson.name;
826
+ const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
827
+ if (!await hfs4.isFile(packageJsonPath)) {
828
+ throw new Error("Cannot find package.json configuration");
829
+ }
830
+ const packageJson = await hfs4.json(packageJsonPath);
831
+ let tsconfig = options.tsconfig;
832
+ if (!tsconfig) {
833
+ tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
834
+ }
835
+ if (!await hfs4.isFile(tsconfig)) {
836
+ throw new Error("Cannot find tsconfig.json configuration");
837
+ }
838
+ let sourceRoot = projectJson.sourceRoot;
839
+ if (!sourceRoot) {
840
+ sourceRoot = joinPaths(projectRoot, "src");
841
+ }
842
+ if (!await hfs4.isDirectory(sourceRoot)) {
843
+ throw new Error("Cannot find sourceRoot directory");
844
+ }
845
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph3(projectGraph);
846
+ if (!projectConfigurations?.projects?.[projectName]) {
847
+ 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.");
848
+ }
849
+ const result = calculateProjectBuildableDependencies2(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
850
+ let dependencies = result.dependencies;
851
+ const tsLibDependency = getHelperDependency(HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
852
+ if (tsLibDependency) {
853
+ dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
854
+ dependencies.push(tsLibDependency);
855
+ }
856
+ const resolvedOptions = {
857
+ name: projectName,
858
+ config,
859
+ projectRoot,
860
+ sourceRoot,
861
+ projectName,
862
+ tsconfig,
863
+ clean: false,
864
+ entries: [
865
+ {
866
+ builder: "mkdist",
867
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
868
+ outDir: joinPaths(relative2(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
869
+ declaration: options.emitTypes !== false,
870
+ format: "esm"
871
+ },
872
+ {
873
+ builder: "mkdist",
874
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
875
+ outDir: joinPaths(relative2(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
876
+ declaration: options.emitTypes !== false,
877
+ format: "cjs",
878
+ ext: "cjs"
879
+ }
880
+ ],
881
+ declaration: options.emitTypes !== false ? "compatible" : false,
882
+ failOnWarn: false,
883
+ sourcemap: options.sourcemap ?? !!options.debug,
884
+ outDir: outputPath,
885
+ parallel: true,
886
+ stub: false,
887
+ stubOptions: {
888
+ jiti: {}
889
+ },
890
+ externals: options.external ?? [],
891
+ dependencies: [],
892
+ peerDependencies: [],
893
+ devDependencies: [],
894
+ hooks: {},
895
+ alias: {},
896
+ replace: {},
897
+ rollup: {
898
+ replace: {},
899
+ alias: {},
900
+ json: {},
901
+ commonjs: {
902
+ sourceMap: options.sourcemap ?? true
903
+ },
904
+ emitCJS: true,
905
+ cjsBridge: true,
906
+ dts: {
907
+ respectExternal: true,
908
+ tsconfig
909
+ },
910
+ output: {
911
+ banner: options.banner || `
912
+ // \u26A1 Built by Storm Software
913
+ `,
914
+ footer: options.footer
915
+ },
916
+ resolve: {
917
+ preferBuiltins: true,
918
+ extensions: [
919
+ ".cjs",
920
+ ".mjs",
921
+ ".js",
922
+ ".jsx",
923
+ ".ts",
924
+ ".tsx",
925
+ ".json"
926
+ ]
927
+ },
928
+ esbuild: {
929
+ minify: !!options.minify,
930
+ splitting: options.splitting !== false,
931
+ treeShaking: options.treeShaking !== false,
932
+ color: true,
933
+ logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
934
+ }
935
+ }
936
+ };
937
+ dependencies = dependencies.filter((dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app");
938
+ if (dependencies.length > 0) {
939
+ resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
940
+ }
941
+ if (packageJson.devDependencies) {
942
+ resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
943
+ }
944
+ if (packageJson.peerDependencies) {
945
+ resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
946
+ }
947
+ if (options.rollup) {
948
+ let rollup = {};
949
+ if (typeof options.rollup === "string") {
950
+ const rollupFile = await loadConfig(options.rollup);
951
+ if (rollupFile) {
952
+ rollup = rollupFile;
953
+ }
954
+ } else {
955
+ rollup = options.rollup;
956
+ }
957
+ resolvedOptions.rollup = defu3(resolvedOptions.rollup ?? {}, rollup);
958
+ }
959
+ resolvedOptions.hooks = {
960
+ "rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
961
+ opts.plugins = options.plugins ?? await getDefaultBuildPlugins(options, resolvedOptions);
962
+ }, "rollup:options")
963
+ };
964
+ stopwatch();
965
+ return resolvedOptions;
966
+ }
967
+ __name(resolveOptions, "resolveOptions");
968
+ async function generatePackageJson(options) {
969
+ if (options.generatePackageJson !== false && await hfs4.isFile(joinPaths(options.projectRoot, "package.json"))) {
970
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
971
+ const stopwatch = getStopwatch("Write package.json file");
972
+ const packageJsonPath = joinPaths(options.projectRoot, "project.json");
973
+ if (!await hfs4.isFile(packageJsonPath)) {
974
+ throw new Error("Cannot find package.json configuration");
975
+ }
976
+ let packageJson = await hfs4.json(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"));
977
+ if (!packageJson) {
978
+ throw new Error("Cannot find package.json configuration file");
979
+ }
980
+ packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
981
+ packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
982
+ packageJson = await addPackageJsonExports(options.sourceRoot, packageJson);
983
+ await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
984
+ stopwatch();
985
+ }
986
+ return options;
987
+ }
988
+ __name(generatePackageJson, "generatePackageJson");
989
+ async function executeUnbuild(options) {
990
+ writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
991
+ const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
992
+ try {
993
+ await unbuild(options.projectRoot, false, {
994
+ ...options,
995
+ rootDir: options.projectRoot
996
+ });
997
+ } finally {
998
+ stopwatch();
999
+ }
1000
+ return options;
1001
+ }
1002
+ __name(executeUnbuild, "executeUnbuild");
1003
+ async function copyBuildAssets(options) {
1004
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
1005
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
1006
+ await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
1007
+ stopwatch();
1008
+ return options;
1009
+ }
1010
+ __name(copyBuildAssets, "copyBuildAssets");
1011
+ async function cleanOutputPath(options) {
1012
+ if (options.clean !== false && options.outDir) {
1013
+ await clean(options.name, options.outDir, options.config);
1014
+ }
1015
+ return options;
1016
+ }
1017
+ __name(cleanOutputPath, "cleanOutputPath");
1018
+ async function build(options) {
1019
+ writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
1020
+ const stopwatch = getStopwatch("Unbuild pipeline");
1021
+ try {
1022
+ const resolvedOptions = await resolveOptions(options);
1023
+ await cleanOutputPath(resolvedOptions);
1024
+ await generatePackageJson(resolvedOptions);
1025
+ await executeUnbuild(resolvedOptions);
1026
+ await copyBuildAssets(resolvedOptions);
1027
+ writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, resolvedOptions.config);
1028
+ } catch (error) {
1029
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
1030
+ throw error;
1031
+ } finally {
1032
+ stopwatch();
1033
+ }
1034
+ }
1035
+ __name(build, "build");
1036
+
1037
+ export {
1038
+ build
1039
+ };