@socketsecurity/lib 1.0.4 → 1.1.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 (80) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/abort.js.map +2 -2
  3. package/dist/argv/parse.js.map +2 -2
  4. package/dist/arrays.d.ts +143 -0
  5. package/dist/arrays.js.map +2 -2
  6. package/dist/bin.js +1 -4
  7. package/dist/bin.js.map +2 -2
  8. package/dist/cacache.d.ts +0 -2
  9. package/dist/cacache.js +0 -1
  10. package/dist/cacache.js.map +2 -2
  11. package/dist/cache-with-ttl.js.map +2 -2
  12. package/dist/dlx.js.map +2 -2
  13. package/dist/external/@yarnpkg/extensions.d.ts +0 -1
  14. package/dist/external/cacache.d.ts +0 -7
  15. package/dist/external/debug.d.ts +0 -3
  16. package/dist/external/fast-sort.d.ts +0 -1
  17. package/dist/external/libnpmpack.d.ts +0 -1
  18. package/dist/external/make-fetch-happen.d.ts +0 -1
  19. package/dist/external/pacote.d.ts +0 -5
  20. package/dist/external/semver.d.ts +0 -1
  21. package/dist/external/validate-npm-package-name.js +1 -1
  22. package/dist/external/yargs-parser.d.ts +0 -1
  23. package/dist/external/yoctocolors-cjs.js +1 -1
  24. package/dist/external/zod.js +9 -9
  25. package/dist/fs.d.ts +595 -23
  26. package/dist/fs.js.map +2 -2
  27. package/dist/git.d.ts +488 -41
  28. package/dist/git.js.map +2 -2
  29. package/dist/github.d.ts +361 -12
  30. package/dist/github.js.map +2 -2
  31. package/dist/http-request.d.ts +463 -4
  32. package/dist/http-request.js.map +2 -2
  33. package/dist/json.d.ts +177 -4
  34. package/dist/json.js.map +2 -2
  35. package/dist/logger.d.ts +823 -70
  36. package/dist/logger.js +654 -51
  37. package/dist/logger.js.map +2 -2
  38. package/dist/objects.d.ts +386 -10
  39. package/dist/objects.js.map +2 -2
  40. package/dist/path.d.ts +270 -6
  41. package/dist/path.js.map +2 -2
  42. package/dist/promises.d.ts +432 -27
  43. package/dist/promises.js +3 -0
  44. package/dist/promises.js.map +2 -2
  45. package/dist/signal-exit.js.map +2 -2
  46. package/dist/sorts.js.map +2 -2
  47. package/dist/spawn.d.ts +242 -33
  48. package/dist/spawn.js.map +2 -2
  49. package/dist/spinner.d.ts +260 -20
  50. package/dist/spinner.js +201 -63
  51. package/dist/spinner.js.map +2 -2
  52. package/dist/stdio/clear.d.ts +130 -9
  53. package/dist/stdio/clear.js.map +2 -2
  54. package/dist/stdio/divider.d.ts +106 -10
  55. package/dist/stdio/divider.js +10 -0
  56. package/dist/stdio/divider.js.map +2 -2
  57. package/dist/stdio/footer.d.ts +70 -3
  58. package/dist/stdio/footer.js.map +2 -2
  59. package/dist/stdio/header.d.ts +93 -12
  60. package/dist/stdio/header.js.map +2 -2
  61. package/dist/stdio/mask.d.ts +82 -14
  62. package/dist/stdio/mask.js +25 -4
  63. package/dist/stdio/mask.js.map +2 -2
  64. package/dist/stdio/progress.d.ts +112 -15
  65. package/dist/stdio/progress.js +43 -3
  66. package/dist/stdio/progress.js.map +2 -2
  67. package/dist/stdio/prompts.d.ts +95 -5
  68. package/dist/stdio/prompts.js.map +2 -2
  69. package/dist/stdio/stderr.d.ts +114 -11
  70. package/dist/stdio/stderr.js.map +2 -2
  71. package/dist/stdio/stdout.d.ts +107 -11
  72. package/dist/stdio/stdout.js.map +2 -2
  73. package/dist/strings.d.ts +357 -28
  74. package/dist/strings.js.map +2 -2
  75. package/dist/suppress-warnings.js.map +2 -2
  76. package/dist/validation/json-parser.d.ts +226 -7
  77. package/dist/validation/json-parser.js.map +2 -2
  78. package/dist/validation/types.d.ts +114 -12
  79. package/dist/validation/types.js.map +1 -1
  80. package/package.json +5 -3
