@socketsecurity/lib 5.7.0 → 5.8.1
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 +48 -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/bin.js +100 -23
- package/dist/cache-with-ttl.js +21 -6
- package/dist/constants/agents.d.ts +0 -1
- package/dist/constants/agents.js +8 -8
- package/dist/constants/node.js +2 -1
- package/dist/cover/formatters.js +5 -3
- package/dist/dlx/detect.js +39 -13
- package/dist/dlx/package.js +10 -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 +63 -23
- 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 +7 -5
- package/dist/releases/github.d.ts +40 -0
- package/dist/releases/github.js +122 -22
- package/dist/spawn.js +31 -6
- package/dist/spinner.js +1 -1
- package/dist/stdio/progress.js +2 -2
- package/package.json +38 -15
package/dist/dlx/detect.js
CHANGED
|
@@ -46,20 +46,50 @@ function getPath() {
|
|
|
46
46
|
return _path;
|
|
47
47
|
}
|
|
48
48
|
const NODE_JS_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
|
|
49
|
+
const packageJsonPathCache = /* @__PURE__ */ new Map();
|
|
50
|
+
const packageJsonContentCache = /* @__PURE__ */ new Map();
|
|
49
51
|
function findPackageJson(filePath) {
|
|
50
52
|
const fs = /* @__PURE__ */ getFs();
|
|
51
53
|
const path = /* @__PURE__ */ getPath();
|
|
52
|
-
|
|
54
|
+
const startDir = path.dirname(path.resolve(filePath));
|
|
55
|
+
const cached = packageJsonPathCache.get(startDir);
|
|
56
|
+
if (cached !== void 0) {
|
|
57
|
+
if (cached === null) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
if (fs.existsSync(cached)) {
|
|
61
|
+
return cached;
|
|
62
|
+
}
|
|
63
|
+
packageJsonPathCache.delete(startDir);
|
|
64
|
+
}
|
|
65
|
+
let currentDir = startDir;
|
|
53
66
|
const root = path.parse(currentDir).root;
|
|
54
67
|
while (currentDir !== root) {
|
|
55
68
|
const packageJsonPath = path.join(currentDir, "package.json");
|
|
56
69
|
if (fs.existsSync(packageJsonPath)) {
|
|
70
|
+
packageJsonPathCache.set(startDir, packageJsonPath);
|
|
57
71
|
return packageJsonPath;
|
|
58
72
|
}
|
|
59
73
|
currentDir = path.dirname(currentDir);
|
|
60
74
|
}
|
|
75
|
+
packageJsonPathCache.set(startDir, null);
|
|
61
76
|
return void 0;
|
|
62
77
|
}
|
|
78
|
+
function readPackageJson(packageJsonPath) {
|
|
79
|
+
const fs = /* @__PURE__ */ getFs();
|
|
80
|
+
const cached = packageJsonContentCache.get(packageJsonPath);
|
|
81
|
+
if (cached !== void 0) {
|
|
82
|
+
return cached;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const content = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
86
|
+
packageJsonContentCache.set(packageJsonPath, content);
|
|
87
|
+
return content;
|
|
88
|
+
} catch {
|
|
89
|
+
packageJsonContentCache.set(packageJsonPath, null);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
63
93
|
function detectDlxExecutableType(filePath) {
|
|
64
94
|
const fs = /* @__PURE__ */ getFs();
|
|
65
95
|
const path = /* @__PURE__ */ getPath();
|
|
@@ -88,20 +118,16 @@ function detectExecutableType(filePath) {
|
|
|
88
118
|
return detectLocalExecutableType(filePath);
|
|
89
119
|
}
|
|
90
120
|
function detectLocalExecutableType(filePath) {
|
|
91
|
-
const fs = /* @__PURE__ */ getFs();
|
|
92
121
|
const packageJsonPath = findPackageJson(filePath);
|
|
93
122
|
if (packageJsonPath !== void 0) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
} catch {
|
|
123
|
+
const packageJson = readPackageJson(packageJsonPath);
|
|
124
|
+
if (packageJson?.bin) {
|
|
125
|
+
return {
|
|
126
|
+
type: "package",
|
|
127
|
+
method: "package-json",
|
|
128
|
+
packageJsonPath,
|
|
129
|
+
inDlxCache: false
|
|
130
|
+
};
|
|
105
131
|
}
|
|
106
132
|
}
|
|
107
133
|
if (isJsFilePath(filePath)) {
|
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,
|
|
@@ -314,15 +314,24 @@ function parsePackageSpec(spec) {
|
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
+
const binaryPathCache = /* @__PURE__ */ new Map();
|
|
317
318
|
function resolveBinaryPath(basePath) {
|
|
318
319
|
if (!import_platform.WIN32) {
|
|
319
320
|
return basePath;
|
|
320
321
|
}
|
|
321
322
|
const fs = /* @__PURE__ */ getFs();
|
|
323
|
+
const cached = binaryPathCache.get(basePath);
|
|
324
|
+
if (cached) {
|
|
325
|
+
if (fs.existsSync(cached)) {
|
|
326
|
+
return cached;
|
|
327
|
+
}
|
|
328
|
+
binaryPathCache.delete(basePath);
|
|
329
|
+
}
|
|
322
330
|
const extensions = [".cmd", ".bat", ".ps1", ".exe", ""];
|
|
323
331
|
for (const ext of extensions) {
|
|
324
332
|
const testPath = basePath + ext;
|
|
325
333
|
if (fs.existsSync(testPath)) {
|
|
334
|
+
binaryPathCache.set(basePath, testPath);
|
|
326
335
|
return testPath;
|
|
327
336
|
}
|
|
328
337
|
}
|