@socketsecurity/cli-with-sentry 0.14.67 → 0.14.69
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/dist/blessed/lib/alias.js +521 -0
- package/dist/blessed/lib/blessed.js +34 -0
- package/dist/blessed/lib/colors.js +492 -0
- package/dist/blessed/lib/events.js +197 -0
- package/dist/blessed/lib/gpmclient.js +247 -0
- package/dist/blessed/lib/helpers.js +172 -0
- package/dist/blessed/lib/keys.js +514 -0
- package/dist/blessed/lib/program.js +4532 -0
- package/dist/blessed/lib/tput.js +3113 -0
- package/dist/blessed/lib/unicode.js +914 -0
- package/dist/blessed/lib/widget.js +62 -0
- package/dist/blessed/lib/widgets/ansiimage.js +175 -0
- package/dist/blessed/lib/widgets/bigtext.js +172 -0
- package/dist/blessed/lib/widgets/box.js +36 -0
- package/dist/blessed/lib/widgets/button.js +64 -0
- package/dist/blessed/lib/widgets/checkbox.js +97 -0
- package/dist/blessed/lib/widgets/element.js +2873 -0
- package/dist/blessed/lib/widgets/filemanager.js +225 -0
- package/dist/blessed/lib/widgets/form.js +303 -0
- package/dist/blessed/lib/widgets/image.js +73 -0
- package/dist/blessed/lib/widgets/input.js +36 -0
- package/dist/blessed/lib/widgets/layout.js +251 -0
- package/dist/blessed/lib/widgets/line.js +61 -0
- package/dist/blessed/lib/widgets/list.js +654 -0
- package/dist/blessed/lib/widgets/listbar.js +454 -0
- package/dist/blessed/lib/widgets/listtable.js +267 -0
- package/dist/blessed/lib/widgets/loading.js +90 -0
- package/dist/blessed/lib/widgets/log.js +84 -0
- package/dist/blessed/lib/widgets/message.js +147 -0
- package/dist/blessed/lib/widgets/node.js +316 -0
- package/dist/blessed/lib/widgets/overlayimage.js +796 -0
- package/dist/blessed/lib/widgets/progressbar.js +168 -0
- package/dist/blessed/lib/widgets/prompt.js +129 -0
- package/dist/blessed/lib/widgets/question.js +131 -0
- package/dist/blessed/lib/widgets/radiobutton.js +64 -0
- package/dist/blessed/lib/widgets/radioset.js +38 -0
- package/dist/blessed/lib/widgets/screen.js +2489 -0
- package/dist/blessed/lib/widgets/scrollablebox.js +417 -0
- package/dist/blessed/lib/widgets/scrollabletext.js +37 -0
- package/dist/blessed/lib/widgets/table.js +385 -0
- package/dist/blessed/lib/widgets/terminal.js +454 -0
- package/dist/blessed/lib/widgets/text.js +37 -0
- package/dist/blessed/lib/widgets/textarea.js +378 -0
- package/dist/blessed/lib/widgets/textbox.js +81 -0
- package/dist/blessed/lib/widgets/video.js +132 -0
- package/dist/blessed/usr/fonts/AUTHORS +1 -0
- package/dist/blessed/usr/fonts/LICENSE +94 -0
- package/dist/blessed/usr/fonts/README +340 -0
- package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
- package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
- package/dist/blessed/usr/linux +0 -0
- package/dist/blessed/usr/windows-ansi +0 -0
- package/dist/blessed/usr/xterm +0 -0
- package/dist/blessed/usr/xterm-256color +0 -0
- package/dist/blessed/usr/xterm.termcap +243 -0
- package/dist/blessed/usr/xterm.terminfo +1977 -0
- package/dist/blessed/vendor/tng.js +1878 -0
- package/dist/constants.d.ts +271 -207
- package/dist/constants.js +271 -227
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.d.ts +1 -1
- package/dist/instrument-with-sentry.js +27 -24
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/artifact.d.ts +60 -26
- package/dist/module-sync/cli.d.ts +1 -1
- package/dist/module-sync/cli.js +6803 -4726
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/cmd.d.ts +4 -4
- package/dist/module-sync/config.d.ts +42 -17
- package/dist/module-sync/edge.d.ts +73 -60
- package/dist/module-sync/errors.d.ts +26 -11
- package/dist/module-sync/index.d.ts +31 -20
- package/dist/module-sync/node.d.ts +118 -83
- package/dist/module-sync/override-set.d.ts +39 -33
- package/dist/module-sync/package-environment.d.ts +83 -52
- package/dist/module-sync/path-resolve.d.ts +14 -9
- package/dist/module-sync/sdk.d.ts +9 -5
- package/dist/module-sync/shadow-bin.d.ts +5 -2
- package/dist/module-sync/shadow-bin.js +82 -66
- package/dist/module-sync/shadow-bin.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.d.ts +1 -1
- package/dist/module-sync/shadow-npm-inject.js +1231 -986
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shadow-npm-paths.d.ts +28 -14
- package/dist/module-sync/shadow-npm-paths.js +300 -208
- package/dist/module-sync/shadow-npm-paths.js.map +1 -1
- package/dist/module-sync/socket-package-alert.d.ts +95 -39
- package/dist/module-sync/types.d.ts +75 -47
- package/dist/module-sync/vendor.js +15055 -0
- package/dist/module-sync/vendor.js.map +1 -0
- package/dist/require/cli.d.ts +1 -1
- package/dist/require/cli.js +6802 -4724
- package/dist/require/cli.js.map +1 -1
- package/dist/require/vendor.js +2 -9145
- package/package.json +48 -38
- package/dist/require/vendor.js.map +0 -1
|
@@ -1,67 +1,73 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
3
|
function _socketInterop(e) {
|
|
4
4
|
let c = 0
|
|
5
5
|
for (const k in e ?? {}) {
|
|
6
6
|
c = c === 0 && k === 'default' ? 1 : 0
|
|
7
|
-
if (!c && k !== '__esModule')
|
|
7
|
+
if (!c && k !== '__esModule') {
|
|
8
|
+
break
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
11
|
return c ? e.default : e
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
const fs = require('node:fs')
|
|
15
|
+
const Module = require('node:module')
|
|
16
|
+
const path = require('node:path')
|
|
17
|
+
const process = require('node:process')
|
|
18
|
+
const logger = require('@socketsecurity/registry/lib/logger')
|
|
19
|
+
const path$1 = require('@socketsecurity/registry/lib/path')
|
|
20
|
+
const constants = require('./constants.js')
|
|
21
|
+
const ignore = _socketInterop(require('ignore'))
|
|
22
|
+
const micromatch = _socketInterop(require('micromatch'))
|
|
23
|
+
const tinyglobby = _socketInterop(require('tinyglobby'))
|
|
24
|
+
const which = _socketInterop(require('which'))
|
|
25
|
+
const debug = require('@socketsecurity/registry/lib/debug')
|
|
26
|
+
const npm = require('@socketsecurity/registry/lib/npm')
|
|
25
27
|
|
|
26
28
|
const ignoredDirs = [
|
|
27
|
-
// Taken from ignore-by-default:
|
|
28
|
-
// https://github.com/novemberborn/ignore-by-default/blob/v2.1.0/index.js
|
|
29
|
-
'.git',
|
|
30
|
-
// Git repository files, see <https://git-scm.com/>
|
|
31
|
-
'.log',
|
|
32
|
-
// Log files emitted by tools such as `tsserver`, see <https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29>
|
|
33
|
-
'.nyc_output',
|
|
34
|
-
// Temporary directory where nyc stores coverage data, see <https://github.com/bcoe/nyc>
|
|
35
|
-
'.sass-cache',
|
|
36
|
-
// Cache folder for node-sass, see <https://github.com/sass/node-sass>
|
|
37
|
-
'.yarn',
|
|
38
|
-
// Where node modules are installed when using Yarn, see <https://yarnpkg.com/>
|
|
39
|
-
'bower_components',
|
|
40
|
-
// Where Bower packages are installed, see <http://bower.io/>
|
|
41
|
-
'coverage',
|
|
42
|
-
// Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
|
|
43
|
-
'node_modules',
|
|
44
|
-
// Where Node modules are installed, see <https://nodejs.org/>
|
|
45
|
-
// Taken from globby:
|
|
46
|
-
// https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
|
|
47
|
-
'flow-typed'
|
|
48
|
-
|
|
29
|
+
// Taken from ignore-by-default:
|
|
30
|
+
// https://github.com/novemberborn/ignore-by-default/blob/v2.1.0/index.js
|
|
31
|
+
'.git',
|
|
32
|
+
// Git repository files, see <https://git-scm.com/>
|
|
33
|
+
'.log',
|
|
34
|
+
// Log files emitted by tools such as `tsserver`, see <https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29>
|
|
35
|
+
'.nyc_output',
|
|
36
|
+
// Temporary directory where nyc stores coverage data, see <https://github.com/bcoe/nyc>
|
|
37
|
+
'.sass-cache',
|
|
38
|
+
// Cache folder for node-sass, see <https://github.com/sass/node-sass>
|
|
39
|
+
'.yarn',
|
|
40
|
+
// Where node modules are installed when using Yarn, see <https://yarnpkg.com/>
|
|
41
|
+
'bower_components',
|
|
42
|
+
// Where Bower packages are installed, see <http://bower.io/>
|
|
43
|
+
'coverage',
|
|
44
|
+
// Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
|
|
45
|
+
'node_modules',
|
|
46
|
+
// Where Node modules are installed, see <https://nodejs.org/>
|
|
47
|
+
// Taken from globby:
|
|
48
|
+
// https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
|
|
49
|
+
'flow-typed'
|
|
50
|
+
]
|
|
51
|
+
const ignoredDirPatterns = ignoredDirs.map(i => `**/${i}`)
|
|
49
52
|
function directoryPatterns() {
|
|
50
|
-
return [...ignoredDirPatterns]
|
|
53
|
+
return [...ignoredDirPatterns]
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
const {
|
|
54
|
-
NODE_MODULES: NODE_MODULES$1,
|
|
55
|
-
NPM: NPM$1,
|
|
56
|
-
shadowBinPath
|
|
57
|
-
} = constants;
|
|
56
|
+
const { NODE_MODULES: NODE_MODULES$1, NPM: NPM$1, shadowBinPath } = constants
|
|
58
57
|
async function filterGlobResultToSupportedFiles(entries, supportedFiles) {
|
|
59
|
-
const patterns = ['golang', NPM$1, 'maven', 'pypi', 'gem', 'nuget'].reduce(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
const patterns = ['golang', NPM$1, 'maven', 'pypi', 'gem', 'nuget'].reduce(
|
|
59
|
+
(r, n) => {
|
|
60
|
+
const supported = supportedFiles[n]
|
|
61
|
+
r.push(
|
|
62
|
+
...(supported
|
|
63
|
+
? Object.values(supported).map(p => `**/${p.pattern}`)
|
|
64
|
+
: [])
|
|
65
|
+
)
|
|
66
|
+
return r
|
|
67
|
+
},
|
|
68
|
+
[]
|
|
69
|
+
)
|
|
70
|
+
return entries.filter(p => micromatch.some(p, patterns))
|
|
65
71
|
}
|
|
66
72
|
async function globWithGitIgnore(patterns, options) {
|
|
67
73
|
const {
|
|
@@ -71,50 +77,74 @@ async function globWithGitIgnore(patterns, options) {
|
|
|
71
77
|
} = {
|
|
72
78
|
__proto__: null,
|
|
73
79
|
...options
|
|
74
|
-
}
|
|
75
|
-
const projectIgnorePaths = socketConfig?.projectIgnorePaths
|
|
80
|
+
}
|
|
81
|
+
const projectIgnorePaths = socketConfig?.projectIgnorePaths
|
|
76
82
|
const ignoreFiles = await tinyglobby.glob(['**/.gitignore'], {
|
|
77
83
|
absolute: true,
|
|
78
84
|
cwd,
|
|
79
85
|
expandDirectories: true
|
|
80
|
-
})
|
|
81
|
-
const ignores = [
|
|
82
|
-
|
|
86
|
+
})
|
|
87
|
+
const ignores = [
|
|
88
|
+
...directoryPatterns(),
|
|
89
|
+
...(Array.isArray(projectIgnorePaths)
|
|
90
|
+
? ignoreFileLinesToGlobPatterns(
|
|
91
|
+
projectIgnorePaths,
|
|
92
|
+
path.join(cwd, '.gitignore'),
|
|
93
|
+
cwd
|
|
94
|
+
)
|
|
95
|
+
: []),
|
|
96
|
+
...(
|
|
97
|
+
await Promise.all(
|
|
98
|
+
ignoreFiles.map(async filepath =>
|
|
99
|
+
ignoreFileToGlobPatterns(
|
|
100
|
+
await fs.promises.readFile(filepath, 'utf8'),
|
|
101
|
+
filepath,
|
|
102
|
+
cwd
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
).flat()
|
|
107
|
+
]
|
|
108
|
+
const hasNegatedPattern = ignores.some(p => p.charCodeAt(0) === 33 /*'!'*/)
|
|
83
109
|
const globOptions = {
|
|
84
110
|
absolute: true,
|
|
85
111
|
cwd,
|
|
86
112
|
expandDirectories: false,
|
|
87
113
|
ignore: hasNegatedPattern ? [] : ignores,
|
|
88
114
|
...additionalOptions
|
|
89
|
-
}
|
|
90
|
-
const result = await tinyglobby.glob(patterns, globOptions)
|
|
115
|
+
}
|
|
116
|
+
const result = await tinyglobby.glob(patterns, globOptions)
|
|
91
117
|
if (!hasNegatedPattern) {
|
|
92
|
-
return result
|
|
118
|
+
return result
|
|
93
119
|
}
|
|
94
|
-
const {
|
|
95
|
-
absolute
|
|
96
|
-
} = globOptions;
|
|
120
|
+
const { absolute } = globOptions
|
|
97
121
|
|
|
98
122
|
// Note: the input files must be INSIDE the cwd. If you get strange looking
|
|
99
123
|
// relative path errors here, most likely your path is outside the given cwd.
|
|
100
|
-
const filtered = ignore()
|
|
101
|
-
|
|
124
|
+
const filtered = ignore()
|
|
125
|
+
.add(ignores)
|
|
126
|
+
.filter(absolute ? result.map(p => path.relative(cwd, p)) : result)
|
|
127
|
+
return absolute ? filtered.map(p => path.resolve(cwd, p)) : filtered
|
|
102
128
|
}
|
|
103
129
|
function ignoreFileLinesToGlobPatterns(lines, filepath, cwd) {
|
|
104
|
-
const base = path.relative(cwd, path.dirname(filepath)).replace(/\\/g, '/')
|
|
105
|
-
const patterns = []
|
|
106
|
-
for (let i = 0, {
|
|
107
|
-
|
|
108
|
-
} = lines; i < length; i += 1) {
|
|
109
|
-
const pattern = lines[i].trim();
|
|
130
|
+
const base = path.relative(cwd, path.dirname(filepath)).replace(/\\/g, '/')
|
|
131
|
+
const patterns = []
|
|
132
|
+
for (let i = 0, { length } = lines; i < length; i += 1) {
|
|
133
|
+
const pattern = lines[i].trim()
|
|
110
134
|
if (pattern.length > 0 && pattern.charCodeAt(0) !== 35 /*'#'*/) {
|
|
111
|
-
patterns.push(
|
|
135
|
+
patterns.push(
|
|
136
|
+
ignorePatternToMinimatch(
|
|
137
|
+
pattern.length && pattern.charCodeAt(0) === 33 /*'!'*/
|
|
138
|
+
? `!${path.posix.join(base, pattern.slice(1))}`
|
|
139
|
+
: path.posix.join(base, pattern)
|
|
140
|
+
)
|
|
141
|
+
)
|
|
112
142
|
}
|
|
113
143
|
}
|
|
114
|
-
return patterns
|
|
144
|
+
return patterns
|
|
115
145
|
}
|
|
116
146
|
function ignoreFileToGlobPatterns(content, filepath, cwd) {
|
|
117
|
-
return ignoreFileLinesToGlobPatterns(content.split(/\r?\n/), filepath, cwd)
|
|
147
|
+
return ignoreFileLinesToGlobPatterns(content.split(/\r?\n/), filepath, cwd)
|
|
118
148
|
}
|
|
119
149
|
|
|
120
150
|
// Based on `@eslint/compat` convertIgnorePatternToMinimatch.
|
|
@@ -122,16 +152,25 @@ function ignoreFileToGlobPatterns(content, filepath, cwd) {
|
|
|
122
152
|
// Copyright Nicholas C. Zakas
|
|
123
153
|
// https://github.com/eslint/rewrite/blob/compat-v1.2.1/packages/compat/src/ignore-file.js#L28
|
|
124
154
|
function ignorePatternToMinimatch(pattern) {
|
|
125
|
-
const isNegated = pattern.startsWith('!')
|
|
126
|
-
const negatedPrefix = isNegated ? '!' : ''
|
|
127
|
-
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd()
|
|
155
|
+
const isNegated = pattern.startsWith('!')
|
|
156
|
+
const negatedPrefix = isNegated ? '!' : ''
|
|
157
|
+
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd()
|
|
128
158
|
// Special cases.
|
|
129
|
-
if (
|
|
130
|
-
|
|
159
|
+
if (
|
|
160
|
+
patternToTest === '' ||
|
|
161
|
+
patternToTest === '**' ||
|
|
162
|
+
patternToTest === '/**' ||
|
|
163
|
+
patternToTest === '**'
|
|
164
|
+
) {
|
|
165
|
+
return `${negatedPrefix}${patternToTest}`
|
|
131
166
|
}
|
|
132
|
-
const firstIndexOfSlash = patternToTest.indexOf('/')
|
|
133
|
-
const matchEverywherePrefix =
|
|
134
|
-
|
|
167
|
+
const firstIndexOfSlash = patternToTest.indexOf('/')
|
|
168
|
+
const matchEverywherePrefix =
|
|
169
|
+
firstIndexOfSlash === -1 || firstIndexOfSlash === patternToTest.length - 1
|
|
170
|
+
? '**/'
|
|
171
|
+
: ''
|
|
172
|
+
const patternWithoutLeadingSlash =
|
|
173
|
+
firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest
|
|
135
174
|
// Escape `{` and `(` because in gitignore patterns they are just
|
|
136
175
|
// literal characters without any specific syntactic meaning,
|
|
137
176
|
// while in minimatch patterns they can form brace expansion or extglob syntax.
|
|
@@ -139,237 +178,290 @@ function ignorePatternToMinimatch(pattern) {
|
|
|
139
178
|
// For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
|
|
140
179
|
// But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
|
|
141
180
|
// Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
|
|
142
|
-
const escapedPatternWithoutLeadingSlash =
|
|
143
|
-
|
|
144
|
-
|
|
181
|
+
const escapedPatternWithoutLeadingSlash =
|
|
182
|
+
patternWithoutLeadingSlash.replaceAll(
|
|
183
|
+
/(?=((?:\\.|[^{(])*))\1([{(])/guy,
|
|
184
|
+
'$1\\$2'
|
|
185
|
+
)
|
|
186
|
+
const matchInsideSuffix = patternToTest.endsWith('/**') ? '/*' : ''
|
|
187
|
+
return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`
|
|
145
188
|
}
|
|
146
189
|
function pathsToPatterns(paths) {
|
|
147
190
|
// TODO: Does not support `~/` paths.
|
|
148
|
-
return paths.map(p => p === '.' ? '**/*' : p)
|
|
191
|
+
return paths.map(p => (p === '.' ? '**/*' : p))
|
|
149
192
|
}
|
|
150
193
|
function findBinPathDetailsSync(binName) {
|
|
151
|
-
const binPaths =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const binPath = binPaths[i];
|
|
194
|
+
const binPaths =
|
|
195
|
+
which.sync(binName, {
|
|
196
|
+
all: true,
|
|
197
|
+
nothrow: true
|
|
198
|
+
}) ?? []
|
|
199
|
+
let shadowIndex = -1
|
|
200
|
+
let theBinPath
|
|
201
|
+
for (let i = 0, { length } = binPaths; i < length; i += 1) {
|
|
202
|
+
const binPath = binPaths[i]
|
|
161
203
|
// Skip our bin directory if it's in the front.
|
|
162
204
|
if (path.dirname(binPath) === shadowBinPath) {
|
|
163
|
-
shadowIndex = i
|
|
205
|
+
shadowIndex = i
|
|
164
206
|
} else {
|
|
165
|
-
theBinPath = npm.resolveBinPath(binPath)
|
|
166
|
-
break
|
|
207
|
+
theBinPath = npm.resolveBinPath(binPath)
|
|
208
|
+
break
|
|
167
209
|
}
|
|
168
210
|
}
|
|
169
211
|
return {
|
|
170
212
|
name: binName,
|
|
171
213
|
path: theBinPath,
|
|
172
214
|
shadowed: shadowIndex !== -1
|
|
173
|
-
}
|
|
215
|
+
}
|
|
174
216
|
}
|
|
175
217
|
function findNpmPathSync(npmBinPath) {
|
|
176
218
|
// Lazily access constants.WIN32.
|
|
177
|
-
const {
|
|
178
|
-
|
|
179
|
-
} = constants;
|
|
180
|
-
let thePath = npmBinPath;
|
|
219
|
+
const { WIN32 } = constants
|
|
220
|
+
let thePath = npmBinPath
|
|
181
221
|
while (true) {
|
|
182
|
-
const libNmNpmPath = path.join(thePath, 'lib', NODE_MODULES$1, NPM$1)
|
|
222
|
+
const libNmNpmPath = path.join(thePath, 'lib', NODE_MODULES$1, NPM$1)
|
|
183
223
|
// mise puts its npm bin in a path like:
|
|
184
224
|
// /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
|
|
185
225
|
// HOWEVER, the location of the npm install is:
|
|
186
226
|
// /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/lib/node_modules/npm.
|
|
187
227
|
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
228
|
+
// Use existsSync here because statsSync, even with { throwIfNoEntry: false },
|
|
229
|
+
// will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
|
|
230
|
+
// See https://github.com/nodejs/node/issues/56993.
|
|
231
|
+
fs.existsSync(libNmNpmPath) &&
|
|
232
|
+
fs
|
|
233
|
+
.statSync(libNmNpmPath, {
|
|
234
|
+
throwIfNoEntry: false
|
|
235
|
+
})
|
|
236
|
+
?.isDirectory()
|
|
237
|
+
) {
|
|
238
|
+
thePath = path.join(libNmNpmPath, NPM$1)
|
|
195
239
|
}
|
|
196
|
-
const nmPath = path.join(thePath, NODE_MODULES$1)
|
|
240
|
+
const nmPath = path.join(thePath, NODE_MODULES$1)
|
|
197
241
|
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
242
|
+
// npm bin paths may look like:
|
|
243
|
+
// /usr/local/share/npm/bin/npm
|
|
244
|
+
// /Users/SomeUsername/.nvm/versions/node/vX.X.X/bin/npm
|
|
245
|
+
// C:\Users\SomeUsername\AppData\Roaming\npm\bin\npm.cmd
|
|
246
|
+
// OR
|
|
247
|
+
// C:\Program Files\nodejs\npm.cmd
|
|
248
|
+
//
|
|
249
|
+
// In practically all cases the npm path contains a node_modules folder:
|
|
250
|
+
// /usr/local/share/npm/bin/npm/node_modules
|
|
251
|
+
// C:\Program Files\nodejs\node_modules
|
|
252
|
+
fs.existsSync(nmPath) &&
|
|
253
|
+
fs
|
|
254
|
+
.statSync(nmPath, {
|
|
255
|
+
throwIfNoEntry: false
|
|
256
|
+
})
|
|
257
|
+
?.isDirectory() &&
|
|
258
|
+
// Optimistically look for the default location.
|
|
259
|
+
(path.basename(thePath) === NPM$1 ||
|
|
260
|
+
// Chocolatey installs npm bins in the same directory as node bins.
|
|
261
|
+
(WIN32 && fs.existsSync(path.join(thePath, `${NPM$1}.cmd`))))
|
|
262
|
+
) {
|
|
263
|
+
return thePath
|
|
216
264
|
}
|
|
217
|
-
const parent = path.dirname(thePath)
|
|
265
|
+
const parent = path.dirname(thePath)
|
|
218
266
|
if (parent === thePath) {
|
|
219
|
-
return undefined
|
|
267
|
+
return undefined
|
|
220
268
|
}
|
|
221
|
-
thePath = parent
|
|
269
|
+
thePath = parent
|
|
222
270
|
}
|
|
223
271
|
}
|
|
224
272
|
async function getPackageFilesForScan(cwd, inputPaths, supportedFiles, config) {
|
|
225
|
-
debug.debugLog(
|
|
273
|
+
debug.debugLog(
|
|
274
|
+
`getPackageFilesForScan: resolving ${inputPaths.length} paths:\n`,
|
|
275
|
+
inputPaths
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
// Lazily access constants.spinner.
|
|
279
|
+
const { spinner } = constants
|
|
280
|
+
spinner.start('Searching for local files to include in scan...')
|
|
226
281
|
const entries = await globWithGitIgnore(pathsToPatterns(inputPaths), {
|
|
227
282
|
cwd,
|
|
228
283
|
socketConfig: config
|
|
229
|
-
})
|
|
230
|
-
debug.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
284
|
+
})
|
|
285
|
+
if (debug.isDebug()) {
|
|
286
|
+
spinner.stop()
|
|
287
|
+
debug.debugLog(
|
|
288
|
+
`Resolved ${inputPaths.length} paths to ${entries.length} local paths:\n`,
|
|
289
|
+
entries
|
|
290
|
+
)
|
|
291
|
+
spinner.start('Searching for files now...')
|
|
292
|
+
} else {
|
|
293
|
+
spinner.start(
|
|
294
|
+
`Resolved ${inputPaths.length} paths to ${entries.length} local paths, searching for files now...`
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
const packageFiles = await filterGlobResultToSupportedFiles(
|
|
298
|
+
entries,
|
|
299
|
+
supportedFiles
|
|
300
|
+
)
|
|
301
|
+
spinner.successAndStop(
|
|
302
|
+
`Found ${packageFiles.length} local file${packageFiles.length === 1 ? '' : 's'}`
|
|
303
|
+
)
|
|
304
|
+
debug.debugLog('Absolute paths:\n', packageFiles)
|
|
305
|
+
return packageFiles
|
|
234
306
|
}
|
|
235
307
|
|
|
236
|
-
const {
|
|
237
|
-
NODE_MODULES,
|
|
238
|
-
NPM,
|
|
239
|
-
NPX,
|
|
240
|
-
SOCKET_CLI_ISSUES_URL
|
|
241
|
-
} = constants;
|
|
308
|
+
const { NODE_MODULES, NPM, NPX, SOCKET_CLI_ISSUES_URL } = constants
|
|
242
309
|
function exitWithBinPathError(binName) {
|
|
243
|
-
logger.logger.fail(
|
|
310
|
+
logger.logger.fail(
|
|
311
|
+
`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`
|
|
312
|
+
)
|
|
244
313
|
// The exit code 127 indicates that the command or binary being executed
|
|
245
314
|
// could not be found.
|
|
246
|
-
process
|
|
315
|
+
// eslint-disable-next-line n/no-process-exit
|
|
316
|
+
process.exit(127)
|
|
247
317
|
}
|
|
248
|
-
let _npmBinPathDetails
|
|
318
|
+
let _npmBinPathDetails
|
|
249
319
|
function getNpmBinPathDetails() {
|
|
250
320
|
if (_npmBinPathDetails === undefined) {
|
|
251
|
-
_npmBinPathDetails = findBinPathDetailsSync(NPM)
|
|
321
|
+
_npmBinPathDetails = findBinPathDetailsSync(NPM)
|
|
252
322
|
}
|
|
253
|
-
return _npmBinPathDetails
|
|
323
|
+
return _npmBinPathDetails
|
|
254
324
|
}
|
|
255
|
-
let _npxBinPathDetails
|
|
325
|
+
let _npxBinPathDetails
|
|
256
326
|
function getNpxBinPathDetails() {
|
|
257
327
|
if (_npxBinPathDetails === undefined) {
|
|
258
|
-
_npxBinPathDetails = findBinPathDetailsSync(NPX)
|
|
328
|
+
_npxBinPathDetails = findBinPathDetailsSync(NPX)
|
|
259
329
|
}
|
|
260
|
-
return _npxBinPathDetails
|
|
330
|
+
return _npxBinPathDetails
|
|
261
331
|
}
|
|
262
|
-
let _npmBinPath
|
|
332
|
+
let _npmBinPath
|
|
263
333
|
function getNpmBinPath() {
|
|
264
334
|
if (_npmBinPath === undefined) {
|
|
265
|
-
_npmBinPath = getNpmBinPathDetails().path
|
|
335
|
+
_npmBinPath = getNpmBinPathDetails().path
|
|
266
336
|
if (!_npmBinPath) {
|
|
267
|
-
exitWithBinPathError(NPM)
|
|
337
|
+
exitWithBinPathError(NPM)
|
|
268
338
|
}
|
|
269
339
|
}
|
|
270
|
-
return _npmBinPath
|
|
340
|
+
return _npmBinPath
|
|
271
341
|
}
|
|
272
342
|
function isNpmBinPathShadowed() {
|
|
273
|
-
return getNpmBinPathDetails().shadowed
|
|
343
|
+
return getNpmBinPathDetails().shadowed
|
|
274
344
|
}
|
|
275
|
-
let _npxBinPath
|
|
345
|
+
let _npxBinPath
|
|
276
346
|
function getNpxBinPath() {
|
|
277
347
|
if (_npxBinPath === undefined) {
|
|
278
|
-
_npxBinPath = getNpxBinPathDetails().path
|
|
348
|
+
_npxBinPath = getNpxBinPathDetails().path
|
|
279
349
|
if (!_npxBinPath) {
|
|
280
|
-
exitWithBinPathError(NPX)
|
|
350
|
+
exitWithBinPathError(NPX)
|
|
281
351
|
}
|
|
282
352
|
}
|
|
283
|
-
return _npxBinPath
|
|
353
|
+
return _npxBinPath
|
|
284
354
|
}
|
|
285
355
|
function isNpxBinPathShadowed() {
|
|
286
|
-
return getNpxBinPathDetails().shadowed
|
|
356
|
+
return getNpxBinPathDetails().shadowed
|
|
287
357
|
}
|
|
288
|
-
let _npmPath
|
|
358
|
+
let _npmPath
|
|
289
359
|
function getNpmPath() {
|
|
290
360
|
if (_npmPath === undefined) {
|
|
291
|
-
const npmBinPath = getNpmBinPath()
|
|
292
|
-
_npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined
|
|
361
|
+
const npmBinPath = getNpmBinPath()
|
|
362
|
+
_npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined
|
|
293
363
|
if (!_npmPath) {
|
|
294
|
-
let message = 'Unable to find npm CLI install directory.'
|
|
364
|
+
let message = 'Unable to find npm CLI install directory.'
|
|
295
365
|
if (npmBinPath) {
|
|
296
|
-
message += `\nSearched parent directories of ${path.dirname(npmBinPath)}
|
|
366
|
+
message += `\nSearched parent directories of ${path.dirname(npmBinPath)}.`
|
|
297
367
|
}
|
|
298
|
-
message += `\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}
|
|
299
|
-
logger.logger.fail(message)
|
|
368
|
+
message += `\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`
|
|
369
|
+
logger.logger.fail(message)
|
|
300
370
|
// The exit code 127 indicates that the command or binary being executed
|
|
301
371
|
// could not be found.
|
|
302
|
-
process
|
|
372
|
+
// eslint-disable-next-line n/no-process-exit
|
|
373
|
+
process.exit(127)
|
|
303
374
|
}
|
|
304
375
|
}
|
|
305
|
-
return _npmPath
|
|
376
|
+
return _npmPath
|
|
306
377
|
}
|
|
307
|
-
let _npmRequire
|
|
378
|
+
let _npmRequire
|
|
308
379
|
function getNpmRequire() {
|
|
309
380
|
if (_npmRequire === undefined) {
|
|
310
|
-
const npmPath = getNpmPath()
|
|
311
|
-
const npmNmPath = path.join(npmPath, NODE_MODULES, NPM)
|
|
312
|
-
_npmRequire = Module.createRequire(
|
|
381
|
+
const npmPath = getNpmPath()
|
|
382
|
+
const npmNmPath = path.join(npmPath, NODE_MODULES, NPM)
|
|
383
|
+
_npmRequire = Module.createRequire(
|
|
384
|
+
path.join(
|
|
385
|
+
fs.existsSync(npmNmPath) ? npmNmPath : npmPath,
|
|
386
|
+
'<dummy-basename>'
|
|
387
|
+
)
|
|
388
|
+
)
|
|
313
389
|
}
|
|
314
|
-
return _npmRequire
|
|
390
|
+
return _npmRequire
|
|
315
391
|
}
|
|
316
|
-
let _arboristPkgPath
|
|
392
|
+
let _arboristPkgPath
|
|
317
393
|
function getArboristPackagePath() {
|
|
318
394
|
if (_arboristPkgPath === undefined) {
|
|
319
|
-
const pkgName = '@npmcli/arborist'
|
|
320
|
-
const mainPathWithForwardSlashes = path$1.normalizePath(
|
|
321
|
-
|
|
395
|
+
const pkgName = '@npmcli/arborist'
|
|
396
|
+
const mainPathWithForwardSlashes = path$1.normalizePath(
|
|
397
|
+
getNpmRequire().resolve(pkgName)
|
|
398
|
+
)
|
|
399
|
+
const arboristPkgPathWithForwardSlashes = mainPathWithForwardSlashes.slice(
|
|
400
|
+
0,
|
|
401
|
+
mainPathWithForwardSlashes.lastIndexOf(pkgName) + pkgName.length
|
|
402
|
+
)
|
|
322
403
|
// Lazily access constants.WIN32.
|
|
323
|
-
_arboristPkgPath = constants.WIN32
|
|
404
|
+
_arboristPkgPath = constants.WIN32
|
|
405
|
+
? path.normalize(arboristPkgPathWithForwardSlashes)
|
|
406
|
+
: arboristPkgPathWithForwardSlashes
|
|
324
407
|
}
|
|
325
|
-
return _arboristPkgPath
|
|
408
|
+
return _arboristPkgPath
|
|
326
409
|
}
|
|
327
|
-
let _arboristClassPath
|
|
410
|
+
let _arboristClassPath
|
|
328
411
|
function getArboristClassPath() {
|
|
329
412
|
if (_arboristClassPath === undefined) {
|
|
330
|
-
_arboristClassPath = path.join(
|
|
413
|
+
_arboristClassPath = path.join(
|
|
414
|
+
getArboristPackagePath(),
|
|
415
|
+
'lib/arborist/index.js'
|
|
416
|
+
)
|
|
331
417
|
}
|
|
332
|
-
return _arboristClassPath
|
|
418
|
+
return _arboristClassPath
|
|
333
419
|
}
|
|
334
|
-
let _arboristDepValidPath
|
|
420
|
+
let _arboristDepValidPath
|
|
335
421
|
function getArboristDepValidPath() {
|
|
336
422
|
if (_arboristDepValidPath === undefined) {
|
|
337
|
-
_arboristDepValidPath = path.join(
|
|
423
|
+
_arboristDepValidPath = path.join(
|
|
424
|
+
getArboristPackagePath(),
|
|
425
|
+
'lib/dep-valid.js'
|
|
426
|
+
)
|
|
338
427
|
}
|
|
339
|
-
return _arboristDepValidPath
|
|
428
|
+
return _arboristDepValidPath
|
|
340
429
|
}
|
|
341
|
-
let _arboristEdgeClassPath
|
|
430
|
+
let _arboristEdgeClassPath
|
|
342
431
|
function getArboristEdgeClassPath() {
|
|
343
432
|
if (_arboristEdgeClassPath === undefined) {
|
|
344
|
-
_arboristEdgeClassPath = path.join(getArboristPackagePath(), 'lib/edge.js')
|
|
433
|
+
_arboristEdgeClassPath = path.join(getArboristPackagePath(), 'lib/edge.js')
|
|
345
434
|
}
|
|
346
|
-
return _arboristEdgeClassPath
|
|
435
|
+
return _arboristEdgeClassPath
|
|
347
436
|
}
|
|
348
|
-
let _arboristNodeClassPath
|
|
437
|
+
let _arboristNodeClassPath
|
|
349
438
|
function getArboristNodeClassPath() {
|
|
350
439
|
if (_arboristNodeClassPath === undefined) {
|
|
351
|
-
_arboristNodeClassPath = path.join(getArboristPackagePath(), 'lib/node.js')
|
|
440
|
+
_arboristNodeClassPath = path.join(getArboristPackagePath(), 'lib/node.js')
|
|
352
441
|
}
|
|
353
|
-
return _arboristNodeClassPath
|
|
442
|
+
return _arboristNodeClassPath
|
|
354
443
|
}
|
|
355
|
-
let _arboristOverrideSetClassPath
|
|
444
|
+
let _arboristOverrideSetClassPath
|
|
356
445
|
function getArboristOverrideSetClassPath() {
|
|
357
446
|
if (_arboristOverrideSetClassPath === undefined) {
|
|
358
|
-
_arboristOverrideSetClassPath = path.join(
|
|
447
|
+
_arboristOverrideSetClassPath = path.join(
|
|
448
|
+
getArboristPackagePath(),
|
|
449
|
+
'lib/override-set.js'
|
|
450
|
+
)
|
|
359
451
|
}
|
|
360
|
-
return _arboristOverrideSetClassPath
|
|
452
|
+
return _arboristOverrideSetClassPath
|
|
361
453
|
}
|
|
362
454
|
|
|
363
|
-
exports.getArboristClassPath = getArboristClassPath
|
|
364
|
-
exports.getArboristDepValidPath = getArboristDepValidPath
|
|
365
|
-
exports.getArboristEdgeClassPath = getArboristEdgeClassPath
|
|
366
|
-
exports.getArboristNodeClassPath = getArboristNodeClassPath
|
|
367
|
-
exports.getArboristOverrideSetClassPath = getArboristOverrideSetClassPath
|
|
368
|
-
exports.getNpmBinPath = getNpmBinPath
|
|
369
|
-
exports.getNpmRequire = getNpmRequire
|
|
370
|
-
exports.getNpxBinPath = getNpxBinPath
|
|
371
|
-
exports.getPackageFilesForScan = getPackageFilesForScan
|
|
372
|
-
exports.isNpmBinPathShadowed = isNpmBinPathShadowed
|
|
373
|
-
exports.isNpxBinPathShadowed = isNpxBinPathShadowed
|
|
374
|
-
//# debugId=
|
|
455
|
+
exports.getArboristClassPath = getArboristClassPath
|
|
456
|
+
exports.getArboristDepValidPath = getArboristDepValidPath
|
|
457
|
+
exports.getArboristEdgeClassPath = getArboristEdgeClassPath
|
|
458
|
+
exports.getArboristNodeClassPath = getArboristNodeClassPath
|
|
459
|
+
exports.getArboristOverrideSetClassPath = getArboristOverrideSetClassPath
|
|
460
|
+
exports.getNpmBinPath = getNpmBinPath
|
|
461
|
+
exports.getNpmRequire = getNpmRequire
|
|
462
|
+
exports.getNpxBinPath = getNpxBinPath
|
|
463
|
+
exports.getPackageFilesForScan = getPackageFilesForScan
|
|
464
|
+
exports.isNpmBinPathShadowed = isNpmBinPathShadowed
|
|
465
|
+
exports.isNpxBinPathShadowed = isNpxBinPathShadowed
|
|
466
|
+
//# debugId=fd0e5d9a-3b0e-4a94-acaf-a84f508b25ed
|
|
375
467
|
//# sourceMappingURL=shadow-npm-paths.js.map
|