@socketsecurity/cli-with-sentry 1.1.14 → 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.
- package/CHANGELOG.md +19 -0
- package/dist/cli.js +114 -32
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +35 -37
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-bin.js +6 -6
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin.js +3 -5
- package/dist/shadow-pnpm-bin.js.map +1 -1
- package/dist/shadow-yarn-bin.js +2 -2
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/env-helpers.d.mts +13 -0
- package/dist/types/commands/fix/env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts.map +1 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
- package/dist/types/constants.d.mts +15 -19
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
- package/dist/types/utils/agent.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/dlx.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/utils.js +70 -29
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +514 -517
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/input.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/password.js +181 -205
- package/external/@socketsecurity/registry/external/@inquirer/search.js +47 -207
- package/external/@socketsecurity/registry/external/@inquirer/select.js +183 -207
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +388 -2280
- package/external/@socketsecurity/registry/external/browserslist.js +11534 -567
- package/external/@socketsecurity/registry/external/cacache.js +2575 -4914
- package/external/@socketsecurity/registry/external/libnpmpack.js +64667 -166061
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +384 -4044
- package/external/@socketsecurity/registry/external/normalize-package-data.js +30 -278
- package/external/@socketsecurity/registry/external/npm-package-arg.js +28 -9
- package/external/@socketsecurity/registry/external/pacote.js +46680 -66482
- package/external/@socketsecurity/registry/external/spdx-correct.js +19 -0
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +19 -0
- package/external/@socketsecurity/registry/lib/agent.js +390 -0
- package/external/@socketsecurity/registry/lib/arrays.js +31 -0
- package/external/@socketsecurity/registry/lib/bin.js +650 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/env.js +17 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/index.js +20 -11
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +2 -2
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +1 -1
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/yarn.js +3 -0
- package/external/@socketsecurity/registry/lib/debug.js +53 -0
- package/external/@socketsecurity/registry/lib/env.js +18 -0
- package/external/@socketsecurity/registry/lib/fs.js +218 -2
- package/external/@socketsecurity/registry/lib/functions.js +5 -0
- package/external/@socketsecurity/registry/lib/globs.js +22 -1
- package/external/@socketsecurity/registry/lib/json.js +16 -0
- package/external/@socketsecurity/registry/lib/logger.js +157 -0
- package/external/@socketsecurity/registry/lib/objects.js +103 -0
- package/external/@socketsecurity/registry/lib/packages.js +88 -0
- package/external/@socketsecurity/registry/lib/path.js +51 -1
- package/external/@socketsecurity/registry/lib/promises.js +55 -0
- package/external/@socketsecurity/registry/lib/regexps.js +5 -0
- package/external/@socketsecurity/registry/lib/sorts.js +17 -0
- package/external/@socketsecurity/registry/lib/spawn.js +105 -7
- package/external/@socketsecurity/registry/lib/streams.js +26 -0
- package/external/@socketsecurity/registry/lib/strings.js +123 -9
- package/external/@socketsecurity/registry/lib/url.js +21 -0
- package/external/@socketsecurity/registry/lib/words.js +16 -0
- package/external/@socketsecurity/registry/manifest.json +5 -4
- package/package.json +5 -4
- package/external/@socketsecurity/registry/external/ansi-regex.js +0 -13
- package/external/@socketsecurity/registry/lib/constants/node-workspaces.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/parse-args-config.js +0 -14
- package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -43
- package/external/@socketsecurity/registry/lib/constants/template-cjs-browser.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs-esm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-constructor.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-prototype-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-static-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32-ensure-tests-by-ecosystem.js +0 -3
- package/external/@socketsecurity/registry/lib/npm.js +0 -404
- /package/external/@socketsecurity/registry/lib/constants/{hidden-package-lock-json.js → dot-package-lock-json.js} +0 -0
|
@@ -46,12 +46,15 @@ const require$$1$1 = [
|
|
|
46
46
|
'Artistic-1.0-Perl',
|
|
47
47
|
'Artistic-1.0-cl8',
|
|
48
48
|
'Artistic-2.0',
|
|
49
|
+
'Artistic-dist',
|
|
50
|
+
'Aspell-RU',
|
|
49
51
|
'BSD-1-Clause',
|
|
50
52
|
'BSD-2-Clause',
|
|
51
53
|
'BSD-2-Clause-Darwin',
|
|
52
54
|
'BSD-2-Clause-Patent',
|
|
53
55
|
'BSD-2-Clause-Views',
|
|
54
56
|
'BSD-2-Clause-first-lines',
|
|
57
|
+
'BSD-2-Clause-pkgconf-disclaimer',
|
|
55
58
|
'BSD-3-Clause',
|
|
56
59
|
'BSD-3-Clause-Attribution',
|
|
57
60
|
'BSD-3-Clause-Clear',
|
|
@@ -192,6 +195,7 @@ const require$$1$1 = [
|
|
|
192
195
|
'Cornell-Lossless-JPEG',
|
|
193
196
|
'Cronyx',
|
|
194
197
|
'Crossword',
|
|
198
|
+
'CryptoSwift',
|
|
195
199
|
'CrystalStacker',
|
|
196
200
|
'Cube',
|
|
197
201
|
'D-FSL-1.0',
|
|
@@ -202,6 +206,7 @@ const require$$1$1 = [
|
|
|
202
206
|
'DRL-1.0',
|
|
203
207
|
'DRL-1.1',
|
|
204
208
|
'DSDP',
|
|
209
|
+
'DocBook-DTD',
|
|
205
210
|
'DocBook-Schema',
|
|
206
211
|
'DocBook-Stylesheet',
|
|
207
212
|
'DocBook-XML',
|
|
@@ -227,7 +232,10 @@ const require$$1$1 = [
|
|
|
227
232
|
'FSFAP-no-warranty-disclaimer',
|
|
228
233
|
'FSFUL',
|
|
229
234
|
'FSFULLR',
|
|
235
|
+
'FSFULLRSD',
|
|
230
236
|
'FSFULLRWD',
|
|
237
|
+
'FSL-1.1-ALv2',
|
|
238
|
+
'FSL-1.1-MIT',
|
|
231
239
|
'FTL',
|
|
232
240
|
'Fair',
|
|
233
241
|
'Ferguson-Twofish',
|
|
@@ -263,11 +271,13 @@ const require$$1$1 = [
|
|
|
263
271
|
'GPL-2.0-or-later',
|
|
264
272
|
'GPL-3.0-only',
|
|
265
273
|
'GPL-3.0-or-later',
|
|
274
|
+
'Game-Programming-Gems',
|
|
266
275
|
'Giftware',
|
|
267
276
|
'Glide',
|
|
268
277
|
'Glulxe',
|
|
269
278
|
'Graphics-Gems',
|
|
270
279
|
'Gutmann',
|
|
280
|
+
'HDF5',
|
|
271
281
|
'HIDAPI',
|
|
272
282
|
'HP-1986',
|
|
273
283
|
'HP-1989',
|
|
@@ -413,6 +423,7 @@ const require$$1$1 = [
|
|
|
413
423
|
'NPL-1.1',
|
|
414
424
|
'NPOSL-3.0',
|
|
415
425
|
'NRL',
|
|
426
|
+
'NTIA-PD',
|
|
416
427
|
'NTP',
|
|
417
428
|
'NTP-0',
|
|
418
429
|
'Naumen',
|
|
@@ -515,11 +526,13 @@ const require$$1$1 = [
|
|
|
515
526
|
'SMLNJ',
|
|
516
527
|
'SMPPL',
|
|
517
528
|
'SNIA',
|
|
529
|
+
'SOFA',
|
|
518
530
|
'SPL-1.0',
|
|
519
531
|
'SSH-OpenSSH',
|
|
520
532
|
'SSH-short',
|
|
521
533
|
'SSLeay-standalone',
|
|
522
534
|
'SSPL-1.0',
|
|
535
|
+
'SUL-1.0',
|
|
523
536
|
'SWL',
|
|
524
537
|
'Saxpath',
|
|
525
538
|
'SchemeReport',
|
|
@@ -565,6 +578,8 @@ const require$$1$1 = [
|
|
|
565
578
|
'Unicode-TOU',
|
|
566
579
|
'UnixCrypt',
|
|
567
580
|
'Unlicense',
|
|
581
|
+
'Unlicense-libtelnet',
|
|
582
|
+
'Unlicense-libwhirlpool',
|
|
568
583
|
'VOSTROM',
|
|
569
584
|
'VSL-1.0',
|
|
570
585
|
'Vim',
|
|
@@ -618,6 +633,8 @@ const require$$1$1 = [
|
|
|
618
633
|
'gtkbook',
|
|
619
634
|
'hdparm',
|
|
620
635
|
'iMatix',
|
|
636
|
+
'jove',
|
|
637
|
+
'libpng-1.6.35',
|
|
621
638
|
'libpng-2.0',
|
|
622
639
|
'libselinux-1.0',
|
|
623
640
|
'libtiff',
|
|
@@ -625,10 +642,12 @@ const require$$1$1 = [
|
|
|
625
642
|
'lsof',
|
|
626
643
|
'magaz',
|
|
627
644
|
'mailprio',
|
|
645
|
+
'man2html',
|
|
628
646
|
'metamail',
|
|
629
647
|
'mpi-permissive',
|
|
630
648
|
'mpich2',
|
|
631
649
|
'mplus',
|
|
650
|
+
'ngrep',
|
|
632
651
|
'pkgconf',
|
|
633
652
|
'pnmstitch',
|
|
634
653
|
'psfrag',
|
|
@@ -46,12 +46,15 @@ const require$$0 = [
|
|
|
46
46
|
'Artistic-1.0-Perl',
|
|
47
47
|
'Artistic-1.0-cl8',
|
|
48
48
|
'Artistic-2.0',
|
|
49
|
+
'Artistic-dist',
|
|
50
|
+
'Aspell-RU',
|
|
49
51
|
'BSD-1-Clause',
|
|
50
52
|
'BSD-2-Clause',
|
|
51
53
|
'BSD-2-Clause-Darwin',
|
|
52
54
|
'BSD-2-Clause-Patent',
|
|
53
55
|
'BSD-2-Clause-Views',
|
|
54
56
|
'BSD-2-Clause-first-lines',
|
|
57
|
+
'BSD-2-Clause-pkgconf-disclaimer',
|
|
55
58
|
'BSD-3-Clause',
|
|
56
59
|
'BSD-3-Clause-Attribution',
|
|
57
60
|
'BSD-3-Clause-Clear',
|
|
@@ -192,6 +195,7 @@ const require$$0 = [
|
|
|
192
195
|
'Cornell-Lossless-JPEG',
|
|
193
196
|
'Cronyx',
|
|
194
197
|
'Crossword',
|
|
198
|
+
'CryptoSwift',
|
|
195
199
|
'CrystalStacker',
|
|
196
200
|
'Cube',
|
|
197
201
|
'D-FSL-1.0',
|
|
@@ -202,6 +206,7 @@ const require$$0 = [
|
|
|
202
206
|
'DRL-1.0',
|
|
203
207
|
'DRL-1.1',
|
|
204
208
|
'DSDP',
|
|
209
|
+
'DocBook-DTD',
|
|
205
210
|
'DocBook-Schema',
|
|
206
211
|
'DocBook-Stylesheet',
|
|
207
212
|
'DocBook-XML',
|
|
@@ -227,7 +232,10 @@ const require$$0 = [
|
|
|
227
232
|
'FSFAP-no-warranty-disclaimer',
|
|
228
233
|
'FSFUL',
|
|
229
234
|
'FSFULLR',
|
|
235
|
+
'FSFULLRSD',
|
|
230
236
|
'FSFULLRWD',
|
|
237
|
+
'FSL-1.1-ALv2',
|
|
238
|
+
'FSL-1.1-MIT',
|
|
231
239
|
'FTL',
|
|
232
240
|
'Fair',
|
|
233
241
|
'Ferguson-Twofish',
|
|
@@ -263,11 +271,13 @@ const require$$0 = [
|
|
|
263
271
|
'GPL-2.0-or-later',
|
|
264
272
|
'GPL-3.0-only',
|
|
265
273
|
'GPL-3.0-or-later',
|
|
274
|
+
'Game-Programming-Gems',
|
|
266
275
|
'Giftware',
|
|
267
276
|
'Glide',
|
|
268
277
|
'Glulxe',
|
|
269
278
|
'Graphics-Gems',
|
|
270
279
|
'Gutmann',
|
|
280
|
+
'HDF5',
|
|
271
281
|
'HIDAPI',
|
|
272
282
|
'HP-1986',
|
|
273
283
|
'HP-1989',
|
|
@@ -413,6 +423,7 @@ const require$$0 = [
|
|
|
413
423
|
'NPL-1.1',
|
|
414
424
|
'NPOSL-3.0',
|
|
415
425
|
'NRL',
|
|
426
|
+
'NTIA-PD',
|
|
416
427
|
'NTP',
|
|
417
428
|
'NTP-0',
|
|
418
429
|
'Naumen',
|
|
@@ -515,11 +526,13 @@ const require$$0 = [
|
|
|
515
526
|
'SMLNJ',
|
|
516
527
|
'SMPPL',
|
|
517
528
|
'SNIA',
|
|
529
|
+
'SOFA',
|
|
518
530
|
'SPL-1.0',
|
|
519
531
|
'SSH-OpenSSH',
|
|
520
532
|
'SSH-short',
|
|
521
533
|
'SSLeay-standalone',
|
|
522
534
|
'SSPL-1.0',
|
|
535
|
+
'SUL-1.0',
|
|
523
536
|
'SWL',
|
|
524
537
|
'Saxpath',
|
|
525
538
|
'SchemeReport',
|
|
@@ -565,6 +578,8 @@ const require$$0 = [
|
|
|
565
578
|
'Unicode-TOU',
|
|
566
579
|
'UnixCrypt',
|
|
567
580
|
'Unlicense',
|
|
581
|
+
'Unlicense-libtelnet',
|
|
582
|
+
'Unlicense-libwhirlpool',
|
|
568
583
|
'VOSTROM',
|
|
569
584
|
'VSL-1.0',
|
|
570
585
|
'Vim',
|
|
@@ -618,6 +633,8 @@ const require$$0 = [
|
|
|
618
633
|
'gtkbook',
|
|
619
634
|
'hdparm',
|
|
620
635
|
'iMatix',
|
|
636
|
+
'jove',
|
|
637
|
+
'libpng-1.6.35',
|
|
621
638
|
'libpng-2.0',
|
|
622
639
|
'libselinux-1.0',
|
|
623
640
|
'libtiff',
|
|
@@ -625,10 +642,12 @@ const require$$0 = [
|
|
|
625
642
|
'lsof',
|
|
626
643
|
'magaz',
|
|
627
644
|
'mailprio',
|
|
645
|
+
'man2html',
|
|
628
646
|
'metamail',
|
|
629
647
|
'mpi-permissive',
|
|
630
648
|
'mpich2',
|
|
631
649
|
'mplus',
|
|
650
|
+
'ngrep',
|
|
632
651
|
'pkgconf',
|
|
633
652
|
'pnmstitch',
|
|
634
653
|
'psfrag',
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
execBin,
|
|
5
|
+
resolveBinPathSync,
|
|
6
|
+
whichBin,
|
|
7
|
+
whichBinSync
|
|
8
|
+
} = /*@__PURE__*/ require('./bin')
|
|
9
|
+
const { isDebug } = /*@__PURE__*/ require('./debug')
|
|
10
|
+
const { findUpSync } = /*@__PURE__*/ require('./fs')
|
|
11
|
+
const { getOwn } = /*@__PURE__*/ require('./objects')
|
|
12
|
+
const { spawn } = /*@__PURE__*/ require('./spawn')
|
|
13
|
+
|
|
14
|
+
const npmAuditFlags = new Set(['--audit', '--no-audit'])
|
|
15
|
+
|
|
16
|
+
const npmFundFlags = new Set(['--fund', '--no-fund'])
|
|
17
|
+
|
|
18
|
+
const npmLogFlags = new Set([
|
|
19
|
+
// --loglevel has several aliases:
|
|
20
|
+
// https://docs.npmjs.com/cli/v11/using-npm/logging#aliases
|
|
21
|
+
'--loglevel',
|
|
22
|
+
'-d',
|
|
23
|
+
'--dd',
|
|
24
|
+
'--ddd',
|
|
25
|
+
'-q',
|
|
26
|
+
'--quiet',
|
|
27
|
+
'-s',
|
|
28
|
+
'--silent'
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
const npmProgressFlags = new Set(['--progress', '--no-progress'])
|
|
32
|
+
|
|
33
|
+
const pnpmIgnoreScriptsFlags = new Set([
|
|
34
|
+
'--ignore-scripts',
|
|
35
|
+
'--no-ignore-scripts'
|
|
36
|
+
])
|
|
37
|
+
|
|
38
|
+
const pnpmFrozenLockfileFlags = new Set([
|
|
39
|
+
'--frozen-lockfile',
|
|
40
|
+
'--no-frozen-lockfile'
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
const pnpmInstallCommands = new Set(['install', 'i'])
|
|
44
|
+
|
|
45
|
+
// Commands that support --ignore-scripts flag in pnpm:
|
|
46
|
+
// Installation-related: install, add, update, remove, link, unlink, import, rebuild.
|
|
47
|
+
const pnpmInstallLikeCommands = new Set([
|
|
48
|
+
'install',
|
|
49
|
+
'i',
|
|
50
|
+
'add',
|
|
51
|
+
'update',
|
|
52
|
+
'up',
|
|
53
|
+
'remove',
|
|
54
|
+
'rm',
|
|
55
|
+
'link',
|
|
56
|
+
'ln',
|
|
57
|
+
'unlink',
|
|
58
|
+
'import',
|
|
59
|
+
'rebuild',
|
|
60
|
+
'rb'
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
// Commands that support --ignore-scripts flag in yarn:
|
|
64
|
+
// Similar to npm/pnpm: installation-related commands.
|
|
65
|
+
const yarnInstallLikeCommands = new Set([
|
|
66
|
+
'install',
|
|
67
|
+
'add',
|
|
68
|
+
'upgrade',
|
|
69
|
+
'remove',
|
|
70
|
+
'link',
|
|
71
|
+
'unlink',
|
|
72
|
+
'import'
|
|
73
|
+
])
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Execute npm commands with optimized flags and settings.
|
|
77
|
+
* @param {string[] | readonly string[]} args - Command arguments to pass to npm.
|
|
78
|
+
* @param {import('./spawn').SpawnOptions} [options] - Spawn options.
|
|
79
|
+
* @returns {Promise<{ stdout: string; stderr: string }>} Command output.
|
|
80
|
+
*/
|
|
81
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
82
|
+
function execNpm(args, options) {
|
|
83
|
+
const useDebug = isDebug()
|
|
84
|
+
const terminatorPos = args.indexOf('--')
|
|
85
|
+
const npmArgs = (
|
|
86
|
+
terminatorPos === -1 ? args : args.slice(0, terminatorPos)
|
|
87
|
+
).filter(
|
|
88
|
+
a => !isNpmAuditFlag(a) && !isNpmFundFlag(a) && !isNpmProgressFlag(a)
|
|
89
|
+
)
|
|
90
|
+
const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)
|
|
91
|
+
const logLevelArgs =
|
|
92
|
+
// The default value of loglevel is "notice". We default to "warn" which is
|
|
93
|
+
// one level quieter.
|
|
94
|
+
useDebug || npmArgs.some(isNpmLoglevelFlag) ? [] : ['--loglevel', 'warn']
|
|
95
|
+
return spawn(
|
|
96
|
+
/*@__PURE__*/ require('./constants/exec-path'),
|
|
97
|
+
[
|
|
98
|
+
.../*@__PURE__*/ require('./constants/node-harden-flags'),
|
|
99
|
+
.../*@__PURE__*/ require('./constants/node-no-warnings-flags'),
|
|
100
|
+
/*@__PURE__*/ require('./constants/npm-real-exec-path'),
|
|
101
|
+
// Even though '--loglevel=error' is passed npm will still run through
|
|
102
|
+
// code paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
|
|
103
|
+
// flags are passed.
|
|
104
|
+
'--no-audit',
|
|
105
|
+
'--no-fund',
|
|
106
|
+
// Add `--no-progress` and `--silent` flags to fix input being swallowed
|
|
107
|
+
// by the spinner when running the command with recent versions of npm.
|
|
108
|
+
'--no-progress',
|
|
109
|
+
// Add '--loglevel=error' if a loglevel flag is not provided and the
|
|
110
|
+
// SOCKET_CLI_DEBUG environment variable is not truthy.
|
|
111
|
+
...logLevelArgs,
|
|
112
|
+
...npmArgs,
|
|
113
|
+
...otherArgs
|
|
114
|
+
],
|
|
115
|
+
{
|
|
116
|
+
__proto__: null,
|
|
117
|
+
...options
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Execute pnpm commands with optimized flags and settings.
|
|
124
|
+
* @param {string[] | readonly string[]} args - Command arguments to pass to pnpm.
|
|
125
|
+
* @param {import('./spawn').SpawnOptions} [options] - Spawn options.
|
|
126
|
+
* @returns {Promise<{ stdout: string; stderr: string }>} Command output.
|
|
127
|
+
*/
|
|
128
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
129
|
+
function execPnpm(args, options) {
|
|
130
|
+
const { allowLockfileUpdate, ...extBinOpts } = { __proto__: null, ...options }
|
|
131
|
+
const useDebug = isDebug()
|
|
132
|
+
const terminatorPos = args.indexOf('--')
|
|
133
|
+
const pnpmArgs = (
|
|
134
|
+
terminatorPos === -1 ? args : args.slice(0, terminatorPos)
|
|
135
|
+
).filter(a => !isNpmProgressFlag(a))
|
|
136
|
+
const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)
|
|
137
|
+
|
|
138
|
+
const firstArg = pnpmArgs[0]
|
|
139
|
+
const supportsIgnoreScripts = pnpmInstallLikeCommands.has(firstArg)
|
|
140
|
+
|
|
141
|
+
// pnpm uses --loglevel for all commands.
|
|
142
|
+
const logLevelArgs =
|
|
143
|
+
useDebug || pnpmArgs.some(isPnpmLoglevelFlag) ? [] : ['--loglevel', 'warn']
|
|
144
|
+
|
|
145
|
+
// Only add --ignore-scripts for commands that support it.
|
|
146
|
+
const hasIgnoreScriptsFlag = pnpmArgs.some(isPnpmIgnoreScriptsFlag)
|
|
147
|
+
const ignoreScriptsArgs =
|
|
148
|
+
!supportsIgnoreScripts || hasIgnoreScriptsFlag ? [] : ['--ignore-scripts']
|
|
149
|
+
|
|
150
|
+
// In CI environments, pnpm uses --frozen-lockfile by default which prevents lockfile updates.
|
|
151
|
+
// For commands that need to update the lockfile (like install with new packages/overrides),
|
|
152
|
+
// we need to explicitly add --no-frozen-lockfile in CI mode if not already present.
|
|
153
|
+
const ENV = /*@__PURE__*/ require('./constants/env')
|
|
154
|
+
const frozenLockfileArgs = []
|
|
155
|
+
if (
|
|
156
|
+
ENV.CI &&
|
|
157
|
+
allowLockfileUpdate &&
|
|
158
|
+
isPnpmInstallCommand(firstArg) &&
|
|
159
|
+
!pnpmArgs.some(isPnpmFrozenLockfileFlag)
|
|
160
|
+
) {
|
|
161
|
+
frozenLockfileArgs.push('--no-frozen-lockfile')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Note: pnpm doesn't have a --no-progress flag. It uses --reporter instead.
|
|
165
|
+
// We removed --no-progress as it causes "Unknown option" errors with pnpm.
|
|
166
|
+
|
|
167
|
+
return execBin(
|
|
168
|
+
'pnpm',
|
|
169
|
+
[
|
|
170
|
+
// Add '--loglevel=warn' if a loglevel flag is not provided and debug is off.
|
|
171
|
+
...logLevelArgs,
|
|
172
|
+
// Add '--ignore-scripts' by default for security (only for installation commands).
|
|
173
|
+
...ignoreScriptsArgs,
|
|
174
|
+
// Add '--no-frozen-lockfile' in CI when lockfile updates are needed.
|
|
175
|
+
...frozenLockfileArgs,
|
|
176
|
+
...pnpmArgs,
|
|
177
|
+
...otherArgs
|
|
178
|
+
],
|
|
179
|
+
extBinOpts
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
184
|
+
function execYarn(args, options) {
|
|
185
|
+
const useDebug = isDebug()
|
|
186
|
+
const terminatorPos = args.indexOf('--')
|
|
187
|
+
const yarnArgs = (
|
|
188
|
+
terminatorPos === -1 ? args : args.slice(0, terminatorPos)
|
|
189
|
+
).filter(a => !isNpmProgressFlag(a))
|
|
190
|
+
const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)
|
|
191
|
+
|
|
192
|
+
const firstArg = yarnArgs[0]
|
|
193
|
+
const supportsIgnoreScripts = yarnInstallLikeCommands.has(firstArg)
|
|
194
|
+
|
|
195
|
+
// Yarn uses --silent flag for quieter output.
|
|
196
|
+
const logLevelArgs =
|
|
197
|
+
useDebug || yarnArgs.some(isNpmLoglevelFlag) ? [] : ['--silent']
|
|
198
|
+
|
|
199
|
+
// Only add --ignore-scripts for commands that support it.
|
|
200
|
+
const hasIgnoreScriptsFlag = yarnArgs.some(isPnpmIgnoreScriptsFlag)
|
|
201
|
+
const ignoreScriptsArgs =
|
|
202
|
+
!supportsIgnoreScripts || hasIgnoreScriptsFlag ? [] : ['--ignore-scripts']
|
|
203
|
+
|
|
204
|
+
return execBin(
|
|
205
|
+
'yarn',
|
|
206
|
+
[
|
|
207
|
+
// Add '--silent' if a loglevel flag is not provided and debug is off.
|
|
208
|
+
...logLevelArgs,
|
|
209
|
+
// Add '--ignore-scripts' by default for security (only for installation commands).
|
|
210
|
+
...ignoreScriptsArgs,
|
|
211
|
+
...yarnArgs,
|
|
212
|
+
...otherArgs
|
|
213
|
+
],
|
|
214
|
+
{
|
|
215
|
+
__proto__: null,
|
|
216
|
+
/**
|
|
217
|
+
* Check if a command argument is an npm audit flag.
|
|
218
|
+
* @param {string} cmdArg - The command argument to check.
|
|
219
|
+
* @returns {boolean} True if the argument is an audit flag.
|
|
220
|
+
*/
|
|
221
|
+
...options
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Check if a command argument is an npm fund flag.
|
|
228
|
+
* @param {string} cmdArg - The command argument to check.
|
|
229
|
+
* @returns {boolean} True if the argument is a fund flag.
|
|
230
|
+
*/
|
|
231
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
232
|
+
function isNpmAuditFlag(cmdArg) {
|
|
233
|
+
return npmAuditFlags.has(cmdArg)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Check if a command argument is an npm loglevel flag.
|
|
238
|
+
* @param {string} cmdArg - The command argument to check.
|
|
239
|
+
* @returns {boolean} True if the argument is a loglevel flag.
|
|
240
|
+
*/
|
|
241
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
242
|
+
function isNpmFundFlag(cmdArg) {
|
|
243
|
+
return npmFundFlags.has(cmdArg)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Check if a command argument is an npm loglevel flag.
|
|
248
|
+
* @param {string} cmdArg - The command argument to check.
|
|
249
|
+
* @returns {boolean} True if the argument is a loglevel flag.
|
|
250
|
+
*/
|
|
251
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
252
|
+
function isNpmLoglevelFlag(cmdArg) {
|
|
253
|
+
// https://docs.npmjs.com/cli/v11/using-npm/logging#setting-log-levels
|
|
254
|
+
return cmdArg.startsWith('--loglevel=') || npmLogFlags.has(cmdArg)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Check if a command argument is an npm node-options flag.
|
|
259
|
+
* @param {string} cmdArg - The command argument to check.
|
|
260
|
+
* @returns {boolean} True if the argument is a node-options flag.
|
|
261
|
+
*/
|
|
262
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
263
|
+
function isNpmNodeOptionsFlag(cmdArg) {
|
|
264
|
+
// https://docs.npmjs.com/cli/v9/using-npm/config#node-options
|
|
265
|
+
return cmdArg.startsWith('--node-options=')
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Check if a command argument is an npm progress flag.
|
|
270
|
+
* @param {string} cmdArg - The command argument to check.
|
|
271
|
+
* @returns {boolean} True if the argument is a progress flag.
|
|
272
|
+
*/
|
|
273
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
274
|
+
function isNpmProgressFlag(cmdArg) {
|
|
275
|
+
return npmProgressFlags.has(cmdArg)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Check if a command argument is a pnpm ignore-scripts flag.
|
|
280
|
+
* @param {string} cmdArg - The command argument to check.
|
|
281
|
+
* @returns {boolean} True if the argument is an ignore-scripts flag.
|
|
282
|
+
*/
|
|
283
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
284
|
+
function isPnpmIgnoreScriptsFlag(cmdArg) {
|
|
285
|
+
return pnpmIgnoreScriptsFlags.has(cmdArg)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Check if a command argument is a pnpm frozen-lockfile flag.
|
|
290
|
+
* @param {string} cmdArg - The command argument to check.
|
|
291
|
+
* @returns {boolean} True if the argument is a frozen-lockfile flag.
|
|
292
|
+
*/
|
|
293
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
294
|
+
function isPnpmFrozenLockfileFlag(cmdArg) {
|
|
295
|
+
return pnpmFrozenLockfileFlags.has(cmdArg)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Check if a command argument is a pnpm install command.
|
|
300
|
+
* @param {string} cmdArg - The command argument to check.
|
|
301
|
+
* @returns {boolean} True if the argument is an install command.
|
|
302
|
+
*/
|
|
303
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
304
|
+
function isPnpmInstallCommand(cmdArg) {
|
|
305
|
+
return pnpmInstallCommands.has(cmdArg)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Alias for isNpmLoglevelFlag for pnpm usage.
|
|
310
|
+
* @param {string} cmdArg - The command argument to check.
|
|
311
|
+
* @returns {boolean} True if the argument is a loglevel flag.
|
|
312
|
+
*/
|
|
313
|
+
const isPnpmLoglevelFlag = isNpmLoglevelFlag
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Execute a package.json script using the appropriate package manager.
|
|
317
|
+
* Automatically detects pnpm, yarn, or npm based on lockfiles.
|
|
318
|
+
* @param {string} scriptName - The name of the script to run.
|
|
319
|
+
* @param {string[] | readonly string[]} args - Additional arguments to pass to the script.
|
|
320
|
+
* @param {ExecScriptOptions} [options] - Spawn options with optional prepost flag.
|
|
321
|
+
* @returns {Promise<{ stdout: string; stderr: string }>} Command output.
|
|
322
|
+
* @typedef {import('./objects').Remap<import('./spawn').SpawnOptions & {prepost?: boolean}>} ExecScriptOptions
|
|
323
|
+
*/
|
|
324
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
325
|
+
function execScript(scriptName, args, options) {
|
|
326
|
+
const { prepost, ...spawnOptions } = { __proto__: null, ...options }
|
|
327
|
+
const useNodeRun =
|
|
328
|
+
!prepost && /*@__PURE__*/ require('./constants/supports-node-run')
|
|
329
|
+
|
|
330
|
+
// Detect package manager based on lockfile by traversing up from current directory.
|
|
331
|
+
const cwd = getOwn(spawnOptions, 'cwd') ?? process.cwd()
|
|
332
|
+
|
|
333
|
+
// Check for pnpm-lock.yaml.
|
|
334
|
+
const PNPM_LOCK_YAML = /*@__PURE__*/ require('./constants/pnpm-lock-yaml')
|
|
335
|
+
const pnpmLockPath = findUpSync(PNPM_LOCK_YAML, { cwd })
|
|
336
|
+
if (pnpmLockPath) {
|
|
337
|
+
return execPnpm(['run', scriptName, ...args], spawnOptions)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Check for package-lock.json.
|
|
341
|
+
// When in an npm workspace, use npm run to ensure workspace binaries are available.
|
|
342
|
+
const PACKAGE_LOCK = /*@__PURE__*/ require('./constants/package-lock-json')
|
|
343
|
+
const packageLockPath = findUpSync(PACKAGE_LOCK, { cwd })
|
|
344
|
+
if (packageLockPath) {
|
|
345
|
+
return execNpm(['run', scriptName, ...args], spawnOptions)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Check for yarn.lock.
|
|
349
|
+
const YARN_LOCK = /*@__PURE__*/ require('./constants/yarn-lock')
|
|
350
|
+
const yarnLockPath = findUpSync(YARN_LOCK, { cwd })
|
|
351
|
+
if (yarnLockPath) {
|
|
352
|
+
return execYarn(['run', scriptName, ...args], spawnOptions)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return spawn(
|
|
356
|
+
/*@__PURE__*/ require('./constants/exec-path'),
|
|
357
|
+
[
|
|
358
|
+
.../*@__PURE__*/ require('./constants/node-no-warnings-flags'),
|
|
359
|
+
...(useNodeRun
|
|
360
|
+
? ['--run']
|
|
361
|
+
: [/*@__PURE__*/ require('./constants/npm-real-exec-path'), 'run']),
|
|
362
|
+
scriptName,
|
|
363
|
+
...args
|
|
364
|
+
],
|
|
365
|
+
{
|
|
366
|
+
__proto__: null,
|
|
367
|
+
...spawnOptions
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
module.exports = {
|
|
373
|
+
execBin,
|
|
374
|
+
execNpm,
|
|
375
|
+
execPnpm,
|
|
376
|
+
execScript,
|
|
377
|
+
execYarn,
|
|
378
|
+
isNpmAuditFlag,
|
|
379
|
+
isNpmFundFlag,
|
|
380
|
+
isNpmLoglevelFlag,
|
|
381
|
+
isNpmNodeOptionsFlag,
|
|
382
|
+
isNpmProgressFlag,
|
|
383
|
+
isPnpmFrozenLockfileFlag,
|
|
384
|
+
isPnpmIgnoreScriptsFlag,
|
|
385
|
+
isPnpmInstallCommand,
|
|
386
|
+
isPnpmLoglevelFlag,
|
|
387
|
+
resolveBinPathSync,
|
|
388
|
+
whichBin,
|
|
389
|
+
whichBinSync
|
|
390
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
let _conjunctionFormatter
|
|
4
|
+
/**
|
|
5
|
+
* Get a cached Intl.ListFormat instance for conjunction (and) formatting.
|
|
6
|
+
* @returns {Intl.ListFormat} The conjunction formatter.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
4
9
|
/*@__NO_SIDE_EFFECTS__*/
|
|
5
10
|
function getConjunctionFormatter() {
|
|
6
11
|
if (_conjunctionFormatter === undefined) {
|
|
@@ -13,6 +18,11 @@ function getConjunctionFormatter() {
|
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
let _disjunctionFormatter
|
|
21
|
+
/**
|
|
22
|
+
* Get a cached Intl.ListFormat instance for disjunction (or) formatting.
|
|
23
|
+
* @returns {Intl.ListFormat} The disjunction formatter.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
16
26
|
/*@__NO_SIDE_EFFECTS__*/
|
|
17
27
|
function getDisjunctionFormatter() {
|
|
18
28
|
if (_disjunctionFormatter === undefined) {
|
|
@@ -24,6 +34,12 @@ function getDisjunctionFormatter() {
|
|
|
24
34
|
return _disjunctionFormatter
|
|
25
35
|
}
|
|
26
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Split an array into chunks of a specified size.
|
|
39
|
+
* @param {any[]} arr - The array to chunk.
|
|
40
|
+
* @param {number} [size=2] - The size of each chunk.
|
|
41
|
+
* @returns {any[][]} Array of chunked arrays.
|
|
42
|
+
*/
|
|
27
43
|
/*@__NO_SIDE_EFFECTS__*/
|
|
28
44
|
function arrayChunk(arr, size = 2) {
|
|
29
45
|
const { length } = arr
|
|
@@ -35,16 +51,31 @@ function arrayChunk(arr, size = 2) {
|
|
|
35
51
|
return chunks
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Get unique values from an array.
|
|
56
|
+
* @param {any[]} arr - The array to deduplicate.
|
|
57
|
+
* @returns {any[]} Array with unique values.
|
|
58
|
+
*/
|
|
38
59
|
/*@__NO_SIDE_EFFECTS__*/
|
|
39
60
|
function arrayUnique(arr) {
|
|
40
61
|
return [...new Set(arr)]
|
|
41
62
|
}
|
|
42
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Join array elements with proper "and" conjunction formatting.
|
|
66
|
+
* @param {string[]} arr - The array to join.
|
|
67
|
+
* @returns {string} The formatted string with "and" conjunction.
|
|
68
|
+
*/
|
|
43
69
|
/*@__NO_SIDE_EFFECTS__*/
|
|
44
70
|
function joinAnd(arr) {
|
|
45
71
|
return getConjunctionFormatter().format(arr)
|
|
46
72
|
}
|
|
47
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Join array elements with proper "or" disjunction formatting.
|
|
76
|
+
* @param {string[]} arr - The array to join.
|
|
77
|
+
* @returns {string} The formatted string with "or" disjunction.
|
|
78
|
+
*/
|
|
48
79
|
/*@__NO_SIDE_EFFECTS__*/
|
|
49
80
|
function joinOr(arr) {
|
|
50
81
|
return getDisjunctionFormatter().format(arr)
|