@socketsecurity/lib 3.2.8 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +19 -240
  3. package/dist/agent.js +10 -10
  4. package/dist/bin.js +4 -4
  5. package/dist/colors.d.ts +37 -0
  6. package/dist/colors.js +58 -0
  7. package/dist/constants/node.js +1 -1
  8. package/dist/constants/packages.js +9 -9
  9. package/dist/constants/process.js +1 -1
  10. package/dist/constants/socket.d.ts +1 -0
  11. package/dist/constants/socket.js +3 -0
  12. package/dist/debug.js +3 -3
  13. package/dist/dlx-binary.js +4 -4
  14. package/dist/effects/text-shimmer.js +1 -1
  15. package/dist/env/ci.js +2 -2
  16. package/dist/env/debug.js +1 -1
  17. package/dist/env/github.js +1 -1
  18. package/dist/env/home.js +1 -1
  19. package/dist/env/locale.js +1 -1
  20. package/dist/env/node-auth-token.js +1 -1
  21. package/dist/env/node-env.js +1 -1
  22. package/dist/env/npm.js +1 -1
  23. package/dist/env/package-manager.js +1 -1
  24. package/dist/env/path.js +1 -1
  25. package/dist/env/pre-commit.js +2 -2
  26. package/dist/env/rewire.d.ts +5 -5
  27. package/dist/env/rewire.js +22 -14
  28. package/dist/env/shell.js +1 -1
  29. package/dist/env/socket-cli-shadow.js +2 -2
  30. package/dist/env/socket-cli.js +2 -2
  31. package/dist/env/socket.js +2 -2
  32. package/dist/env/temp-dir.js +1 -1
  33. package/dist/env/term.js +1 -1
  34. package/dist/env/test.js +3 -3
  35. package/dist/env/windows.js +1 -1
  36. package/dist/env/xdg.js +1 -1
  37. package/dist/external/@inquirer/checkbox.js +3361 -3
  38. package/dist/external/@inquirer/confirm.js +1 -0
  39. package/dist/external/@inquirer/input.js +1 -0
  40. package/dist/external/@inquirer/password.js +1 -0
  41. package/dist/external/@inquirer/search.js +1 -0
  42. package/dist/external/@inquirer/select.js +1 -0
  43. package/dist/fs.js +4 -6
  44. package/dist/git.js +1 -1
  45. package/dist/github.js +2 -2
  46. package/dist/globs.js +3 -4
  47. package/dist/lifecycle-script-names.d.ts +8 -2
  48. package/dist/lifecycle-script-names.js +9 -4
  49. package/dist/logger.d.ts +106 -81
  50. package/dist/logger.js +234 -205
  51. package/dist/maintained-node-versions.d.ts +2 -2
  52. package/dist/maintained-node-versions.js +9 -4
  53. package/dist/objects.js +1 -1
  54. package/dist/package-default-node-range.d.ts +2 -2
  55. package/dist/package-default-node-range.js +10 -5
  56. package/dist/package-default-socket-categories.d.ts +6 -2
  57. package/dist/package-default-socket-categories.js +9 -4
  58. package/dist/package-extensions.d.ts +2 -2
  59. package/dist/package-extensions.js +9 -4
  60. package/dist/packages/exports.js +1 -1
  61. package/dist/packages/isolation.js +2 -2
  62. package/dist/packages/licenses.js +2 -2
  63. package/dist/packages/manifest.js +3 -3
  64. package/dist/packages/normalize.js +1 -1
  65. package/dist/packages/operations.js +5 -5
  66. package/dist/packages/provenance.js +1 -1
  67. package/dist/path.d.ts +11 -0
  68. package/dist/path.js +1 -1
  69. package/dist/paths.js +14 -14
  70. package/dist/promises.js +2 -2
  71. package/dist/spawn.js +1 -1
  72. package/dist/spinner.d.ts +29 -51
  73. package/dist/spinner.js +155 -149
  74. package/dist/stdio/prompts.d.ts +17 -0
  75. package/dist/stdio/prompts.js +11 -12
  76. package/dist/temporary-executor.js +1 -1
  77. package/dist/themes/types.d.ts +2 -1
  78. package/dist/themes/utils.d.ts +1 -1
  79. package/dist/utils/get-ipc.d.ts +0 -1
  80. package/dist/utils/get-ipc.js +4 -4
  81. package/dist/versions.d.ts +1 -1
  82. package/package.json +15 -11
  83. package/dist/external/@inquirer/core.js +0 -4
  84. package/dist/external/@inquirer/prompts.js +0 -4
