@socketsecurity/lib 5.6.0 → 5.8.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 +92 -2
- package/README.md +190 -18
- package/dist/archives.d.ts +58 -0
- package/dist/archives.js +313 -0
- package/dist/arrays.js +2 -3
- package/dist/cache-with-ttl.js +25 -6
- package/dist/constants/node.js +2 -1
- package/dist/cover/formatters.js +5 -3
- package/dist/dlx/binary.d.ts +20 -0
- package/dist/dlx/binary.js +115 -99
- package/dist/dlx/detect.d.ts +8 -8
- package/dist/dlx/detect.js +18 -18
- package/dist/dlx/manifest.d.ts +32 -31
- package/dist/dlx/manifest.js +114 -112
- package/dist/dlx/package.d.ts +55 -0
- package/dist/dlx/package.js +90 -80
- package/dist/env/ci.js +1 -2
- package/dist/env/rewire.d.ts +33 -22
- package/dist/env/rewire.js +20 -7
- package/dist/env/socket-cli.d.ts +24 -24
- package/dist/env/socket-cli.js +12 -12
- package/dist/env/temp-dir.d.ts +6 -6
- package/dist/env/temp-dir.js +4 -4
- package/dist/env/windows.d.ts +6 -6
- package/dist/env/windows.js +4 -4
- package/dist/external/@npmcli/package-json.js +352 -824
- package/dist/external/adm-zip.js +2695 -0
- package/dist/external/debug.js +183 -7
- package/dist/external/external-pack.js +19 -1409
- package/dist/external/libnpmexec.js +2 -2
- package/dist/external/npm-pack.js +18777 -19997
- package/dist/external/pico-pack.js +29 -5
- package/dist/external/spdx-pack.js +41 -263
- package/dist/external/tar-fs.js +3053 -0
- package/dist/git.js +22 -4
- package/dist/github.js +17 -9
- package/dist/globs.js +20 -1
- package/dist/http-request.js +1 -1
- package/dist/memoization.js +22 -13
- package/dist/package-extensions.js +4 -2
- package/dist/packages/normalize.js +3 -0
- package/dist/packages/specs.js +1 -1
- package/dist/process-lock.js +4 -2
- package/dist/releases/github.d.ts +55 -4
- package/dist/releases/github.js +203 -101
- package/dist/spawn.js +1 -1
- package/dist/spinner.js +1 -1
- package/dist/stdio/progress.js +2 -2
- package/package.json +38 -15
package/dist/releases/github.js
CHANGED
|
@@ -30,6 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var github_exports = {};
|
|
31
31
|
__export(github_exports, {
|
|
32
32
|
SOCKET_BTM_REPO: () => SOCKET_BTM_REPO,
|
|
33
|
+
createAssetMatcher: () => createAssetMatcher,
|
|
34
|
+
downloadAndExtractArchive: () => downloadAndExtractArchive,
|
|
35
|
+
downloadAndExtractZip: () => downloadAndExtractZip,
|
|
33
36
|
downloadGitHubRelease: () => downloadGitHubRelease,
|
|
34
37
|
downloadReleaseAsset: () => downloadReleaseAsset,
|
|
35
38
|
getAuthHeaders: () => getAuthHeaders,
|
|
@@ -38,12 +41,12 @@ __export(github_exports, {
|
|
|
38
41
|
});
|
|
39
42
|
module.exports = __toCommonJS(github_exports);
|
|
40
43
|
var import_picomatch = __toESM(require("../external/picomatch.js"));
|
|
44
|
+
var import_archives = require("../archives.js");
|
|
41
45
|
var import_fs = require("../fs.js");
|
|
42
46
|
var import_http_request = require("../http-request.js");
|
|
43
47
|
var import_logger = require("../logger.js");
|
|
44
48
|
var import_promises = require("../promises.js");
|
|
45
49
|
var import_spawn = require("../spawn.js");
|
|
46
|
-
const logger = (0, import_logger.getDefaultLogger)();
|
|
47
50
|
const RETRY_CONFIG = Object.freeze({
|
|
48
51
|
__proto__: null,
|
|
49
52
|
// Exponential backoff: delay doubles with each retry (5s, 10s, 20s).
|
|
@@ -53,19 +56,13 @@ const RETRY_CONFIG = Object.freeze({
|
|
|
53
56
|
// Maximum number of retry attempts (excluding initial request).
|
|
54
57
|
retries: 2
|
|
55
58
|
});
|
|
59
|
+
const SOCKET_BTM_REPO = {
|
|
60
|
+
owner: "SocketDev",
|
|
61
|
+
repo: "socket-btm"
|
|
62
|
+
};
|
|
63
|
+
const logger = (0, import_logger.getDefaultLogger)();
|
|
56
64
|
let _fs;
|
|
57
65
|
let _path;
|
|
58
|
-
function createMatcher(pattern) {
|
|
59
|
-
if (typeof pattern === "string") {
|
|
60
|
-
const isMatch = (0, import_picomatch.default)(pattern);
|
|
61
|
-
return (input) => isMatch(input);
|
|
62
|
-
}
|
|
63
|
-
if (pattern instanceof RegExp) {
|
|
64
|
-
return (input) => pattern.test(input);
|
|
65
|
-
}
|
|
66
|
-
const { prefix, suffix } = pattern;
|
|
67
|
-
return (input) => input.startsWith(prefix) && input.endsWith(suffix);
|
|
68
|
-
}
|
|
69
66
|
// @__NO_SIDE_EFFECTS__
|
|
70
67
|
function getFs() {
|
|
71
68
|
if (_fs === void 0) {
|
|
@@ -80,10 +77,91 @@ function getPath() {
|
|
|
80
77
|
}
|
|
81
78
|
return _path;
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
function createAssetMatcher(pattern) {
|
|
81
|
+
if (typeof pattern === "string") {
|
|
82
|
+
const isMatch = (0, import_picomatch.default)(pattern);
|
|
83
|
+
return (input) => isMatch(input);
|
|
84
|
+
}
|
|
85
|
+
if (pattern instanceof RegExp) {
|
|
86
|
+
return (input) => pattern.test(input);
|
|
87
|
+
}
|
|
88
|
+
const { prefix, suffix } = pattern;
|
|
89
|
+
return (input) => input.startsWith(prefix) && input.endsWith(suffix);
|
|
90
|
+
}
|
|
91
|
+
async function downloadGitHubRelease(config) {
|
|
92
|
+
const {
|
|
93
|
+
assetName,
|
|
94
|
+
binaryName,
|
|
95
|
+
cwd = process.cwd(),
|
|
96
|
+
downloadDir = "build/downloaded",
|
|
97
|
+
owner,
|
|
98
|
+
platformArch,
|
|
99
|
+
quiet = false,
|
|
100
|
+
removeMacOSQuarantine = true,
|
|
101
|
+
repo,
|
|
102
|
+
tag: explicitTag,
|
|
103
|
+
toolName,
|
|
104
|
+
toolPrefix
|
|
105
|
+
} = config;
|
|
106
|
+
let tag;
|
|
107
|
+
if (explicitTag) {
|
|
108
|
+
tag = explicitTag;
|
|
109
|
+
} else if (toolPrefix) {
|
|
110
|
+
const latestTag = await getLatestRelease(
|
|
111
|
+
toolPrefix,
|
|
112
|
+
{ owner, repo },
|
|
113
|
+
{ quiet }
|
|
114
|
+
);
|
|
115
|
+
if (!latestTag) {
|
|
116
|
+
throw new Error(`No ${toolPrefix} release found in ${owner}/${repo}`);
|
|
117
|
+
}
|
|
118
|
+
tag = latestTag;
|
|
119
|
+
} else {
|
|
120
|
+
throw new Error("Either toolPrefix or tag must be provided");
|
|
121
|
+
}
|
|
122
|
+
const path = /* @__PURE__ */ getPath();
|
|
123
|
+
const resolvedDownloadDir = path.isAbsolute(downloadDir) ? downloadDir : path.join(cwd, downloadDir);
|
|
124
|
+
const binaryDir = path.join(resolvedDownloadDir, toolName, platformArch);
|
|
125
|
+
const binaryPath = path.join(binaryDir, binaryName);
|
|
126
|
+
const versionPath = path.join(binaryDir, ".version");
|
|
127
|
+
const fs = /* @__PURE__ */ getFs();
|
|
128
|
+
if (fs.existsSync(versionPath) && fs.existsSync(binaryPath)) {
|
|
129
|
+
const cachedVersion = (await fs.promises.readFile(versionPath, "utf8")).trim();
|
|
130
|
+
if (cachedVersion === tag && fs.existsSync(binaryPath)) {
|
|
131
|
+
if (!quiet) {
|
|
132
|
+
logger.info(`Using cached ${toolName} (${platformArch}): ${binaryPath}`);
|
|
133
|
+
}
|
|
134
|
+
return binaryPath;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!quiet) {
|
|
138
|
+
logger.info(`Downloading ${toolName} for ${platformArch}...`);
|
|
139
|
+
}
|
|
140
|
+
await downloadReleaseAsset(
|
|
141
|
+
tag,
|
|
142
|
+
assetName,
|
|
143
|
+
binaryPath,
|
|
144
|
+
{ owner, repo },
|
|
145
|
+
{ quiet }
|
|
146
|
+
);
|
|
147
|
+
const isWindows = binaryName.endsWith(".exe");
|
|
148
|
+
if (!isWindows) {
|
|
149
|
+
fs.chmodSync(binaryPath, 493);
|
|
150
|
+
if (removeMacOSQuarantine && process.platform === "darwin" && platformArch.startsWith("darwin")) {
|
|
151
|
+
try {
|
|
152
|
+
await (0, import_spawn.spawn)("xattr", ["-d", "com.apple.quarantine", binaryPath], {
|
|
153
|
+
stdio: "ignore"
|
|
154
|
+
});
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
await fs.promises.writeFile(versionPath, tag, "utf8");
|
|
160
|
+
if (!quiet) {
|
|
161
|
+
logger.info(`Downloaded ${toolName} to ${binaryPath}`);
|
|
162
|
+
}
|
|
163
|
+
return binaryPath;
|
|
164
|
+
}
|
|
87
165
|
async function downloadReleaseAsset(tag, assetPattern, outputPath, repoConfig, options = {}) {
|
|
88
166
|
const { owner, repo } = repoConfig;
|
|
89
167
|
const { quiet = false } = options;
|
|
@@ -120,7 +198,7 @@ function getAuthHeaders() {
|
|
|
120
198
|
async function getLatestRelease(toolPrefix, repoConfig, options = {}) {
|
|
121
199
|
const { assetPattern, quiet = false } = options;
|
|
122
200
|
const { owner, repo } = repoConfig;
|
|
123
|
-
const isMatch = assetPattern ?
|
|
201
|
+
const isMatch = assetPattern ? createAssetMatcher(assetPattern) : void 0;
|
|
124
202
|
return await (0, import_promises.pRetry)(
|
|
125
203
|
async () => {
|
|
126
204
|
const response = await (0, import_http_request.httpRequest)(
|
|
@@ -132,27 +210,33 @@ async function getLatestRelease(toolPrefix, repoConfig, options = {}) {
|
|
|
132
210
|
if (!response.ok) {
|
|
133
211
|
throw new Error(`Failed to fetch releases: ${response.status}`);
|
|
134
212
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
213
|
+
let releases;
|
|
214
|
+
try {
|
|
215
|
+
releases = JSON.parse(response.body.toString("utf8"));
|
|
216
|
+
} catch (cause) {
|
|
217
|
+
throw new Error(
|
|
218
|
+
`Failed to parse GitHub releases response from https://api.github.com/repos/${owner}/${repo}/releases`,
|
|
219
|
+
{ cause }
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
const matchingReleases = releases.filter((release) => {
|
|
223
|
+
const { assets, tag_name: tag2 } = release;
|
|
224
|
+
if (!tag2.startsWith(toolPrefix)) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
if (!assets || assets.length === 0) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
if (isMatch) {
|
|
231
|
+
const hasMatchingAsset = assets.some(
|
|
232
|
+
(a) => isMatch(a.name)
|
|
233
|
+
);
|
|
234
|
+
if (!hasMatchingAsset) {
|
|
143
235
|
return false;
|
|
144
236
|
}
|
|
145
|
-
if (isMatch) {
|
|
146
|
-
const hasMatchingAsset = assets.some(
|
|
147
|
-
(a) => isMatch(a.name)
|
|
148
|
-
);
|
|
149
|
-
if (!hasMatchingAsset) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return true;
|
|
154
237
|
}
|
|
155
|
-
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
156
240
|
if (matchingReleases.length === 0) {
|
|
157
241
|
if (!quiet) {
|
|
158
242
|
logger.info(`No ${toolPrefix} release found in latest 100 releases`);
|
|
@@ -188,7 +272,7 @@ async function getLatestRelease(toolPrefix, repoConfig, options = {}) {
|
|
|
188
272
|
async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
|
|
189
273
|
const { owner, repo } = repoConfig;
|
|
190
274
|
const { quiet = false } = options;
|
|
191
|
-
const isMatch = typeof assetPattern === "string" && !assetPattern.includes("*") && !assetPattern.includes("{") ? (input) => input === assetPattern :
|
|
275
|
+
const isMatch = typeof assetPattern === "string" && !assetPattern.includes("*") && !assetPattern.includes("{") ? (input) => input === assetPattern : createAssetMatcher(assetPattern);
|
|
192
276
|
return await (0, import_promises.pRetry)(
|
|
193
277
|
async () => {
|
|
194
278
|
const response = await (0, import_http_request.httpRequest)(
|
|
@@ -200,10 +284,16 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
|
|
|
200
284
|
if (!response.ok) {
|
|
201
285
|
throw new Error(`Failed to fetch release ${tag}: ${response.status}`);
|
|
202
286
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
)
|
|
287
|
+
let release;
|
|
288
|
+
try {
|
|
289
|
+
release = JSON.parse(response.body.toString("utf8"));
|
|
290
|
+
} catch (cause) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
`Failed to parse GitHub release response for tag ${tag}`,
|
|
293
|
+
{ cause }
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
const asset = release.assets.find((a) => isMatch(a.name));
|
|
207
297
|
if (!asset) {
|
|
208
298
|
const patternDesc = typeof assetPattern === "string" ? assetPattern : "matching pattern";
|
|
209
299
|
throw new Error(`Asset ${patternDesc} not found in release ${tag}`);
|
|
@@ -229,83 +319,95 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
|
|
|
229
319
|
}
|
|
230
320
|
);
|
|
231
321
|
}
|
|
232
|
-
async function
|
|
233
|
-
const {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
322
|
+
async function downloadAndExtractZip(tag, assetPattern, outputDir, repoConfig, options = {}) {
|
|
323
|
+
const { cleanup = true, quiet = false } = options;
|
|
324
|
+
const path = /* @__PURE__ */ getPath();
|
|
325
|
+
const fs = /* @__PURE__ */ getFs();
|
|
326
|
+
await (0, import_fs.safeMkdir)(outputDir);
|
|
327
|
+
const zipPath = path.join(outputDir, "__temp_download__.zip");
|
|
328
|
+
if (!quiet) {
|
|
329
|
+
logger.info(`Downloading zip asset from release ${tag}...`);
|
|
330
|
+
}
|
|
331
|
+
await downloadReleaseAsset(tag, assetPattern, zipPath, repoConfig, { quiet });
|
|
332
|
+
if (!quiet) {
|
|
333
|
+
logger.info(`Extracting zip to ${outputDir}...`);
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
await (0, import_archives.extractArchive)(zipPath, outputDir, { quiet });
|
|
337
|
+
if (!quiet) {
|
|
338
|
+
logger.info(`Extracted zip contents to ${outputDir}`);
|
|
339
|
+
}
|
|
340
|
+
} catch (cause) {
|
|
341
|
+
throw new Error(`Failed to extract zip file: ${zipPath}`, { cause });
|
|
342
|
+
} finally {
|
|
343
|
+
if (cleanup) {
|
|
344
|
+
try {
|
|
345
|
+
await fs.promises.unlink(zipPath);
|
|
346
|
+
if (!quiet) {
|
|
347
|
+
logger.info("Cleaned up temporary zip file");
|
|
348
|
+
}
|
|
349
|
+
} catch (error) {
|
|
350
|
+
if (!quiet) {
|
|
351
|
+
logger.warn(`Failed to cleanup zip file: ${error}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
258
354
|
}
|
|
259
|
-
tag = latestTag;
|
|
260
|
-
} else {
|
|
261
|
-
throw new Error("Either toolPrefix or tag must be provided");
|
|
262
355
|
}
|
|
356
|
+
return outputDir;
|
|
357
|
+
}
|
|
358
|
+
async function downloadAndExtractArchive(tag, assetPattern, outputDir, repoConfig, options = {}) {
|
|
359
|
+
const { cleanup = true, format, quiet = false, strip } = options;
|
|
263
360
|
const path = /* @__PURE__ */ getPath();
|
|
264
|
-
const resolvedDownloadDir = path.isAbsolute(downloadDir) ? downloadDir : path.join(cwd, downloadDir);
|
|
265
|
-
const binaryDir = path.join(resolvedDownloadDir, toolName, platformArch);
|
|
266
|
-
const binaryPath = path.join(binaryDir, binaryName);
|
|
267
|
-
const versionPath = path.join(binaryDir, ".version");
|
|
268
361
|
const fs = /* @__PURE__ */ getFs();
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
362
|
+
await (0, import_fs.safeMkdir)(outputDir);
|
|
363
|
+
let ext = ".archive";
|
|
364
|
+
if (format) {
|
|
365
|
+
ext = format === "tar.gz" ? ".tar.gz" : `.${format}`;
|
|
366
|
+
} else if (typeof assetPattern === "string") {
|
|
367
|
+
const detectedFormat = (0, import_archives.detectArchiveFormat)(assetPattern);
|
|
368
|
+
if (detectedFormat) {
|
|
369
|
+
ext = detectedFormat === "tar.gz" ? ".tar.gz" : `.${detectedFormat}`;
|
|
276
370
|
}
|
|
277
371
|
}
|
|
372
|
+
const archivePath = path.join(outputDir, `__temp_download__${ext}`);
|
|
278
373
|
if (!quiet) {
|
|
279
|
-
logger.info(`Downloading
|
|
374
|
+
logger.info(`Downloading archive from release ${tag}...`);
|
|
280
375
|
}
|
|
281
|
-
await downloadReleaseAsset(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
376
|
+
await downloadReleaseAsset(tag, assetPattern, archivePath, repoConfig, {
|
|
377
|
+
quiet
|
|
378
|
+
});
|
|
379
|
+
if (!quiet) {
|
|
380
|
+
logger.info(`Extracting archive to ${outputDir}...`);
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
await (0, import_archives.extractArchive)(archivePath, outputDir, { quiet, strip });
|
|
384
|
+
if (!quiet) {
|
|
385
|
+
logger.info(`Extracted archive contents to ${outputDir}`);
|
|
386
|
+
}
|
|
387
|
+
} catch (cause) {
|
|
388
|
+
throw new Error(`Failed to extract archive: ${archivePath}`, { cause });
|
|
389
|
+
} finally {
|
|
390
|
+
if (cleanup) {
|
|
292
391
|
try {
|
|
293
|
-
await (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
392
|
+
await fs.promises.unlink(archivePath);
|
|
393
|
+
if (!quiet) {
|
|
394
|
+
logger.info("Cleaned up temporary archive file");
|
|
395
|
+
}
|
|
396
|
+
} catch (error) {
|
|
397
|
+
if (!quiet) {
|
|
398
|
+
logger.warn(`Failed to cleanup archive file: ${error}`);
|
|
399
|
+
}
|
|
297
400
|
}
|
|
298
401
|
}
|
|
299
402
|
}
|
|
300
|
-
|
|
301
|
-
if (!quiet) {
|
|
302
|
-
logger.info(`Downloaded ${toolName} to ${binaryPath}`);
|
|
303
|
-
}
|
|
304
|
-
return binaryPath;
|
|
403
|
+
return outputDir;
|
|
305
404
|
}
|
|
306
405
|
// Annotate the CommonJS export names for ESM import in node:
|
|
307
406
|
0 && (module.exports = {
|
|
308
407
|
SOCKET_BTM_REPO,
|
|
408
|
+
createAssetMatcher,
|
|
409
|
+
downloadAndExtractArchive,
|
|
410
|
+
downloadAndExtractZip,
|
|
309
411
|
downloadGitHubRelease,
|
|
310
412
|
downloadReleaseAsset,
|
|
311
413
|
getAuthHeaders,
|
package/dist/spawn.js
CHANGED
|
@@ -92,7 +92,7 @@ function enhanceSpawnError(error) {
|
|
|
92
92
|
}
|
|
93
93
|
const trimmedStderr = stderrText.trim();
|
|
94
94
|
if (trimmedStderr) {
|
|
95
|
-
const firstLine = trimmedStderr.split("\n")[0];
|
|
95
|
+
const firstLine = trimmedStderr.split("\n")[0] ?? "";
|
|
96
96
|
if (firstLine.length < 200) {
|
|
97
97
|
enhancedMessage += `
|
|
98
98
|
${firstLine}`;
|
package/dist/spinner.js
CHANGED
|
@@ -66,7 +66,7 @@ function desc(value) {
|
|
|
66
66
|
}
|
|
67
67
|
function formatProgress(progress) {
|
|
68
68
|
const { current, total, unit } = progress;
|
|
69
|
-
const percentage = Math.round(current / total * 100);
|
|
69
|
+
const percentage = total === 0 ? 0 : Math.round(current / total * 100);
|
|
70
70
|
const bar = renderProgressBar(percentage);
|
|
71
71
|
const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`;
|
|
72
72
|
return `${bar} ${percentage}% (${count})`;
|
package/dist/stdio/progress.js
CHANGED
|
@@ -128,11 +128,11 @@ class ProgressBar {
|
|
|
128
128
|
*/
|
|
129
129
|
render(tokens) {
|
|
130
130
|
const colorFn = import_yoctocolors_cjs.default[this.options.color] || ((s) => s);
|
|
131
|
-
const percent = Math.floor(this.current / this.total * 100);
|
|
131
|
+
const percent = this.total === 0 ? 0 : Math.floor(this.current / this.total * 100);
|
|
132
132
|
const elapsed = Date.now() - this.startTime;
|
|
133
133
|
const eta = this.current === 0 ? 0 : elapsed / this.current * (this.total - this.current);
|
|
134
134
|
const availableWidth = this.options.width;
|
|
135
|
-
const filledWidth = Math.floor(this.current / this.total * availableWidth);
|
|
135
|
+
const filledWidth = this.total === 0 ? 0 : Math.floor(this.current / this.total * availableWidth);
|
|
136
136
|
const emptyWidth = availableWidth - filledWidth;
|
|
137
137
|
const filled = (0, import_strings.repeatString)(this.options.complete, filledWidth);
|
|
138
138
|
const empty = (0, import_strings.repeatString)(this.options.incomplete, emptyWidth);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/lib",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"packageManager": "pnpm@10.
|
|
3
|
+
"version": "5.8.0",
|
|
4
|
+
"packageManager": "pnpm@10.32.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Core utilities and infrastructure for Socket.dev security tools",
|
|
7
7
|
"keywords": [
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
"types": "./dist/ansi.d.ts",
|
|
104
104
|
"default": "./dist/ansi.js"
|
|
105
105
|
},
|
|
106
|
+
"./archives": {
|
|
107
|
+
"types": "./dist/archives.d.ts",
|
|
108
|
+
"default": "./dist/archives.js"
|
|
109
|
+
},
|
|
106
110
|
"./argv/flags": {
|
|
107
111
|
"types": "./dist/argv/flags.d.ts",
|
|
108
112
|
"default": "./dist/argv/flags.js"
|
|
@@ -679,7 +683,6 @@
|
|
|
679
683
|
"types": "./dist/zod.d.ts",
|
|
680
684
|
"default": "./dist/zod.js"
|
|
681
685
|
},
|
|
682
|
-
"./biome.json": "./biome.json",
|
|
683
686
|
"./data/extensions.json": "./data/extensions.json",
|
|
684
687
|
"./package.json": "./package.json",
|
|
685
688
|
"./tsconfig.dts.json": "./tsconfig.dts.json",
|
|
@@ -703,7 +706,11 @@
|
|
|
703
706
|
"cover": "node scripts/test/cover.mjs",
|
|
704
707
|
"dev": "node scripts/build/main.mjs --watch",
|
|
705
708
|
"fix": "node scripts/lint.mjs --fix",
|
|
709
|
+
"format": "oxfmt",
|
|
710
|
+
"format:check": "oxfmt --check",
|
|
706
711
|
"lint": "node scripts/lint.mjs",
|
|
712
|
+
"lint:oxlint": "oxlint .",
|
|
713
|
+
"lint:oxfmt": "oxfmt --check .",
|
|
707
714
|
"prepare": "husky",
|
|
708
715
|
"prepublishOnly": "pnpm run build",
|
|
709
716
|
"test": "node scripts/test/main.mjs",
|
|
@@ -714,10 +721,7 @@
|
|
|
714
721
|
"@babel/parser": "7.28.4",
|
|
715
722
|
"@babel/traverse": "7.28.4",
|
|
716
723
|
"@babel/types": "7.28.4",
|
|
717
|
-
"@biomejs/biome": "2.2.4",
|
|
718
724
|
"@dotenvx/dotenvx": "1.49.0",
|
|
719
|
-
"@eslint/compat": "1.4.0",
|
|
720
|
-
"@eslint/js": "9.38.0",
|
|
721
725
|
"@inquirer/checkbox": "4.3.1",
|
|
722
726
|
"@inquirer/confirm": "5.1.16",
|
|
723
727
|
"@inquirer/input": "4.2.2",
|
|
@@ -730,31 +734,27 @@
|
|
|
730
734
|
"@socketregistry/is-unicode-supported": "1.0.5",
|
|
731
735
|
"@socketregistry/packageurl-js": "1.3.5",
|
|
732
736
|
"@socketregistry/yocto-spinner": "1.0.25",
|
|
733
|
-
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.
|
|
737
|
+
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.7.0",
|
|
734
738
|
"@types/node": "24.9.2",
|
|
735
739
|
"@typescript/native-preview": "7.0.0-dev.20250920.1",
|
|
736
740
|
"@vitest/coverage-v8": "4.0.3",
|
|
737
741
|
"@vitest/ui": "4.0.3",
|
|
738
742
|
"@yarnpkg/core": "4.5.0",
|
|
739
743
|
"@yarnpkg/extensions": "2.0.6",
|
|
744
|
+
"adm-zip": "0.5.16",
|
|
740
745
|
"cacache": "20.0.1",
|
|
741
746
|
"debug": "4.4.3",
|
|
742
747
|
"del": "8.0.1",
|
|
743
748
|
"del-cli": "6.0.0",
|
|
744
749
|
"esbuild": "0.25.11",
|
|
745
|
-
"eslint": "9.35.0",
|
|
746
|
-
"eslint-import-resolver-typescript": "4.4.4",
|
|
747
|
-
"eslint-plugin-import-x": "4.16.1",
|
|
748
|
-
"eslint-plugin-n": "17.23.1",
|
|
749
750
|
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
750
|
-
"eslint-plugin-unicorn": "61.0.2",
|
|
751
751
|
"fast-glob": "3.3.3",
|
|
752
752
|
"fast-sort": "3.4.1",
|
|
753
753
|
"get-east-asian-width": "1.3.0",
|
|
754
754
|
"globals": "16.4.0",
|
|
755
755
|
"has-flag": "5.0.1",
|
|
756
756
|
"husky": "9.1.7",
|
|
757
|
-
"libnpmexec": "
|
|
757
|
+
"libnpmexec": "10.2.3",
|
|
758
758
|
"libnpmpack": "9.0.9",
|
|
759
759
|
"lint-staged": "15.2.11",
|
|
760
760
|
"magic-string": "0.30.17",
|
|
@@ -762,6 +762,8 @@
|
|
|
762
762
|
"nock": "14.0.10",
|
|
763
763
|
"normalize-package-data": "8.0.0",
|
|
764
764
|
"npm-package-arg": "13.0.0",
|
|
765
|
+
"oxfmt": "^0.37.0",
|
|
766
|
+
"oxlint": "^1.52.0",
|
|
765
767
|
"pacote": "21.0.1",
|
|
766
768
|
"picomatch": "2.3.1",
|
|
767
769
|
"pony-cause": "2.1.11",
|
|
@@ -771,11 +773,12 @@
|
|
|
771
773
|
"spdx-expression-parse": "4.0.0",
|
|
772
774
|
"streaming-iterables": "8.0.1",
|
|
773
775
|
"supports-color": "10.0.0",
|
|
776
|
+
"tar-fs": "3.1.2",
|
|
777
|
+
"tar-stream": "3.1.8",
|
|
774
778
|
"taze": "19.9.2",
|
|
775
779
|
"trash": "10.0.0",
|
|
776
780
|
"type-coverage": "2.29.7",
|
|
777
781
|
"typescript": "5.9.2",
|
|
778
|
-
"typescript-eslint": "8.44.1",
|
|
779
782
|
"validate-npm-package-name": "6.0.2",
|
|
780
783
|
"vite-tsconfig-paths": "5.1.4",
|
|
781
784
|
"vitest": "4.0.3",
|
|
@@ -794,23 +797,40 @@
|
|
|
794
797
|
},
|
|
795
798
|
"pnpm": {
|
|
796
799
|
"overrides": {
|
|
800
|
+
"@inquirer/ansi": "1.0.2",
|
|
801
|
+
"@inquirer/core": "10.3.1",
|
|
802
|
+
"@inquirer/figures": "1.0.15",
|
|
797
803
|
"@npmcli/arborist": "9.1.6",
|
|
804
|
+
"@npmcli/git": "6.0.3",
|
|
798
805
|
"@npmcli/run-script": "10.0.0",
|
|
799
806
|
"@sigstore/core": "3.1.0",
|
|
800
807
|
"@sigstore/sign": "4.1.0",
|
|
801
808
|
"ansi-regex": "6.2.2",
|
|
809
|
+
"chownr": "3.0.0",
|
|
802
810
|
"debug": "4.4.3",
|
|
803
811
|
"execa": "5.1.1",
|
|
804
812
|
"has-flag": "5.0.1",
|
|
813
|
+
"hosted-git-info": "8.1.0",
|
|
805
814
|
"isexe": "3.1.1",
|
|
806
815
|
"lru-cache": "11.2.2",
|
|
816
|
+
"minimatch": "9.0.5",
|
|
817
|
+
"minipass": "7.1.3",
|
|
818
|
+
"minipass@7": "7.1.3",
|
|
819
|
+
"minipass-fetch": "4.0.1",
|
|
820
|
+
"minipass-sized": "1.0.3",
|
|
821
|
+
"minizlib": "3.1.0",
|
|
822
|
+
"npm-package-arg": "12.0.2",
|
|
823
|
+
"npm-pick-manifest": "10.0.0",
|
|
807
824
|
"picomatch": "4.0.3",
|
|
808
825
|
"proc-log": "6.1.0",
|
|
809
826
|
"semver": "7.7.2",
|
|
810
827
|
"signal-exit": "4.1.0",
|
|
828
|
+
"spdx-expression-parse": "4.0.0",
|
|
829
|
+
"ssri": "12.0.0",
|
|
811
830
|
"string-width": "8.1.0",
|
|
812
831
|
"strip-ansi": "7.1.2",
|
|
813
832
|
"supports-color": "10.0.0",
|
|
833
|
+
"tar": "7.5.11",
|
|
814
834
|
"which": "5.0.0",
|
|
815
835
|
"wrap-ansi": "9.0.2",
|
|
816
836
|
"yoctocolors-cjs": "2.1.3"
|
|
@@ -819,7 +839,10 @@
|
|
|
819
839
|
"@npmcli/run-script@10.0.0": "patches/@npmcli__run-script@10.0.0.patch",
|
|
820
840
|
"@sigstore/sign@4.1.0": "patches/@sigstore__sign@4.1.0.patch",
|
|
821
841
|
"execa@5.1.1": "patches/execa@5.1.1.patch",
|
|
822
|
-
"
|
|
842
|
+
"minipass-flush@1.0.5": "patches/minipass-flush@1.0.5.patch",
|
|
843
|
+
"minipass-pipeline@1.2.4": "patches/minipass-pipeline@1.2.4.patch",
|
|
844
|
+
"node-gyp@11.5.0": "patches/node-gyp@11.5.0.patch",
|
|
845
|
+
"minipass-sized@1.0.3": "patches/minipass-sized@1.0.3.patch"
|
|
823
846
|
}
|
|
824
847
|
}
|
|
825
848
|
}
|