@storm-software/unbuild 0.23.0 → 0.23.2

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 (73) hide show
  1. package/README.md +1 -1
  2. package/bin/unbuild.js +49761 -1652
  3. package/bin/unbuild.mjs +49737 -1611
  4. package/dist/build.js +16 -10
  5. package/dist/build.mjs +15 -9
  6. package/dist/chunk-26H2BQTK.mjs +2446 -0
  7. package/dist/{chunk-3OJD7CO4.js → chunk-27VOTZLA.js} +7 -5
  8. package/dist/chunk-3TNHGERR.mjs +49 -0
  9. package/dist/chunk-45FJ3WQ6.js +7528 -0
  10. package/dist/{chunk-BIZYEBW3.mjs → chunk-4ENAOJ33.mjs} +4 -2
  11. package/dist/chunk-4HFICKAT.js +451 -0
  12. package/dist/chunk-4IU7LXNH.mjs +4054 -0
  13. package/dist/{chunk-IIVTCNH5.mjs → chunk-4QTKZ7Y7.mjs} +5 -3
  14. package/dist/chunk-7G3WYTPJ.js +6 -0
  15. package/dist/chunk-AMTVM7UD.js +4054 -0
  16. package/dist/{chunk-WPOEGALQ.js → chunk-D4WJVAJM.js} +7 -5
  17. package/dist/chunk-DIRFSBOA.mjs +84 -0
  18. package/dist/chunk-EGCWTBMT.mjs +1120 -0
  19. package/dist/chunk-EKTZK3IJ.mjs +765 -0
  20. package/dist/chunk-FAXWFK7Q.mjs +7528 -0
  21. package/dist/chunk-J3DIENOH.mjs +3056 -0
  22. package/dist/{chunk-AICX43E6.mjs → chunk-JLKG5B52.mjs} +6584 -143
  23. package/dist/chunk-K5SQO3GD.mjs +451 -0
  24. package/dist/{chunk-DFIGNXGY.js → chunk-L76UPCDF.js} +7631 -1190
  25. package/dist/chunk-NMYL4VJJ.js +84 -0
  26. package/dist/chunk-NOVWJHZD.mjs +6 -0
  27. package/dist/{chunk-FDF3FMZP.mjs → chunk-NXZFF473.mjs} +5 -3
  28. package/dist/{chunk-RCEWRXM5.js → chunk-P6LWSWAQ.js} +4 -2
  29. package/dist/{chunk-XEAFTDQ7.js → chunk-QPMFJ7G7.js} +7 -5
  30. package/dist/chunk-RBSVNX4W.js +49 -0
  31. package/dist/chunk-RM7SW35Z.js +1120 -0
  32. package/dist/chunk-RNM4JSUG.js +29 -0
  33. package/dist/chunk-S532A3LO.js +510 -0
  34. package/dist/{chunk-T5NKX2EJ.mjs → chunk-TCARWZKA.mjs} +8 -6
  35. package/dist/{chunk-OG2CKJQU.mjs → chunk-UT4OJQUT.mjs} +5 -3
  36. package/dist/chunk-VJI72AA6.mjs +510 -0
  37. package/dist/chunk-W7YS7HE5.js +765 -0
  38. package/dist/chunk-X6Y2OZGW.js +3056 -0
  39. package/dist/chunk-YXF5LOZH.js +2449 -0
  40. package/dist/clean.js +4 -4
  41. package/dist/clean.mjs +3 -3
  42. package/dist/config.js +8 -8
  43. package/dist/config.mjs +7 -7
  44. package/dist/dist-JWSUGJW5.js +17571 -0
  45. package/dist/dist-LXRVOZWD.mjs +17570 -0
  46. package/dist/esm-2JSYGY2W.js +1716 -0
  47. package/dist/esm-2LICJFKF.mjs +1716 -0
  48. package/dist/execa-2KYLC5PR.mjs +2424 -0
  49. package/dist/execa-QRX32ES4.js +2424 -0
  50. package/dist/index.js +22 -11
  51. package/dist/index.mjs +21 -10
  52. package/dist/json5-JI6Y4EBT.mjs +10 -0
  53. package/dist/json5-ZRUT32KA.js +10 -0
  54. package/dist/jsonc-2MC7UMCL.js +15 -0
  55. package/dist/jsonc-PDDMSRDH.mjs +15 -0
  56. package/dist/multipart-parser-FQDS23TV.mjs +187 -0
  57. package/dist/multipart-parser-IX66WIWH.js +187 -0
  58. package/dist/toml-IHKP66UV.mjs +10 -0
  59. package/dist/toml-MDHAEB3G.js +10 -0
  60. package/dist/types.js +2 -1
  61. package/dist/types.mjs +2 -1
  62. package/dist/yaml-GMY56OHD.mjs +10 -0
  63. package/dist/yaml-UTMAXQ2T.js +10 -0
  64. package/package.json +3 -3
  65. package/dist/chunk-3GQAWCBQ.js +0 -13
  66. package/dist/chunk-AW52DUNE.mjs +0 -1043
  67. package/dist/chunk-AYRYNROK.js +0 -27
  68. package/dist/chunk-B5GGHMTB.mjs +0 -604
  69. package/dist/chunk-ERHVDARL.mjs +0 -0
  70. package/dist/chunk-LPEX4YW6.mjs +0 -13
  71. package/dist/chunk-OQPSH7GE.js +0 -604
  72. package/dist/chunk-OULCUN6I.js +0 -1
  73. package/dist/chunk-T2OTJN2D.js +0 -1043
