@socketsecurity/lib 5.7.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 +29 -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 +21 -6
- package/dist/constants/node.js +2 -1
- package/dist/cover/formatters.js +5 -3
- package/dist/dlx/package.js +1 -1
- 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 +7 -8
- 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/process-lock.js +4 -2
- package/dist/releases/github.d.ts +40 -0
- package/dist/releases/github.js +122 -22
- 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/cache-with-ttl.js
CHANGED
|
@@ -55,7 +55,8 @@ function createTtlCache(options) {
|
|
|
55
55
|
}
|
|
56
56
|
function isExpired(entry) {
|
|
57
57
|
const now = Date.now();
|
|
58
|
-
|
|
58
|
+
const maxFutureMs = 1e4;
|
|
59
|
+
if (entry.expiresAt > now + ttl + maxFutureMs) {
|
|
59
60
|
return true;
|
|
60
61
|
}
|
|
61
62
|
return now > entry.expiresAt;
|
|
@@ -114,7 +115,7 @@ function createTtlCache(options) {
|
|
|
114
115
|
memoCache.delete(key);
|
|
115
116
|
continue;
|
|
116
117
|
}
|
|
117
|
-
const originalKey = key.slice(
|
|
118
|
+
const originalKey = opts.prefix ? key.slice(opts.prefix.length + 1) : key;
|
|
118
119
|
results.set(originalKey, entry.data);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
@@ -128,7 +129,7 @@ function createTtlCache(options) {
|
|
|
128
129
|
if (!matches(cacheEntry.key)) {
|
|
129
130
|
continue;
|
|
130
131
|
}
|
|
131
|
-
const originalKey = cacheEntry.key.slice(
|
|
132
|
+
const originalKey = opts.prefix ? cacheEntry.key.slice(opts.prefix.length + 1) : cacheEntry.key;
|
|
132
133
|
if (results.has(originalKey)) {
|
|
133
134
|
continue;
|
|
134
135
|
}
|
|
@@ -174,14 +175,28 @@ function createTtlCache(options) {
|
|
|
174
175
|
} catch {
|
|
175
176
|
}
|
|
176
177
|
}
|
|
178
|
+
const inflightRequests = /* @__PURE__ */ new Map();
|
|
177
179
|
async function getOrFetch(key, fetcher) {
|
|
178
180
|
const cached = await get(key);
|
|
179
181
|
if (cached !== void 0) {
|
|
180
182
|
return cached;
|
|
181
183
|
}
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
const fullKey = buildKey(key);
|
|
185
|
+
const existing = inflightRequests.get(fullKey);
|
|
186
|
+
if (existing) {
|
|
187
|
+
return await existing;
|
|
188
|
+
}
|
|
189
|
+
const promise = (async () => {
|
|
190
|
+
try {
|
|
191
|
+
const data = await fetcher();
|
|
192
|
+
await set(key, data);
|
|
193
|
+
return data;
|
|
194
|
+
} finally {
|
|
195
|
+
inflightRequests.delete(fullKey);
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
inflightRequests.set(fullKey, promise);
|
|
199
|
+
return await promise;
|
|
185
200
|
}
|
|
186
201
|
async function deleteEntry(key) {
|
|
187
202
|
if (key.includes("*")) {
|
package/dist/constants/node.js
CHANGED
|
@@ -47,7 +47,8 @@ function getNodeVersion() {
|
|
|
47
47
|
return NODE_VERSION;
|
|
48
48
|
}
|
|
49
49
|
function getNodeMajorVersion() {
|
|
50
|
-
|
|
50
|
+
const major = NODE_VERSION.slice(1).split(".")[0] ?? "0";
|
|
51
|
+
return Number.parseInt(major, 10) || 0;
|
|
51
52
|
}
|
|
52
53
|
function getNodeMinorVersion() {
|
|
53
54
|
return Number.parseInt(NODE_VERSION.split(".")[1] ?? "0", 10);
|
package/dist/cover/formatters.js
CHANGED
|
@@ -77,7 +77,8 @@ function formatCoverage(options) {
|
|
|
77
77
|
{ count: 2 }
|
|
78
78
|
);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const overallValue = Number.parseFloat(overall);
|
|
81
|
+
const emoji = getCoverageEmoji(Number.isNaN(overallValue) ? 0 : overallValue);
|
|
81
82
|
output += `
|
|
82
83
|
Overall: ${overall}%${emoji}
|
|
83
84
|
`;
|
|
@@ -89,9 +90,10 @@ function calculateOverall(code, type) {
|
|
|
89
90
|
Number.parseFloat(code.branches.percent),
|
|
90
91
|
Number.parseFloat(code.functions.percent),
|
|
91
92
|
Number.parseFloat(code.lines.percent)
|
|
92
|
-
];
|
|
93
|
+
].map((val) => Number.isNaN(val) ? 0 : val);
|
|
93
94
|
if (type) {
|
|
94
|
-
|
|
95
|
+
const typePercent = Number.parseFloat(type.percent);
|
|
96
|
+
metrics.push(Number.isNaN(typePercent) ? 0 : typePercent);
|
|
95
97
|
}
|
|
96
98
|
const average = metrics.reduce((sum, val) => sum + val, 0) / metrics.length;
|
|
97
99
|
return average.toFixed(2);
|
package/dist/dlx/package.js
CHANGED
|
@@ -234,7 +234,7 @@ function findBinaryPath(packageDir, packageName, binaryName) {
|
|
|
234
234
|
});
|
|
235
235
|
binPath = binObj[binName];
|
|
236
236
|
} catch {
|
|
237
|
-
const lastSegment = packageName.split("/").pop();
|
|
237
|
+
const lastSegment = packageName.split("/").pop() ?? packageName;
|
|
238
238
|
const candidates = [
|
|
239
239
|
binaryName,
|
|
240
240
|
lastSegment,
|