@socketsecurity/lib 5.2.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/bin.d.ts +0 -9
- package/dist/bin.js +70 -48
- package/dist/constants/agents.js +2 -2
- package/dist/constants/platform.d.ts +21 -0
- package/dist/constants/platform.js +30 -6
- package/dist/cover/code.js +13 -5
- package/dist/debug.js +1 -1
- package/dist/dlx/binary.d.ts +1 -1
- package/dist/dlx/binary.js +49 -39
- package/dist/dlx/cache.js +10 -2
- package/dist/dlx/dir.js +1 -1
- package/dist/dlx/manifest.d.ts +2 -1
- package/dist/dlx/manifest.js +45 -41
- package/dist/dlx/package.js +39 -19
- package/dist/dlx/packages.js +1 -1
- package/dist/dlx/paths.js +1 -1
- package/dist/env/rewire.js +10 -2
- package/dist/external/@inquirer/checkbox.js +4 -2528
- package/dist/external/@inquirer/confirm.js +4 -2371
- package/dist/external/@inquirer/input.js +4 -2395
- package/dist/external/@inquirer/password.js +4 -2503
- package/dist/external/@inquirer/search.js +4 -2500
- package/dist/external/@inquirer/select.js +4 -2617
- package/dist/external/del.js +4 -7139
- package/dist/external/fast-glob.js +4 -5776
- package/dist/external/inquirer-pack.js +4610 -0
- package/dist/external/npm-core.js +3 -1
- package/dist/external/pico-pack.js +7162 -0
- package/dist/external/picomatch.js +4 -1523
- package/dist/external/spdx-correct.js +4 -1384
- package/dist/external/spdx-expression-parse.js +4 -1047
- package/dist/external/spdx-pack.js +1640 -0
- package/dist/external/validate-npm-package-name.js +4 -104
- package/dist/fs.js +3 -3
- package/dist/git.js +41 -38
- package/dist/http-request.js +12 -4
- package/dist/ipc.js +53 -29
- package/dist/json/edit.js +1 -1
- package/dist/json/format.js +1 -1
- package/dist/logger.js +1 -1
- package/dist/packages/edit.js +3 -3
- package/dist/packages/isolation.js +45 -23
- package/dist/packages/licenses.js +10 -2
- package/dist/paths/normalize.js +3 -3
- package/dist/paths/packages.js +1 -1
- package/dist/paths/socket.d.ts +2 -2
- package/dist/paths/socket.js +27 -21
- package/dist/process-lock.js +23 -14
- package/dist/promises.js +1 -1
- package/dist/releases/github.d.ts +82 -137
- package/dist/releases/github.js +91 -48
- package/dist/releases/socket-btm.d.ts +78 -192
- package/dist/releases/socket-btm.js +112 -50
- package/dist/signal-exit.js +1 -1
- package/dist/spawn.js +11 -4
- package/dist/stdio/mask.d.ts +6 -21
- package/dist/stdio/mask.js +18 -14
- package/dist/themes/context.js +10 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.4.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.4.0) - 2026-01-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **releases/github**: Extended release functions to accept glob patterns for asset discovery
|
|
13
|
+
- `getReleaseAssetUrl()` now accepts glob patterns: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
|
|
14
|
+
- `downloadReleaseAsset()` now accepts glob patterns for automatic asset discovery
|
|
15
|
+
- `getLatestRelease()` now accepts asset patterns to find releases with matching assets
|
|
16
|
+
- Supports wildcards, brace expansion, RegExp patterns, and prefix/suffix objects
|
|
17
|
+
- Uses picomatch for robust glob pattern matching
|
|
18
|
+
|
|
19
|
+
- **releases/socket-btm**: Extended `downloadSocketBtmRelease()` to accept glob patterns
|
|
20
|
+
- `asset` parameter now accepts wildcards: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
|
|
21
|
+
- Automatically discovers and downloads latest matching asset
|
|
22
|
+
- Eliminates need for hardcoded asset names in build scripts
|
|
23
|
+
|
|
24
|
+
## [5.3.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.3.0) - 2026-01-07
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **releases/socket-btm**: Exported helper functions for external use
|
|
29
|
+
- `detectLibc()`: Detect musl vs glibc on Linux systems
|
|
30
|
+
- `getBinaryAssetName()`: Get GitHub asset name for platform/arch
|
|
31
|
+
- `getBinaryName()`: Get binary filename with platform-appropriate extension
|
|
32
|
+
- `getPlatformArch()`: Get platform-arch identifier for directory structure
|
|
33
|
+
|
|
34
|
+
- **releases/github**: Exported `getAuthHeaders()` for GitHub API authentication
|
|
35
|
+
- Returns headers with `Accept`, `X-GitHub-Api-Version`, and optional `Authorization`
|
|
36
|
+
- Checks `GH_TOKEN` and `GITHUB_TOKEN` environment variables
|
|
37
|
+
|
|
8
38
|
## [5.2.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.2.1) - 2026-01-06
|
|
9
39
|
|
|
10
40
|
### Fixed
|
package/dist/bin.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Private Helper Functions
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// ============================================================================
|
|
5
|
-
// Types and Interfaces
|
|
6
|
-
// ============================================================================
|
|
7
1
|
/**
|
|
8
2
|
* Options for the which function.
|
|
9
3
|
*/
|
|
@@ -21,9 +15,6 @@ export interface WhichOptions {
|
|
|
21
15
|
/** Current working directory for resolving relative paths. */
|
|
22
16
|
cwd?: string | undefined;
|
|
23
17
|
}
|
|
24
|
-
// ============================================================================
|
|
25
|
-
// Public API (alphabetically sorted)
|
|
26
|
-
// ============================================================================
|
|
27
18
|
/**
|
|
28
19
|
* Execute a binary with the given arguments.
|
|
29
20
|
*/
|
package/dist/bin.js
CHANGED
|
@@ -42,8 +42,6 @@ __export(bin_exports, {
|
|
|
42
42
|
whichSync: () => whichSync
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(bin_exports);
|
|
45
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
46
|
-
var import_node_path = __toESM(require("node:path"));
|
|
47
45
|
var import_home = require("./env/home");
|
|
48
46
|
var import_windows = require("./env/windows");
|
|
49
47
|
var import_xdg = require("./env/xdg");
|
|
@@ -52,6 +50,22 @@ var import_which = __toESM(require("./external/which"));
|
|
|
52
50
|
var import_fs = require("./fs");
|
|
53
51
|
var import_normalize = require("./paths/normalize");
|
|
54
52
|
var import_spawn = require("./spawn");
|
|
53
|
+
let _fs;
|
|
54
|
+
// @__NO_SIDE_EFFECTS__
|
|
55
|
+
function getFs() {
|
|
56
|
+
if (_fs === void 0) {
|
|
57
|
+
_fs = require("fs");
|
|
58
|
+
}
|
|
59
|
+
return _fs;
|
|
60
|
+
}
|
|
61
|
+
let _path;
|
|
62
|
+
// @__NO_SIDE_EFFECTS__
|
|
63
|
+
function getPath() {
|
|
64
|
+
if (_path === void 0) {
|
|
65
|
+
_path = require("path");
|
|
66
|
+
}
|
|
67
|
+
return _path;
|
|
68
|
+
}
|
|
55
69
|
// @__NO_SIDE_EFFECTS__
|
|
56
70
|
async function execBin(binPath, args, options) {
|
|
57
71
|
const resolvedPath = (0, import_normalize.isPath)(binPath) ? /* @__PURE__ */ resolveRealBinSync(binPath) : await whichReal(binPath);
|
|
@@ -77,19 +91,21 @@ To resolve:
|
|
|
77
91
|
});
|
|
78
92
|
}
|
|
79
93
|
function findRealBin(binName, commonPaths = []) {
|
|
94
|
+
const fs = /* @__PURE__ */ getFs();
|
|
95
|
+
const path = /* @__PURE__ */ getPath();
|
|
80
96
|
for (const binPath2 of commonPaths) {
|
|
81
|
-
if (
|
|
97
|
+
if (fs.existsSync(binPath2)) {
|
|
82
98
|
return binPath2;
|
|
83
99
|
}
|
|
84
100
|
}
|
|
85
101
|
const binPath = import_which.default.sync(binName, { nothrow: true });
|
|
86
102
|
if (binPath) {
|
|
87
|
-
const binDir =
|
|
103
|
+
const binDir = path.dirname(binPath);
|
|
88
104
|
if (isShadowBinPath(binDir)) {
|
|
89
105
|
const allPaths = import_which.default.sync(binName, { all: true, nothrow: true }) || [];
|
|
90
106
|
const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
|
|
91
107
|
for (const altPath of pathsArray) {
|
|
92
|
-
const altDir =
|
|
108
|
+
const altDir = path.dirname(altPath);
|
|
93
109
|
if (!isShadowBinPath(altDir)) {
|
|
94
110
|
return altPath;
|
|
95
111
|
}
|
|
@@ -100,49 +116,53 @@ function findRealBin(binName, commonPaths = []) {
|
|
|
100
116
|
return void 0;
|
|
101
117
|
}
|
|
102
118
|
function findRealNpm() {
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
119
|
+
const fs = /* @__PURE__ */ getFs();
|
|
120
|
+
const path = /* @__PURE__ */ getPath();
|
|
121
|
+
const nodeDir = path.dirname(process.execPath);
|
|
122
|
+
const npmInNodeDir = path.join(nodeDir, "npm");
|
|
123
|
+
if (fs.existsSync(npmInNodeDir)) {
|
|
106
124
|
return npmInNodeDir;
|
|
107
125
|
}
|
|
108
126
|
const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
|
|
109
127
|
const result = findRealBin("npm", commonPaths);
|
|
110
|
-
if (result &&
|
|
128
|
+
if (result && fs.existsSync(result)) {
|
|
111
129
|
return result;
|
|
112
130
|
}
|
|
113
131
|
const npmPath = whichRealSync("npm", { nothrow: true });
|
|
114
|
-
if (npmPath && typeof npmPath === "string" &&
|
|
132
|
+
if (npmPath && typeof npmPath === "string" && fs.existsSync(npmPath)) {
|
|
115
133
|
return npmPath;
|
|
116
134
|
}
|
|
117
135
|
return "npm";
|
|
118
136
|
}
|
|
119
137
|
function findRealPnpm() {
|
|
138
|
+
const path = /* @__PURE__ */ getPath();
|
|
120
139
|
const commonPaths = import_platform.WIN32 ? [
|
|
121
140
|
// Windows common paths.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
path.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
|
|
142
|
+
path.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
|
|
143
|
+
path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
|
|
144
|
+
path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
|
|
126
145
|
"C:\\Program Files\\nodejs\\pnpm.cmd",
|
|
127
146
|
"C:\\Program Files\\nodejs\\pnpm"
|
|
128
147
|
].filter(Boolean) : [
|
|
129
148
|
// Unix common paths.
|
|
130
149
|
"/usr/local/bin/pnpm",
|
|
131
150
|
"/usr/bin/pnpm",
|
|
132
|
-
|
|
151
|
+
path.join(
|
|
133
152
|
(0, import_xdg.getXdgDataHome)() || `${(0, import_home.getHome)()}/.local/share`,
|
|
134
153
|
"pnpm/pnpm"
|
|
135
154
|
),
|
|
136
|
-
|
|
155
|
+
path.join((0, import_home.getHome)(), ".pnpm/pnpm")
|
|
137
156
|
].filter(Boolean);
|
|
138
157
|
return findRealBin("pnpm", commonPaths) ?? "";
|
|
139
158
|
}
|
|
140
159
|
function findRealYarn() {
|
|
160
|
+
const path = /* @__PURE__ */ getPath();
|
|
141
161
|
const commonPaths = [
|
|
142
162
|
"/usr/local/bin/yarn",
|
|
143
163
|
"/usr/bin/yarn",
|
|
144
|
-
|
|
145
|
-
|
|
164
|
+
path.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
|
|
165
|
+
path.join(
|
|
146
166
|
(0, import_home.getHome)(),
|
|
147
167
|
".config/yarn/global/node_modules/.bin/yarn"
|
|
148
168
|
)
|
|
@@ -158,7 +178,9 @@ function isShadowBinPath(dirPath) {
|
|
|
158
178
|
}
|
|
159
179
|
// @__NO_SIDE_EFFECTS__
|
|
160
180
|
function resolveRealBinSync(binPath) {
|
|
161
|
-
|
|
181
|
+
const fs = /* @__PURE__ */ getFs();
|
|
182
|
+
const path = /* @__PURE__ */ getPath();
|
|
183
|
+
if (!path.isAbsolute(binPath)) {
|
|
162
184
|
try {
|
|
163
185
|
const resolved = whichRealSync(binPath);
|
|
164
186
|
if (resolved) {
|
|
@@ -171,17 +193,17 @@ function resolveRealBinSync(binPath) {
|
|
|
171
193
|
if (binPath === ".") {
|
|
172
194
|
return binPath;
|
|
173
195
|
}
|
|
174
|
-
const ext =
|
|
196
|
+
const ext = path.extname(binPath);
|
|
175
197
|
const extLowered = ext.toLowerCase();
|
|
176
|
-
const basename =
|
|
198
|
+
const basename = path.basename(binPath, ext);
|
|
177
199
|
const voltaIndex = basename === "node" ? -1 : /(?<=\/)\.volta\//i.exec(binPath)?.index ?? -1;
|
|
178
200
|
if (voltaIndex !== -1) {
|
|
179
201
|
const voltaPath = binPath.slice(0, voltaIndex);
|
|
180
|
-
const voltaToolsPath =
|
|
181
|
-
const voltaImagePath =
|
|
182
|
-
const voltaUserPath =
|
|
202
|
+
const voltaToolsPath = path.join(voltaPath, "tools");
|
|
203
|
+
const voltaImagePath = path.join(voltaToolsPath, "image");
|
|
204
|
+
const voltaUserPath = path.join(voltaToolsPath, "user");
|
|
183
205
|
const voltaPlatform = (0, import_fs.readJsonSync)(
|
|
184
|
-
|
|
206
|
+
path.join(voltaUserPath, "platform.json"),
|
|
185
207
|
{ throws: false }
|
|
186
208
|
);
|
|
187
209
|
const voltaNodeVersion = voltaPlatform?.node?.runtime;
|
|
@@ -190,35 +212,35 @@ function resolveRealBinSync(binPath) {
|
|
|
190
212
|
if (basename === "npm" || basename === "npx") {
|
|
191
213
|
if (voltaNpmVersion) {
|
|
192
214
|
const relCliPath = `bin/${basename}-cli.js`;
|
|
193
|
-
voltaBinPath =
|
|
215
|
+
voltaBinPath = path.join(
|
|
194
216
|
voltaImagePath,
|
|
195
217
|
`npm/${voltaNpmVersion}/${relCliPath}`
|
|
196
218
|
);
|
|
197
|
-
if (voltaNodeVersion && !
|
|
198
|
-
voltaBinPath =
|
|
219
|
+
if (voltaNodeVersion && !fs.existsSync(voltaBinPath)) {
|
|
220
|
+
voltaBinPath = path.join(
|
|
199
221
|
voltaImagePath,
|
|
200
222
|
`node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`
|
|
201
223
|
);
|
|
202
|
-
if (!
|
|
224
|
+
if (!fs.existsSync(voltaBinPath)) {
|
|
203
225
|
voltaBinPath = "";
|
|
204
226
|
}
|
|
205
227
|
}
|
|
206
228
|
}
|
|
207
229
|
} else {
|
|
208
|
-
const voltaUserBinPath =
|
|
230
|
+
const voltaUserBinPath = path.join(voltaUserPath, "bin");
|
|
209
231
|
const binInfo = (0, import_fs.readJsonSync)(
|
|
210
|
-
|
|
232
|
+
path.join(voltaUserBinPath, `${basename}.json`),
|
|
211
233
|
{ throws: false }
|
|
212
234
|
);
|
|
213
235
|
const binPackage = binInfo?.package;
|
|
214
236
|
if (binPackage) {
|
|
215
|
-
voltaBinPath =
|
|
237
|
+
voltaBinPath = path.join(
|
|
216
238
|
voltaImagePath,
|
|
217
239
|
`packages/${binPackage}/bin/${basename}`
|
|
218
240
|
);
|
|
219
|
-
if (!
|
|
241
|
+
if (!fs.existsSync(voltaBinPath)) {
|
|
220
242
|
voltaBinPath = `${voltaBinPath}.cmd`;
|
|
221
|
-
if (!
|
|
243
|
+
if (!fs.existsSync(voltaBinPath)) {
|
|
222
244
|
voltaBinPath = "";
|
|
223
245
|
}
|
|
224
246
|
}
|
|
@@ -226,7 +248,7 @@ function resolveRealBinSync(binPath) {
|
|
|
226
248
|
}
|
|
227
249
|
if (voltaBinPath) {
|
|
228
250
|
try {
|
|
229
|
-
return (0, import_normalize.normalizePath)(
|
|
251
|
+
return (0, import_normalize.normalizePath)(fs.realpathSync.native(voltaBinPath));
|
|
230
252
|
} catch {
|
|
231
253
|
}
|
|
232
254
|
return voltaBinPath;
|
|
@@ -237,13 +259,13 @@ function resolveRealBinSync(binPath) {
|
|
|
237
259
|
const isNpmOrNpx = basename === "npm" || basename === "npx";
|
|
238
260
|
const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
|
|
239
261
|
if (hasKnownExt && isNpmOrNpx) {
|
|
240
|
-
const quickPath =
|
|
241
|
-
|
|
262
|
+
const quickPath = path.join(
|
|
263
|
+
path.dirname(binPath),
|
|
242
264
|
`node_modules/npm/bin/${basename}-cli.js`
|
|
243
265
|
);
|
|
244
|
-
if (
|
|
266
|
+
if (fs.existsSync(quickPath)) {
|
|
245
267
|
try {
|
|
246
|
-
return
|
|
268
|
+
return fs.realpathSync.native(quickPath);
|
|
247
269
|
} catch {
|
|
248
270
|
}
|
|
249
271
|
return quickPath;
|
|
@@ -253,8 +275,8 @@ function resolveRealBinSync(binPath) {
|
|
|
253
275
|
if (hasKnownExt && // Only parse shell scripts and batch files, not actual executables.
|
|
254
276
|
// .exe files are already executables and don't need path resolution from wrapper scripts.
|
|
255
277
|
extLowered !== ".exe" && // Check if file exists before attempting to read it to avoid ENOENT errors.
|
|
256
|
-
|
|
257
|
-
const source =
|
|
278
|
+
fs.existsSync(binPath)) {
|
|
279
|
+
const source = fs.readFileSync(binPath, "utf8");
|
|
258
280
|
if (isNpmOrNpx) {
|
|
259
281
|
if (extLowered === ".cmd") {
|
|
260
282
|
relPath = basename === "npm" ? /(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "" : /(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "";
|
|
@@ -301,7 +323,7 @@ function resolveRealBinSync(binPath) {
|
|
|
301
323
|
relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
|
|
302
324
|
}
|
|
303
325
|
if (relPath) {
|
|
304
|
-
binPath = (0, import_normalize.normalizePath)(
|
|
326
|
+
binPath = (0, import_normalize.normalizePath)(path.resolve(path.dirname(binPath), relPath));
|
|
305
327
|
}
|
|
306
328
|
}
|
|
307
329
|
} else {
|
|
@@ -313,10 +335,10 @@ function resolveRealBinSync(binPath) {
|
|
|
313
335
|
if (binIndex !== -1) {
|
|
314
336
|
const baseBinPath = binPath.slice(0, binIndex + "/.bin/pnpm".length);
|
|
315
337
|
try {
|
|
316
|
-
const stats =
|
|
338
|
+
const stats = fs.statSync(baseBinPath);
|
|
317
339
|
if (stats.isFile()) {
|
|
318
340
|
binPath = (0, import_normalize.normalizePath)(baseBinPath);
|
|
319
|
-
hasNoExt = !
|
|
341
|
+
hasNoExt = !path.extname(binPath);
|
|
320
342
|
}
|
|
321
343
|
} catch {
|
|
322
344
|
}
|
|
@@ -324,8 +346,8 @@ function resolveRealBinSync(binPath) {
|
|
|
324
346
|
}
|
|
325
347
|
if (hasNoExt && (isPnpmOrYarn || isNpmOrNpx) && // For extensionless files (Unix shell scripts), verify existence before reading.
|
|
326
348
|
// This prevents ENOENT errors when the bin path doesn't exist.
|
|
327
|
-
|
|
328
|
-
const source =
|
|
349
|
+
fs.existsSync(binPath)) {
|
|
350
|
+
const source = fs.readFileSync(binPath, "utf8");
|
|
329
351
|
let relPath = "";
|
|
330
352
|
if (isPnpmOrYarn) {
|
|
331
353
|
relPath = /(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
|
|
@@ -347,12 +369,12 @@ function resolveRealBinSync(binPath) {
|
|
|
347
369
|
relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
|
|
348
370
|
}
|
|
349
371
|
if (relPath) {
|
|
350
|
-
binPath = (0, import_normalize.normalizePath)(
|
|
372
|
+
binPath = (0, import_normalize.normalizePath)(path.resolve(path.dirname(binPath), relPath));
|
|
351
373
|
}
|
|
352
374
|
}
|
|
353
375
|
}
|
|
354
376
|
try {
|
|
355
|
-
const realPath =
|
|
377
|
+
const realPath = fs.realpathSync.native(binPath);
|
|
356
378
|
return (0, import_normalize.normalizePath)(realPath);
|
|
357
379
|
} catch {
|
|
358
380
|
}
|
package/dist/constants/agents.js
CHANGED
|
@@ -70,8 +70,8 @@ const NPM_BIN_PATH = /* @__PURE__ */ (() => {
|
|
|
70
70
|
})();
|
|
71
71
|
const NPM_REAL_EXEC_PATH = /* @__PURE__ */ (() => {
|
|
72
72
|
try {
|
|
73
|
-
const { existsSync } = require("
|
|
74
|
-
const path = require("
|
|
73
|
+
const { existsSync } = require("fs");
|
|
74
|
+
const path = require("path");
|
|
75
75
|
const npmBin = import_which.default.sync("npm", { nothrow: true });
|
|
76
76
|
if (!npmBin) {
|
|
77
77
|
return void 0;
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPU architecture type.
|
|
3
|
+
*/
|
|
4
|
+
export type Arch = NodeJS.Architecture;
|
|
5
|
+
/**
|
|
6
|
+
* Linux libc variant.
|
|
7
|
+
*/
|
|
8
|
+
export type Libc = 'glibc' | 'musl';
|
|
9
|
+
/**
|
|
10
|
+
* Operating system platform type.
|
|
11
|
+
*/
|
|
12
|
+
export type Platform = NodeJS.Platform;
|
|
13
|
+
/**
|
|
14
|
+
* Get the current CPU architecture (memoized).
|
|
15
|
+
*/
|
|
16
|
+
export declare function getArch(): Arch;
|
|
17
|
+
/**
|
|
18
|
+
* Get the current platform (memoized).
|
|
19
|
+
*/
|
|
20
|
+
export declare function getPlatform(): Platform;
|
|
21
|
+
// Platform detection (memoized at module load).
|
|
1
22
|
export declare const DARWIN: boolean;
|
|
2
23
|
export declare const WIN32: boolean;
|
|
3
24
|
// File permission modes.
|
|
@@ -23,13 +23,35 @@ __export(platform_exports, {
|
|
|
23
23
|
S_IXGRP: () => S_IXGRP,
|
|
24
24
|
S_IXOTH: () => S_IXOTH,
|
|
25
25
|
S_IXUSR: () => S_IXUSR,
|
|
26
|
-
WIN32: () => WIN32
|
|
26
|
+
WIN32: () => WIN32,
|
|
27
|
+
getArch: () => getArch,
|
|
28
|
+
getPlatform: () => getPlatform
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(platform_exports);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let _os;
|
|
32
|
+
// @__NO_SIDE_EFFECTS__
|
|
33
|
+
function getOs() {
|
|
34
|
+
if (_os === void 0) {
|
|
35
|
+
_os = require("os");
|
|
36
|
+
}
|
|
37
|
+
return _os;
|
|
38
|
+
}
|
|
39
|
+
let _arch;
|
|
40
|
+
function getArch() {
|
|
41
|
+
if (_arch === void 0) {
|
|
42
|
+
_arch = (/* @__PURE__ */ getOs()).arch();
|
|
43
|
+
}
|
|
44
|
+
return _arch;
|
|
45
|
+
}
|
|
46
|
+
let _platform;
|
|
47
|
+
function getPlatform() {
|
|
48
|
+
if (_platform === void 0) {
|
|
49
|
+
_platform = (/* @__PURE__ */ getOs()).platform();
|
|
50
|
+
}
|
|
51
|
+
return _platform;
|
|
52
|
+
}
|
|
53
|
+
const DARWIN = getPlatform() === "darwin";
|
|
54
|
+
const WIN32 = getPlatform() === "win32";
|
|
33
55
|
const S_IXUSR = 64;
|
|
34
56
|
const S_IXGRP = 8;
|
|
35
57
|
const S_IXOTH = 1;
|
|
@@ -39,5 +61,7 @@ const S_IXOTH = 1;
|
|
|
39
61
|
S_IXGRP,
|
|
40
62
|
S_IXOTH,
|
|
41
63
|
S_IXUSR,
|
|
42
|
-
WIN32
|
|
64
|
+
WIN32,
|
|
65
|
+
getArch,
|
|
66
|
+
getPlatform
|
|
43
67
|
});
|
package/dist/cover/code.js
CHANGED
|
@@ -22,15 +22,22 @@ __export(code_exports, {
|
|
|
22
22
|
getCodeCoverage: () => getCodeCoverage
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(code_exports);
|
|
25
|
-
var import_fs = require("fs");
|
|
26
|
-
var import_fs2 = require("../fs");
|
|
25
|
+
var import_fs = require("../fs");
|
|
27
26
|
var import_objects = require("../objects");
|
|
28
27
|
var import_spawn = require("../spawn");
|
|
28
|
+
let _fs;
|
|
29
29
|
let _path;
|
|
30
30
|
// @__NO_SIDE_EFFECTS__
|
|
31
|
+
function getFs() {
|
|
32
|
+
if (_fs === void 0) {
|
|
33
|
+
_fs = require("fs");
|
|
34
|
+
}
|
|
35
|
+
return _fs;
|
|
36
|
+
}
|
|
37
|
+
// @__NO_SIDE_EFFECTS__
|
|
31
38
|
function getPath() {
|
|
32
39
|
if (_path === void 0) {
|
|
33
|
-
_path = require("
|
|
40
|
+
_path = require("path");
|
|
34
41
|
}
|
|
35
42
|
return _path;
|
|
36
43
|
}
|
|
@@ -46,7 +53,8 @@ async function getCodeCoverage(options) {
|
|
|
46
53
|
if (!coveragePath) {
|
|
47
54
|
throw new Error("Coverage path is required");
|
|
48
55
|
}
|
|
49
|
-
const
|
|
56
|
+
const fs = /* @__PURE__ */ getFs();
|
|
57
|
+
const coverageExists = await fs.promises.access(coveragePath).then(() => true).catch(() => false);
|
|
50
58
|
if (!coverageExists) {
|
|
51
59
|
if (generateIfMissing) {
|
|
52
60
|
await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
|
|
@@ -59,7 +67,7 @@ async function getCodeCoverage(options) {
|
|
|
59
67
|
);
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
|
-
const coverageData = await (0,
|
|
70
|
+
const coverageData = await (0, import_fs.readJson)(coveragePath);
|
|
63
71
|
if (!(0, import_objects.isObjectObject)(coverageData)) {
|
|
64
72
|
throw new Error(`Invalid coverage data format in "${coveragePath}"`);
|
|
65
73
|
}
|
package/dist/debug.js
CHANGED
package/dist/dlx/binary.d.ts
CHANGED