package/dist/spinner.js CHANGED
@@ -294,31 +294,51 @@ function Spinner(options) {
294
294
  super.text = this.#buildDisplayText();
295
295
  }
296
296
  /**
297
- * Show a debug message without stopping the spinner (only if debug mode enabled).
297
+ * Show a debug message (ℹ) without stopping the spinner.
298
+ * Only displays if debug mode is enabled via environment variable.
298
299
  * Outputs to stderr and continues spinning.
300
+ *
301
+ * @param text - Debug message to display
302
+ * @param extras - Additional values to log
303
+ * @returns This spinner for chaining
299
304
  */
300
- debug(...args) {
305
+ debug(text, ...extras) {
301
306
  const { isDebug } = require("./debug.js");
302
307
  if (isDebug()) {
303
- return this.#showStatusAndKeepSpinning("info", args);
308
+ return this.#showStatusAndKeepSpinning("info", [text, ...extras]);
304
309
  }
305
310
  return this;
306
311
  }
307
312
  /**
308
- * Show a debug message and stop the spinner (only if debug mode enabled).
313
+ * Show a debug message (ℹ) and stop the spinner.
314
+ * Only displays if debug mode is enabled via environment variable.
309
315
  * Auto-clears the spinner line before displaying the message.
316
+ *
317
+ * @param text - Debug message to display
318
+ * @param extras - Additional values to log
319
+ * @returns This spinner for chaining
310
320
  */
311
- debugAndStop(...args) {
321
+ debugAndStop(text, ...extras) {
312
322
  const { isDebug } = require("./debug.js");
313
323
  if (isDebug()) {
314
- return this.#apply("info", args);
324
+ return this.#apply("info", [text, ...extras]);
315
325
  }
316
326
  return this;
317
327
  }
318
328
  /**
319
- * Decrease indentation level.
320
- * Pass 0 to reset indentation to zero.
321
- * @param spaces - Number of spaces to remove (default: 2)
329
+ * Decrease indentation level by removing spaces from the left.
330
+ * Pass 0 to reset indentation to zero completely.
331
+ *
332
+ * @param spaces - Number of spaces to remove
333
+ * @returns This spinner for chaining
334
+ * @default spaces=2
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * spinner.dedent() // Remove 2 spaces
339
+ * spinner.dedent(4) // Remove 4 spaces
340
+ * spinner.dedent(0) // Reset to zero indentation
341
+ * ```
322
342
  */
323
343
  dedent(spaces) {
324
344
  if (spaces === 0) {
@@ -332,40 +352,68 @@ function Spinner(options) {
332
352
  return this;
333
353
  }
334
354
  /**
335
- * Alias for success() (shorter name).
336
- * DESIGN DECISION: Unlike yocto-spinner, our done() does NOT stop the spinner.
337
- * Use doneAndStop() if you want to stop the spinner.
355
+ * Show a done/success message () without stopping the spinner.
356
+ * Alias for `success()` with a shorter name.
357
+ *
358
+ * DESIGN DECISION: Unlike yocto-spinner, our `done()` does NOT stop the spinner.
359
+ * Use `doneAndStop()` if you want to stop the spinner.
360
+ *
361
+ * @param text - Message to display
362
+ * @param extras - Additional values to log
363
+ * @returns This spinner for chaining
338
364
  */
339
- done(...args) {
340
- return this.#showStatusAndKeepSpinning("success", args);
365
+ done(text, ...extras) {
366
+ return this.#showStatusAndKeepSpinning("success", [text, ...extras]);
341
367
  }
342
368
  /**
343
- * Show a done message and stop the spinner.
369
+ * Show a done/success message (✓) and stop the spinner.
344
370
  * Auto-clears the spinner line before displaying the success message.
371
+ *
372
+ * @param text - Message to display
373
+ * @param extras - Additional values to log
374
+ * @returns This spinner for chaining
345
375
  */
346
- doneAndStop(...args) {
347
- return this.#apply("success", args);
376
+ doneAndStop(text, ...extras) {
377
+ return this.#apply("success", [text, ...extras]);
348
378
  }
349
379
  /**
350
- * Show a failure message without stopping the spinner.
351
- * DESIGN DECISION: Unlike yocto-spinner, our fail() does NOT stop the spinner.
380
+ * Show a failure message (✗) without stopping the spinner.
381
+ * DESIGN DECISION: Unlike yocto-spinner, our `fail()` does NOT stop the spinner.
352
382
  * This allows displaying errors while continuing to spin.
353
- * Use failAndStop() if you want to stop the spinner.
383
+ * Use `failAndStop()` if you want to stop the spinner.
384
+ *
385
+ * @param text - Error message to display
386
+ * @param extras - Additional values to log
387
+ * @returns This spinner for chaining
354
388
  */
355
- fail(...args) {
356
- return this.#showStatusAndKeepSpinning("fail", args);
389
+ fail(text, ...extras) {
390
+ return this.#showStatusAndKeepSpinning("fail", [text, ...extras]);
357
391
  }
358
392
  /**
359
- * Show a failure message and stop the spinner.
393
+ * Show a failure message (✗) and stop the spinner.
360
394
  * Auto-clears the spinner line before displaying the error message.
395
+ *
396
+ * @param text - Error message to display
397
+ * @param extras - Additional values to log
398
+ * @returns This spinner for chaining
361
399
  */
362
- failAndStop(...args) {
363
- return this.#apply("error", args);
400
+ failAndStop(text, ...extras) {
401
+ return this.#apply("error", [text, ...extras]);
364
402
  }
365
403
  /**
366
- * Increase indentation level.
367
- * Pass 0 to reset indentation to zero.
368
- * @param spaces - Number of spaces to add (default: 2)
404
+ * Increase indentation level by adding spaces to the left.
405
+ * Pass 0 to reset indentation to zero completely.
406
+ *
407
+ * @param spaces - Number of spaces to add
408
+ * @returns This spinner for chaining
409
+ * @default spaces=2
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * spinner.indent() // Add 2 spaces
414
+ * spinner.indent(4) // Add 4 spaces
415
+ * spinner.indent(0) // Reset to zero indentation
416
+ * ```
369
417
  */
370
418
  indent(spaces) {
371
419
  if (spaces === 0) {
@@ -378,22 +426,33 @@ function Spinner(options) {
378
426
  return this;
379
427
  }
380
428
  /**
381
- * Show an info message without stopping the spinner.
429
+ * Show an info message (ℹ) without stopping the spinner.
382
430
  * Outputs to stderr and continues spinning.
431
+ *
432
+ * @param text - Info message to display
433
+ * @param extras - Additional values to log
434
+ * @returns This spinner for chaining
383
435
  */
384
- info(...args) {
385
- return this.#showStatusAndKeepSpinning("info", args);
436
+ info(text, ...extras) {
437
+ return this.#showStatusAndKeepSpinning("info", [text, ...extras]);
386
438
  }
387
439
  /**
388
- * Show an info message and stop the spinner.
440
+ * Show an info message (ℹ) and stop the spinner.
389
441
  * Auto-clears the spinner line before displaying the message.
442
+ *
443
+ * @param text - Info message to display
444
+ * @param extras - Additional values to log
445
+ * @returns This spinner for chaining
390
446
  */
391
- infoAndStop(...args) {
392
- return this.#apply("info", args);
447
+ infoAndStop(text, ...extras) {
448
+ return this.#apply("info", [text, ...extras]);
393
449
  }
394
450
  /**
395
451
  * Log a message to stdout without stopping the spinner.
396
- * Unlike other methods, this outputs to stdout for data logging.
452
+ * Unlike other status methods, this outputs to stdout for data logging.
453
+ *
454
+ * @param args - Values to log to stdout
455
+ * @returns This spinner for chaining
397
456
  */
398
457
  log(...args) {
399
458
  const { logger } = require("./logger.js");
@@ -401,18 +460,30 @@ function Spinner(options) {
401
460
  return this;
402
461
  }
403
462
  /**
404
- * Log a message and stop the spinner.
463
+ * Log a message to stdout and stop the spinner.
405
464
  * Auto-clears the spinner line before displaying the message.
465
+ *
466
+ * @param text - Message to display
467
+ * @param extras - Additional values to log
468
+ * @returns This spinner for chaining
406
469
  */
407
- logAndStop(...args) {
408
- return this.#apply("stop", args);
470
+ logAndStop(text, ...extras) {
471
+ return this.#apply("stop", [text, ...extras]);
409
472
  }
410
473
  /**
411
474
  * Update progress information displayed with the spinner.
412
475
  * Shows a progress bar with percentage and optional unit label.
476
+ *
413
477
  * @param current - Current progress value
414
- * @param total - Total progress value
478
+ * @param total - Total/maximum progress value
415
479
  * @param unit - Optional unit label (e.g., 'files', 'items')
480
+ * @returns This spinner for chaining
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * spinner.progress(5, 10) // "███████░░░░░░░░░░░░░ 50% (5/10)"
485
+ * spinner.progress(7, 20, 'files') // "███████░░░░░░░░░░░░░ 35% (7/20 files)"
486
+ * ```
416
487
  */
417
488
  progress = (current, total, unit) => {
418
489
  this.#progress = {
@@ -427,7 +498,18 @@ function Spinner(options) {
427
498
  /**
428
499
  * Increment progress by a specified amount.
429
500
  * Updates the progress bar displayed with the spinner.
430
- * @param amount - Amount to increment (default: 1)
501
+ * Clamps the result between 0 and the total value.
502
+ *
503
+ * @param amount - Amount to increment by
504
+ * @returns This spinner for chaining
505
+ * @default amount=1
506
+ *
507
+ * @example
508
+ * ```ts
509
+ * spinner.progress(0, 10, 'files')
510
+ * spinner.progressStep() // Progress: 1/10
511
+ * spinner.progressStep(3) // Progress: 4/10
512
+ * ```
431
513
  */
432
514
  progressStep(amount = 1) {
433
515
  if (this.#progress) {
@@ -444,8 +526,17 @@ function Spinner(options) {
444
526
  }
445
527
  /**
446
528
  * Start the spinner animation with optional text.
447
- * Begins displaying the animated spinner.
529
+ * Begins displaying the animated spinner on stderr.
530
+ *
448
531
  * @param text - Optional text to display with the spinner
532
+ * @returns This spinner for chaining
533
+ *
534
+ * @example
535
+ * ```ts
536
+ * spinner.start('Loading…')
537
+ * // Later:
538
+ * spinner.successAndStop('Done!')
539
+ * ```
449
540
  */
450
541
  start(...args) {
451
542
  if (args.length) {
@@ -464,27 +555,47 @@ function Spinner(options) {
464
555
  /**
465
556
  * Log a main step message to stderr without stopping the spinner.
466
557
  * Adds a blank line before the message for visual separation.
467
- * Aligns with logger.step() to use stderr for status messages.
558
+ * Aligns with `logger.step()` to use stderr for status messages.
559
+ *
560
+ * @param text - Step message to display
561
+ * @param extras - Additional values to log
562
+ * @returns This spinner for chaining
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * spinner.step('Building application')
567
+ * spinner.substep('Compiling TypeScript')
568
+ * spinner.substep('Bundling assets')
569
+ * ```
468
570
  */
469
- step(...args) {
470
- const text = args[0];
571
+ step(text, ...extras) {
471
572
  const { logger } = require("./logger.js");
472
573
  if (typeof text === "string") {
473
574
  logger.error("");
474
- logger.error(text, ...args.slice(1));
575
+ logger.error(text, ...extras);
475
576
  }
476
577
  return this;
477
578
  }
478
579
  /**
479
580
  * Log an indented substep message to stderr without stopping the spinner.
480
581
  * Adds 2-space indentation to the message.
481
- * Aligns with logger.substep() to use stderr for status messages.
582
+ * Aligns with `logger.substep()` to use stderr for status messages.
583
+ *
584
+ * @param text - Substep message to display
585
+ * @param extras - Additional values to log
586
+ * @returns This spinner for chaining
587
+ *
588
+ * @example
589
+ * ```ts
590
+ * spinner.step('Building application')
591
+ * spinner.substep('Compiling TypeScript')
592
+ * spinner.substep('Bundling assets')
593
+ * ```
482
594
  */
483
- substep(...args) {
484
- const text = args[0];
595
+ substep(text, ...extras) {
485
596
  if (typeof text === "string") {
486
597
  const { logger } = require("./logger.js");
487
- logger.error(` ${text}`, ...args.slice(1));
598
+ logger.error(` ${text}`, ...extras);
488
599
  }
489
600
  return this;
490
601
  }
@@ -492,7 +603,18 @@ function Spinner(options) {
492
603
  * Stop the spinner animation and clear internal state.
493
604
  * Auto-clears the spinner line via yocto-spinner.stop().
494
605
  * Resets progress, shimmer, and text state.
606
+ *
495
607
  * @param text - Optional final text to display after stopping
608
+ * @returns This spinner for chaining
609
+ *
610
+ * @example
611
+ * ```ts
612
+ * spinner.start('Processing…')
613
+ * // Do work
614
+ * spinner.stop() // Just stop, no message
615
+ * // or
616
+ * spinner.stop('Finished processing')
617
+ * ```
496
618
  */
497
619
  stop(...args) {
498
620
  this.#baseText = "";
@@ -506,20 +628,28 @@ function Spinner(options) {
506
628
  return result;
507
629
  }
508
630
  /**
509
- * Show a success message without stopping the spinner.
510
- * DESIGN DECISION: Unlike yocto-spinner, our success() does NOT stop the spinner.
631
+ * Show a success message (✓) without stopping the spinner.
632
+ * DESIGN DECISION: Unlike yocto-spinner, our `success()` does NOT stop the spinner.
511
633
  * This allows displaying success messages while continuing to spin for multi-step operations.
512
- * Use successAndStop() if you want to stop the spinner.
634
+ * Use `successAndStop()` if you want to stop the spinner.
635
+ *
636
+ * @param text - Success message to display
637
+ * @param extras - Additional values to log
638
+ * @returns This spinner for chaining
513
639
  */
514
- success(...args) {
515
- return this.#showStatusAndKeepSpinning("success", args);
640
+ success(text, ...extras) {
641
+ return this.#showStatusAndKeepSpinning("success", [text, ...extras]);
516
642
  }
517
643
  /**
518
- * Show a success message and stop the spinner.
644
+ * Show a success message (✓) and stop the spinner.
519
645
  * Auto-clears the spinner line before displaying the success message.
646
+ *
647
+ * @param text - Success message to display
648
+ * @param extras - Additional values to log
649
+ * @returns This spinner for chaining
520
650
  */
521
- successAndStop(...args) {
522
- return this.#apply("success", args);
651
+ successAndStop(text, ...extras) {
652
+ return this.#apply("success", [text, ...extras]);
523
653
  }
524
654
  text(value) {
525
655
  if (arguments.length === 0) {
@@ -530,18 +660,26 @@ function Spinner(options) {
530
660
  return this;
531
661
  }
532
662
  /**
533
- * Show a warning message without stopping the spinner.
663
+ * Show a warning message (⚠) without stopping the spinner.
534
664
  * Outputs to stderr and continues spinning.
665
+ *
666
+ * @param text - Warning message to display
667
+ * @param extras - Additional values to log
668
+ * @returns This spinner for chaining
535
669
  */
536
- warn(...args) {
537
- return this.#showStatusAndKeepSpinning("warn", args);
670
+ warn(text, ...extras) {
671
+ return this.#showStatusAndKeepSpinning("warn", [text, ...extras]);
538
672
  }
539
673
  /**
540
- * Show a warning message and stop the spinner.
674
+ * Show a warning message (⚠) and stop the spinner.
541
675
  * Auto-clears the spinner line before displaying the warning message.
676
+ *
677
+ * @param text - Warning message to display
678
+ * @param extras - Additional values to log
679
+ * @returns This spinner for chaining
542
680
  */
543
- warnAndStop(...args) {
544
- return this.#apply("warning", args);
681
+ warnAndStop(text, ...extras) {
682
+ return this.#apply("warning", [text, ...extras]);
545
683
  }
546
684
  /**
547
685
  * Toggle shimmer effect or update shimmer configuration.