@@ -3202,3 +3202,4 @@ var require_commonjs4 = __commonJS({
3202
3202
 
3203
3203
  // src/external/@inquirer/confirm.js
3204
3204
  module.exports = require_commonjs4();
3205
+ if (module.exports && module.exports.default && Object.keys(module.exports).length === 1) { module.exports = module.exports.default; }
@@ -3226,3 +3226,4 @@ var require_commonjs4 = __commonJS({
3226
3226
 
3227
3227
  // src/external/@inquirer/input.js
3228
3228
  module.exports = require_commonjs4();
3229
+ if (module.exports && module.exports.default && Object.keys(module.exports).length === 1) { module.exports = module.exports.default; }
@@ -3334,3 +3334,4 @@ var require_commonjs4 = __commonJS({
3334
3334
 
3335
3335
  // src/external/@inquirer/password.js
3336
3336
  module.exports = require_commonjs4();
3337
+ if (module.exports && module.exports.default && Object.keys(module.exports).length === 1) { module.exports = module.exports.default; }
@@ -3331,3 +3331,4 @@ ${theme.style.description(selectedChoice.description)}` : ``;
3331
3331
 
3332
3332
  // src/external/@inquirer/search.js
3333
3333
  module.exports = require_commonjs4();
3334
+ if (module.exports && module.exports.default && Object.keys(module.exports).length === 1) { module.exports = module.exports.default; }
@@ -3448,3 +3448,4 @@ ${page}${helpTipBottom}${choiceDescription}${ansi_escapes_1.default.cursorHide}`
3448
3448
 
3449
3449
  // src/external/@inquirer/select.js
3450
3450
  module.exports = require_commonjs4();
3451
+ if (module.exports && module.exports.default && Object.keys(module.exports).length === 1) { module.exports = module.exports.default; }
package/dist/fs.js CHANGED
@@ -48,7 +48,7 @@ __export(fs_exports, {
48
48
  writeJsonSync: () => writeJsonSync
49
49
  });
50
50
  module.exports = __toCommonJS(fs_exports);
51
- var import_process = require("./constants/process");
51
+ var import_process = require("#constants/process");
52
52
  var import_arrays = require("./arrays");
53
53
  var import_globs = require("./globs");
54
54
  var import_json = require("./json");
@@ -429,7 +429,7 @@ function getAllowedDirectories() {
429
429
  getOsTmpDir,
430
430
  getSocketCacacheDir,
431
431
  getSocketUserDir
432
- } = require("./paths");
432
+ } = require("#lib/paths");
433
433
  _cachedAllowedDirs = [
434
434
  path.resolve(getOsTmpDir()),
435
435
  path.resolve(getSocketCacacheDir()),
@@ -444,8 +444,7 @@ function invalidatePathCache() {
444
444
  (0, import_rewire.registerCacheInvalidation)(invalidatePathCache);
445
445
  // @__NO_SIDE_EFFECTS__
446
446
  async function safeDelete(filepath, options) {
447
- const del = require("./external/del");
448
- const { deleteAsync } = del;
447
+ const { deleteAsync } = require("./external/del");
449
448
  const opts = { __proto__: null, ...options };
450
449
  const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
451
450
  let shouldForce = opts.force !== false;
@@ -477,8 +476,7 @@ async function safeDelete(filepath, options) {
477
476
  }
478
477
  // @__NO_SIDE_EFFECTS__
479
478
  function safeDeleteSync(filepath, options) {
480
- const del = require("./external/del");
481
- const { deleteSync } = del;
479
+ const { deleteSync } = require("./external/del");
482
480
  const opts = { __proto__: null, ...options };
483
481
  const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
484
482
  let shouldForce = opts.force !== false;
package/dist/git.js CHANGED
@@ -45,7 +45,7 @@ __export(git_exports, {
45
45
  });
46
46
  module.exports = __toCommonJS(git_exports);
47
47
  var import_path = __toESM(require("path"));
48
- var import_platform = require("./constants/platform");
48
+ var import_platform = require("#constants/platform");
49
49
  var import_debug = require("./debug");
50
50
  var import_globs = require("./globs");
51
51
  var import_path2 = require("./path");
package/dist/github.js CHANGED
@@ -31,8 +31,8 @@ __export(github_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(github_exports);
33
33
  var import_cache_with_ttl = require("./cache-with-ttl");
34
- var import_github = require("./env/github");
35
- var import_socket_cli = require("./env/socket-cli");
34
+ var import_github = require("#env/github");
35
+ var import_socket_cli = require("#env/socket-cli");
36
36
  var import_http_request = require("./http-request");
37
37
  var import_spawn = require("./spawn");
38
38
  const GITHUB_API_BASE_URL = "https://api.github.com";
package/dist/globs.js CHANGED
@@ -77,8 +77,7 @@ let _fastGlob;
77
77
  // @__NO_SIDE_EFFECTS__
78
78
  function getFastGlob() {
79
79
  if (_fastGlob === void 0) {
80
- const globExport = require("./external/fast-glob");
81
- _fastGlob = "default" in globExport ? globExport.default : globExport;
80
+ _fastGlob = require("./external/fast-glob");
82
81
  }
83
82
  return _fastGlob;
84
83
  }
@@ -97,14 +96,14 @@ function globStreamLicenses(dirname, options) {
97
96
  if (ignoreOriginals) {
98
97
  const { LICENSE_ORIGINAL_GLOB_RECURSIVE } = (
99
98
  /*@__INLINE__*/
100
- require("./constants/paths")
99
+ require("#constants/paths")
101
100
  );
102
101
  ignore.push(LICENSE_ORIGINAL_GLOB_RECURSIVE);
103
102
  }
104
103
  const fastGlob = /* @__PURE__ */ getFastGlob();
105
104
  const paths = (
106
105
  /*@__INLINE__*/
107
- require("./constants/paths")
106
+ require("#constants/paths")
108
107
  );
109
108
  return fastGlob.globStream(
110
109
  [recursive ? paths.LICENSE_GLOB_RECURSIVE : paths.LICENSE_GLOB],
@@ -1,2 +1,8 @@
1
- declare const _default: Set<string>;
2
- export default _default;
1
+ /**
2
+ * @fileoverview NPM lifecycle script names.
3
+ *
4
+ * Standard npm lifecycle hooks that can be defined in package.json scripts.
5
+ * https://docs.npmjs.com/cli/v10/using-npm/scripts#life-cycle-scripts
6
+ */
7
+ declare const lifecycleScriptNames: Set<string>;
8
+ export { lifecycleScriptNames };
@@ -18,8 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  };
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var lifecycle_script_names_exports = {};
21
- /* module.exports will be set at end of file */
22
- var lifecycle_script_names_default = new Set(
21
+ __export(lifecycle_script_names_exports, {
22
+ lifecycleScriptNames: () => lifecycleScriptNames
23
+ });
24
+ module.exports = __toCommonJS(lifecycle_script_names_exports);
25
+ const lifecycleScriptNames = new Set(
23
26
  [
24
27
  "dependencies",
25
28
  "prepublishOnly",
@@ -35,5 +38,7 @@ var lifecycle_script_names_default = new Set(
35
38
  ].map((n) => [`pre${n}`, n, `post${n}`])
36
39
  ].flat()
37
40
  );
38
-
39
- module.exports = lifecycle_script_names_default;
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ lifecycleScriptNames
44
+ });
package/dist/logger.d.ts CHANGED
@@ -13,6 +13,7 @@
13
13
  * console.log(`${LOG_SYMBOLS.warn} Warning message`)
14
14
  * console.log(`${LOG_SYMBOLS.info} Information message`)
15
15
  * console.log(`${LOG_SYMBOLS.step} Processing step`)
16
+ * console.log(`${LOG_SYMBOLS.reason} Working through logic`)
16
17
  * ```
17
18
  */
18
19
  type LogSymbols = {
@@ -20,6 +21,8 @@ type LogSymbols = {
20
21
  fail: string;
21
22
  /** Blue colored information symbol (ℹ or i in ASCII) */
22
23
  info: string;
24
+ /** Dimmed yellow reasoning/working symbol (∴ or :. in ASCII) */
25
+ reason: string;
23
26
  /** Cyan colored step symbol (→ or > in ASCII) */
24
27
  step: string;
25
28
  /** Green colored success symbol (✔ or √ in ASCII) */
@@ -62,9 +65,9 @@ export type { LogSymbols, LoggerMethods, Task };
62
65
  /**
63
66
  * Log symbols for terminal output with colored indicators.
64
67
  *
65
- * Provides colored Unicode symbols (✔, ✖, ⚠, ℹ, ) with ASCII fallbacks (√, ×, ‼, i, >)
68
+ * Provides colored Unicode symbols (✖, ℹ, ∴, →, ✔, ⚠) with ASCII fallbacks (×, i, :., >, √, ‼)
66
69
  * for terminals that don't support Unicode. Symbols are colored according to the active
67
- * theme's color palette (success, error, warning, info, step).
70
+ * theme's color palette (error, info, reason, step, success, warning).
68
71
  *
69
72
  * The symbols are lazily initialized on first access and automatically update when the
70
73
  * fallback theme changes (via setTheme()). Note that LOG_SYMBOLS reflect the global
@@ -74,11 +77,12 @@ export type { LogSymbols, LoggerMethods, Task };
74
77
  * ```typescript
75
78
  * import { LOG_SYMBOLS } from '@socketsecurity/lib'
76
79
  *
77
- * console.log(`${LOG_SYMBOLS.success} Build completed`) // Theme success color ✔
78
80
  * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Theme error color ✖
79
- * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Theme warning color ⚠
80
81
  * console.log(`${LOG_SYMBOLS.info} Starting process`) // Theme info color ℹ
82
+ * console.log(`${LOG_SYMBOLS.reason} Analyzing dependencies`) // Dimmed yellow ∴
81
83
  * console.log(`${LOG_SYMBOLS.step} Processing files`) // Theme step color →
84
+ * console.log(`${LOG_SYMBOLS.success} Build completed`) // Theme success color ✔
85
+ * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Theme warning color ⚠
82
86
  * ```
83
87
  */
84
88
  export declare const LOG_SYMBOLS: Record<string, string>;
@@ -288,6 +292,35 @@ export declare class Logger {
288
292
  * ```
289
293
  */
290
294
  assert(value: unknown, ...message: unknown[]): this;
295
+ /**
296
+ * Clears the current line in the terminal.
297
+ *
298
+ * Moves the cursor to the beginning of the line and clears all content.
299
+ * Works in both TTY and non-TTY environments. Useful for clearing
300
+ * progress indicators created with `progress()`.
301
+ *
302
+ * The stream to clear (stderr or stdout) depends on whether the logger
303
+ * is stream-bound.
304
+ *
305
+ * @returns The logger instance for chaining
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * logger.progress('Loading...')
310
+ * // ... do work ...
311
+ * logger.clearLine()
312
+ * logger.success('Loaded')
313
+ *
314
+ * // Clear multiple progress updates
315
+ * for (const file of files) {
316
+ * logger.progress(`Processing ${file}`)
317
+ * processFile(file)
318
+ * logger.clearLine()
319
+ * }
320
+ * logger.success('All files processed')
321
+ * ```
322
+ */
323
+ clearLine(): this;
291
324
  /**
292
325
  * Clears the visible terminal screen.
293
326
  *
@@ -413,6 +446,28 @@ export declare class Logger {
413
446
  * ```
414
447
  */
415
448
  dirxml(...data: unknown[]): this;
449
+ /**
450
+ * Logs a completion message with a success symbol (alias for `success()`).
451
+ *
452
+ * Provides semantic clarity when marking something as "done". Does NOT
453
+ * automatically clear the current line - call `clearLine()` first if
454
+ * needed after using `progress()`.
455
+ *
456
+ * @param args - Message and additional arguments to log
457
+ * @returns The logger instance for chaining
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * logger.done('Task completed')
462
+ *
463
+ * // After progress indicator
464
+ * logger.progress('Processing...')
465
+ * // ... do work ...
466
+ * logger.clearLine()
467
+ * logger.done('Processing complete')
468
+ * ```
469
+ */
470
+ done(...args: unknown[]): this;
416
471
  /**
417
472
  * Logs an error message to stderr.
418
473
  *
@@ -614,6 +669,53 @@ export declare class Logger {
614
669
  * ```
615
670
  */
616
671
  logNewline(): this;
672
+ /**
673
+ * Shows a progress indicator that can be cleared with `clearLine()`.
674
+ *
675
+ * Displays a simple status message with a '∴' prefix. Does not include
676
+ * animation or spinner. Intended to be cleared once the operation completes.
677
+ * The output stream (stderr or stdout) depends on whether the logger is
678
+ * stream-bound.
679
+ *
680
+ * @param text - The progress message to display
681
+ * @returns The logger instance for chaining
682
+ *
683
+ * @example
684
+ * ```typescript
685
+ * logger.progress('Processing files...')
686
+ * // ... do work ...
687
+ * logger.clearLine()
688
+ * logger.success('Files processed')
689
+ *
690
+ * // Stream-specific progress
691
+ * logger.stdout.progress('Loading...')
692
+ * // ... do work ...
693
+ * logger.stdout.clearLine()
694
+ * logger.stdout.log('Done')
695
+ * ```
696
+ */
697
+ progress(text: string): this;
698
+ /**
699
+ * Logs a reasoning/working message with a dimmed yellow therefore symbol.
700
+ *
701
+ * Automatically prefixes the message with `LOG_SYMBOLS.reason` (dimmed yellow ∴).
702
+ * Useful for showing intermediate reasoning, logic steps, or "working" output
703
+ * that leads to a conclusion. Always outputs to stderr. If the message starts
704
+ * with an existing symbol, it will be stripped and replaced.
705
+ *
706
+ * @param args - Message and additional arguments to log
707
+ * @returns The logger instance for chaining
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * logger.step('Analyzing package security')
712
+ * logger.reason('Found 3 direct dependencies')
713
+ * logger.reason('Checking 47 transitive dependencies')
714
+ * logger.reason('Risk score: 8.5/10')
715
+ * logger.fail('Package blocked due to high risk')
716
+ * ```
717
+ */
718
+ reason(...args: unknown[]): this;
617
719
  /**
618
720
  * Resets all indentation to zero.
619
721
  *
@@ -706,28 +808,6 @@ export declare class Logger {
706
808
  * ```
707
809
  */
708
810
  success(...args: unknown[]): this;
709
- /**
710
- * Logs a completion message with a success symbol (alias for `success()`).
711
- *
712
- * Provides semantic clarity when marking something as "done". Does NOT
713
- * automatically clear the current line - call `clearLine()` first if
714
- * needed after using `progress()`.
715
- *
716
- * @param args - Message and additional arguments to log
717
- * @returns The logger instance for chaining
718
- *
719
- * @example
720
- * ```typescript
721
- * logger.done('Task completed')
722
- *
723
- * // After progress indicator
724
- * logger.progress('Processing...')
725
- * // ... do work ...
726
- * logger.clearLine()
727
- * logger.done('Processing complete')
728
- * ```
729
- */
730
- done(...args: unknown[]): this;
731
811
  /**
732
812
  * Displays data in a table format.
733
813
  *
@@ -893,61 +973,6 @@ export declare class Logger {
893
973
  * ```
894
974
  */
895
975
  write(text: string): this;
896
- /**
897
- * Shows a progress indicator that can be cleared with `clearLine()`.
898
- *
899
- * Displays a simple status message with a '∴' prefix. Does not include
900
- * animation or spinner. Intended to be cleared once the operation completes.
901
- * The output stream (stderr or stdout) depends on whether the logger is
902
- * stream-bound.
903
- *
904
- * @param text - The progress message to display
905
- * @returns The logger instance for chaining
906
- *
907
- * @example
908
- * ```typescript
909
- * logger.progress('Processing files...')
910
- * // ... do work ...
911
- * logger.clearLine()
912
- * logger.success('Files processed')
913
- *
914
- * // Stream-specific progress
915
- * logger.stdout.progress('Loading...')
916
- * // ... do work ...
917
- * logger.stdout.clearLine()
918
- * logger.stdout.log('Done')
919
- * ```
920
- */
921
- progress(text: string): this;
922
- /**
923
- * Clears the current line in the terminal.
924
- *
925
- * Moves the cursor to the beginning of the line and clears all content.
926
- * Works in both TTY and non-TTY environments. Useful for clearing
927
- * progress indicators created with `progress()`.
928
- *
929
- * The stream to clear (stderr or stdout) depends on whether the logger
930
- * is stream-bound.
931
- *
932
- * @returns The logger instance for chaining
933
- *
934
- * @example
935
- * ```typescript
936
- * logger.progress('Loading...')
937
- * // ... do work ...
938
- * logger.clearLine()
939
- * logger.success('Loaded')
940
- *
941
- * // Clear multiple progress updates
942
- * for (const file of files) {
943
- * logger.progress(`Processing ${file}`)
944
- * processFile(file)
945
- * logger.clearLine()
946
- * }
947
- * logger.success('All files processed')
948
- * ```
949
- */
950
- clearLine(): this;
951
976
  }
952
977
  /**
953
978
  * Get the default logger instance.