@socketsecurity/cli-with-sentry 1.1.15 → 1.1.17

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 (103) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cli.js +14 -15
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +35 -37
  5. package/dist/constants.js.map +1 -1
  6. package/dist/shadow-npm-bin.js +6 -6
  7. package/dist/shadow-npm-bin.js.map +1 -1
  8. package/dist/shadow-pnpm-bin.js +3 -5
  9. package/dist/shadow-pnpm-bin.js.map +1 -1
  10. package/dist/shadow-yarn-bin.js +2 -2
  11. package/dist/shadow-yarn-bin.js.map +1 -1
  12. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  13. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  14. package/dist/types/commands/optimize/apply-optimization.d.mts.map +1 -1
  15. package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
  16. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
  17. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
  18. package/dist/types/commands/yarn/cmd-yarn.d.mts +1 -1
  19. package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
  20. package/dist/types/constants.d.mts +15 -19
  21. package/dist/types/constants.d.mts.map +1 -1
  22. package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
  23. package/dist/types/utils/agent.d.mts.map +1 -1
  24. package/dist/types/utils/dlx.d.mts.map +1 -1
  25. package/dist/types/utils/package-environment.d.mts.map +1 -1
  26. package/dist/types/utils/path-resolve.d.mts.map +1 -1
  27. package/dist/utils.js +65 -27
  28. package/dist/utils.js.map +1 -1
  29. package/dist/vendor.js +514 -517
  30. package/external/@socketsecurity/registry/external/@inquirer/confirm.js +45 -205
  31. package/external/@socketsecurity/registry/external/@inquirer/input.js +45 -205
  32. package/external/@socketsecurity/registry/external/@inquirer/password.js +181 -205
  33. package/external/@socketsecurity/registry/external/@inquirer/search.js +47 -207
  34. package/external/@socketsecurity/registry/external/@inquirer/select.js +183 -207
  35. package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +388 -2280
  36. package/external/@socketsecurity/registry/external/browserslist.js +11534 -567
  37. package/external/@socketsecurity/registry/external/cacache.js +2575 -4914
  38. package/external/@socketsecurity/registry/external/libnpmpack.js +64667 -166061
  39. package/external/@socketsecurity/registry/external/make-fetch-happen.js +384 -4044
  40. package/external/@socketsecurity/registry/external/normalize-package-data.js +30 -278
  41. package/external/@socketsecurity/registry/external/npm-package-arg.js +28 -9
  42. package/external/@socketsecurity/registry/external/pacote.js +46680 -66482
  43. package/external/@socketsecurity/registry/external/spdx-correct.js +19 -0
  44. package/external/@socketsecurity/registry/external/spdx-expression-parse.js +19 -0
  45. package/external/@socketsecurity/registry/lib/agent.js +390 -0
  46. package/external/@socketsecurity/registry/lib/arrays.js +31 -0
  47. package/external/@socketsecurity/registry/lib/bin.js +650 -0
  48. package/external/@socketsecurity/registry/lib/constants/bun-lock.js +3 -0
  49. package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +3 -0
  50. package/external/@socketsecurity/registry/lib/constants/bun.js +3 -0
  51. package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +3 -0
  52. package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +3 -0
  53. package/external/@socketsecurity/registry/lib/constants/empty-value.js +3 -0
  54. package/external/@socketsecurity/registry/lib/constants/env.js +17 -3
  55. package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +3 -0
  56. package/external/@socketsecurity/registry/lib/constants/ext-yml.js +3 -0
  57. package/external/@socketsecurity/registry/lib/constants/index.js +20 -11
  58. package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +2 -2
  59. package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +1 -1
  60. package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +3 -0
  61. package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +5 -0
  62. package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +3 -0
  63. package/external/@socketsecurity/registry/lib/constants/unknown-error.js +3 -0
  64. package/external/@socketsecurity/registry/lib/constants/unknown-value.js +3 -0
  65. package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +3 -0
  66. package/external/@socketsecurity/registry/lib/constants/vlt.js +3 -0
  67. package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +3 -0
  68. package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +3 -0
  69. package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +5 -0
  70. package/external/@socketsecurity/registry/lib/constants/yarn.js +3 -0
  71. package/external/@socketsecurity/registry/lib/debug.js +53 -0
  72. package/external/@socketsecurity/registry/lib/env.js +18 -0
  73. package/external/@socketsecurity/registry/lib/fs.js +218 -2
  74. package/external/@socketsecurity/registry/lib/functions.js +5 -0
  75. package/external/@socketsecurity/registry/lib/globs.js +22 -1
  76. package/external/@socketsecurity/registry/lib/json.js +16 -0
  77. package/external/@socketsecurity/registry/lib/logger.js +157 -0
  78. package/external/@socketsecurity/registry/lib/objects.js +103 -0
  79. package/external/@socketsecurity/registry/lib/packages.js +88 -0
  80. package/external/@socketsecurity/registry/lib/path.js +51 -1
  81. package/external/@socketsecurity/registry/lib/promises.js +55 -0
  82. package/external/@socketsecurity/registry/lib/regexps.js +5 -0
  83. package/external/@socketsecurity/registry/lib/sorts.js +17 -0
  84. package/external/@socketsecurity/registry/lib/spawn.js +105 -7
  85. package/external/@socketsecurity/registry/lib/streams.js +26 -0
  86. package/external/@socketsecurity/registry/lib/strings.js +123 -9
  87. package/external/@socketsecurity/registry/lib/url.js +21 -0
  88. package/external/@socketsecurity/registry/lib/words.js +16 -0
  89. package/external/@socketsecurity/registry/manifest.json +5 -4
  90. package/package.json +5 -4
  91. package/external/@socketsecurity/registry/external/ansi-regex.js +0 -13
  92. package/external/@socketsecurity/registry/lib/constants/node-workspaces.js +0 -3
  93. package/external/@socketsecurity/registry/lib/constants/parse-args-config.js +0 -14
  94. package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -43
  95. package/external/@socketsecurity/registry/lib/constants/template-cjs-browser.js +0 -3
  96. package/external/@socketsecurity/registry/lib/constants/template-cjs-esm.js +0 -3
  97. package/external/@socketsecurity/registry/lib/constants/template-cjs.js +0 -3
  98. package/external/@socketsecurity/registry/lib/constants/template-es-shim-constructor.js +0 -3
  99. package/external/@socketsecurity/registry/lib/constants/template-es-shim-prototype-method.js +0 -3
  100. package/external/@socketsecurity/registry/lib/constants/template-es-shim-static-method.js +0 -3
  101. package/external/@socketsecurity/registry/lib/constants/win32-ensure-tests-by-ecosystem.js +0 -3
  102. package/external/@socketsecurity/registry/lib/npm.js +0 -404
  103. /package/external/@socketsecurity/registry/lib/constants/{hidden-package-lock-json.js → dot-package-lock-json.js} +0 -0
