@storm-software/unbuild 0.25.2 → 0.26.0

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