@@ -0,0 +1,2446 @@
1
+ import {
2
+ basename,
3
+ dirname,
4
+ extname,
5
+ fileURLToPath,
6
+ findWorkspaceDir,
7
+ join,
8
+ readPackageJSON,
9
+ resolve
10
+ } from "./chunk-FAXWFK7Q.mjs";
11
+ import {
12
+ clean
13
+ } from "./chunk-4QTKZ7Y7.mjs";
14
+ import {
15
+ getDefaultBuildPlugins
16
+ } from "./chunk-TCARWZKA.mjs";
17
+ import {
18
+ loadConfig
19
+ } from "./chunk-JLKG5B52.mjs";
20
+ import {
21
+ LogLevel,
22
+ LogLevelLabel,
23
+ correctPaths,
24
+ findWorkspaceRoot,
25
+ formatLogMessage,
26
+ getDefaultConfig,
27
+ getLogLevel,
28
+ getLogLevelLabel,
29
+ getStopwatch,
30
+ isVerbose,
31
+ joinPaths,
32
+ writeDebug,
33
+ writeError,
34
+ writeFatal,
35
+ writeSuccess,
36
+ writeSystem,
37
+ writeTrace,
38
+ writeWarning
39
+ } from "./chunk-J3DIENOH.mjs";
40
+ import {
41
+ __commonJS,
42
+ __name,
43
+ __require,
44
+ __toESM,
45
+ init_esm_shims
46
+ } from "./chunk-3TNHGERR.mjs";
47
+
48
+ // ../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/package.json
49
+ var require_package = __commonJS({
50
+ "../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/package.json"(exports, module) {
51
+ module.exports = {
52
+ name: "dotenv",
53
+ version: "16.4.7",
54
+ description: "Loads environment variables from .env file",
55
+ main: "lib/main.js",
56
+ types: "lib/main.d.ts",
57
+ exports: {
58
+ ".": {
59
+ types: "./lib/main.d.ts",
60
+ require: "./lib/main.js",
61
+ default: "./lib/main.js"
62
+ },
63
+ "./config": "./config.js",
64
+ "./config.js": "./config.js",
65
+ "./lib/env-options": "./lib/env-options.js",
66
+ "./lib/env-options.js": "./lib/env-options.js",
67
+ "./lib/cli-options": "./lib/cli-options.js",
68
+ "./lib/cli-options.js": "./lib/cli-options.js",
69
+ "./package.json": "./package.json"
70
+ },
71
+ scripts: {
72
+ "dts-check": "tsc --project tests/types/tsconfig.json",
73
+ lint: "standard",
74
+ pretest: "npm run lint && npm run dts-check",
75
+ test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
76
+ "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",
77
+ prerelease: "npm test",
78
+ release: "standard-version"
79
+ },
80
+ repository: {
81
+ type: "git",
82
+ url: "git://github.com/motdotla/dotenv.git"
83
+ },
84
+ funding: "https://dotenvx.com",
85
+ keywords: [
86
+ "dotenv",
87
+ "env",
88
+ ".env",
89
+ "environment",
90
+ "variables",
91
+ "config",
92
+ "settings"
93
+ ],
94
+ readmeFilename: "README.md",
95
+ license: "BSD-2-Clause",
96
+ devDependencies: {
97
+ "@types/node": "^18.11.3",
98
+ decache: "^4.6.2",
99
+ sinon: "^14.0.1",
100
+ standard: "^17.0.0",
101
+ "standard-version": "^9.5.0",
102
+ tap: "^19.2.0",
103
+ typescript: "^4.8.4"
104
+ },
105
+ engines: {
106
+ node: ">=12"
107
+ },
108
+ browser: {
109
+ fs: false
110
+ }
111
+ };
112
+ }
113
+ });
114
+
115
+ // ../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/lib/main.js
116
+ var require_main = __commonJS({
117
+ "../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/lib/main.js"(exports, module) {
118
+ init_esm_shims();
119
+ var fs = __require("fs");
120
+ var path = __require("path");
121
+ var os = __require("os");
122
+ var crypto = __require("crypto");
123
+ var packageJson = require_package();
124
+ var version = packageJson.version;
125
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
126
+ function parse3(src) {
127
+ const obj = {};
128
+ let lines = src.toString();
129
+ lines = lines.replace(/\r\n?/mg, "\n");
130
+ let match;
131
+ while ((match = LINE.exec(lines)) != null) {
132
+ const key = match[1];
133
+ let value = match[2] || "";
134
+ value = value.trim();
135
+ const maybeQuote = value[0];
136
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
137
+ if (maybeQuote === '"') {
138
+ value = value.replace(/\\n/g, "\n");
139
+ value = value.replace(/\\r/g, "\r");
140
+ }
141
+ obj[key] = value;
142
+ }
143
+ return obj;
144
+ }
145
+ __name(parse3, "parse");
146
+ function _parseVault(options) {
147
+ const vaultPath = _vaultPath(options);
148
+ const result = DotenvModule.configDotenv({
149
+ path: vaultPath
150
+ });
151
+ if (!result.parsed) {
152
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
153
+ err.code = "MISSING_DATA";
154
+ throw err;
155
+ }
156
+ const keys = _dotenvKey(options).split(",");
157
+ const length = keys.length;
158
+ let decrypted;
159
+ for (let i = 0; i < length; i++) {
160
+ try {
161
+ const key = keys[i].trim();
162
+ const attrs = _instructions(result, key);
163
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
164
+ break;
165
+ } catch (error) {
166
+ if (i + 1 >= length) {
167
+ throw error;
168
+ }
169
+ }
170
+ }
171
+ return DotenvModule.parse(decrypted);
172
+ }
173
+ __name(_parseVault, "_parseVault");
174
+ function _log(message) {
175
+ console.log(`[dotenv@${version}][INFO] ${message}`);
176
+ }
177
+ __name(_log, "_log");
178
+ function _warn(message) {
179
+ console.log(`[dotenv@${version}][WARN] ${message}`);
180
+ }
181
+ __name(_warn, "_warn");
182
+ function _debug(message) {
183
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
184
+ }
185
+ __name(_debug, "_debug");
186
+ function _dotenvKey(options) {
187
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
188
+ return options.DOTENV_KEY;
189
+ }
190
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
191
+ return process.env.DOTENV_KEY;
192
+ }
193
+ return "";
194
+ }
195
+ __name(_dotenvKey, "_dotenvKey");
196
+ function _instructions(result, dotenvKey) {
197
+ let uri;
198
+ try {
199
+ uri = new URL(dotenvKey);
200
+ } catch (error) {
201
+ if (error.code === "ERR_INVALID_URL") {
202
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
203
+ err.code = "INVALID_DOTENV_KEY";
204
+ throw err;
205
+ }
206
+ throw error;
207
+ }
208
+ const key = uri.password;
209
+ if (!key) {
210
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
211
+ err.code = "INVALID_DOTENV_KEY";
212
+ throw err;
213
+ }
214
+ const environment = uri.searchParams.get("environment");
215
+ if (!environment) {
216
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
217
+ err.code = "INVALID_DOTENV_KEY";
218
+ throw err;
219
+ }
220
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
221
+ const ciphertext = result.parsed[environmentKey];
222
+ if (!ciphertext) {
223
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
224
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
225
+ throw err;
226
+ }
227
+ return {
228
+ ciphertext,
229
+ key
230
+ };
231
+ }
232
+ __name(_instructions, "_instructions");
233
+ function _vaultPath(options) {
234
+ let possibleVaultPath = null;
235
+ if (options && options.path && options.path.length > 0) {
236
+ if (Array.isArray(options.path)) {
237
+ for (const filepath of options.path) {
238
+ if (fs.existsSync(filepath)) {
239
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
240
+ }
241
+ }
242
+ } else {
243
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
244
+ }
245
+ } else {
246
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
247
+ }
248
+ if (fs.existsSync(possibleVaultPath)) {
249
+ return possibleVaultPath;
250
+ }
251
+ return null;
252
+ }
253
+ __name(_vaultPath, "_vaultPath");
254
+ function _resolveHome(envPath) {
255
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
256
+ }
257
+ __name(_resolveHome, "_resolveHome");
258
+ function _configVault(options) {
259
+ _log("Loading env from encrypted .env.vault");
260
+ const parsed = DotenvModule._parseVault(options);
261
+ let processEnv = process.env;
262
+ if (options && options.processEnv != null) {
263
+ processEnv = options.processEnv;
264
+ }
265
+ DotenvModule.populate(processEnv, parsed, options);
266
+ return {
267
+ parsed
268
+ };
269
+ }
270
+ __name(_configVault, "_configVault");
271
+ function configDotenv(options) {
272
+ const dotenvPath = path.resolve(process.cwd(), ".env");
273
+ let encoding = "utf8";
274
+ const debug = Boolean(options && options.debug);
275
+ if (options && options.encoding) {
276
+ encoding = options.encoding;
277
+ } else {
278
+ if (debug) {
279
+ _debug("No encoding is specified. UTF-8 is used by default");
280
+ }
281
+ }
282
+ let optionPaths = [
283
+ dotenvPath
284
+ ];
285
+ if (options && options.path) {
286
+ if (!Array.isArray(options.path)) {
287
+ optionPaths = [
288
+ _resolveHome(options.path)
289
+ ];
290
+ } else {
291
+ optionPaths = [];
292
+ for (const filepath of options.path) {
293
+ optionPaths.push(_resolveHome(filepath));
294
+ }
295
+ }
296
+ }
297
+ let lastError;
298
+ const parsedAll = {};
299
+ for (const path2 of optionPaths) {
300
+ try {
301
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, {
302
+ encoding
303
+ }));
304
+ DotenvModule.populate(parsedAll, parsed, options);
305
+ } catch (e) {
306
+ if (debug) {
307
+ _debug(`Failed to load ${path2} ${e.message}`);
308
+ }
309
+ lastError = e;
310
+ }
311
+ }
312
+ let processEnv = process.env;
313
+ if (options && options.processEnv != null) {
314
+ processEnv = options.processEnv;
315
+ }
316
+ DotenvModule.populate(processEnv, parsedAll, options);
317
+ if (lastError) {
318
+ return {
319
+ parsed: parsedAll,
320
+ error: lastError
321
+ };
322
+ } else {
323
+ return {
324
+ parsed: parsedAll
325
+ };
326
+ }
327
+ }
328
+ __name(configDotenv, "configDotenv");
329
+ function config(options) {
330
+ if (_dotenvKey(options).length === 0) {
331
+ return DotenvModule.configDotenv(options);
332
+ }
333
+ const vaultPath = _vaultPath(options);
334
+ if (!vaultPath) {
335
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
336
+ return DotenvModule.configDotenv(options);
337
+ }
338
+ return DotenvModule._configVault(options);
339
+ }
340
+ __name(config, "config");
341
+ function decrypt(encrypted, keyStr) {
342
+ const key = Buffer.from(keyStr.slice(-64), "hex");
343
+ let ciphertext = Buffer.from(encrypted, "base64");
344
+ const nonce = ciphertext.subarray(0, 12);
345
+ const authTag = ciphertext.subarray(-16);
346
+ ciphertext = ciphertext.subarray(12, -16);
347
+ try {
348
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
349
+ aesgcm.setAuthTag(authTag);
350
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
351
+ } catch (error) {
352
+ const isRange = error instanceof RangeError;
353
+ const invalidKeyLength = error.message === "Invalid key length";
354
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
355
+ if (isRange || invalidKeyLength) {
356
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
357
+ err.code = "INVALID_DOTENV_KEY";
358
+ throw err;
359
+ } else if (decryptionFailed) {
360
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
361
+ err.code = "DECRYPTION_FAILED";
362
+ throw err;
363
+ } else {
364
+ throw error;
365
+ }
366
+ }
367
+ }
368
+ __name(decrypt, "decrypt");
369
+ function populate(processEnv, parsed, options = {}) {
370
+ const debug = Boolean(options && options.debug);
371
+ const override = Boolean(options && options.override);
372
+ if (typeof parsed !== "object") {
373
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
374
+ err.code = "OBJECT_REQUIRED";
375
+ throw err;
376
+ }
377
+ for (const key of Object.keys(parsed)) {
378
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
379
+ if (override === true) {
380
+ processEnv[key] = parsed[key];
381
+ }
382
+ if (debug) {
383
+ if (override === true) {
384
+ _debug(`"${key}" is already defined and WAS overwritten`);
385
+ } else {
386
+ _debug(`"${key}" is already defined and was NOT overwritten`);
387
+ }
388
+ }
389
+ } else {
390
+ processEnv[key] = parsed[key];
391
+ }
392
+ }
393
+ }
394
+ __name(populate, "populate");
395
+ var DotenvModule = {
396
+ configDotenv,
397
+ _configVault,
398
+ _parseVault,
399
+ config,
400
+ decrypt,
401
+ parse: parse3,
402
+ populate
403
+ };
404
+ module.exports.configDotenv = DotenvModule.configDotenv;
405
+ module.exports._configVault = DotenvModule._configVault;
406
+ module.exports._parseVault = DotenvModule._parseVault;
407
+ module.exports.config = DotenvModule.config;
408
+ module.exports.decrypt = DotenvModule.decrypt;
409
+ module.exports.parse = DotenvModule.parse;
410
+ module.exports.populate = DotenvModule.populate;
411
+ module.exports = DotenvModule;
412
+ }
413
+ });
414
+
415
+ // src/build.ts
416
+ init_esm_shims();
417
+ import { readCachedProjectGraph, writeJsonFile } from "@nx/devkit";
418
+ import { getHelperDependency, HelperDependency } from "@nx/js";
419
+ import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
420
+ import { addPackageDependencies, addPackageJsonExports, addWorkspacePackageJsonFields, copyAssets } from "@storm-software/build-tools";
421
+
422
+ // ../config-tools/src/create-storm-config.ts
423
+ init_esm_shims();
424
+ import { StormConfigSchema } from "@storm-software/config/schema";
425
+ import defu4 from "defu";
426
+
427
+ // ../config-tools/src/config-file/get-config-file.ts
428
+ init_esm_shims();
429
+
430
+ // ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
431
+ init_esm_shims();
432
+
433
+ // ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
434
+ init_esm_shims();
435
+ import { existsSync as existsSync2, promises } from "node:fs";
436
+ import { rm, readFile } from "node:fs/promises";
437
+ import { homedir as homedir2 } from "node:os";
438
+ import { createJiti } from "jiti";
439
+
440
+ // ../../node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
441
+ init_esm_shims();
442
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
443
+ import { resolve as resolve2 } from "node:path";
444
+ import { homedir } from "node:os";
445
+
446
+ // ../../node_modules/.pnpm/destr@2.0.3/node_modules/destr/dist/index.mjs
447
+ init_esm_shims();
448
+ var suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
449
+ var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
450
+ var JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
451
+ function jsonParseTransform(key, value) {
452
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
453
+ warnKeyDropped(key);
454
+ return;
455
+ }
456
+ return value;
457
+ }
458
+ __name(jsonParseTransform, "jsonParseTransform");
459
+ function warnKeyDropped(key) {
460
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
461
+ }
462
+ __name(warnKeyDropped, "warnKeyDropped");
463
+ function destr(value, options = {}) {
464
+ if (typeof value !== "string") {
465
+ return value;
466
+ }
467
+ const _value = value.trim();
468
+ if (
469
+ // eslint-disable-next-line unicorn/prefer-at
470
+ value[0] === '"' && value.endsWith('"') && !value.includes("\\")
471
+ ) {
472
+ return _value.slice(1, -1);
473
+ }
474
+ if (_value.length <= 9) {
475
+ const _lval = _value.toLowerCase();
476
+ if (_lval === "true") {
477
+ return true;
478
+ }
479
+ if (_lval === "false") {
480
+ return false;
481
+ }
482
+ if (_lval === "undefined") {
483
+ return void 0;
484
+ }
485
+ if (_lval === "null") {
486
+ return null;
487
+ }
488
+ if (_lval === "nan") {
489
+ return Number.NaN;
490
+ }
491
+ if (_lval === "infinity") {
492
+ return Number.POSITIVE_INFINITY;
493
+ }
494
+ if (_lval === "-infinity") {
495
+ return Number.NEGATIVE_INFINITY;
496
+ }
497
+ }
498
+ if (!JsonSigRx.test(value)) {
499
+ if (options.strict) {
500
+ throw new SyntaxError("[destr] Invalid JSON");
501
+ }
502
+ return value;
503
+ }
504
+ try {
505
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
506
+ if (options.strict) {
507
+ throw new Error("[destr] Possible prototype pollution");
508
+ }
509
+ return JSON.parse(value, jsonParseTransform);
510
+ }
511
+ return JSON.parse(value);
512
+ } catch (error) {
513
+ if (options.strict) {
514
+ throw error;
515
+ }
516
+ return value;
517
+ }
518
+ }
519
+ __name(destr, "destr");
520
+
521
+ // ../../node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
522
+ import { defu } from "defu";
523
+ function isBuffer(obj) {
524
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
525
+ }
526
+ __name(isBuffer, "isBuffer");
527
+ function keyIdentity(key) {
528
+ return key;
529
+ }
530
+ __name(keyIdentity, "keyIdentity");
531
+ function flatten(target, opts) {
532
+ opts = opts || {};
533
+ const delimiter = opts.delimiter || ".";
534
+ const maxDepth = opts.maxDepth;
535
+ const transformKey = opts.transformKey || keyIdentity;
536
+ const output = {};
537
+ function step(object, prev, currentDepth) {
538
+ currentDepth = currentDepth || 1;
539
+ Object.keys(object).forEach(function(key) {
540
+ const value = object[key];
541
+ const isarray = opts.safe && Array.isArray(value);
542
+ const type = Object.prototype.toString.call(value);
543
+ const isbuffer = isBuffer(value);
544
+ const isobject = type === "[object Object]" || type === "[object Array]";
545
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
546
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
547
+ return step(value, newKey, currentDepth + 1);
548
+ }
549
+ output[newKey] = value;
550
+ });
551
+ }
552
+ __name(step, "step");
553
+ step(target);
554
+ return output;
555
+ }
556
+ __name(flatten, "flatten");
557
+ function unflatten(target, opts) {
558
+ opts = opts || {};
559
+ const delimiter = opts.delimiter || ".";
560
+ const overwrite = opts.overwrite || false;
561
+ const transformKey = opts.transformKey || keyIdentity;
562
+ const result = {};
563
+ const isbuffer = isBuffer(target);
564
+ if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
565
+ return target;
566
+ }
567
+ function getkey(key) {
568
+ const parsedKey = Number(key);
569
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
570
+ }
571
+ __name(getkey, "getkey");
572
+ function addKeys(keyPrefix, recipient, target2) {
573
+ return Object.keys(target2).reduce(function(result2, key) {
574
+ result2[keyPrefix + delimiter + key] = target2[key];
575
+ return result2;
576
+ }, recipient);
577
+ }
578
+ __name(addKeys, "addKeys");
579
+ function isEmpty(val) {
580
+ const type = Object.prototype.toString.call(val);
581
+ const isArray = type === "[object Array]";
582
+ const isObject = type === "[object Object]";
583
+ if (!val) {
584
+ return true;
585
+ } else if (isArray) {
586
+ return !val.length;
587
+ } else if (isObject) {
588
+ return !Object.keys(val).length;
589
+ }
590
+ }
591
+ __name(isEmpty, "isEmpty");
592
+ target = Object.keys(target).reduce(function(result2, key) {
593
+ const type = Object.prototype.toString.call(target[key]);
594
+ const isObject = type === "[object Object]" || type === "[object Array]";
595
+ if (!isObject || isEmpty(target[key])) {
596
+ result2[key] = target[key];
597
+ return result2;
598
+ } else {
599
+ return addKeys(
600
+ key,
601
+ result2,
602
+ flatten(target[key], opts)
603
+ );
604
+ }
605
+ }, {});
606
+ Object.keys(target).forEach(function(key) {
607
+ const split = key.split(delimiter).map(transformKey);
608
+ let key1 = getkey(split.shift());
609
+ let key2 = getkey(split[0]);
610
+ let recipient = result;
611
+ while (key2 !== void 0) {
612
+ if (key1 === "__proto__") {
613
+ return;
614
+ }
615
+ const type = Object.prototype.toString.call(recipient[key1]);
616
+ const isobject = type === "[object Object]" || type === "[object Array]";
617
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
618
+ return;
619
+ }
620
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
621
+ recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
622
+ }
623
+ recipient = recipient[key1];
624
+ if (split.length > 0) {
625
+ key1 = getkey(split.shift());
626
+ key2 = getkey(split[0]);
627
+ }
628
+ }
629
+ recipient[key1] = unflatten(target[key], opts);
630
+ });
631
+ return result;
632
+ }
633
+ __name(unflatten, "unflatten");
634
+ var RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
635
+ var RE_LINES = /\n|\r|\r\n/;
636
+ var defaults = {
637
+ name: ".conf",
638
+ dir: process.cwd(),
639
+ flat: false
640
+ };
641
+ function withDefaults(options) {
642
+ if (typeof options === "string") {
643
+ options = { name: options };
644
+ }
645
+ return { ...defaults, ...options };
646
+ }
647
+ __name(withDefaults, "withDefaults");
648
+ function parse(contents, options = {}) {
649
+ const config = {};
650
+ const lines = contents.split(RE_LINES);
651
+ for (const line of lines) {
652
+ const match = line.match(RE_KEY_VAL);
653
+ if (!match) {
654
+ continue;
655
+ }
656
+ const key = match[1];
657
+ if (!key || key === "__proto__" || key === "constructor") {
658
+ continue;
659
+ }
660
+ const value = destr(
661
+ (match[2] || "").trim()
662
+ /* val */
663
+ );
664
+ if (key.endsWith("[]")) {
665
+ const nkey = key.slice(0, Math.max(0, key.length - 2));
666
+ config[nkey] = (config[nkey] || []).concat(value);
667
+ continue;
668
+ }
669
+ config[key] = value;
670
+ }
671
+ return options.flat ? config : unflatten(config, { overwrite: true });
672
+ }
673
+ __name(parse, "parse");
674
+ function parseFile(path, options) {
675
+ if (!existsSync(path)) {
676
+ return {};
677
+ }
678
+ return parse(readFileSync(path, "utf8"), options);
679
+ }
680
+ __name(parseFile, "parseFile");
681
+ function read(options) {
682
+ options = withDefaults(options);
683
+ return parseFile(resolve2(options.dir, options.name), options);
684
+ }
685
+ __name(read, "read");
686
+ function readUser(options) {
687
+ options = withDefaults(options);
688
+ options.dir = process.env.XDG_CONFIG_HOME || homedir();
689
+ return read(options);
690
+ }
691
+ __name(readUser, "readUser");
692
+
693
+ // ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
694
+ import { defu as defu2 } from "defu";
695
+
696
+ // ../../node_modules/.pnpm/ohash@1.1.4/node_modules/ohash/dist/index.mjs
697
+ init_esm_shims();
698
+ var defaults2 = Object.freeze({
699
+ ignoreUnknown: false,
700
+ respectType: false,
701
+ respectFunctionNames: false,
702
+ respectFunctionProperties: false,
703
+ unorderedObjects: true,
704
+ unorderedArrays: false,
705
+ unorderedSets: false,
706
+ excludeKeys: void 0,
707
+ excludeValues: void 0,
708
+ replacer: void 0
709
+ });
710
+ function objectHash(object, options) {
711
+ if (options) {
712
+ options = { ...defaults2, ...options };
713
+ } else {
714
+ options = defaults2;
715
+ }
716
+ const hasher = createHasher(options);
717
+ hasher.dispatch(object);
718
+ return hasher.toString();
719
+ }
720
+ __name(objectHash, "objectHash");
721
+ var defaultPrototypesKeys = Object.freeze([
722
+ "prototype",
723
+ "__proto__",
724
+ "constructor"
725
+ ]);
726
+ function createHasher(options) {
727
+ let buff = "";
728
+ let context = /* @__PURE__ */ new Map();
729
+ const write = /* @__PURE__ */ __name((str) => {
730
+ buff += str;
731
+ }, "write");
732
+ return {
733
+ toString() {
734
+ return buff;
735
+ },
736
+ getContext() {
737
+ return context;
738
+ },
739
+ dispatch(value) {
740
+ if (options.replacer) {
741
+ value = options.replacer(value);
742
+ }
743
+ const type = value === null ? "null" : typeof value;
744
+ return this[type](value);
745
+ },
746
+ object(object) {
747
+ if (object && typeof object.toJSON === "function") {
748
+ return this.object(object.toJSON());
749
+ }
750
+ const objString = Object.prototype.toString.call(object);
751
+ let objType = "";
752
+ const objectLength = objString.length;
753
+ if (objectLength < 10) {
754
+ objType = "unknown:[" + objString + "]";
755
+ } else {
756
+ objType = objString.slice(8, objectLength - 1);
757
+ }
758
+ objType = objType.toLowerCase();
759
+ let objectNumber = null;
760
+ if ((objectNumber = context.get(object)) === void 0) {
761
+ context.set(object, context.size);
762
+ } else {
763
+ return this.dispatch("[CIRCULAR:" + objectNumber + "]");
764
+ }
765
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
766
+ write("buffer:");
767
+ return write(object.toString("utf8"));
768
+ }
769
+ if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
770
+ if (this[objType]) {
771
+ this[objType](object);
772
+ } else if (!options.ignoreUnknown) {
773
+ this.unkown(object, objType);
774
+ }
775
+ } else {
776
+ let keys = Object.keys(object);
777
+ if (options.unorderedObjects) {
778
+ keys = keys.sort();
779
+ }
780
+ let extraKeys = [];
781
+ if (options.respectType !== false && !isNativeFunction(object)) {
782
+ extraKeys = defaultPrototypesKeys;
783
+ }
784
+ if (options.excludeKeys) {
785
+ keys = keys.filter((key) => {
786
+ return !options.excludeKeys(key);
787
+ });
788
+ extraKeys = extraKeys.filter((key) => {
789
+ return !options.excludeKeys(key);
790
+ });
791
+ }
792
+ write("object:" + (keys.length + extraKeys.length) + ":");
793
+ const dispatchForKey = /* @__PURE__ */ __name((key) => {
794
+ this.dispatch(key);
795
+ write(":");
796
+ if (!options.excludeValues) {
797
+ this.dispatch(object[key]);
798
+ }
799
+ write(",");
800
+ }, "dispatchForKey");
801
+ for (const key of keys) {
802
+ dispatchForKey(key);
803
+ }
804
+ for (const key of extraKeys) {
805
+ dispatchForKey(key);
806
+ }
807
+ }
808
+ },
809
+ array(arr, unordered) {
810
+ unordered = unordered === void 0 ? options.unorderedArrays !== false : unordered;
811
+ write("array:" + arr.length + ":");
812
+ if (!unordered || arr.length <= 1) {
813
+ for (const entry of arr) {
814
+ this.dispatch(entry);
815
+ }
816
+ return;
817
+ }
818
+ const contextAdditions = /* @__PURE__ */ new Map();
819
+ const entries = arr.map((entry) => {
820
+ const hasher = createHasher(options);
821
+ hasher.dispatch(entry);
822
+ for (const [key, value] of hasher.getContext()) {
823
+ contextAdditions.set(key, value);
824
+ }
825
+ return hasher.toString();
826
+ });
827
+ context = contextAdditions;
828
+ entries.sort();
829
+ return this.array(entries, false);
830
+ },
831
+ date(date) {
832
+ return write("date:" + date.toJSON());
833
+ },
834
+ symbol(sym) {
835
+ return write("symbol:" + sym.toString());
836
+ },
837
+ unkown(value, type) {
838
+ write(type);
839
+ if (!value) {
840
+ return;
841
+ }
842
+ write(":");
843
+ if (value && typeof value.entries === "function") {
844
+ return this.array(
845
+ Array.from(value.entries()),
846
+ true
847
+ /* ordered */
848
+ );
849
+ }
850
+ },
851
+ error(err) {
852
+ return write("error:" + err.toString());
853
+ },
854
+ boolean(bool) {
855
+ return write("bool:" + bool);
856
+ },
857
+ string(string) {
858
+ write("string:" + string.length + ":");
859
+ write(string);
860
+ },
861
+ function(fn) {
862
+ write("fn:");
863
+ if (isNativeFunction(fn)) {
864
+ this.dispatch("[native]");
865
+ } else {
866
+ this.dispatch(fn.toString());
867
+ }
868
+ if (options.respectFunctionNames !== false) {
869
+ this.dispatch("function-name:" + String(fn.name));
870
+ }
871
+ if (options.respectFunctionProperties) {
872
+ this.object(fn);
873
+ }
874
+ },
875
+ number(number) {
876
+ return write("number:" + number);
877
+ },
878
+ xml(xml) {
879
+ return write("xml:" + xml.toString());
880
+ },
881
+ null() {
882
+ return write("Null");
883
+ },
884
+ undefined() {
885
+ return write("Undefined");
886
+ },
887
+ regexp(regex) {
888
+ return write("regex:" + regex.toString());
889
+ },
890
+ uint8array(arr) {
891
+ write("uint8array:");
892
+ return this.dispatch(Array.prototype.slice.call(arr));
893
+ },
894
+ uint8clampedarray(arr) {
895
+ write("uint8clampedarray:");
896
+ return this.dispatch(Array.prototype.slice.call(arr));
897
+ },
898
+ int8array(arr) {
899
+ write("int8array:");
900
+ return this.dispatch(Array.prototype.slice.call(arr));
901
+ },
902
+ uint16array(arr) {
903
+ write("uint16array:");
904
+ return this.dispatch(Array.prototype.slice.call(arr));
905
+ },
906
+ int16array(arr) {
907
+ write("int16array:");
908
+ return this.dispatch(Array.prototype.slice.call(arr));
909
+ },
910
+ uint32array(arr) {
911
+ write("uint32array:");
912
+ return this.dispatch(Array.prototype.slice.call(arr));
913
+ },
914
+ int32array(arr) {
915
+ write("int32array:");
916
+ return this.dispatch(Array.prototype.slice.call(arr));
917
+ },
918
+ float32array(arr) {
919
+ write("float32array:");
920
+ return this.dispatch(Array.prototype.slice.call(arr));
921
+ },
922
+ float64array(arr) {
923
+ write("float64array:");
924
+ return this.dispatch(Array.prototype.slice.call(arr));
925
+ },
926
+ arraybuffer(arr) {
927
+ write("arraybuffer:");
928
+ return this.dispatch(new Uint8Array(arr));
929
+ },
930
+ url(url) {
931
+ return write("url:" + url.toString());
932
+ },
933
+ map(map) {
934
+ write("map:");
935
+ const arr = [...map];
936
+ return this.array(arr, options.unorderedSets !== false);
937
+ },
938
+ set(set) {
939
+ write("set:");
940
+ const arr = [...set];
941
+ return this.array(arr, options.unorderedSets !== false);
942
+ },
943
+ file(file) {
944
+ write("file:");
945
+ return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
946
+ },
947
+ blob() {
948
+ if (options.ignoreUnknown) {
949
+ return write("[blob]");
950
+ }
951
+ throw new Error(
952
+ 'Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n'
953
+ );
954
+ },
955
+ domwindow() {
956
+ return write("domwindow");
957
+ },
958
+ bigint(number) {
959
+ return write("bigint:" + number.toString());
960
+ },
961
+ /* Node.js standard native objects */
962
+ process() {
963
+ return write("process");
964
+ },
965
+ timer() {
966
+ return write("timer");
967
+ },
968
+ pipe() {
969
+ return write("pipe");
970
+ },
971
+ tcp() {
972
+ return write("tcp");
973
+ },
974
+ udp() {
975
+ return write("udp");
976
+ },
977
+ tty() {
978
+ return write("tty");
979
+ },
980
+ statwatcher() {
981
+ return write("statwatcher");
982
+ },
983
+ securecontext() {
984
+ return write("securecontext");
985
+ },
986
+ connection() {
987
+ return write("connection");
988
+ },
989
+ zlib() {
990
+ return write("zlib");
991
+ },
992
+ context() {
993
+ return write("context");
994
+ },
995
+ nodescript() {
996
+ return write("nodescript");
997
+ },
998
+ httpparser() {
999
+ return write("httpparser");
1000
+ },
1001
+ dataview() {
1002
+ return write("dataview");
1003
+ },
1004
+ signal() {
1005
+ return write("signal");
1006
+ },
1007
+ fsevent() {
1008
+ return write("fsevent");
1009
+ },
1010
+ tlswrap() {
1011
+ return write("tlswrap");
1012
+ }
1013
+ };
1014
+ }
1015
+ __name(createHasher, "createHasher");
1016
+ var nativeFunc = "[native code] }";
1017
+ var nativeFuncLength = nativeFunc.length;
1018
+ function isNativeFunction(f) {
1019
+ if (typeof f !== "function") {
1020
+ return false;
1021
+ }
1022
+ return Function.prototype.toString.call(f).slice(-nativeFuncLength) === nativeFunc;
1023
+ }
1024
+ __name(isNativeFunction, "isNativeFunction");
1025
+ var __defProp$1 = Object.defineProperty;
1026
+ var __defNormalProp$1 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp$1");
1027
+ var __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => {
1028
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1029
+ return value;
1030
+ }, "__publicField$1");
1031
+ var WordArray = class _WordArray {
1032
+ static {
1033
+ __name(this, "WordArray");
1034
+ }
1035
+ constructor(words, sigBytes) {
1036
+ __publicField$1(this, "words");
1037
+ __publicField$1(this, "sigBytes");
1038
+ words = this.words = words || [];
1039
+ this.sigBytes = sigBytes === void 0 ? words.length * 4 : sigBytes;
1040
+ }
1041
+ toString(encoder) {
1042
+ return (encoder || Hex).stringify(this);
1043
+ }
1044
+ concat(wordArray) {
1045
+ this.clamp();
1046
+ if (this.sigBytes % 4) {
1047
+ for (let i = 0; i < wordArray.sigBytes; i++) {
1048
+ const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1049
+ this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
1050
+ }
1051
+ } else {
1052
+ for (let j = 0; j < wordArray.sigBytes; j += 4) {
1053
+ this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
1054
+ }
1055
+ }
1056
+ this.sigBytes += wordArray.sigBytes;
1057
+ return this;
1058
+ }
1059
+ clamp() {
1060
+ this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
1061
+ this.words.length = Math.ceil(this.sigBytes / 4);
1062
+ }
1063
+ clone() {
1064
+ return new _WordArray([...this.words]);
1065
+ }
1066
+ };
1067
+ var Hex = {
1068
+ stringify(wordArray) {
1069
+ const hexChars = [];
1070
+ for (let i = 0; i < wordArray.sigBytes; i++) {
1071
+ const bite = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1072
+ hexChars.push((bite >>> 4).toString(16), (bite & 15).toString(16));
1073
+ }
1074
+ return hexChars.join("");
1075
+ }
1076
+ };
1077
+ var Base64 = {
1078
+ stringify(wordArray) {
1079
+ const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1080
+ const base64Chars = [];
1081
+ for (let i = 0; i < wordArray.sigBytes; i += 3) {
1082
+ const byte1 = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1083
+ const byte2 = wordArray.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
1084
+ const byte3 = wordArray.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
1085
+ const triplet = byte1 << 16 | byte2 << 8 | byte3;
1086
+ for (let j = 0; j < 4 && i * 8 + j * 6 < wordArray.sigBytes * 8; j++) {
1087
+ base64Chars.push(keyStr.charAt(triplet >>> 6 * (3 - j) & 63));
1088
+ }
1089
+ }
1090
+ return base64Chars.join("");
1091
+ }
1092
+ };
1093
+ var Latin1 = {
1094
+ parse(latin1Str) {
1095
+ const latin1StrLength = latin1Str.length;
1096
+ const words = [];
1097
+ for (let i = 0; i < latin1StrLength; i++) {
1098
+ words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
1099
+ }
1100
+ return new WordArray(words, latin1StrLength);
1101
+ }
1102
+ };
1103
+ var Utf8 = {
1104
+ parse(utf8Str) {
1105
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
1106
+ }
1107
+ };
1108
+ var BufferedBlockAlgorithm = class {
1109
+ static {
1110
+ __name(this, "BufferedBlockAlgorithm");
1111
+ }
1112
+ constructor() {
1113
+ __publicField$1(this, "_data", new WordArray());
1114
+ __publicField$1(this, "_nDataBytes", 0);
1115
+ __publicField$1(this, "_minBufferSize", 0);
1116
+ __publicField$1(this, "blockSize", 512 / 32);
1117
+ }
1118
+ reset() {
1119
+ this._data = new WordArray();
1120
+ this._nDataBytes = 0;
1121
+ }
1122
+ _append(data) {
1123
+ if (typeof data === "string") {
1124
+ data = Utf8.parse(data);
1125
+ }
1126
+ this._data.concat(data);
1127
+ this._nDataBytes += data.sigBytes;
1128
+ }
1129
+ _doProcessBlock(_dataWords, _offset) {
1130
+ }
1131
+ _process(doFlush) {
1132
+ let processedWords;
1133
+ let nBlocksReady = this._data.sigBytes / (this.blockSize * 4);
1134
+ if (doFlush) {
1135
+ nBlocksReady = Math.ceil(nBlocksReady);
1136
+ } else {
1137
+ nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
1138
+ }
1139
+ const nWordsReady = nBlocksReady * this.blockSize;
1140
+ const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
1141
+ if (nWordsReady) {
1142
+ for (let offset = 0; offset < nWordsReady; offset += this.blockSize) {
1143
+ this._doProcessBlock(this._data.words, offset);
1144
+ }
1145
+ processedWords = this._data.words.splice(0, nWordsReady);
1146
+ this._data.sigBytes -= nBytesReady;
1147
+ }
1148
+ return new WordArray(processedWords, nBytesReady);
1149
+ }
1150
+ };
1151
+ var Hasher = class extends BufferedBlockAlgorithm {
1152
+ static {
1153
+ __name(this, "Hasher");
1154
+ }
1155
+ update(messageUpdate) {
1156
+ this._append(messageUpdate);
1157
+ this._process();
1158
+ return this;
1159
+ }
1160
+ finalize(messageUpdate) {
1161
+ if (messageUpdate) {
1162
+ this._append(messageUpdate);
1163
+ }
1164
+ }
1165
+ };
1166
+ var __defProp = Object.defineProperty;
1167
+ var __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
1168
+ var __publicField = /* @__PURE__ */ __name((obj, key, value) => {
1169
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1170
+ return value;
1171
+ }, "__publicField");
1172
+ var H = [
1173
+ 1779033703,
1174
+ -1150833019,
1175
+ 1013904242,
1176
+ -1521486534,
1177
+ 1359893119,
1178
+ -1694144372,
1179
+ 528734635,
1180
+ 1541459225
1181
+ ];
1182
+ var K = [
1183
+ 1116352408,
1184
+ 1899447441,
1185
+ -1245643825,
1186
+ -373957723,
1187
+ 961987163,
1188
+ 1508970993,
1189
+ -1841331548,
1190
+ -1424204075,
1191
+ -670586216,
1192
+ 310598401,
1193
+ 607225278,
1194
+ 1426881987,
1195
+ 1925078388,
1196
+ -2132889090,
1197
+ -1680079193,
1198
+ -1046744716,
1199
+ -459576895,
1200
+ -272742522,
1201
+ 264347078,
1202
+ 604807628,
1203
+ 770255983,
1204
+ 1249150122,
1205
+ 1555081692,
1206
+ 1996064986,
1207
+ -1740746414,
1208
+ -1473132947,
1209
+ -1341970488,
1210
+ -1084653625,
1211
+ -958395405,
1212
+ -710438585,
1213
+ 113926993,
1214
+ 338241895,
1215
+ 666307205,
1216
+ 773529912,
1217
+ 1294757372,
1218
+ 1396182291,
1219
+ 1695183700,
1220
+ 1986661051,
1221
+ -2117940946,
1222
+ -1838011259,
1223
+ -1564481375,
1224
+ -1474664885,
1225
+ -1035236496,
1226
+ -949202525,
1227
+ -778901479,
1228
+ -694614492,
1229
+ -200395387,
1230
+ 275423344,
1231
+ 430227734,
1232
+ 506948616,
1233
+ 659060556,
1234
+ 883997877,
1235
+ 958139571,
1236
+ 1322822218,
1237
+ 1537002063,
1238
+ 1747873779,
1239
+ 1955562222,
1240
+ 2024104815,
1241
+ -2067236844,
1242
+ -1933114872,
1243
+ -1866530822,
1244
+ -1538233109,
1245
+ -1090935817,
1246
+ -965641998
1247
+ ];
1248
+ var W = [];
1249
+ var SHA256 = class extends Hasher {
1250
+ static {
1251
+ __name(this, "SHA256");
1252
+ }
1253
+ constructor() {
1254
+ super(...arguments);
1255
+ __publicField(this, "_hash", new WordArray([...H]));
1256
+ }
1257
+ /**
1258
+ * Resets the internal state of the hash object to initial values.
1259
+ */
1260
+ reset() {
1261
+ super.reset();
1262
+ this._hash = new WordArray([...H]);
1263
+ }
1264
+ _doProcessBlock(M, offset) {
1265
+ const H2 = this._hash.words;
1266
+ let a = H2[0];
1267
+ let b = H2[1];
1268
+ let c = H2[2];
1269
+ let d = H2[3];
1270
+ let e = H2[4];
1271
+ let f = H2[5];
1272
+ let g = H2[6];
1273
+ let h = H2[7];
1274
+ for (let i = 0; i < 64; i++) {
1275
+ if (i < 16) {
1276
+ W[i] = M[offset + i] | 0;
1277
+ } else {
1278
+ const gamma0x = W[i - 15];
1279
+ const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
1280
+ const gamma1x = W[i - 2];
1281
+ const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
1282
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
1283
+ }
1284
+ const ch = e & f ^ ~e & g;
1285
+ const maj = a & b ^ a & c ^ b & c;
1286
+ const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
1287
+ const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
1288
+ const t1 = h + sigma1 + ch + K[i] + W[i];
1289
+ const t2 = sigma0 + maj;
1290
+ h = g;
1291
+ g = f;
1292
+ f = e;
1293
+ e = d + t1 | 0;
1294
+ d = c;
1295
+ c = b;
1296
+ b = a;
1297
+ a = t1 + t2 | 0;
1298
+ }
1299
+ H2[0] = H2[0] + a | 0;
1300
+ H2[1] = H2[1] + b | 0;
1301
+ H2[2] = H2[2] + c | 0;
1302
+ H2[3] = H2[3] + d | 0;
1303
+ H2[4] = H2[4] + e | 0;
1304
+ H2[5] = H2[5] + f | 0;
1305
+ H2[6] = H2[6] + g | 0;
1306
+ H2[7] = H2[7] + h | 0;
1307
+ }
1308
+ /**
1309
+ * Finishes the hash calculation and returns the hash as a WordArray.
1310
+ *
1311
+ * @param {string} messageUpdate - Additional message content to include in the hash.
1312
+ * @returns {WordArray} The finalised hash as a WordArray.
1313
+ */
1314
+ finalize(messageUpdate) {
1315
+ super.finalize(messageUpdate);
1316
+ const nBitsTotal = this._nDataBytes * 8;
1317
+ const nBitsLeft = this._data.sigBytes * 8;
1318
+ this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
1319
+ this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(
1320
+ nBitsTotal / 4294967296
1321
+ );
1322
+ this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
1323
+ this._data.sigBytes = this._data.words.length * 4;
1324
+ this._process();
1325
+ return this._hash;
1326
+ }
1327
+ };
1328
+ function sha256base64(message) {
1329
+ return new SHA256().finalize(message).toString(Base64);
1330
+ }
1331
+ __name(sha256base64, "sha256base64");
1332
+ function hash(object, options = {}) {
1333
+ const hashed = typeof object === "string" ? object : objectHash(object, options);
1334
+ return sha256base64(hashed).slice(0, 10);
1335
+ }
1336
+ __name(hash, "hash");
1337
+
1338
+ // ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/shared/c12.B4fc1S0C.mjs
1339
+ var dotenv = __toESM(require_main(), 1);
1340
+ async function setupDotenv(options) {
1341
+ const targetEnvironment = options.env ?? process.env;
1342
+ const environment = await loadDotenv({
1343
+ cwd: options.cwd,
1344
+ fileName: options.fileName ?? ".env",
1345
+ env: targetEnvironment,
1346
+ interpolate: options.interpolate ?? true
1347
+ });
1348
+ for (const key in environment) {
1349
+ if (!key.startsWith("_") && targetEnvironment[key] === void 0) {
1350
+ targetEnvironment[key] = environment[key];
1351
+ }
1352
+ }
1353
+ return environment;
1354
+ }
1355
+ __name(setupDotenv, "setupDotenv");
1356
+ async function loadDotenv(options) {
1357
+ const environment = /* @__PURE__ */ Object.create(null);
1358
+ const dotenvFile = resolve(options.cwd, options.fileName);
1359
+ if (existsSync2(dotenvFile)) {
1360
+ const parsed = dotenv.parse(await promises.readFile(dotenvFile, "utf8"));
1361
+ Object.assign(environment, parsed);
1362
+ }
1363
+ if (!options.env?._applied) {
1364
+ Object.assign(environment, options.env);
1365
+ environment._applied = true;
1366
+ }
1367
+ if (options.interpolate) {
1368
+ interpolate(environment);
1369
+ }
1370
+ return environment;
1371
+ }
1372
+ __name(loadDotenv, "loadDotenv");
1373
+ function interpolate(target, source = {}, parse3 = (v) => v) {
1374
+ function getValue(key) {
1375
+ return source[key] === void 0 ? target[key] : source[key];
1376
+ }
1377
+ __name(getValue, "getValue");
1378
+ function interpolate2(value, parents = []) {
1379
+ if (typeof value !== "string") {
1380
+ return value;
1381
+ }
1382
+ const matches = value.match(/(.?\${?(?:[\w:]+)?}?)/g) || [];
1383
+ return parse3(
1384
+ // eslint-disable-next-line unicorn/no-array-reduce
1385
+ matches.reduce((newValue, match) => {
1386
+ const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
1387
+ const prefix = parts[1];
1388
+ let value2, replacePart;
1389
+ if (prefix === "\\") {
1390
+ replacePart = parts[0] || "";
1391
+ value2 = replacePart.replace(String.raw`\$`, "$");
1392
+ } else {
1393
+ const key = parts[2];
1394
+ replacePart = (parts[0] || "").slice(prefix.length);
1395
+ if (parents.includes(key)) {
1396
+ console.warn(
1397
+ `Please avoid recursive environment variables ( loop: ${parents.join(
1398
+ " > "
1399
+ )} > ${key} )`
1400
+ );
1401
+ return "";
1402
+ }
1403
+ value2 = getValue(key);
1404
+ value2 = interpolate2(value2, [...parents, key]);
1405
+ }
1406
+ return value2 === void 0 ? newValue : newValue.replace(replacePart, value2);
1407
+ }, value)
1408
+ );
1409
+ }
1410
+ __name(interpolate2, "interpolate2");
1411
+ for (const key in target) {
1412
+ target[key] = interpolate2(getValue(key));
1413
+ }
1414
+ }
1415
+ __name(interpolate, "interpolate");
1416
+ var _normalize = /* @__PURE__ */ __name((p) => p?.replace(/\\/g, "/"), "_normalize");
1417
+ var ASYNC_LOADERS = {
1418
+ ".yaml": /* @__PURE__ */ __name(() => import("./yaml-GMY56OHD.mjs").then((r) => r.parseYAML), ".yaml"),
1419
+ ".yml": /* @__PURE__ */ __name(() => import("./yaml-GMY56OHD.mjs").then((r) => r.parseYAML), ".yml"),
1420
+ ".jsonc": /* @__PURE__ */ __name(() => import("./jsonc-PDDMSRDH.mjs").then((r) => r.parseJSONC), ".jsonc"),
1421
+ ".json5": /* @__PURE__ */ __name(() => import("./json5-JI6Y4EBT.mjs").then((r) => r.parseJSON5), ".json5"),
1422
+ ".toml": /* @__PURE__ */ __name(() => import("./toml-IHKP66UV.mjs").then((r) => r.parseTOML), ".toml")
1423
+ };
1424
+ var SUPPORTED_EXTENSIONS = [
1425
+ // with jiti
1426
+ ".js",
1427
+ ".ts",
1428
+ ".mjs",
1429
+ ".cjs",
1430
+ ".mts",
1431
+ ".cts",
1432
+ ".json",
1433
+ // with confbox
1434
+ ".jsonc",
1435
+ ".json5",
1436
+ ".yaml",
1437
+ ".yml",
1438
+ ".toml"
1439
+ ];
1440
+ async function loadConfig2(options) {
1441
+ options.cwd = resolve(process.cwd(), options.cwd || ".");
1442
+ options.name = options.name || "config";
1443
+ options.envName = options.envName ?? process.env.NODE_ENV;
1444
+ options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
1445
+ options.rcFile = options.rcFile ?? `.${options.name}rc`;
1446
+ if (options.extend !== false) {
1447
+ options.extend = {
1448
+ extendKey: "extends",
1449
+ ...options.extend
1450
+ };
1451
+ }
1452
+ const _merger = options.merger || defu2;
1453
+ options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
1454
+ interopDefault: true,
1455
+ moduleCache: false,
1456
+ extensions: [...SUPPORTED_EXTENSIONS],
1457
+ ...options.jitiOptions
1458
+ });
1459
+ const r = {
1460
+ config: {},
1461
+ cwd: options.cwd,
1462
+ configFile: resolve(options.cwd, options.configFile),
1463
+ layers: []
1464
+ };
1465
+ const _configs = {
1466
+ overrides: options.overrides,
1467
+ main: void 0,
1468
+ rc: void 0,
1469
+ packageJson: void 0,
1470
+ defaultConfig: options.defaultConfig
1471
+ };
1472
+ if (options.dotenv) {
1473
+ await setupDotenv({
1474
+ cwd: options.cwd,
1475
+ ...options.dotenv === true ? {} : options.dotenv
1476
+ });
1477
+ }
1478
+ const _mainConfig = await resolveConfig(".", options);
1479
+ if (_mainConfig.configFile) {
1480
+ _configs.main = _mainConfig.config;
1481
+ r.configFile = _mainConfig.configFile;
1482
+ }
1483
+ if (options.rcFile) {
1484
+ const rcSources = [];
1485
+ rcSources.push(read({ name: options.rcFile, dir: options.cwd }));
1486
+ if (options.globalRc) {
1487
+ const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {
1488
+ });
1489
+ if (workspaceDir) {
1490
+ rcSources.push(read({ name: options.rcFile, dir: workspaceDir }));
1491
+ }
1492
+ rcSources.push(readUser({ name: options.rcFile, dir: options.cwd }));
1493
+ }
1494
+ _configs.rc = _merger({}, ...rcSources);
1495
+ }
1496
+ if (options.packageJson) {
1497
+ const keys = (Array.isArray(options.packageJson) ? options.packageJson : [
1498
+ typeof options.packageJson === "string" ? options.packageJson : options.name
1499
+ ]).filter((t) => t && typeof t === "string");
1500
+ const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {
1501
+ });
1502
+ const values = keys.map((key) => pkgJsonFile?.[key]);
1503
+ _configs.packageJson = _merger({}, ...values);
1504
+ }
1505
+ const configs = {};
1506
+ for (const key in _configs) {
1507
+ const value = _configs[key];
1508
+ configs[key] = await (typeof value === "function" ? value({ configs }) : value);
1509
+ }
1510
+ r.config = _merger(
1511
+ configs.overrides,
1512
+ configs.main,
1513
+ configs.rc,
1514
+ configs.packageJson,
1515
+ configs.defaultConfig
1516
+ );
1517
+ if (options.extend) {
1518
+ await extendConfig(r.config, options);
1519
+ r.layers = r.config._layers;
1520
+ delete r.config._layers;
1521
+ r.config = _merger(r.config, ...r.layers.map((e) => e.config));
1522
+ }
1523
+ const baseLayers = [
1524
+ configs.overrides && {
1525
+ config: configs.overrides,
1526
+ configFile: void 0,
1527
+ cwd: void 0
1528
+ },
1529
+ { config: configs.main, configFile: options.configFile, cwd: options.cwd },
1530
+ configs.rc && { config: configs.rc, configFile: options.rcFile },
1531
+ configs.packageJson && {
1532
+ config: configs.packageJson,
1533
+ configFile: "package.json"
1534
+ }
1535
+ ].filter((l) => l && l.config);
1536
+ r.layers = [...baseLayers, ...r.layers];
1537
+ if (options.defaults) {
1538
+ r.config = _merger(r.config, options.defaults);
1539
+ }
1540
+ if (options.omit$Keys) {
1541
+ for (const key in r.config) {
1542
+ if (key.startsWith("$")) {
1543
+ delete r.config[key];
1544
+ }
1545
+ }
1546
+ }
1547
+ return r;
1548
+ }
1549
+ __name(loadConfig2, "loadConfig");
1550
+ async function extendConfig(config, options) {
1551
+ config._layers = config._layers || [];
1552
+ if (!options.extend) {
1553
+ return;
1554
+ }
1555
+ let keys = options.extend.extendKey;
1556
+ if (typeof keys === "string") {
1557
+ keys = [keys];
1558
+ }
1559
+ const extendSources = [];
1560
+ for (const key of keys) {
1561
+ extendSources.push(
1562
+ ...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(
1563
+ Boolean
1564
+ )
1565
+ );
1566
+ delete config[key];
1567
+ }
1568
+ for (let extendSource of extendSources) {
1569
+ const originalExtendSource = extendSource;
1570
+ let sourceOptions = {};
1571
+ if (extendSource.source) {
1572
+ sourceOptions = extendSource.options || {};
1573
+ extendSource = extendSource.source;
1574
+ }
1575
+ if (Array.isArray(extendSource)) {
1576
+ sourceOptions = extendSource[1] || {};
1577
+ extendSource = extendSource[0];
1578
+ }
1579
+ if (typeof extendSource !== "string") {
1580
+ console.warn(
1581
+ `Cannot extend config from \`${JSON.stringify(
1582
+ originalExtendSource
1583
+ )}\` in ${options.cwd}`
1584
+ );
1585
+ continue;
1586
+ }
1587
+ const _config = await resolveConfig(extendSource, options, sourceOptions);
1588
+ if (!_config.config) {
1589
+ console.warn(
1590
+ `Cannot extend config from \`${extendSource}\` in ${options.cwd}`
1591
+ );
1592
+ continue;
1593
+ }
1594
+ await extendConfig(_config.config, { ...options, cwd: _config.cwd });
1595
+ config._layers.push(_config);
1596
+ if (_config.config._layers) {
1597
+ config._layers.push(..._config.config._layers);
1598
+ delete _config.config._layers;
1599
+ }
1600
+ }
1601
+ }
1602
+ __name(extendConfig, "extendConfig");
1603
+ var GIGET_PREFIXES = [
1604
+ "gh:",
1605
+ "github:",
1606
+ "gitlab:",
1607
+ "bitbucket:",
1608
+ "https://",
1609
+ "http://"
1610
+ ];
1611
+ var NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
1612
+ async function resolveConfig(source, options, sourceOptions = {}) {
1613
+ if (options.resolve) {
1614
+ const res2 = await options.resolve(source, options);
1615
+ if (res2) {
1616
+ return res2;
1617
+ }
1618
+ }
1619
+ const _merger = options.merger || defu2;
1620
+ if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
1621
+ const { downloadTemplate } = await import("./dist-LXRVOZWD.mjs");
1622
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
1623
+ let cloneDir;
1624
+ const localNodeModules = resolve(options.cwd, "node_modules");
1625
+ const parentDir = dirname(options.cwd);
1626
+ if (basename(parentDir) === ".c12") {
1627
+ cloneDir = join(parentDir, cloneName);
1628
+ } else if (existsSync2(localNodeModules)) {
1629
+ cloneDir = join(localNodeModules, ".c12", cloneName);
1630
+ } else {
1631
+ cloneDir = process.env.XDG_CACHE_HOME ? resolve(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve(homedir2(), ".cache/c12", cloneName);
1632
+ }
1633
+ if (existsSync2(cloneDir) && !sourceOptions.install) {
1634
+ await rm(cloneDir, { recursive: true });
1635
+ }
1636
+ const cloned = await downloadTemplate(source, {
1637
+ dir: cloneDir,
1638
+ install: sourceOptions.install,
1639
+ force: sourceOptions.install,
1640
+ auth: sourceOptions.auth,
1641
+ ...options.giget,
1642
+ ...sourceOptions.giget
1643
+ });
1644
+ source = cloned.dir;
1645
+ }
1646
+ const tryResolve = /* @__PURE__ */ __name((id) => {
1647
+ const resolved = options.jiti.esmResolve(id, { try: true });
1648
+ return resolved ? fileURLToPath(resolved) : void 0;
1649
+ }, "tryResolve");
1650
+ if (NPM_PACKAGE_RE.test(source)) {
1651
+ source = tryResolve(source) || source;
1652
+ }
1653
+ const ext = extname(source);
1654
+ const isDir = !ext || ext === basename(source);
1655
+ const cwd = resolve(options.cwd, isDir ? source : dirname(source));
1656
+ if (isDir) {
1657
+ source = options.configFile;
1658
+ }
1659
+ const res = {
1660
+ config: void 0,
1661
+ configFile: void 0,
1662
+ cwd,
1663
+ source,
1664
+ sourceOptions
1665
+ };
1666
+ res.configFile = tryResolve(resolve(cwd, source)) || tryResolve(resolve(cwd, ".config", source.replace(/\.config$/, ""))) || tryResolve(resolve(cwd, ".config", source)) || source;
1667
+ if (!existsSync2(res.configFile)) {
1668
+ return res;
1669
+ }
1670
+ const configFileExt = extname(res.configFile) || "";
1671
+ if (configFileExt in ASYNC_LOADERS) {
1672
+ const asyncLoader = await ASYNC_LOADERS[configFileExt]();
1673
+ const contents = await readFile(res.configFile, "utf8");
1674
+ res.config = asyncLoader(contents);
1675
+ } else {
1676
+ res.config = await options.jiti.import(res.configFile, {
1677
+ default: true
1678
+ });
1679
+ }
1680
+ if (res.config instanceof Function) {
1681
+ res.config = await res.config();
1682
+ }
1683
+ if (options.envName) {
1684
+ const envConfig = {
1685
+ ...res.config["$" + options.envName],
1686
+ ...res.config.$env?.[options.envName]
1687
+ };
1688
+ if (Object.keys(envConfig).length > 0) {
1689
+ res.config = _merger(envConfig, res.config);
1690
+ }
1691
+ }
1692
+ res.meta = defu2(res.sourceOptions.meta, res.config.$meta);
1693
+ delete res.config.$meta;
1694
+ if (res.sourceOptions.overrides) {
1695
+ res.config = _merger(res.sourceOptions.overrides, res.config);
1696
+ }
1697
+ res.configFile = _normalize(res.configFile);
1698
+ res.source = _normalize(res.source);
1699
+ return res;
1700
+ }
1701
+ __name(resolveConfig, "resolveConfig");
1702
+
1703
+ // ../../node_modules/.pnpm/c12@2.0.1/node_modules/c12/dist/index.mjs
1704
+ import "jiti";
1705
+ import "defu";
1706
+ var import_dotenv = __toESM(require_main(), 1);
1707
+
1708
+ // ../config-tools/src/config-file/get-config-file.ts
1709
+ import defu3 from "defu";
1710
+ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
1711
+ const workspacePath = filePath || findWorkspaceRoot(filePath);
1712
+ let config = await loadConfig2({
1713
+ cwd: workspacePath,
1714
+ packageJson: true,
1715
+ name: fileName,
1716
+ envName: fileName?.toUpperCase(),
1717
+ jitiOptions: {
1718
+ debug: false,
1719
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
1720
+ },
1721
+ ...options
1722
+ });
1723
+ if (!config || Object.keys(config).length === 0) {
1724
+ config = await loadConfig2({
1725
+ cwd: workspacePath,
1726
+ packageJson: true,
1727
+ name: fileName,
1728
+ envName: fileName?.toUpperCase(),
1729
+ jitiOptions: {
1730
+ debug: false,
1731
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
1732
+ },
1733
+ configFile: fileName,
1734
+ ...options
1735
+ });
1736
+ }
1737
+ return config;
1738
+ }, "getConfigFileByName");
1739
+ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
1740
+ const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
1741
+ const result = await getConfigFileByName("storm", workspacePath);
1742
+ let config = result.config;
1743
+ const configFile = result.configFile;
1744
+ if (config && configFile && Object.keys(config).length > 0) {
1745
+ writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
1746
+ logLevel: "all"
1747
+ });
1748
+ }
1749
+ if (additionalFileNames && additionalFileNames.length > 0) {
1750
+ const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
1751
+ for (const result2 of results) {
1752
+ if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
1753
+ writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
1754
+ logLevel: "all"
1755
+ });
1756
+ config = defu3(result2.config ?? {}, config ?? {});
1757
+ }
1758
+ }
1759
+ }
1760
+ if (!config) {
1761
+ return void 0;
1762
+ }
1763
+ config.configFile = configFile;
1764
+ return config;
1765
+ }, "getConfigFile");
1766
+
1767
+ // ../config-tools/src/env/get-env.ts
1768
+ init_esm_shims();
1769
+ import { COLOR_KEYS, STORM_DEFAULT_DOCS, STORM_DEFAULT_HOMEPAGE, STORM_DEFAULT_LICENSING } from "@storm-software/config";
1770
+ var getConfigEnv = /* @__PURE__ */ __name(() => {
1771
+ const prefix = "STORM_";
1772
+ let config = {
1773
+ extends: process.env[`${prefix}EXTENDS`] || void 0,
1774
+ name: process.env[`${prefix}NAME`] || void 0,
1775
+ namespace: process.env[`${prefix}NAMESPACE`] || void 0,
1776
+ owner: process.env[`${prefix}OWNER`] || void 0,
1777
+ bot: {
1778
+ name: process.env[`${prefix}BOT_NAME`] || void 0,
1779
+ email: process.env[`${prefix}BOT_EMAIL`] || void 0
1780
+ },
1781
+ organization: process.env[`${prefix}ORGANIZATION`] || void 0,
1782
+ packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
1783
+ license: process.env[`${prefix}LICENSE`] || void 0,
1784
+ homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
1785
+ docs: process.env[`${prefix}DOCS`] || void 0,
1786
+ licensing: process.env[`${prefix}LICENSING`] || void 0,
1787
+ timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
1788
+ locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
1789
+ configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
1790
+ workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
1791
+ directories: {
1792
+ cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
1793
+ data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
1794
+ config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
1795
+ temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
1796
+ log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
1797
+ build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
1798
+ },
1799
+ skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
1800
+ env: (process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
1801
+ // ci:
1802
+ // process.env[`${prefix}CI`] !== undefined
1803
+ // ? Boolean(
1804
+ // process.env[`${prefix}CI`] ??
1805
+ // process.env.CI ??
1806
+ // process.env.CONTINUOUS_INTEGRATION
1807
+ // )
1808
+ // : undefined,
1809
+ repository: process.env[`${prefix}REPOSITORY`] || void 0,
1810
+ branch: process.env[`${prefix}BRANCH`] || void 0,
1811
+ preid: process.env[`${prefix}PRE_ID`] || void 0,
1812
+ externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
1813
+ registry: {
1814
+ github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
1815
+ npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
1816
+ cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
1817
+ cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
1818
+ container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
1819
+ },
1820
+ 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
1821
+ };
1822
+ 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}`)));
1823
+ config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
1824
+ ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
1825
+ return ret;
1826
+ }, {}) : getThemeColorConfigEnv(prefix);
1827
+ if (config.docs === STORM_DEFAULT_DOCS) {
1828
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
1829
+ config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
1830
+ } else {
1831
+ config.docs = `${config.homepage}/docs`;
1832
+ }
1833
+ }
1834
+ if (config.licensing === STORM_DEFAULT_LICENSING) {
1835
+ if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
1836
+ config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
1837
+ } else {
1838
+ config.licensing = `${config.homepage}/docs`;
1839
+ }
1840
+ }
1841
+ const serializedConfig = process.env[`${prefix}CONFIG`];
1842
+ if (serializedConfig) {
1843
+ const parsed = JSON.parse(serializedConfig);
1844
+ config = {
1845
+ ...config,
1846
+ ...parsed,
1847
+ colors: {
1848
+ ...config.colors,
1849
+ ...parsed.colors
1850
+ },
1851
+ extensions: {
1852
+ ...config.extensions,
1853
+ ...parsed.extensions
1854
+ }
1855
+ };
1856
+ }
1857
+ return config;
1858
+ }, "getConfigEnv");
1859
+ var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
1860
+ const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
1861
+ return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
1862
+ }, "getThemeColorConfigEnv");
1863
+ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
1864
+ return {
1865
+ dark: process.env[`${prefix}DARK`],
1866
+ light: process.env[`${prefix}LIGHT`],
1867
+ brand: process.env[`${prefix}BRAND`],
1868
+ alternate: process.env[`${prefix}ALTERNATE`],
1869
+ accent: process.env[`${prefix}ACCENT`],
1870
+ link: process.env[`${prefix}LINK`],
1871
+ help: process.env[`${prefix}HELP`],
1872
+ success: process.env[`${prefix}SUCCESS`],
1873
+ info: process.env[`${prefix}INFO`],
1874
+ warning: process.env[`${prefix}WARNING`],
1875
+ danger: process.env[`${prefix}DANGER`],
1876
+ fatal: process.env[`${prefix}FATAL`],
1877
+ positive: process.env[`${prefix}POSITIVE`],
1878
+ negative: process.env[`${prefix}NEGATIVE`]
1879
+ };
1880
+ }, "getSingleThemeColorConfigEnv");
1881
+ var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
1882
+ return {
1883
+ light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
1884
+ dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
1885
+ };
1886
+ }, "getMultiThemeColorConfigEnv");
1887
+ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
1888
+ return {
1889
+ foreground: process.env[`${prefix}FOREGROUND`],
1890
+ background: process.env[`${prefix}BACKGROUND`],
1891
+ brand: process.env[`${prefix}BRAND`],
1892
+ alternate: process.env[`${prefix}ALTERNATE`],
1893
+ accent: process.env[`${prefix}ACCENT`],
1894
+ link: process.env[`${prefix}LINK`],
1895
+ help: process.env[`${prefix}HELP`],
1896
+ success: process.env[`${prefix}SUCCESS`],
1897
+ info: process.env[`${prefix}INFO`],
1898
+ warning: process.env[`${prefix}WARNING`],
1899
+ danger: process.env[`${prefix}DANGER`],
1900
+ fatal: process.env[`${prefix}FATAL`],
1901
+ positive: process.env[`${prefix}POSITIVE`],
1902
+ negative: process.env[`${prefix}NEGATIVE`]
1903
+ };
1904
+ }, "getBaseThemeColorConfigEnv");
1905
+
1906
+ // ../config-tools/src/env/set-env.ts
1907
+ init_esm_shims();
1908
+ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
1909
+ for (const key of Object.keys(extension ?? {})) {
1910
+ if (extension[key]) {
1911
+ const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
1912
+ let extensionKey;
1913
+ if (result.length === 0) {
1914
+ return;
1915
+ }
1916
+ if (result.length === 1) {
1917
+ extensionKey = result[0]?.toUpperCase() ?? "";
1918
+ } else {
1919
+ extensionKey = result.reduce((ret, part) => {
1920
+ return `${ret}_${part.toLowerCase()}`;
1921
+ });
1922
+ }
1923
+ process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
1924
+ }
1925
+ }
1926
+ }, "setExtensionEnv");
1927
+ var setConfigEnv = /* @__PURE__ */ __name((config) => {
1928
+ const prefix = "STORM_";
1929
+ if (config.extends) {
1930
+ process.env[`${prefix}EXTENDS`] = config.extends;
1931
+ }
1932
+ if (config.name) {
1933
+ process.env[`${prefix}NAME`] = config.name;
1934
+ }
1935
+ if (config.namespace) {
1936
+ process.env[`${prefix}NAMESPACE`] = config.namespace;
1937
+ }
1938
+ if (config.owner) {
1939
+ process.env[`${prefix}OWNER`] = config.owner;
1940
+ }
1941
+ if (config.bot) {
1942
+ process.env[`${prefix}BOT_NAME`] = config.bot.name;
1943
+ process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
1944
+ }
1945
+ if (config.organization) {
1946
+ process.env[`${prefix}ORGANIZATION`] = config.organization;
1947
+ }
1948
+ if (config.packageManager) {
1949
+ process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
1950
+ }
1951
+ if (config.license) {
1952
+ process.env[`${prefix}LICENSE`] = config.license;
1953
+ }
1954
+ if (config.homepage) {
1955
+ process.env[`${prefix}HOMEPAGE`] = config.homepage;
1956
+ }
1957
+ if (config.docs) {
1958
+ process.env[`${prefix}DOCS`] = config.docs;
1959
+ }
1960
+ if (config.licensing) {
1961
+ process.env[`${prefix}LICENSING`] = config.licensing;
1962
+ }
1963
+ if (config.timezone) {
1964
+ process.env[`${prefix}TIMEZONE`] = config.timezone;
1965
+ process.env.TZ = config.timezone;
1966
+ process.env.DEFAULT_TIMEZONE = config.timezone;
1967
+ }
1968
+ if (config.locale) {
1969
+ process.env[`${prefix}LOCALE`] = config.locale;
1970
+ process.env.LOCALE = config.locale;
1971
+ process.env.DEFAULT_LOCALE = config.locale;
1972
+ process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
1973
+ }
1974
+ if (config.configFile) {
1975
+ process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
1976
+ }
1977
+ if (config.workspaceRoot) {
1978
+ process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
1979
+ process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
1980
+ process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
1981
+ }
1982
+ if (config.directories) {
1983
+ if (!config.skipCache && config.directories.cache) {
1984
+ process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
1985
+ }
1986
+ if (config.directories.data) {
1987
+ process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
1988
+ }
1989
+ if (config.directories.config) {
1990
+ process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
1991
+ }
1992
+ if (config.directories.temp) {
1993
+ process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
1994
+ }
1995
+ if (config.directories.log) {
1996
+ process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
1997
+ }
1998
+ if (config.directories.build) {
1999
+ process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
2000
+ }
2001
+ }
2002
+ if (config.skipCache !== void 0) {
2003
+ process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
2004
+ if (config.skipCache) {
2005
+ process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
2006
+ process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
2007
+ }
2008
+ }
2009
+ if (config.env) {
2010
+ process.env[`${prefix}ENV`] = config.env;
2011
+ process.env.NODE_ENV = config.env;
2012
+ process.env.ENVIRONMENT = config.env;
2013
+ }
2014
+ if (config.colors?.base?.light || config.colors?.base?.dark) {
2015
+ for (const key of Object.keys(config.colors)) {
2016
+ setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
2017
+ }
2018
+ } else {
2019
+ setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
2020
+ }
2021
+ if (config.repository) {
2022
+ process.env[`${prefix}REPOSITORY`] = config.repository;
2023
+ }
2024
+ if (config.branch) {
2025
+ process.env[`${prefix}BRANCH`] = config.branch;
2026
+ }
2027
+ if (config.preid) {
2028
+ process.env[`${prefix}PRE_ID`] = String(config.preid);
2029
+ }
2030
+ if (config.externalPackagePatterns) {
2031
+ process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
2032
+ }
2033
+ if (config.registry) {
2034
+ if (config.registry.github) {
2035
+ process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
2036
+ }
2037
+ if (config.registry.npm) {
2038
+ process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
2039
+ }
2040
+ if (config.registry.cargo) {
2041
+ process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
2042
+ }
2043
+ if (config.registry.cyclone) {
2044
+ process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
2045
+ }
2046
+ if (config.registry.container) {
2047
+ process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
2048
+ }
2049
+ }
2050
+ if (config.logLevel) {
2051
+ process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
2052
+ process.env.LOG_LEVEL = String(config.logLevel);
2053
+ process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
2054
+ process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
2055
+ }
2056
+ process.env[`${prefix}CONFIG`] = JSON.stringify(config);
2057
+ for (const key of Object.keys(config.extensions ?? {})) {
2058
+ config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
2059
+ }
2060
+ }, "setConfigEnv");
2061
+ var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
2062
+ return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
2063
+ }, "setThemeColorConfigEnv");
2064
+ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
2065
+ if (config.dark) {
2066
+ process.env[`${prefix}DARK`] = config.dark;
2067
+ }
2068
+ if (config.light) {
2069
+ process.env[`${prefix}LIGHT`] = config.light;
2070
+ }
2071
+ if (config.brand) {
2072
+ process.env[`${prefix}BRAND`] = config.brand;
2073
+ }
2074
+ if (config.alternate) {
2075
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
2076
+ }
2077
+ if (config.accent) {
2078
+ process.env[`${prefix}ACCENT`] = config.accent;
2079
+ }
2080
+ if (config.link) {
2081
+ process.env[`${prefix}LINK`] = config.link;
2082
+ }
2083
+ if (config.help) {
2084
+ process.env[`${prefix}HELP`] = config.help;
2085
+ }
2086
+ if (config.success) {
2087
+ process.env[`${prefix}SUCCESS`] = config.success;
2088
+ }
2089
+ if (config.info) {
2090
+ process.env[`${prefix}INFO`] = config.info;
2091
+ }
2092
+ if (config.warning) {
2093
+ process.env[`${prefix}WARNING`] = config.warning;
2094
+ }
2095
+ if (config.danger) {
2096
+ process.env[`${prefix}DANGER`] = config.danger;
2097
+ }
2098
+ if (config.fatal) {
2099
+ process.env[`${prefix}FATAL`] = config.fatal;
2100
+ }
2101
+ if (config.positive) {
2102
+ process.env[`${prefix}POSITIVE`] = config.positive;
2103
+ }
2104
+ if (config.negative) {
2105
+ process.env[`${prefix}NEGATIVE`] = config.negative;
2106
+ }
2107
+ }, "setSingleThemeColorConfigEnv");
2108
+ var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
2109
+ return {
2110
+ light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
2111
+ dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
2112
+ };
2113
+ }, "setMultiThemeColorConfigEnv");
2114
+ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
2115
+ if (config.foreground) {
2116
+ process.env[`${prefix}FOREGROUND`] = config.foreground;
2117
+ }
2118
+ if (config.background) {
2119
+ process.env[`${prefix}BACKGROUND`] = config.background;
2120
+ }
2121
+ if (config.brand) {
2122
+ process.env[`${prefix}BRAND`] = config.brand;
2123
+ }
2124
+ if (config.alternate) {
2125
+ process.env[`${prefix}ALTERNATE`] = config.alternate;
2126
+ }
2127
+ if (config.accent) {
2128
+ process.env[`${prefix}ACCENT`] = config.accent;
2129
+ }
2130
+ if (config.link) {
2131
+ process.env[`${prefix}LINK`] = config.link;
2132
+ }
2133
+ if (config.help) {
2134
+ process.env[`${prefix}HELP`] = config.help;
2135
+ }
2136
+ if (config.success) {
2137
+ process.env[`${prefix}SUCCESS`] = config.success;
2138
+ }
2139
+ if (config.info) {
2140
+ process.env[`${prefix}INFO`] = config.info;
2141
+ }
2142
+ if (config.warning) {
2143
+ process.env[`${prefix}WARNING`] = config.warning;
2144
+ }
2145
+ if (config.danger) {
2146
+ process.env[`${prefix}DANGER`] = config.danger;
2147
+ }
2148
+ if (config.fatal) {
2149
+ process.env[`${prefix}FATAL`] = config.fatal;
2150
+ }
2151
+ if (config.positive) {
2152
+ process.env[`${prefix}POSITIVE`] = config.positive;
2153
+ }
2154
+ if (config.negative) {
2155
+ process.env[`${prefix}NEGATIVE`] = config.negative;
2156
+ }
2157
+ }, "setBaseThemeColorConfigEnv");
2158
+
2159
+ // ../config-tools/src/create-storm-config.ts
2160
+ var _static_cache = void 0;
2161
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
2162
+ let config = {};
2163
+ if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
2164
+ writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
2165
+ return _static_cache.data;
2166
+ }
2167
+ let _workspaceRoot = workspaceRoot;
2168
+ if (!_workspaceRoot) {
2169
+ _workspaceRoot = findWorkspaceRoot();
2170
+ }
2171
+ const configFile = await getConfigFile(_workspaceRoot);
2172
+ if (!configFile) {
2173
+ 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", {
2174
+ logLevel: "all"
2175
+ });
2176
+ }
2177
+ config = defu4(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
2178
+ setConfigEnv(config);
2179
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
2180
+ ${formatLogMessage(config)}`, config);
2181
+ return config;
2182
+ }, "loadStormConfig");
2183
+
2184
+ // src/build.ts
2185
+ import defu5 from "defu";
2186
+ import { createJiti as createJiti2 } from "jiti";
2187
+ import { existsSync as existsSync3 } from "node:fs";
2188
+ import { readFile as readFile2 } from "node:fs/promises";
2189
+ import { relative } from "node:path";
2190
+ import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
2191
+ async function resolveOptions(options) {
2192
+ const projectRoot = options.projectRoot;
2193
+ if (!projectRoot) {
2194
+ throw new Error("Cannot find project root");
2195
+ }
2196
+ const outputPath = options.outputPath || joinPaths("dist", projectRoot);
2197
+ const workspaceRoot = findWorkspaceRoot2(projectRoot);
2198
+ if (!workspaceRoot) {
2199
+ throw new Error("Cannot find workspace root");
2200
+ }
2201
+ const config = await loadStormConfig(workspaceRoot.dir);
2202
+ writeDebug(" \u2699\uFE0F Resolving build options", config);
2203
+ const stopwatch = getStopwatch("Build options resolution");
2204
+ if (options.configPath) {
2205
+ const configFile = await loadConfig(options.configPath);
2206
+ if (configFile) {
2207
+ options = defu5(options, configFile);
2208
+ }
2209
+ }
2210
+ const projectGraph = readCachedProjectGraph();
2211
+ const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
2212
+ if (!existsSync3(projectJsonPath)) {
2213
+ throw new Error("Cannot find project.json configuration");
2214
+ }
2215
+ const projectJsonContent = await readFile2(projectJsonPath, "utf8");
2216
+ const projectJson = JSON.parse(projectJsonContent);
2217
+ const projectName = projectJson.name;
2218
+ const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
2219
+ if (!existsSync3(packageJsonPath)) {
2220
+ throw new Error("Cannot find package.json configuration");
2221
+ }
2222
+ const packageJsonContent = await readFile2(packageJsonPath, "utf8");
2223
+ const packageJson = JSON.parse(packageJsonContent);
2224
+ let tsconfig = options.tsconfig;
2225
+ if (!tsconfig) {
2226
+ tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
2227
+ }
2228
+ if (!existsSync3(tsconfig)) {
2229
+ throw new Error("Cannot find tsconfig.json configuration");
2230
+ }
2231
+ let sourceRoot = projectJson.sourceRoot;
2232
+ if (!sourceRoot) {
2233
+ sourceRoot = joinPaths(projectRoot, "src");
2234
+ }
2235
+ if (!existsSync3(sourceRoot)) {
2236
+ throw new Error("Cannot find sourceRoot directory");
2237
+ }
2238
+ const result = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
2239
+ let dependencies = result.dependencies;
2240
+ const tsLibDependency = getHelperDependency(HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
2241
+ if (tsLibDependency) {
2242
+ dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
2243
+ dependencies.push(tsLibDependency);
2244
+ }
2245
+ const jiti = createJiti2(config.workspaceRoot, {
2246
+ fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
2247
+ interopDefault: true
2248
+ });
2249
+ const resolvedOptions = {
2250
+ name: projectName,
2251
+ config,
2252
+ projectRoot,
2253
+ sourceRoot,
2254
+ projectName,
2255
+ tsconfig,
2256
+ jiti,
2257
+ clean: false,
2258
+ entries: [
2259
+ {
2260
+ builder: "mkdist",
2261
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
2262
+ outDir: joinPaths(relative(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
2263
+ declaration: options.emitTypes !== false,
2264
+ format: "esm"
2265
+ },
2266
+ {
2267
+ builder: "mkdist",
2268
+ input: `.${sourceRoot.replace(projectRoot, "")}`,
2269
+ outDir: joinPaths(relative(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
2270
+ declaration: options.emitTypes !== false,
2271
+ format: "cjs",
2272
+ ext: "cjs"
2273
+ }
2274
+ ],
2275
+ declaration: options.emitTypes !== false ? "compatible" : false,
2276
+ failOnWarn: false,
2277
+ sourcemap: options.sourcemap ?? !!options.debug,
2278
+ outDir: outputPath,
2279
+ parallel: true,
2280
+ stub: false,
2281
+ stubOptions: {
2282
+ jiti: {}
2283
+ },
2284
+ externals: options.external ?? [],
2285
+ dependencies: [],
2286
+ peerDependencies: [],
2287
+ devDependencies: [],
2288
+ hooks: {},
2289
+ alias: {},
2290
+ replace: {},
2291
+ rollup: {
2292
+ replace: {},
2293
+ alias: {},
2294
+ json: {},
2295
+ commonjs: {
2296
+ sourceMap: options.sourcemap ?? true
2297
+ },
2298
+ emitCJS: true,
2299
+ cjsBridge: true,
2300
+ dts: {
2301
+ respectExternal: true,
2302
+ tsconfig
2303
+ },
2304
+ output: {
2305
+ banner: options.banner || `
2306
+ // \u26A1 Built by Storm Software
2307
+ `,
2308
+ footer: options.footer
2309
+ },
2310
+ resolve: {
2311
+ preferBuiltins: true,
2312
+ extensions: [
2313
+ ".cjs",
2314
+ ".mjs",
2315
+ ".js",
2316
+ ".jsx",
2317
+ ".ts",
2318
+ ".tsx",
2319
+ ".json"
2320
+ ]
2321
+ },
2322
+ esbuild: {
2323
+ minify: options.minify !== false,
2324
+ splitting: options.splitting !== false,
2325
+ treeShaking: options.treeShaking !== false,
2326
+ color: true,
2327
+ logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
2328
+ }
2329
+ }
2330
+ };
2331
+ dependencies = dependencies.filter((dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app");
2332
+ if (dependencies.length > 0) {
2333
+ resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
2334
+ }
2335
+ if (packageJson.devDependencies) {
2336
+ resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
2337
+ }
2338
+ if (packageJson.peerDependencies) {
2339
+ resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
2340
+ }
2341
+ if (options.rollup) {
2342
+ let rollup = {};
2343
+ if (typeof options.rollup === "string") {
2344
+ const rollupFile = await loadConfig(options.rollup);
2345
+ if (rollupFile) {
2346
+ rollup = rollupFile;
2347
+ }
2348
+ } else {
2349
+ rollup = options.rollup;
2350
+ }
2351
+ resolvedOptions.rollup = defu5(resolvedOptions.rollup ?? {}, rollup);
2352
+ }
2353
+ resolvedOptions.hooks = {
2354
+ "rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
2355
+ opts.plugins = options.plugins ?? await getDefaultBuildPlugins(options, resolvedOptions);
2356
+ }, "rollup:options")
2357
+ };
2358
+ stopwatch();
2359
+ return resolvedOptions;
2360
+ }
2361
+ __name(resolveOptions, "resolveOptions");
2362
+ async function generatePackageJson(options) {
2363
+ if (options.generatePackageJson !== false && existsSync3(joinPaths(options.projectRoot, "package.json"))) {
2364
+ writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
2365
+ const stopwatch = getStopwatch("Write package.json file");
2366
+ const packageJsonPath = joinPaths(options.projectRoot, "project.json");
2367
+ if (!existsSync3(packageJsonPath)) {
2368
+ throw new Error("Cannot find package.json configuration");
2369
+ }
2370
+ let packageJsonContent = await readFile2(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
2371
+ if (!packageJsonContent) {
2372
+ throw new Error("Cannot find package.json configuration file");
2373
+ }
2374
+ let packageJson = JSON.parse(packageJsonContent);
2375
+ packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
2376
+ packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
2377
+ await writeJsonFile(joinPaths(options.outDir, "package.json"), await addPackageJsonExports(options.sourceRoot, packageJson));
2378
+ stopwatch();
2379
+ }
2380
+ return options;
2381
+ }
2382
+ __name(generatePackageJson, "generatePackageJson");
2383
+ async function resolveUnbuild(options) {
2384
+ writeTrace(`Resolving Unbuild package with Jiti`, options.config);
2385
+ try {
2386
+ return options.jiti.import("unbuild");
2387
+ } catch (error) {
2388
+ writeError(" \u274C An error occurred while resolving the Unbuild package", options.config);
2389
+ throw new Error("An error occurred while resolving the Unbuild package", {
2390
+ cause: error
2391
+ });
2392
+ }
2393
+ }
2394
+ __name(resolveUnbuild, "resolveUnbuild");
2395
+ async function executeUnbuild(options) {
2396
+ writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
2397
+ const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
2398
+ try {
2399
+ const unbuild = await resolveUnbuild(options);
2400
+ await unbuild.build(options.projectRoot, false, {
2401
+ ...options,
2402
+ rootDir: options.projectRoot
2403
+ });
2404
+ } finally {
2405
+ stopwatch();
2406
+ }
2407
+ return options;
2408
+ }
2409
+ __name(executeUnbuild, "executeUnbuild");
2410
+ async function copyBuildAssets(options) {
2411
+ writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
2412
+ const stopwatch = getStopwatch(`${options.name} asset copy`);
2413
+ await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
2414
+ stopwatch();
2415
+ return options;
2416
+ }
2417
+ __name(copyBuildAssets, "copyBuildAssets");
2418
+ async function cleanOutputPath(options) {
2419
+ if (options.clean !== false && options.outDir) {
2420
+ await clean(options.name, options.outDir, options.config);
2421
+ }
2422
+ return options;
2423
+ }
2424
+ __name(cleanOutputPath, "cleanOutputPath");
2425
+ async function build(options) {
2426
+ writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
2427
+ const stopwatch = getStopwatch("Unbuild pipeline");
2428
+ try {
2429
+ const resolvedOptions = await resolveOptions(options);
2430
+ await cleanOutputPath(resolvedOptions);
2431
+ await generatePackageJson(resolvedOptions);
2432
+ await executeUnbuild(resolvedOptions);
2433
+ await copyBuildAssets(resolvedOptions);
2434
+ writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, resolvedOptions.config);
2435
+ } catch (error) {
2436
+ writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
2437
+ throw error;
2438
+ } finally {
2439
+ stopwatch();
2440
+ }
2441
+ }
2442
+ __name(build, "build");
2443
+
2444
+ export {
2445
+ build
2446
+ };