@@ -37,6 +37,11 @@ const identSymbol = Symbol.for('indent')
37
37
  const newlineSymbol = Symbol.for('newline')
38
38
 
39
39
  let _cacache
40
+ /**
41
+ * Get the cacache module for cache operations.
42
+ * @returns {Object} The cacache module.
43
+ * @private
44
+ */
40
45
  /*@__NO_SIDE_EFFECTS__*/
41
46
  function getCacache() {
42
47
  if (_cacache === undefined) {
@@ -46,6 +51,11 @@ function getCacache() {
46
51
  }
47
52
 
48
53
  let _EditablePackageJsonClass
54
+ /**
55
+ * Get the EditablePackageJson class for package.json manipulation.
56
+ * @returns {Class} The EditablePackageJson class.
57
+ * @private
58
+ */
49
59
  /*@__NO_SIDE_EFFECTS__*/
50
60
  function getEditablePackageJsonClass() {
51
61
  if (_EditablePackageJsonClass === undefined) {
@@ -461,6 +471,11 @@ function getValidateNpmPackageName() {
461
471
  return _validateNpmPackageName
462
472
  }
463
473
 
474
+ /**
475
+ * Collect licenses that are incompatible (copyleft).
476
+ * @param {Object[]} licenseNodes - Array of license nodes.
477
+ * @returns {Object[]} Array of incompatible license nodes.
478
+ */
464
479
  /*@__NO_SIDE_EFFECTS__*/
465
480
  function collectIncompatibleLicenses(licenseNodes) {
466
481
  const result = []
@@ -473,6 +488,11 @@ function collectIncompatibleLicenses(licenseNodes) {
473
488
  return result
474
489
  }
475
490
 
491
+ /**
492
+ * Collect warnings from license nodes.
493
+ * @param {Object[]} licenseNodes - Array of license nodes.
494
+ * @returns {string[]} Array of warning messages.
495
+ */
476
496
  /*@__NO_SIDE_EFFECTS__*/
477
497
  function collectLicenseWarnings(licenseNodes) {
478
498
  const warnings = new Map()
@@ -488,6 +508,11 @@ function collectLicenseWarnings(licenseNodes) {
488
508
  return [...warnings.values()]
489
509
  }
490
510
 
511
+ /**
512
+ * Create an AST node from a raw node.
513
+ * @param {Object} rawNode - Raw node data.
514
+ * @returns {Object} AST node.
515
+ */
491
516
  /*@__NO_SIDE_EFFECTS__*/
492
517
  function createAstNode(rawNode) {
493
518
  return ObjectHasOwn(rawNode, 'license')
@@ -495,6 +520,11 @@ function createAstNode(rawNode) {
495
520
  : createBinaryOperationNode(rawNode)
496
521
  }
497
522
 
523
+ /**
524
+ * Create a binary operation AST node.
525
+ * @param {Object} rawNode - Raw node with left, right, and conjunction.
526
+ * @returns {Object} Binary operation node.
527
+ */
498
528
  /*@__NO_SIDE_EFFECTS__*/
499
529
  function createBinaryOperationNode(rawNode) {
500
530
  let left
@@ -523,11 +553,23 @@ function createBinaryOperationNode(rawNode) {
523
553
  }
524
554
  }
525
555
 
556
+ /**
557
+ * Create a license AST node.
558
+ * @param {Object} rawNode - Raw license node data.
559
+ * @returns {Object} License node.
560
+ */
526
561
  /*@__NO_SIDE_EFFECTS__*/
527
562
  function createLicenseNode(rawNode) {
528
563
  return { __proto__: null, ...rawNode, type: LICENSE_NODE_TYPE }
529
564
  }
530
565
 
566
+ /**
567
+ * Create a package.json object for a Socket registry package.
568
+ * @param {string} sockRegPkgName - Socket registry package name.
569
+ * @param {string} directory - Directory path.
570
+ * @param {Object} [options] - Creation options.
571
+ * @returns {Object} Package.json object.
572
+ */
531
573
  /*@__NO_SIDE_EFFECTS__*/
532
574
  function createPackageJson(sockRegPkgName, directory, options) {
533
575
  const {
@@ -606,6 +648,13 @@ function createPackageJson(sockRegPkgName, directory, options) {
606
648
  }
607
649
  }
608
650
 
651
+ /**
652
+ * Extract a package to a destination directory.
653
+ * @param {string} pkgNameOrId - Package name or identifier.
654
+ * @param {Object} [options] - Extraction options.
655
+ * @param {Function} [callback] - Callback to execute after extraction.
656
+ * @returns {Promise<void>} Resolves when extraction is complete.
657
+ */
609
658
  /*@__NO_SIDE_EFFECTS__*/
610
659
  async function extractPackage(pkgNameOrId, options, callback) {
611
660
  if (arguments.length === 2 && typeof options === 'function') {
@@ -645,6 +694,12 @@ async function extractPackage(pkgNameOrId, options, callback) {
645
694
  }
646
695
  }
647
696
 
697
+ /**
698
+ * Fetch the manifest for a package.
699
+ * @param {string} pkgNameOrId - Package name or identifier.
700
+ * @param {Object} [options] - Fetch options.
701
+ * @returns {Promise<Object|null>} Package manifest or null if failed.
702
+ */
648
703
  /*@__NO_SIDE_EFFECTS__*/
649
704
  async function fetchPackageManifest(pkgNameOrId, options) {
650
705
  const pacoteOptions = {
@@ -679,6 +734,12 @@ async function fetchPackageManifest(pkgNameOrId, options) {
679
734
  : null
680
735
  }
681
736
 
737
+ /**
738
+ * Fetch the packument (package document) for a package.
739
+ * @param {string} pkgNameOrId - Package name or identifier.
740
+ * @param {Object} [options] - Fetch options.
741
+ * @returns {Promise<Object|null>} Package packument or null if failed.
742
+ */
682
743
  /*@__NO_SIDE_EFFECTS__*/
683
744
  async function fetchPackagePackument(pkgNameOrId, options) {
684
745
  const pacote = getPacote()
@@ -694,6 +755,12 @@ async function fetchPackagePackument(pkgNameOrId, options) {
694
755
  return null
695
756
  }
696
757
 
758
+ /**
759
+ * Find package extensions for a given package.
760
+ * @param {string} pkgName - Package name.
761
+ * @param {string} pkgVer - Package version.
762
+ * @returns {Object} Package extensions.
763
+ */
697
764
  /*@__NO_SIDE_EFFECTS__*/
698
765
  function findPackageExtensions(pkgName, pkgVer) {
699
766
  let result
@@ -715,6 +782,12 @@ function findPackageExtensions(pkgName, pkgVer) {
715
782
  return result
716
783
  }
717
784
 
785
+ /**
786
+ * Find types for a subpath in package exports.
787
+ * @param {Object} entryExports - Package exports object.
788
+ * @param {string} subpath - Subpath to find types for.
789
+ * @returns {string|undefined} Types path if found.
790
+ */
718
791
  /*@__NO_SIDE_EFFECTS__*/
719
792
  function findTypesForSubpath(entryExports, subpath) {
720
793
  const queue = [entryExports]
@@ -752,12 +825,22 @@ function findTypesForSubpath(entryExports, subpath) {
752
825
  return undefined
753
826
  }
754
827
 
828
+ /**
829
+ * Get the release tag for a version.
830
+ * @param {string} version - Version string.
831
+ * @returns {string} Release tag.
832
+ */
755
833
  /*@__NO_SIDE_EFFECTS__*/
756
834
  function getReleaseTag(version) {
757
835
  const semver = getSemver()
758
836
  return semver.prerelease(version)?.join('.') ?? 'latest'
759
837
  }
760
838
 
839
+ /**
840
+ * Extract details from a repository URL.
841
+ * @param {string} [repoUrl=''] - Repository URL.
842
+ * @returns {Object} Repository details with host, user, and project.
843
+ */
761
844
  /*@__NO_SIDE_EFFECTS__*/
762
845
  function getRepoUrlDetails(repoUrl = '') {
763
846
  const userAndRepo = repoUrl.replace(/^.+github.com\//, '').split('/')
@@ -767,6 +850,11 @@ function getRepoUrlDetails(repoUrl = '') {
767
850
  return { user, project }
768
851
  }
769
852
 
853
+ /**
854
+ * Get subpaths from package exports.
855
+ * @param {Object} entryExports - Package exports object.
856
+ * @returns {string[]} Array of subpaths.
857
+ */
770
858
  /*@__NO_SIDE_EFFECTS__*/
771
859
  function getSubpaths(entryExports) {
772
860
  const result = []
@@ -7,6 +7,11 @@ const slashRegExp = /[/\\]/
7
7
  const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/
8
8
 
9
9
  let _buffer
10
+ /**
11
+ * Lazily load the buffer module.
12
+ * @returns {import('buffer')} The Node.js buffer module.
13
+ * @private
14
+ */
10
15
  /*@__NO_SIDE_EFFECTS__*/
11
16
  function getBuffer() {
12
17
  if (_buffer === undefined) {
@@ -18,6 +23,11 @@ function getBuffer() {
18
23
  }
19
24
 
20
25
  let _path
26
+ /**
27
+ * Lazily load the path module.
28
+ * @returns {import('path')} The Node.js path module.
29
+ * @private
30
+ */
21
31
  /*@__NO_SIDE_EFFECTS__*/
22
32
  function getPath() {
23
33
  if (_path === undefined) {
@@ -29,6 +39,11 @@ function getPath() {
29
39
  }
30
40
 
31
41
  let _url
42
+ /**
43
+ * Lazily load the url module.
44
+ * @returns {import('url')} The Node.js url module.
45
+ * @private
46
+ */
32
47
  /*@__NO_SIDE_EFFECTS__*/
33
48
  function getUrl() {
34
49
  if (_url === undefined) {
@@ -39,17 +54,32 @@ function getUrl() {
39
54
  return _url
40
55
  }
41
56
 
57
+ /**
58
+ * Check if a path contains node_modules directory.
59
+ * @param {string | Buffer | URL} pathLike - The path to check.
60
+ * @returns {boolean} True if the path contains node_modules.
61
+ */
42
62
  /*@__NO_SIDE_EFFECTS__*/
43
63
  function isNodeModules(pathLike) {
44
64
  const filepath = pathLikeToString(pathLike)
45
65
  return nodeModulesPathRegExp.test(filepath)
46
66
  }
47
67
 
68
+ /**
69
+ * Check if a value is a valid file path (absolute or relative).
70
+ * @param {any} pathLike - The value to check.
71
+ * @returns {boolean} True if the value is a valid path.
72
+ */
48
73
  /*@__NO_SIDE_EFFECTS__*/
49
74
  function isPath(pathLike) {
50
75
  return isRelative(pathLike) || getPath().isAbsolute(pathLike)
51
76
  }
52
77
 
78
+ /**
79
+ * Check if a path is relative (starts with . or ..).
80
+ * @param {any} pathLike - The path to check.
81
+ * @returns {boolean} True if the path is relative.
82
+ */
53
83
  /*@__NO_SIDE_EFFECTS__*/
54
84
  function isRelative(pathLike) {
55
85
  const filepath = pathLikeToString(pathLike)
@@ -73,6 +103,11 @@ function isRelative(pathLike) {
73
103
  return false
74
104
  }
75
105
 
106
+ /**
107
+ * Normalize a path by converting backslashes to forward slashes and collapsing segments.
108
+ * @param {string | Buffer | URL} pathLike - The path to normalize.
109
+ * @returns {string} The normalized path.
110
+ */
76
111
  /*@__NO_SIDE_EFFECTS__*/
77
112
  function normalizePath(pathLike) {
78
113
  const filepath = pathLikeToString(pathLike)
@@ -142,12 +177,17 @@ function normalizePath(pathLike) {
142
177
  return prefix + collapsed
143
178
  }
144
179
 
180
+ /**
181
+ * Convert a path-like value to a string.
182
+ * @param {string | Buffer | URL | any} pathLike - The path-like value to convert.
183
+ * @returns {string} The path as a string.
184
+ */
145
185
  /*@__NO_SIDE_EFFECTS__*/
146
186
  function pathLikeToString(pathLike) {
147
187
  if (typeof pathLike === 'string') {
148
188
  return pathLike
149
189
  }
150
- const Buffer = getBuffer()
190
+ const { Buffer } = getBuffer()
151
191
  if (Buffer.isBuffer(pathLike)) {
152
192
  return pathLike.toString('utf8')
153
193
  }
@@ -158,12 +198,22 @@ function pathLikeToString(pathLike) {
158
198
  return String(pathLike)
159
199
  }
160
200
 
201
+ /**
202
+ * Split a path into an array of segments.
203
+ * @param {string | Buffer | URL} pathLike - The path to split.
204
+ * @returns {string[]} Array of path segments.
205
+ */
161
206
  /*@__NO_SIDE_EFFECTS__*/
162
207
  function splitPath(pathLike) {
163
208
  const filepath = pathLikeToString(pathLike)
164
209
  return filepath.split(slashRegExp)
165
210
  }
166
211
 
212
+ /**
213
+ * Remove leading ./ or ../ from a path.
214
+ * @param {string | Buffer | URL} pathLike - The path to trim.
215
+ * @returns {string} The path without leading dot-slash.
216
+ */
167
217
  /*@__NO_SIDE_EFFECTS__*/
168
218
  function trimLeadingDotSlash(pathLike) {
169
219
  const filepath = pathLikeToString(pathLike)
@@ -3,6 +3,11 @@
3
3
  const { arrayChunk } = /*@__PURE__*/ require('./arrays')
4
4
 
5
5
  let _timers
6
+ /**
7
+ * Get the timers/promises module.
8
+ * @returns {Object} The timers/promises module.
9
+ * @private
10
+ */
6
11
  /*@__NO_SIDE_EFFECTS__*/
7
12
  function getTimers() {
8
13
  if (_timers === undefined) {
@@ -13,6 +18,11 @@ function getTimers() {
13
18
  return _timers
14
19
  }
15
20
 
21
+ /**
22
+ * Normalize options for iteration functions.
23
+ * @param {Object} [options] - Iteration options.
24
+ * @returns {Object} Normalized iteration options.
25
+ */
16
26
  /*@__NO_SIDE_EFFECTS__*/
17
27
  function normalizeIterationOptions(options) {
18
28
  const {
@@ -32,6 +42,11 @@ function normalizeIterationOptions(options) {
32
42
  }
33
43
  }
34
44
 
45
+ /**
46
+ * Normalize options for retry functionality.
47
+ * @param {Object|number} [options] - Retry options or number of retries.
48
+ * @returns {Object} Normalized retry options.
49
+ */
35
50
  /*@__NO_SIDE_EFFECTS__*/
36
51
  function normalizeRetryOptions(options) {
37
52
  const {
@@ -72,6 +87,11 @@ function normalizeRetryOptions(options) {
72
87
  }
73
88
  }
74
89
 
90
+ /**
91
+ * Resolve retry options from various input formats.
92
+ * @param {Object|number} [options] - Options object or number of retries.
93
+ * @returns {Object} Resolved retry options object.
94
+ */
75
95
  /*@__NO_SIDE_EFFECTS__*/
76
96
  function resolveRetryOptions(options) {
77
97
  return {
@@ -80,6 +100,13 @@ function resolveRetryOptions(options) {
80
100
  }
81
101
  }
82
102
 
103
+ /**
104
+ * Execute an async function for each array element with concurrency control.
105
+ * @param {any[]} array - Array to iterate over.
106
+ * @param {Function} callbackFn - Async function to execute for each element.
107
+ * @param {Object} [options] - Iteration options including concurrency and retries.
108
+ * @returns {Promise<void>} Resolves when all iterations complete.
109
+ */
83
110
  /*@__NO_SIDE_EFFECTS__*/
84
111
  async function pEach(array, callbackFn, options) {
85
112
  const iterOpts = normalizeIterationOptions(options)
@@ -90,6 +117,13 @@ async function pEach(array, callbackFn, options) {
90
117
  )
91
118
  }
92
119
 
120
+ /**
121
+ * Filter an array asynchronously with concurrency control.
122
+ * @param {any[]} array - Array to filter.
123
+ * @param {Function} callbackFn - Async predicate function.
124
+ * @param {Object} [options] - Iteration options including concurrency and retries.
125
+ * @returns {Promise<any[]>} Filtered array.
126
+ */
93
127
  /*@__NO_SIDE_EFFECTS__*/
94
128
  async function pFilter(array, callbackFn, options) {
95
129
  const iterOpts = normalizeIterationOptions(options)
@@ -102,6 +136,13 @@ async function pFilter(array, callbackFn, options) {
102
136
  ).flat()
103
137
  }
104
138
 
139
+ /**
140
+ * Process chunked arrays with an async callback.
141
+ * @param {any[][]} chunks - Array of array chunks.
142
+ * @param {Function} callbackFn - Async function to execute for each element.
143
+ * @param {Object} [options] - Retry options.
144
+ * @returns {Promise<void>} Resolves when all chunks are processed.
145
+ */
105
146
  /*@__NO_SIDE_EFFECTS__*/
106
147
  async function pEachChunk(chunks, callbackFn, options) {
107
148
  const retryOpts = normalizeRetryOptions(options)
@@ -122,6 +163,13 @@ async function pEachChunk(chunks, callbackFn, options) {
122
163
  }
123
164
  }
124
165
 
166
+ /**
167
+ * Filter chunked arrays with an async predicate.
168
+ * @param {any[][]} chunks - Array of array chunks.
169
+ * @param {Function} callbackFn - Async predicate function.
170
+ * @param {Object} [options] - Retry options.
171
+ * @returns {Promise<any[][]>} Filtered chunks.
172
+ */
125
173
  /*@__NO_SIDE_EFFECTS__*/
126
174
  async function pFilterChunk(chunks, callbackFn, options) {
127
175
  const retryOpts = normalizeRetryOptions(options)
@@ -149,6 +197,13 @@ async function pFilterChunk(chunks, callbackFn, options) {
149
197
  return filteredChunks
150
198
  }
151
199
 
200
+ /**
201
+ * Retry an async function with exponential backoff.
202
+ * @param {Function} callbackFn - Async function to retry.
203
+ * @param {Object} [options] - Retry options including retries, backoff, and delays.
204
+ * @returns {Promise<any>} Result of the successful function call.
205
+ * @throws {Error} The last error if all retries fail.
206
+ */
152
207
  /*@__NO_SIDE_EFFECTS__*/
153
208
  async function pRetry(callbackFn, options) {
154
209
  const {
@@ -5,6 +5,11 @@
5
5
  // MIT License
6
6
  // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
7
7
 
8
+ /**
9
+ * Escape special characters in a string for use in a regular expression.
10
+ * @param {string} str - The string to escape.
11
+ * @returns {string} The escaped string safe for use in a RegExp.
12
+ */
8
13
  /*@__NO_SIDE_EFFECTS__*/
9
14
  function escapeRegExp(str) {
10
15
  // Escape characters with special meaning either inside or outside character sets.
@@ -1,6 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  let _localeCompare
4
+ /**
5
+ * Compare two strings using locale-aware comparison.
6
+ * @param {string} x - First string to compare.
7
+ * @param {string} y - Second string to compare.
8
+ * @returns {number} Negative if x < y, positive if x > y, 0 if equal.
9
+ */
4
10
  /*@__NO_SIDE_EFFECTS__*/
5
11
  function localeCompare(x, y) {
6
12
  if (_localeCompare === undefined) {
@@ -11,6 +17,12 @@ function localeCompare(x, y) {
11
17
  }
12
18
 
13
19
  let _naturalCompare
20
+ /**
21
+ * Compare two strings using natural sorting (numeric-aware, case-insensitive).
22
+ * @param {string} x - First string to compare.
23
+ * @param {string} y - Second string to compare.
24
+ * @returns {number} Negative if x < y, positive if x > y, 0 if equal.
25
+ */
14
26
  /*@__NO_SIDE_EFFECTS__*/
15
27
  function naturalCompare(x, y) {
16
28
  if (_naturalCompare === undefined) {
@@ -34,6 +46,11 @@ function naturalCompare(x, y) {
34
46
  }
35
47
 
36
48
  let _naturalSorter
49
+ /**
50
+ * Sort an array using natural comparison.
51
+ * @param {any[]} arrayToSort - The array to sort.
52
+ * @returns {any} The fast-sort instance with natural comparison.
53
+ */
37
54
  /*@__NO_SIDE_EFFECTS__*/
38
55
  function naturalSorter(arrayToSort) {
39
56
  if (_naturalSorter === undefined) {
@@ -3,9 +3,16 @@
3
3
  const { isArray: ArrayIsArray } = Array
4
4
  const { hasOwn: ObjectHasOwn, keys: ObjectKeys } = Object
5
5
 
6
+ const { getOwn } = /*@__PURE__*/ require('./objects')
6
7
  const { stripAnsi } = /*@__PURE__*/ require('./strings')
7
8
 
9
+ const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i
10
+
8
11
  let _child_process
12
+ /**
13
+ * Lazily load the child_process module.
14
+ * @returns {import('child_process')} The Node.js child_process module.
15
+ */
9
16
  /*@__NO_SIDE_EFFECTS__*/
10
17
  function getChildProcess() {
11
18
  if (_child_process === undefined) {
@@ -16,15 +23,49 @@ function getChildProcess() {
16
23
  return _child_process
17
24
  }
18
25
 
19
- let _spawn
26
+ let _npmCliPromiseSpawn
27
+ /**
28
+ * Lazily load the promise-spawn module for async process spawning.
29
+ * @returns {Function} The promise-spawn module.
30
+ */
20
31
  /*@__NO_SIDE_EFFECTS__*/
21
- function getSpawn() {
22
- if (_spawn === undefined) {
23
- _spawn = /*@__PURE__*/ require('../external/@npmcli/promise-spawn')
32
+ function getNpmcliPromiseSpawn() {
33
+ if (_npmCliPromiseSpawn === undefined) {
34
+ _npmCliPromiseSpawn = /*@__PURE__*/ require('../external/@npmcli/promise-spawn')
24
35
  }
25
- return _spawn
36
+ return _npmCliPromiseSpawn
26
37
  }
27
38
 
39
+ let _path
40
+ /**
41
+ * Lazily load the path module to avoid Webpack errors.
42
+ * @returns {import('path')} The Node.js path module.
43
+ */
44
+ /*@__NO_SIDE_EFFECTS__*/
45
+ function getPath() {
46
+ if (_path === undefined) {
47
+ // Use non-'node:' prefixed require to avoid Webpack errors.
48
+ // eslint-disable-next-line n/prefer-node-protocol
49
+ _path = /*@__PURE__*/ require('path')
50
+ }
51
+ return _path
52
+ }
53
+
54
+ /**
55
+ * Check if a value is a spawn error.
56
+ * @param {any} value - The value to check.
57
+ * @returns {value is SpawnError} True if the value is a spawn error.
58
+ * @typedef {Object} SpawnError
59
+ * @property {string[]} args - Command arguments.
60
+ * @property {string} cmd - Command that was run.
61
+ * @property {number} code - Exit code.
62
+ * @property {string} name - Error name.
63
+ * @property {string} message - Error message.
64
+ * @property {AbortSignal | null} signal - Abort signal.
65
+ * @property {string} stack - Stack trace.
66
+ * @property {string | Buffer} stderr - Standard error output.
67
+ * @property {string | Buffer} stdout - Standard output.
68
+ */
28
69
  /*@__NO_SIDE_EFFECTS__*/
29
70
  function isSpawnError(value) {
30
71
  return (
@@ -39,6 +80,12 @@ function isSpawnError(value) {
39
80
  )
40
81
  }
41
82
 
83
+ /**
84
+ * Check if stdio configuration matches a specific type.
85
+ * @param {string | string[] | readonly string[]} stdio - The stdio configuration.
86
+ * @param {import('child_process').IOType | 'ipc' | Array<import('child_process').IOType | 'ipc'>} type - The type to check.
87
+ * @returns {boolean} True if the stdio matches the type.
88
+ */
42
89
  /*@__NO_SIDE_EFFECTS__*/
43
90
  function isStdioType(stdio, type) {
44
91
  return (
@@ -52,6 +99,11 @@ function isStdioType(stdio, type) {
52
99
  )
53
100
  }
54
101
 
102
+ /**
103
+ * Strip ANSI escape codes from spawn result stdout and stderr.
104
+ * @param {{ stdout?: string; stderr?: string }} result - The spawn result.
105
+ * @returns {{ stdout?: string; stderr?: string }} The result with ANSI codes stripped.
106
+ */
55
107
  /*@__NO_SIDE_EFFECTS__*/
56
108
  function stripAnsiFromSpawnResult(result) {
57
109
  const { stderr, stdout } = result
@@ -65,7 +117,32 @@ function stripAnsiFromSpawnResult(result) {
65
117
  }
66
118
 
67
119
  /*@__NO_SIDE_EFFECTS__*/
120
+ /**
121
+ * Spawn a child process with enhanced error handling and output capture.
122
+ * @template {SpawnOptions} O
123
+ * @param {string} cmd - The command to execute.
124
+ * @param {string[] | readonly string[]} [args=[]] - Arguments to pass to the command.
125
+ * @param {O} [options] - Spawn options.
126
+ * @param {Record<any, any>} [extra] - Additional data to include in the result.
127
+ * @returns {SpawnResult<O extends {stdioString: false} ? Buffer : string, typeof extra>} Command result with process handle.
128
+ * @typedef {import('./objects').Remap<import('child_process').SpawnOptions & {spinner?: import('./spinner').Spinner; stdioString?: boolean; stripAnsi?: boolean}>} SpawnOptions
129
+ * @typedef {Promise<SpawnStdioResult> & {process: import('child_process').ChildProcess; stdin: import('stream').Writable | null}} SpawnResult
130
+ * @typedef {{cmd: string; args: string[] | readonly string[]; code: number; signal: AbortSignal | null; stdout: string | Buffer; stderr: string | Buffer}} SpawnStdioResult
131
+ */
68
132
  function spawn(cmd, args, options, extra) {
133
+ // On Windows with shell: true, use just the command name, not the full path.
134
+ // When shell: true is used, Windows cmd.exe has issues executing full paths to
135
+ // .cmd/.bat files (e.g., 'C:\...\pnpm.cmd'), often resulting in ENOENT errors.
136
+ // Using just the command name (e.g., 'pnpm') allows cmd.exe to find it via PATH.
137
+ // See: https://github.com/nodejs/node/issues/3675
138
+ // Check for .cmd, .bat, .ps1 extensions that indicate a Windows script.
139
+ const shell = getOwn(options, 'shell')
140
+ const WIN32 = /*@__PURE__*/ require('./constants/win32')
141
+ if (WIN32 && shell && windowsScriptExtRegExp.test(cmd)) {
142
+ const path = getPath()
143
+ // Extract just the command name without path and extension.
144
+ cmd = path.basename(cmd, path.extname(cmd))
145
+ }
69
146
  const {
70
147
  spinner = /*@__PURE__*/ require('./constants/spinner'),
71
148
  stripAnsi: shouldStripAnsi = true,
@@ -81,8 +158,8 @@ function spawn(cmd, args, options, extra) {
81
158
  if (shouldStopSpinner) {
82
159
  spinner.stop()
83
160
  }
84
- const spawn = getSpawn()
85
- let spawnPromise = spawn(
161
+ const npmCliPromiseSpawn = getNpmcliPromiseSpawn()
162
+ let spawnPromise = npmCliPromiseSpawn(
86
163
  cmd,
87
164
  args,
88
165
  {
@@ -119,7 +196,28 @@ function spawn(cmd, args, options, extra) {
119
196
  }
120
197
 
121
198
  /*@__NO_SIDE_EFFECTS__*/
199
+ /**
200
+ * Synchronously spawn a child process.
201
+ * @param {string} cmd - The command to execute.
202
+ * @param {string[] | readonly string[]} [args] - Arguments to pass to the command.
203
+ * @param {SpawnSyncOptions} [options] - Spawn options without spinner support.
204
+ * @returns {import('child_process').SpawnSyncReturns<string | Buffer>} Command result.
205
+ * @typedef {Omit<SpawnOptions, 'spinner'>} SpawnSyncOptions
206
+ */
122
207
  function spawnSync(cmd, args, options) {
208
+ // On Windows with shell: true, use just the command name, not the full path.
209
+ // When shell: true is used, Windows cmd.exe has issues executing full paths to
210
+ // .cmd/.bat files (e.g., 'C:\...\pnpm.cmd'), often resulting in ENOENT errors.
211
+ // Using just the command name (e.g., 'pnpm') allows cmd.exe to find it via PATH.
212
+ // See: https://github.com/nodejs/node/issues/3675
213
+ // Check for .cmd, .bat, .ps1 extensions that indicate a Windows script.
214
+ const shell = getOwn(options, 'shell')
215
+ const WIN32 = /*@__PURE__*/ require('./constants/win32')
216
+ if (WIN32 && shell && windowsScriptExtRegExp.test(cmd)) {
217
+ const path = getPath()
218
+ // Extract just the command name without path and extension.
219
+ cmd = path.basename(cmd, path.extname(cmd))
220
+ }
123
221
  const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
124
222
  __proto__: null,
125
223
  ...options
@@ -6,6 +6,11 @@ const {
6
6
  } = /*@__PURE__*/ require('./promises')
7
7
 
8
8
  let _streamingIterables
9
+ /**
10
+ * Get the streaming-iterables module.
11
+ * @returns {Object} The streaming-iterables module.
12
+ * @private
13
+ */
9
14
  /*@__NO_SIDE_EFFECTS__*/
10
15
  function getStreamingIterables() {
11
16
  if (_streamingIterables === undefined) {
@@ -14,6 +19,13 @@ function getStreamingIterables() {
14
19
  return _streamingIterables
15
20
  }
16
21
 
22
+ /**
23
+ * Execute a function for each item in an iterable in parallel.
24
+ * @param {AsyncIterable} iterable - The async iterable to process.
25
+ * @param {Function} func - Function to execute for each item.
26
+ * @param {Object} [options] - Iteration options including concurrency.
27
+ * @returns {Promise<void>} Resolves when all items are processed.
28
+ */
17
29
  /*@__NO_SIDE_EFFECTS__*/
18
30
  async function parallelEach(iterable, func, options) {
19
31
  for await (const _ of parallelMap(iterable, func, options)) {
@@ -21,6 +33,13 @@ async function parallelEach(iterable, func, options) {
21
33
  }
22
34
  }
23
35
 
36
+ /**
37
+ * Map over an iterable in parallel with concurrency control.
38
+ * @param {AsyncIterable} iterable - The async iterable to map.
39
+ * @param {Function} func - Mapping function.
40
+ * @param {Object} [options] - Iteration options including concurrency.
41
+ * @returns {AsyncIterable} Async iterable of mapped values.
42
+ */
24
43
  /*@__NO_SIDE_EFFECTS__*/
25
44
  function parallelMap(iterable, func, options) {
26
45
  const streamingIterables = getStreamingIterables()
@@ -36,6 +55,13 @@ function parallelMap(iterable, func, options) {
36
55
  )
37
56
  }
38
57
 
58
+ /**
59
+ * Transform an iterable with a function.
60
+ * @param {AsyncIterable} iterable - The async iterable to transform.
61
+ * @param {Function} func - Transform function.
62
+ * @param {Object} [options] - Iteration options including concurrency.
63
+ * @returns {AsyncIterable} Transformed async iterable.
64
+ */
39
65
  /*@__NO_SIDE_EFFECTS__*/
40
66
  function transform(iterable, func, options) {
41
67
  const streamingIterables = getStreamingIterables()