@sentenel/node-utils 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/asset-manifest-cjs.json +15 -0
  3. package/dist/cjs/dotenv/dotenv.async.d.ts +3 -0
  4. package/dist/cjs/dotenv/dotenv.async.d.ts.map +1 -0
  5. package/dist/cjs/dotenv/dotenv.sync.d.ts +3 -0
  6. package/dist/cjs/dotenv/dotenv.sync.d.ts.map +1 -0
  7. package/dist/cjs/dotenv/index.d.ts +3 -0
  8. package/dist/cjs/dotenv/index.d.ts.map +1 -0
  9. package/dist/cjs/index.cjs +30 -706
  10. package/dist/cjs/index.d.ts +3 -0
  11. package/dist/cjs/index.d.ts.map +1 -0
  12. package/dist/cjs/paths/index.d.ts +2 -0
  13. package/dist/cjs/paths/index.d.ts.map +1 -0
  14. package/dist/cjs/paths/paths.d.ts +4 -0
  15. package/dist/cjs/paths/paths.d.ts.map +1 -0
  16. package/dist/cjs/paths/root.path.global.d.ts +12 -0
  17. package/dist/cjs/paths/root.path.global.d.ts.map +1 -0
  18. package/dist/esm/asset-manifest-mjs.json +15 -0
  19. package/dist/esm/dotenv/dotenv.async.d.ts +3 -0
  20. package/dist/esm/dotenv/dotenv.async.d.ts.map +1 -0
  21. package/dist/esm/dotenv/dotenv.sync.d.ts +3 -0
  22. package/dist/esm/dotenv/dotenv.sync.d.ts.map +1 -0
  23. package/dist/esm/dotenv/index.d.ts +3 -0
  24. package/dist/esm/dotenv/index.d.ts.map +1 -0
  25. package/dist/esm/index.d.ts +3 -0
  26. package/dist/esm/index.d.ts.map +1 -0
  27. package/dist/esm/index.js +2 -688
  28. package/dist/esm/paths/index.d.ts +2 -0
  29. package/dist/esm/paths/index.d.ts.map +1 -0
  30. package/dist/esm/paths/paths.d.ts +4 -0
  31. package/dist/esm/paths/paths.d.ts.map +1 -0
  32. package/dist/esm/paths/root.path.global.d.ts +12 -0
  33. package/dist/esm/paths/root.path.global.d.ts.map +1 -0
  34. package/package.json +2 -1
@@ -1,5 +1,22 @@
1
1
  "use strict";
2
- var __webpack_require__ = {};
2
+ var __webpack_modules__ = {
3
+ "./dotenv" (module) {
4
+ module.exports = require("./dotenv/index.cjs");
5
+ },
6
+ "./paths" (module) {
7
+ module.exports = require("./paths/index.cjs");
8
+ }
9
+ };
10
+ var __webpack_module_cache__ = {};
11
+ function __webpack_require__(moduleId) {
12
+ var cachedModule = __webpack_module_cache__[moduleId];
13
+ if (void 0 !== cachedModule) return cachedModule.exports;
14
+ var module = __webpack_module_cache__[moduleId] = {
15
+ exports: {}
16
+ };
17
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
18
+ return module.exports;
19
+ }
3
20
  (()=>{
4
21
  __webpack_require__.n = (module)=>{
5
22
  var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
@@ -31,711 +48,18 @@ var __webpack_require__ = {};
31
48
  };
32
49
  })();
33
50
  var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- asyncExpandDotEnv: ()=>asyncExpandDotEnv,
37
- syncExpandDotEnv: ()=>syncExpandDotEnv,
38
- resolveRootPath: ()=>resolveRootPath,
39
- resolveWorkspaceDirectory: ()=>resolveWorkspaceDirectory
40
- });
41
- const external_node_fs_namespaceObject = require("node:fs");
42
- const { NODE_ENV } = process.env;
43
- async function asyncExpandDotEnv(path) {
44
- const dotenvFiles = [
45
- `${path}.${NODE_ENV}.local`,
46
- `${path}.${NODE_ENV}`,
47
- "test" !== NODE_ENV ? `${path}.local` : null,
48
- path
49
- ].filter(Boolean);
50
- await Promise.all(dotenvFiles.map(async (dotenvFile)=>{
51
- if ((0, external_node_fs_namespaceObject.existsSync)(dotenvFile)) import("dotenv-expand").then(async ()=>{
52
- import("dotenv").then((config)=>{
53
- config.config({
54
- path: dotenvFile
55
- });
56
- });
57
- });
58
- }));
59
- }
60
- const external_dotenv_namespaceObject = require("dotenv");
61
- const external_dotenv_expand_namespaceObject = require("dotenv-expand");
62
- const { NODE_ENV: dotenv_sync_NODE_ENV } = process.env;
63
- async function syncExpandDotEnv(path) {
64
- const dotenvFiles = [
65
- `${path}.${dotenv_sync_NODE_ENV}.local`,
66
- `${path}.${dotenv_sync_NODE_ENV}`,
67
- "test" !== dotenv_sync_NODE_ENV ? `${path}.local` : null,
68
- path
69
- ].filter(Boolean);
70
- dotenvFiles.map(async (dotenvFile)=>{
71
- if ((0, external_node_fs_namespaceObject.existsSync)(dotenvFile)) (0, external_dotenv_expand_namespaceObject.expand)((0, external_dotenv_namespaceObject.config)({
72
- path: dotenvFile
73
- }));
74
- });
75
- }
76
- const external_node_path_namespaceObject = require("node:path");
77
- const external_node_module_namespaceObject = require("node:module");
78
- var external_node_module_default = /*#__PURE__*/ __webpack_require__.n(external_node_module_namespaceObject);
79
- const ANSI_BACKGROUND_OFFSET = 10;
80
- const wrapAnsi16 = (offset = 0)=>(code)=>`\u001B[${code + offset}m`;
81
- const wrapAnsi256 = (offset = 0)=>(code)=>`\u001B[${38 + offset};5;${code}m`;
82
- const wrapAnsi16m = (offset = 0)=>(red, green, blue)=>`\u001B[${38 + offset};2;${red};${green};${blue}m`;
83
- const styles = {
84
- modifier: {
85
- reset: [
86
- 0,
87
- 0
88
- ],
89
- bold: [
90
- 1,
91
- 22
92
- ],
93
- dim: [
94
- 2,
95
- 22
96
- ],
97
- italic: [
98
- 3,
99
- 23
100
- ],
101
- underline: [
102
- 4,
103
- 24
104
- ],
105
- overline: [
106
- 53,
107
- 55
108
- ],
109
- inverse: [
110
- 7,
111
- 27
112
- ],
113
- hidden: [
114
- 8,
115
- 28
116
- ],
117
- strikethrough: [
118
- 9,
119
- 29
120
- ]
121
- },
122
- color: {
123
- black: [
124
- 30,
125
- 39
126
- ],
127
- red: [
128
- 31,
129
- 39
130
- ],
131
- green: [
132
- 32,
133
- 39
134
- ],
135
- yellow: [
136
- 33,
137
- 39
138
- ],
139
- blue: [
140
- 34,
141
- 39
142
- ],
143
- magenta: [
144
- 35,
145
- 39
146
- ],
147
- cyan: [
148
- 36,
149
- 39
150
- ],
151
- white: [
152
- 37,
153
- 39
154
- ],
155
- blackBright: [
156
- 90,
157
- 39
158
- ],
159
- gray: [
160
- 90,
161
- 39
162
- ],
163
- grey: [
164
- 90,
165
- 39
166
- ],
167
- redBright: [
168
- 91,
169
- 39
170
- ],
171
- greenBright: [
172
- 92,
173
- 39
174
- ],
175
- yellowBright: [
176
- 93,
177
- 39
178
- ],
179
- blueBright: [
180
- 94,
181
- 39
182
- ],
183
- magentaBright: [
184
- 95,
185
- 39
186
- ],
187
- cyanBright: [
188
- 96,
189
- 39
190
- ],
191
- whiteBright: [
192
- 97,
193
- 39
194
- ]
195
- },
196
- bgColor: {
197
- bgBlack: [
198
- 40,
199
- 49
200
- ],
201
- bgRed: [
202
- 41,
203
- 49
204
- ],
205
- bgGreen: [
206
- 42,
207
- 49
208
- ],
209
- bgYellow: [
210
- 43,
211
- 49
212
- ],
213
- bgBlue: [
214
- 44,
215
- 49
216
- ],
217
- bgMagenta: [
218
- 45,
219
- 49
220
- ],
221
- bgCyan: [
222
- 46,
223
- 49
224
- ],
225
- bgWhite: [
226
- 47,
227
- 49
228
- ],
229
- bgBlackBright: [
230
- 100,
231
- 49
232
- ],
233
- bgGray: [
234
- 100,
235
- 49
236
- ],
237
- bgGrey: [
238
- 100,
239
- 49
240
- ],
241
- bgRedBright: [
242
- 101,
243
- 49
244
- ],
245
- bgGreenBright: [
246
- 102,
247
- 49
248
- ],
249
- bgYellowBright: [
250
- 103,
251
- 49
252
- ],
253
- bgBlueBright: [
254
- 104,
255
- 49
256
- ],
257
- bgMagentaBright: [
258
- 105,
259
- 49
260
- ],
261
- bgCyanBright: [
262
- 106,
263
- 49
264
- ],
265
- bgWhiteBright: [
266
- 107,
267
- 49
268
- ]
269
- }
270
- };
271
- Object.keys(styles.modifier);
272
- const foregroundColorNames = Object.keys(styles.color);
273
- const backgroundColorNames = Object.keys(styles.bgColor);
274
- [
275
- ...foregroundColorNames,
276
- ...backgroundColorNames
277
- ];
278
- function assembleStyles() {
279
- const codes = new Map();
280
- for (const [groupName, group] of Object.entries(styles)){
281
- for (const [styleName, style] of Object.entries(group)){
282
- styles[styleName] = {
283
- open: `\u001B[${style[0]}m`,
284
- close: `\u001B[${style[1]}m`
285
- };
286
- group[styleName] = styles[styleName];
287
- codes.set(style[0], style[1]);
288
- }
289
- Object.defineProperty(styles, groupName, {
290
- value: group,
291
- enumerable: false
292
- });
293
- }
294
- Object.defineProperty(styles, 'codes', {
295
- value: codes,
296
- enumerable: false
297
- });
298
- styles.color.close = '\u001B[39m';
299
- styles.bgColor.close = '\u001B[49m';
300
- styles.color.ansi = wrapAnsi16();
301
- styles.color.ansi256 = wrapAnsi256();
302
- styles.color.ansi16m = wrapAnsi16m();
303
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
304
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
305
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
306
- Object.defineProperties(styles, {
307
- rgbToAnsi256: {
308
- value (red, green, blue) {
309
- if (red === green && green === blue) {
310
- if (red < 8) return 16;
311
- if (red > 248) return 231;
312
- return Math.round((red - 8) / 247 * 24) + 232;
313
- }
314
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
315
- },
316
- enumerable: false
317
- },
318
- hexToRgb: {
319
- value (hex) {
320
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
321
- if (!matches) return [
322
- 0,
323
- 0,
324
- 0
325
- ];
326
- let [colorString] = matches;
327
- if (3 === colorString.length) colorString = [
328
- ...colorString
329
- ].map((character)=>character + character).join('');
330
- const integer = Number.parseInt(colorString, 16);
331
- return [
332
- integer >> 16 & 0xFF,
333
- integer >> 8 & 0xFF,
334
- 0xFF & integer
335
- ];
336
- },
337
- enumerable: false
338
- },
339
- hexToAnsi256: {
340
- value: (hex)=>styles.rgbToAnsi256(...styles.hexToRgb(hex)),
341
- enumerable: false
342
- },
343
- ansi256ToAnsi: {
344
- value (code) {
345
- if (code < 8) return 30 + code;
346
- if (code < 16) return 90 + (code - 8);
347
- let red;
348
- let green;
349
- let blue;
350
- if (code >= 232) {
351
- red = ((code - 232) * 10 + 8) / 255;
352
- green = red;
353
- blue = red;
354
- } else {
355
- code -= 16;
356
- const remainder = code % 36;
357
- red = Math.floor(code / 36) / 5;
358
- green = Math.floor(remainder / 6) / 5;
359
- blue = remainder % 6 / 5;
360
- }
361
- const value = 2 * Math.max(red, green, blue);
362
- if (0 === value) return 30;
363
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
364
- if (2 === value) result += 60;
365
- return result;
366
- },
367
- enumerable: false
368
- },
369
- rgbToAnsi: {
370
- value: (red, green, blue)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
371
- enumerable: false
372
- },
373
- hexToAnsi: {
374
- value: (hex)=>styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
375
- enumerable: false
376
- }
377
- });
378
- return styles;
379
- }
380
- const ansiStyles = assembleStyles();
381
- const ansi_styles = ansiStyles;
382
- const external_node_process_namespaceObject = require("node:process");
383
- const external_node_os_namespaceObject = require("node:os");
384
- const external_node_tty_namespaceObject = require("node:tty");
385
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : external_node_process_namespaceObject.argv) {
386
- const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
387
- const position = argv.indexOf(prefix + flag);
388
- const terminatorPosition = argv.indexOf('--');
389
- return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
390
- }
391
- const { env } = external_node_process_namespaceObject;
392
- let flagForceColor;
393
- if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
394
- else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
395
- function envForceColor() {
396
- if ('FORCE_COLOR' in env) {
397
- if ('true' === env.FORCE_COLOR) return 1;
398
- if ('false' === env.FORCE_COLOR) return 0;
399
- return 0 === env.FORCE_COLOR.length ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
400
- }
401
- }
402
- function translateLevel(level) {
403
- if (0 === level) return false;
404
- return {
405
- level,
406
- hasBasic: true,
407
- has256: level >= 2,
408
- has16m: level >= 3
409
- };
410
- }
411
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
412
- const noFlagForceColor = envForceColor();
413
- if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
414
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
415
- if (0 === forceColor) return 0;
416
- if (sniffFlags) {
417
- if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
418
- if (hasFlag('color=256')) return 2;
419
- }
420
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
421
- if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
422
- const min = forceColor || 0;
423
- if ('dumb' === env.TERM) return min;
424
- if ('win32' === external_node_process_namespaceObject.platform) {
425
- const osRelease = external_node_os_namespaceObject.release().split('.');
426
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
427
- return 1;
428
- }
429
- if ('CI' in env) {
430
- if ([
431
- 'GITHUB_ACTIONS',
432
- 'GITEA_ACTIONS',
433
- 'CIRCLECI'
434
- ].some((key)=>key in env)) return 3;
435
- if ([
436
- 'TRAVIS',
437
- 'APPVEYOR',
438
- 'GITLAB_CI',
439
- 'BUILDKITE',
440
- 'DRONE'
441
- ].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
442
- return min;
443
- }
444
- if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
445
- if ('truecolor' === env.COLORTERM) return 3;
446
- if ('xterm-kitty' === env.TERM) return 3;
447
- if ('xterm-ghostty' === env.TERM) return 3;
448
- if ('wezterm' === env.TERM) return 3;
449
- if ('TERM_PROGRAM' in env) {
450
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
451
- switch(env.TERM_PROGRAM){
452
- case 'iTerm.app':
453
- return version >= 3 ? 3 : 2;
454
- case 'Apple_Terminal':
455
- return 2;
456
- }
457
- }
458
- if (/-256(color)?$/i.test(env.TERM)) return 2;
459
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
460
- if ('COLORTERM' in env) return 1;
461
- return min;
462
- }
463
- function createSupportsColor(stream, options = {}) {
464
- const level = _supportsColor(stream, {
465
- streamIsTTY: stream && stream.isTTY,
466
- ...options
467
- });
468
- return translateLevel(level);
469
- }
470
- const supportsColor = {
471
- stdout: createSupportsColor({
472
- isTTY: external_node_tty_namespaceObject.isatty(1)
473
- }),
474
- stderr: createSupportsColor({
475
- isTTY: external_node_tty_namespaceObject.isatty(2)
476
- })
477
- };
478
- const supports_color = supportsColor;
479
- function stringReplaceAll(string, substring, replacer) {
480
- let index = string.indexOf(substring);
481
- if (-1 === index) return string;
482
- const substringLength = substring.length;
483
- let endIndex = 0;
484
- let returnValue = '';
485
- do {
486
- returnValue += string.slice(endIndex, index) + substring + replacer;
487
- endIndex = index + substringLength;
488
- index = string.indexOf(substring, endIndex);
489
- }while (-1 !== index);
490
- returnValue += string.slice(endIndex);
491
- return returnValue;
492
- }
493
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
494
- let endIndex = 0;
495
- let returnValue = '';
496
- do {
497
- const gotCR = '\r' === string[index - 1];
498
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
499
- endIndex = index + 1;
500
- index = string.indexOf('\n', endIndex);
501
- }while (-1 !== index);
502
- returnValue += string.slice(endIndex);
503
- return returnValue;
504
- }
505
- const { stdout: stdoutColor, stderr: stderrColor } = supports_color;
506
- const GENERATOR = Symbol('GENERATOR');
507
- const STYLER = Symbol('STYLER');
508
- const IS_EMPTY = Symbol('IS_EMPTY');
509
- const levelMapping = [
510
- 'ansi',
511
- 'ansi',
512
- 'ansi256',
513
- 'ansi16m'
514
- ];
515
- const source_styles = Object.create(null);
516
- const applyOptions = (object, options = {})=>{
517
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error('The `level` option should be an integer from 0 to 3');
518
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
519
- object.level = void 0 === options.level ? colorLevel : options.level;
520
- };
521
- const chalkFactory = (options)=>{
522
- const chalk = (...strings)=>strings.join(' ');
523
- applyOptions(chalk, options);
524
- Object.setPrototypeOf(chalk, createChalk.prototype);
525
- return chalk;
526
- };
527
- function createChalk(options) {
528
- return chalkFactory(options);
529
- }
530
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
531
- for (const [styleName, style] of Object.entries(ansi_styles))source_styles[styleName] = {
532
- get () {
533
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
534
- Object.defineProperty(this, styleName, {
535
- value: builder
536
- });
537
- return builder;
538
- }
539
- };
540
- source_styles.visible = {
541
- get () {
542
- const builder = createBuilder(this, this[STYLER], true);
543
- Object.defineProperty(this, 'visible', {
544
- value: builder
545
- });
546
- return builder;
547
- }
548
- };
549
- const getModelAnsi = (model, level, type, ...arguments_)=>{
550
- if ('rgb' === model) {
551
- if ('ansi16m' === level) return ansi_styles[type].ansi16m(...arguments_);
552
- if ('ansi256' === level) return ansi_styles[type].ansi256(ansi_styles.rgbToAnsi256(...arguments_));
553
- return ansi_styles[type].ansi(ansi_styles.rgbToAnsi(...arguments_));
554
- }
555
- if ('hex' === model) return getModelAnsi('rgb', level, type, ...ansi_styles.hexToRgb(...arguments_));
556
- return ansi_styles[type][model](...arguments_);
557
- };
558
- const usedModels = [
559
- 'rgb',
560
- 'hex',
561
- 'ansi256'
562
- ];
563
- for (const model of usedModels){
564
- source_styles[model] = {
565
- get () {
566
- const { level } = this;
567
- return function(...arguments_) {
568
- const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansi_styles.color.close, this[STYLER]);
569
- return createBuilder(this, styler, this[IS_EMPTY]);
570
- };
571
- }
572
- };
573
- const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
574
- source_styles[bgModel] = {
575
- get () {
576
- const { level } = this;
577
- return function(...arguments_) {
578
- const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansi_styles.bgColor.close, this[STYLER]);
579
- return createBuilder(this, styler, this[IS_EMPTY]);
580
- };
581
- }
582
- };
583
- }
584
- const proto = Object.defineProperties(()=>{}, {
585
- ...source_styles,
586
- level: {
587
- enumerable: true,
588
- get () {
589
- return this[GENERATOR].level;
590
- },
591
- set (level) {
592
- this[GENERATOR].level = level;
593
- }
594
- }
595
- });
596
- const createStyler = (open, close, parent)=>{
597
- let openAll;
598
- let closeAll;
599
- if (void 0 === parent) {
600
- openAll = open;
601
- closeAll = close;
602
- } else {
603
- openAll = parent.openAll + open;
604
- closeAll = close + parent.closeAll;
605
- }
606
- return {
607
- open,
608
- close,
609
- openAll,
610
- closeAll,
611
- parent
612
- };
613
- };
614
- const createBuilder = (self, _styler, _isEmpty)=>{
615
- const builder = (...arguments_)=>applyStyle(builder, 1 === arguments_.length ? '' + arguments_[0] : arguments_.join(' '));
616
- Object.setPrototypeOf(builder, proto);
617
- builder[GENERATOR] = self;
618
- builder[STYLER] = _styler;
619
- builder[IS_EMPTY] = _isEmpty;
620
- return builder;
621
- };
622
- const applyStyle = (self, string)=>{
623
- if (self.level <= 0 || !string) return self[IS_EMPTY] ? '' : string;
624
- let styler = self[STYLER];
625
- if (void 0 === styler) return string;
626
- const { openAll, closeAll } = styler;
627
- if (string.includes('\u001B')) while(void 0 !== styler){
628
- string = stringReplaceAll(string, styler.close, styler.open);
629
- styler = styler.parent;
630
- }
631
- const lfIndex = string.indexOf('\n');
632
- if (-1 !== lfIndex) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
633
- return openAll + string + closeAll;
634
- };
635
- Object.defineProperties(createChalk.prototype, source_styles);
636
- const source_chalk = createChalk();
637
- createChalk({
638
- level: stderrColor ? stderrColor.level : 0
639
- });
640
- const source = source_chalk;
641
- var root_path_global_ProcessEnvProp = /*#__PURE__*/ function(ProcessEnvProp) {
642
- ProcessEnvProp["WorkingDirLogsLevel"] = "ENABLE_WORKING_DIR_LOGS_LEVEL";
643
- ProcessEnvProp["RootWorkingDirectory"] = "ROOT_WORKING_DIRECTORY";
644
- return ProcessEnvProp;
645
- }(root_path_global_ProcessEnvProp || {});
646
- var root_path_global_WorkingDirLogsLevel = /*#__PURE__*/ function(WorkingDirLogsLevel) {
647
- WorkingDirLogsLevel["None"] = "none";
648
- WorkingDirLogsLevel["Info"] = "info";
649
- WorkingDirLogsLevel["Verbose"] = "verbose";
650
- return WorkingDirLogsLevel;
651
- }(root_path_global_WorkingDirLogsLevel || {});
652
- function logInfo(...args) {
653
- console.info("SENTENEL PATH::", source.blueBright(...args.map((arg)=>String(arg))));
654
- }
655
- function getRootWorkingDirectory() {
656
- const workingDirLogsLevel = process.env["ENABLE_WORKING_DIR_LOGS_LEVEL"] || "none";
657
- if (!Object.values(root_path_global_WorkingDirLogsLevel).includes(workingDirLogsLevel)) console.error(`Invalid value for environment variable ENABLE_WORKING_DIR_LOGS_LEVEL: ${workingDirLogsLevel}. Defaulting to none.`);
658
- if ("info" === workingDirLogsLevel || "verbose" === workingDirLogsLevel) logInfo("Getting root working directory from environment variable ROOT_WORKING_DIRECTORY...");
659
- const isVerbose = "verbose" === workingDirLogsLevel;
660
- const isInfo = "info" === workingDirLogsLevel || isVerbose;
661
- const currentWorkingDirectory = (0, external_node_fs_namespaceObject.realpathSync)(process.cwd());
662
- const nodeModulesPathList = external_node_module_default()._nodeModulePaths(currentWorkingDirectory);
663
- isVerbose && logInfo("Current working directory:", currentWorkingDirectory);
664
- isVerbose && logInfo("Node modules path list:", nodeModulesPathList);
665
- const packageJsonPathList = nodeModulesPathList.map((nodeModulesPath)=>{
666
- const packageJsonPath = nodeModulesPath.replace("node_modules", "package.json");
667
- return packageJsonPath;
668
- });
669
- isVerbose && logInfo("Package.json path list:", packageJsonPathList);
670
- const packageJsonExistsPathList = packageJsonPathList.filter((packageJsonPath)=>{
671
- try {
672
- (0, external_node_fs_namespaceObject.realpathSync)(packageJsonPath);
673
- return true;
674
- } catch {
675
- return false;
676
- }
677
- });
678
- isVerbose && logInfo("Existing package.json path list:", packageJsonExistsPathList);
679
- if (0 === packageJsonExistsPathList.length) isInfo && logInfo("No package.json found in node modules paths.");
680
- const workspacePackageJsonList = packageJsonExistsPathList.filter((packageJsonPath)=>{
681
- const packageJsonBuffer = (0, external_node_fs_namespaceObject.readFileSync)(packageJsonPath);
682
- const packageJsonContent = JSON.parse(packageJsonBuffer);
683
- if (packageJsonContent?.workspaces && packageJsonContent?.workspaces.length > 0) return true;
684
- return false;
685
- });
686
- isVerbose && logInfo("Workspace package.json list:", workspacePackageJsonList);
687
- if (0 === workspacePackageJsonList.length) {
688
- isInfo && logInfo("No workspace package.json found in node modules paths.");
689
- const rootWorkingDirectory = currentWorkingDirectory;
690
- if (!rootWorkingDirectory) throw new Error("Environment variable ROOT_WORKING_DIRECTORY is not set.");
691
- isInfo && logInfo(`Current working directory determined: ${currentWorkingDirectory}`);
692
- isInfo && logInfo(`Root working directory determined: ${rootWorkingDirectory}`);
693
- process.env["ROOT_WORKING_DIRECTORY"] = rootWorkingDirectory;
694
- return rootWorkingDirectory;
695
- }
696
- if (1 === workspacePackageJsonList.length) {
697
- isInfo && logInfo(`Single workspace package.json file found: ${workspacePackageJsonList[0]}`);
698
- const rootPackageJsonPath = (0, external_node_fs_namespaceObject.realpathSync)(workspacePackageJsonList[0]);
699
- const rootWorkingDirectory = rootPackageJsonPath.replace("/package.json", "");
700
- isInfo && logInfo(`Current working directory determined: ${currentWorkingDirectory}`);
701
- isInfo && logInfo(`Root working directory determined: ${rootWorkingDirectory}`);
702
- process.env["ROOT_WORKING_DIRECTORY"] = rootWorkingDirectory;
703
- return rootWorkingDirectory;
704
- }
705
- if (workspacePackageJsonList.length > 1) {
706
- isInfo && logInfo(`Multiple workspace package.json files found: ${workspacePackageJsonList.join(", ")}`);
707
- const rootWorkingDirectory = currentWorkingDirectory;
708
- isInfo && logInfo(`Current working directory determined (fallback): ${currentWorkingDirectory}`);
709
- isInfo && logInfo(`Root working directory determined (fallback): ${rootWorkingDirectory}`);
710
- process.env["ROOT_WORKING_DIRECTORY"] = rootWorkingDirectory;
711
- return rootWorkingDirectory;
712
- }
713
- console.error("Unable to determine root working directory.");
714
- }
715
- getRootWorkingDirectory();
716
- const paths_currentWorkingDirectory = (0, external_node_fs_namespaceObject.realpathSync)(process.cwd());
717
- const paths_rootWorkingDirectory = (0, external_node_fs_namespaceObject.realpathSync)(process.env["ROOT_WORKING_DIRECTORY"] || paths_currentWorkingDirectory);
718
- function resolveRootPath(relativePath) {
719
- if (!paths_rootWorkingDirectory) {
720
- console.log("Define \"process.env[ProcessEnvProp.WorkingDirLogsLevel]\"='none' | 'info' | 'verbose' to enable logging of the working directory resolution process.");
721
- throw new Error("Root working directory is not defined. Please set the environment variable ROOT_WORKING_DIRECTORY to the desired root working directory path.");
722
- }
723
- return external_node_path_namespaceObject.resolve(paths_rootWorkingDirectory, relativePath);
724
- }
725
- function resolveWorkspaceDirectory(relativePath) {
726
- if (!paths_currentWorkingDirectory) throw new Error("Current working directory is not defined. Please set the environment variable ROOT_WORKING_DIRECTORY to the desired root working directory path.");
727
- return external_node_path_namespaceObject.resolve(paths_currentWorkingDirectory, relativePath);
728
- }
729
- exports.asyncExpandDotEnv = __webpack_exports__.asyncExpandDotEnv;
730
- exports.resolveRootPath = __webpack_exports__.resolveRootPath;
731
- exports.resolveWorkspaceDirectory = __webpack_exports__.resolveWorkspaceDirectory;
732
- exports.syncExpandDotEnv = __webpack_exports__.syncExpandDotEnv;
733
- for(var __rspack_i in __webpack_exports__)if (-1 === [
734
- "asyncExpandDotEnv",
735
- "resolveRootPath",
736
- "resolveWorkspaceDirectory",
737
- "syncExpandDotEnv"
738
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
51
+ (()=>{
52
+ __webpack_require__.r(__webpack_exports__);
53
+ var _dotenv__rspack_import_0 = __webpack_require__("./dotenv");
54
+ var __rspack_reexport = {};
55
+ for(const __rspack_import_key in _dotenv__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_dotenv__rspack_import_0[__rspack_import_key];
56
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
57
+ var _paths__rspack_import_1 = __webpack_require__("./paths");
58
+ var __rspack_reexport = {};
59
+ for(const __rspack_import_key in _paths__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_paths__rspack_import_1[__rspack_import_key];
60
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
61
+ })();
62
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
739
63
  Object.defineProperty(exports, '__esModule', {
740
64
  value: true
741
65
  });