@socketsecurity/lib 3.4.0 → 4.0.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 +15 -0
- package/README.md +8 -8
- package/dist/agent.js +11 -24
- package/dist/bin.d.ts +97 -40
- package/dist/bin.js +129 -134
- package/dist/cacache.d.ts +5 -2
- package/dist/cacache.js +29 -18
- package/dist/cache-with-ttl.js +1 -1
- package/dist/constants/agents.d.ts +0 -4
- package/dist/constants/agents.js +13 -4
- package/dist/constants/node.d.ts +1 -0
- package/dist/constants/node.js +2 -5
- package/dist/constants/packages.js +22 -10
- package/dist/dlx-binary.js +9 -17
- package/dist/dlx-manifest.js +2 -2
- package/dist/dlx-package.js +22 -62
- package/dist/dlx.js +14 -14
- package/dist/fs.js +19 -24
- package/dist/git.d.ts +6 -6
- package/dist/git.js +11 -14
- package/dist/globs.js +16 -29
- package/dist/ipc.d.ts +4 -4
- package/dist/ipc.js +3 -3
- package/dist/logger.d.ts +0 -25
- package/dist/logger.js +0 -26
- package/dist/package-default-node-range.js +13 -3
- package/dist/package-extensions.d.ts +2 -1
- package/dist/package-extensions.js +12 -2
- package/dist/packages/editable.d.ts +0 -3
- package/dist/packages/editable.js +34 -24
- package/dist/packages/isolation.js +32 -32
- package/dist/packages/licenses.js +18 -32
- package/dist/packages/manifest.js +18 -33
- package/dist/packages/normalize.js +19 -43
- package/dist/packages/operations.js +33 -80
- package/dist/packages/provenance.js +14 -4
- package/dist/packages/specs.js +13 -12
- package/dist/packages/validation.js +12 -10
- package/dist/packages.d.ts +1 -1
- package/dist/packages.js +3 -3
- package/dist/paths/dirnames.d.ts +13 -0
- package/dist/paths/dirnames.js +50 -0
- package/dist/paths/exts.d.ts +18 -0
- package/dist/paths/exts.js +68 -0
- package/dist/paths/filenames.d.ts +16 -0
- package/dist/paths/filenames.js +62 -0
- package/dist/paths/globs.d.ts +10 -0
- package/dist/paths/globs.js +44 -0
- package/dist/{path.d.ts → paths/normalize.d.ts} +41 -0
- package/dist/{path.js → paths/normalize.js} +17 -4
- package/dist/{packages/paths.js → paths/packages.js} +8 -8
- package/dist/{paths.js → paths/socket.js} +29 -65
- package/dist/sea.js +2 -2
- package/dist/shadow.js +3 -3
- package/dist/sorts.js +12 -2
- package/dist/spawn.d.ts +15 -12
- package/dist/spawn.js +42 -30
- package/dist/spinner.d.ts +2 -6
- package/dist/spinner.js +6 -39
- package/dist/stdio/prompts.d.ts +8 -10
- package/dist/stdio/prompts.js +14 -12
- package/dist/streams.d.ts +0 -4
- package/dist/streams.js +3 -12
- package/dist/temporary-executor.js +3 -3
- package/dist/versions.js +31 -28
- package/package.json +28 -16
- package/dist/constants/paths.d.ts +0 -51
- package/dist/constants/paths.js +0 -152
- /package/dist/{packages/paths.d.ts → paths/packages.d.ts} +0 -0
- /package/dist/{paths.d.ts → paths/socket.d.ts} +0 -0
package/dist/bin.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all)
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
var bin_exports = {};
|
|
21
31
|
__export(bin_exports, {
|
|
@@ -25,47 +35,26 @@ __export(bin_exports, {
|
|
|
25
35
|
findRealPnpm: () => findRealPnpm,
|
|
26
36
|
findRealYarn: () => findRealYarn,
|
|
27
37
|
isShadowBinPath: () => isShadowBinPath,
|
|
28
|
-
|
|
38
|
+
resolveRealBinSync: () => resolveRealBinSync,
|
|
29
39
|
which: () => which,
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
whichReal: () => whichReal,
|
|
41
|
+
whichRealSync: () => whichRealSync,
|
|
32
42
|
whichSync: () => whichSync
|
|
33
43
|
});
|
|
34
44
|
module.exports = __toCommonJS(bin_exports);
|
|
45
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
46
|
+
var import_node_path = __toESM(require("node:path"));
|
|
35
47
|
var import_home = require("#env/home");
|
|
36
48
|
var import_windows = require("#env/windows");
|
|
37
49
|
var import_xdg = require("#env/xdg");
|
|
38
50
|
var import_platform = require("#constants/platform");
|
|
51
|
+
var import_which = __toESM(require("./external/which"));
|
|
39
52
|
var import_fs = require("./fs");
|
|
40
|
-
var
|
|
53
|
+
var import_normalize = require("./paths/normalize");
|
|
41
54
|
var import_spawn = require("./spawn");
|
|
42
|
-
let _fs;
|
|
43
|
-
// @__NO_SIDE_EFFECTS__
|
|
44
|
-
function getFs() {
|
|
45
|
-
if (_fs === void 0) {
|
|
46
|
-
_fs = require("node:fs");
|
|
47
|
-
}
|
|
48
|
-
return _fs;
|
|
49
|
-
}
|
|
50
|
-
let _path;
|
|
51
|
-
// @__NO_SIDE_EFFECTS__
|
|
52
|
-
function getPath() {
|
|
53
|
-
if (_path === void 0) {
|
|
54
|
-
_path = require("node:path");
|
|
55
|
-
}
|
|
56
|
-
return _path;
|
|
57
|
-
}
|
|
58
|
-
let _which;
|
|
59
|
-
// @__NO_SIDE_EFFECTS__
|
|
60
|
-
function getWhich() {
|
|
61
|
-
if (_which === void 0) {
|
|
62
|
-
_which = require("./external/which.js");
|
|
63
|
-
}
|
|
64
|
-
return _which;
|
|
65
|
-
}
|
|
66
55
|
// @__NO_SIDE_EFFECTS__
|
|
67
56
|
async function execBin(binPath, args, options) {
|
|
68
|
-
const resolvedPath = (0,
|
|
57
|
+
const resolvedPath = (0, import_normalize.isPath)(binPath) ? /* @__PURE__ */ resolveRealBinSync(binPath) : await whichReal(binPath);
|
|
69
58
|
if (!resolvedPath) {
|
|
70
59
|
const error = new Error(
|
|
71
60
|
`Binary not found: ${binPath}
|
|
@@ -87,61 +76,20 @@ To resolve:
|
|
|
87
76
|
...options
|
|
88
77
|
});
|
|
89
78
|
}
|
|
90
|
-
async function which(binName, options) {
|
|
91
|
-
return await (/* @__PURE__ */ getWhich())(binName, options);
|
|
92
|
-
}
|
|
93
|
-
function whichSync(binName, options) {
|
|
94
|
-
return (/* @__PURE__ */ getWhich()).sync(binName, options);
|
|
95
|
-
}
|
|
96
|
-
async function whichBin(binName, options) {
|
|
97
|
-
const which2 = /* @__PURE__ */ getWhich();
|
|
98
|
-
const opts = { nothrow: true, ...options };
|
|
99
|
-
const result = await which2(binName, opts);
|
|
100
|
-
if (opts?.all) {
|
|
101
|
-
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
102
|
-
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
|
|
103
|
-
}
|
|
104
|
-
if (!result) {
|
|
105
|
-
return void 0;
|
|
106
|
-
}
|
|
107
|
-
return /* @__PURE__ */ resolveBinPathSync(result);
|
|
108
|
-
}
|
|
109
|
-
function whichBinSync(binName, options) {
|
|
110
|
-
const opts = { nothrow: true, ...options };
|
|
111
|
-
const result = whichSync(binName, opts);
|
|
112
|
-
if (opts.all) {
|
|
113
|
-
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
114
|
-
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
|
|
115
|
-
}
|
|
116
|
-
if (!result) {
|
|
117
|
-
return void 0;
|
|
118
|
-
}
|
|
119
|
-
return /* @__PURE__ */ resolveBinPathSync(result);
|
|
120
|
-
}
|
|
121
|
-
function isShadowBinPath(dirPath) {
|
|
122
|
-
if (!dirPath) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
const normalized = dirPath.replace(/\\/g, "/");
|
|
126
|
-
return normalized.includes("node_modules/.bin");
|
|
127
|
-
}
|
|
128
79
|
function findRealBin(binName, commonPaths = []) {
|
|
129
|
-
const fs = /* @__PURE__ */ getFs();
|
|
130
|
-
const path = /* @__PURE__ */ getPath();
|
|
131
|
-
const which2 = /* @__PURE__ */ getWhich();
|
|
132
80
|
for (const binPath2 of commonPaths) {
|
|
133
|
-
if (
|
|
81
|
+
if (import_node_fs.default.existsSync(binPath2)) {
|
|
134
82
|
return binPath2;
|
|
135
83
|
}
|
|
136
84
|
}
|
|
137
|
-
const binPath =
|
|
85
|
+
const binPath = import_which.default.sync(binName, { nothrow: true });
|
|
138
86
|
if (binPath) {
|
|
139
|
-
const binDir =
|
|
87
|
+
const binDir = import_node_path.default.dirname(binPath);
|
|
140
88
|
if (isShadowBinPath(binDir)) {
|
|
141
|
-
const allPaths =
|
|
89
|
+
const allPaths = import_which.default.sync(binName, { all: true, nothrow: true }) || [];
|
|
142
90
|
const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
|
|
143
91
|
for (const altPath of pathsArray) {
|
|
144
|
-
const altDir =
|
|
92
|
+
const altDir = import_node_path.default.dirname(altPath);
|
|
145
93
|
if (!isShadowBinPath(altDir)) {
|
|
146
94
|
return altPath;
|
|
147
95
|
}
|
|
@@ -152,87 +100,88 @@ function findRealBin(binName, commonPaths = []) {
|
|
|
152
100
|
return void 0;
|
|
153
101
|
}
|
|
154
102
|
function findRealNpm() {
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const npmInNodeDir = path?.join(nodeDir, "npm");
|
|
159
|
-
if (fs?.existsSync(npmInNodeDir)) {
|
|
103
|
+
const nodeDir = import_node_path.default.dirname(process.execPath);
|
|
104
|
+
const npmInNodeDir = import_node_path.default.join(nodeDir, "npm");
|
|
105
|
+
if (import_node_fs.default.existsSync(npmInNodeDir)) {
|
|
160
106
|
return npmInNodeDir;
|
|
161
107
|
}
|
|
162
108
|
const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
|
|
163
109
|
const result = findRealBin("npm", commonPaths);
|
|
164
|
-
if (result &&
|
|
110
|
+
if (result && import_node_fs.default.existsSync(result)) {
|
|
165
111
|
return result;
|
|
166
112
|
}
|
|
167
|
-
const npmPath =
|
|
168
|
-
if (npmPath && typeof npmPath === "string" &&
|
|
113
|
+
const npmPath = whichRealSync("npm", { nothrow: true });
|
|
114
|
+
if (npmPath && typeof npmPath === "string" && import_node_fs.default.existsSync(npmPath)) {
|
|
169
115
|
return npmPath;
|
|
170
116
|
}
|
|
171
117
|
return "npm";
|
|
172
118
|
}
|
|
173
119
|
function findRealPnpm() {
|
|
174
|
-
const path = /* @__PURE__ */ getPath();
|
|
175
120
|
const commonPaths = import_platform.WIN32 ? [
|
|
176
121
|
// Windows common paths.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
122
|
+
import_node_path.default.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
|
|
123
|
+
import_node_path.default.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
|
|
124
|
+
import_node_path.default.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
|
|
125
|
+
import_node_path.default.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
|
|
181
126
|
"C:\\Program Files\\nodejs\\pnpm.cmd",
|
|
182
127
|
"C:\\Program Files\\nodejs\\pnpm"
|
|
183
128
|
].filter(Boolean) : [
|
|
184
129
|
// Unix common paths.
|
|
185
130
|
"/usr/local/bin/pnpm",
|
|
186
131
|
"/usr/bin/pnpm",
|
|
187
|
-
|
|
132
|
+
import_node_path.default.join(
|
|
188
133
|
(0, import_xdg.getXdgDataHome)() || `${(0, import_home.getHome)()}/.local/share`,
|
|
189
134
|
"pnpm/pnpm"
|
|
190
135
|
),
|
|
191
|
-
|
|
136
|
+
import_node_path.default.join((0, import_home.getHome)(), ".pnpm/pnpm")
|
|
192
137
|
].filter(Boolean);
|
|
193
138
|
return findRealBin("pnpm", commonPaths) ?? "";
|
|
194
139
|
}
|
|
195
140
|
function findRealYarn() {
|
|
196
|
-
const path = /* @__PURE__ */ getPath();
|
|
197
141
|
const commonPaths = [
|
|
198
142
|
"/usr/local/bin/yarn",
|
|
199
143
|
"/usr/bin/yarn",
|
|
200
|
-
|
|
201
|
-
|
|
144
|
+
import_node_path.default.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
|
|
145
|
+
import_node_path.default.join(
|
|
202
146
|
(0, import_home.getHome)(),
|
|
203
147
|
".config/yarn/global/node_modules/.bin/yarn"
|
|
204
148
|
)
|
|
205
149
|
].filter(Boolean);
|
|
206
150
|
return findRealBin("yarn", commonPaths) ?? "";
|
|
207
151
|
}
|
|
152
|
+
function isShadowBinPath(dirPath) {
|
|
153
|
+
if (!dirPath) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const normalized = dirPath.replace(/\\/g, "/");
|
|
157
|
+
return normalized.includes("node_modules/.bin");
|
|
158
|
+
}
|
|
208
159
|
// @__NO_SIDE_EFFECTS__
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
const path = /* @__PURE__ */ getPath();
|
|
212
|
-
if (!path?.isAbsolute(binPath)) {
|
|
160
|
+
function resolveRealBinSync(binPath) {
|
|
161
|
+
if (!import_node_path.default.isAbsolute(binPath)) {
|
|
213
162
|
try {
|
|
214
|
-
const resolved =
|
|
163
|
+
const resolved = whichRealSync(binPath);
|
|
215
164
|
if (resolved) {
|
|
216
165
|
binPath = resolved;
|
|
217
166
|
}
|
|
218
167
|
} catch {
|
|
219
168
|
}
|
|
220
169
|
}
|
|
221
|
-
binPath = (0,
|
|
170
|
+
binPath = (0, import_normalize.normalizePath)(binPath);
|
|
222
171
|
if (binPath === ".") {
|
|
223
172
|
return binPath;
|
|
224
173
|
}
|
|
225
|
-
const ext =
|
|
174
|
+
const ext = import_node_path.default.extname(binPath);
|
|
226
175
|
const extLowered = ext.toLowerCase();
|
|
227
|
-
const basename =
|
|
176
|
+
const basename = import_node_path.default.basename(binPath, ext);
|
|
228
177
|
const voltaIndex = basename === "node" ? -1 : /(?<=\/)\.volta\//i.exec(binPath)?.index ?? -1;
|
|
229
178
|
if (voltaIndex !== -1) {
|
|
230
179
|
const voltaPath = binPath.slice(0, voltaIndex);
|
|
231
|
-
const voltaToolsPath =
|
|
232
|
-
const voltaImagePath =
|
|
233
|
-
const voltaUserPath =
|
|
180
|
+
const voltaToolsPath = import_node_path.default.join(voltaPath, "tools");
|
|
181
|
+
const voltaImagePath = import_node_path.default.join(voltaToolsPath, "image");
|
|
182
|
+
const voltaUserPath = import_node_path.default.join(voltaToolsPath, "user");
|
|
234
183
|
const voltaPlatform = (0, import_fs.readJsonSync)(
|
|
235
|
-
|
|
184
|
+
import_node_path.default.join(voltaUserPath, "platform.json"),
|
|
236
185
|
{ throws: false }
|
|
237
186
|
);
|
|
238
187
|
const voltaNodeVersion = voltaPlatform?.node?.runtime;
|
|
@@ -241,35 +190,35 @@ function resolveBinPathSync(binPath) {
|
|
|
241
190
|
if (basename === "npm" || basename === "npx") {
|
|
242
191
|
if (voltaNpmVersion) {
|
|
243
192
|
const relCliPath = `bin/${basename}-cli.js`;
|
|
244
|
-
voltaBinPath =
|
|
193
|
+
voltaBinPath = import_node_path.default.join(
|
|
245
194
|
voltaImagePath,
|
|
246
195
|
`npm/${voltaNpmVersion}/${relCliPath}`
|
|
247
196
|
);
|
|
248
|
-
if (voltaNodeVersion && !
|
|
249
|
-
voltaBinPath =
|
|
197
|
+
if (voltaNodeVersion && !import_node_fs.default.existsSync(voltaBinPath)) {
|
|
198
|
+
voltaBinPath = import_node_path.default.join(
|
|
250
199
|
voltaImagePath,
|
|
251
200
|
`node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`
|
|
252
201
|
);
|
|
253
|
-
if (!
|
|
202
|
+
if (!import_node_fs.default.existsSync(voltaBinPath)) {
|
|
254
203
|
voltaBinPath = "";
|
|
255
204
|
}
|
|
256
205
|
}
|
|
257
206
|
}
|
|
258
207
|
} else {
|
|
259
|
-
const voltaUserBinPath =
|
|
208
|
+
const voltaUserBinPath = import_node_path.default.join(voltaUserPath, "bin");
|
|
260
209
|
const binInfo = (0, import_fs.readJsonSync)(
|
|
261
|
-
|
|
210
|
+
import_node_path.default.join(voltaUserBinPath, `${basename}.json`),
|
|
262
211
|
{ throws: false }
|
|
263
212
|
);
|
|
264
213
|
const binPackage = binInfo?.package;
|
|
265
214
|
if (binPackage) {
|
|
266
|
-
voltaBinPath =
|
|
215
|
+
voltaBinPath = import_node_path.default.join(
|
|
267
216
|
voltaImagePath,
|
|
268
217
|
`packages/${binPackage}/bin/${basename}`
|
|
269
218
|
);
|
|
270
|
-
if (!
|
|
219
|
+
if (!import_node_fs.default.existsSync(voltaBinPath)) {
|
|
271
220
|
voltaBinPath = `${voltaBinPath}.cmd`;
|
|
272
|
-
if (!
|
|
221
|
+
if (!import_node_fs.default.existsSync(voltaBinPath)) {
|
|
273
222
|
voltaBinPath = "";
|
|
274
223
|
}
|
|
275
224
|
}
|
|
@@ -277,7 +226,7 @@ function resolveBinPathSync(binPath) {
|
|
|
277
226
|
}
|
|
278
227
|
if (voltaBinPath) {
|
|
279
228
|
try {
|
|
280
|
-
return (0,
|
|
229
|
+
return (0, import_normalize.normalizePath)(import_node_fs.default.realpathSync.native(voltaBinPath));
|
|
281
230
|
} catch {
|
|
282
231
|
}
|
|
283
232
|
return voltaBinPath;
|
|
@@ -288,13 +237,13 @@ function resolveBinPathSync(binPath) {
|
|
|
288
237
|
const isNpmOrNpx = basename === "npm" || basename === "npx";
|
|
289
238
|
const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
|
|
290
239
|
if (hasKnownExt && isNpmOrNpx) {
|
|
291
|
-
const quickPath =
|
|
292
|
-
|
|
240
|
+
const quickPath = import_node_path.default.join(
|
|
241
|
+
import_node_path.default.dirname(binPath),
|
|
293
242
|
`node_modules/npm/bin/${basename}-cli.js`
|
|
294
243
|
);
|
|
295
|
-
if (
|
|
244
|
+
if (import_node_fs.default.existsSync(quickPath)) {
|
|
296
245
|
try {
|
|
297
|
-
return
|
|
246
|
+
return import_node_fs.default.realpathSync.native(quickPath);
|
|
298
247
|
} catch {
|
|
299
248
|
}
|
|
300
249
|
return quickPath;
|
|
@@ -304,8 +253,8 @@ function resolveBinPathSync(binPath) {
|
|
|
304
253
|
if (hasKnownExt && // Only parse shell scripts and batch files, not actual executables.
|
|
305
254
|
// .exe files are already executables and don't need path resolution from wrapper scripts.
|
|
306
255
|
extLowered !== ".exe" && // Check if file exists before attempting to read it to avoid ENOENT errors.
|
|
307
|
-
|
|
308
|
-
const source =
|
|
256
|
+
import_node_fs.default.existsSync(binPath)) {
|
|
257
|
+
const source = import_node_fs.default.readFileSync(binPath, "utf8");
|
|
309
258
|
if (isNpmOrNpx) {
|
|
310
259
|
if (extLowered === ".cmd") {
|
|
311
260
|
relPath = basename === "npm" ? /(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "" : /(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "";
|
|
@@ -352,7 +301,7 @@ function resolveBinPathSync(binPath) {
|
|
|
352
301
|
relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
|
|
353
302
|
}
|
|
354
303
|
if (relPath) {
|
|
355
|
-
binPath = (0,
|
|
304
|
+
binPath = (0, import_normalize.normalizePath)(import_node_path.default.resolve(import_node_path.default.dirname(binPath), relPath));
|
|
356
305
|
}
|
|
357
306
|
}
|
|
358
307
|
} else {
|
|
@@ -364,10 +313,10 @@ function resolveBinPathSync(binPath) {
|
|
|
364
313
|
if (binIndex !== -1) {
|
|
365
314
|
const baseBinPath = binPath.slice(0, binIndex + "/.bin/pnpm".length);
|
|
366
315
|
try {
|
|
367
|
-
const stats =
|
|
316
|
+
const stats = import_node_fs.default.statSync(baseBinPath);
|
|
368
317
|
if (stats.isFile()) {
|
|
369
|
-
binPath = (0,
|
|
370
|
-
hasNoExt = !
|
|
318
|
+
binPath = (0, import_normalize.normalizePath)(baseBinPath);
|
|
319
|
+
hasNoExt = !import_node_path.default.extname(binPath);
|
|
371
320
|
}
|
|
372
321
|
} catch {
|
|
373
322
|
}
|
|
@@ -375,8 +324,8 @@ function resolveBinPathSync(binPath) {
|
|
|
375
324
|
}
|
|
376
325
|
if (hasNoExt && (isPnpmOrYarn || isNpmOrNpx) && // For extensionless files (Unix shell scripts), verify existence before reading.
|
|
377
326
|
// This prevents ENOENT errors when the bin path doesn't exist.
|
|
378
|
-
|
|
379
|
-
const source =
|
|
327
|
+
import_node_fs.default.existsSync(binPath)) {
|
|
328
|
+
const source = import_node_fs.default.readFileSync(binPath, "utf8");
|
|
380
329
|
let relPath = "";
|
|
381
330
|
if (isPnpmOrYarn) {
|
|
382
331
|
relPath = /(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
|
|
@@ -398,16 +347,62 @@ function resolveBinPathSync(binPath) {
|
|
|
398
347
|
relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
|
|
399
348
|
}
|
|
400
349
|
if (relPath) {
|
|
401
|
-
binPath = (0,
|
|
350
|
+
binPath = (0, import_normalize.normalizePath)(import_node_path.default.resolve(import_node_path.default.dirname(binPath), relPath));
|
|
402
351
|
}
|
|
403
352
|
}
|
|
404
353
|
}
|
|
405
354
|
try {
|
|
406
|
-
const realPath =
|
|
407
|
-
return (0,
|
|
355
|
+
const realPath = import_node_fs.default.realpathSync.native(binPath);
|
|
356
|
+
return (0, import_normalize.normalizePath)(realPath);
|
|
357
|
+
} catch {
|
|
358
|
+
}
|
|
359
|
+
return (0, import_normalize.normalizePath)(binPath);
|
|
360
|
+
}
|
|
361
|
+
async function which(binName, options) {
|
|
362
|
+
if ((0, import_normalize.isPath)(binName)) {
|
|
363
|
+
return binName;
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
const result = await (0, import_which.default)(binName, options);
|
|
367
|
+
return result;
|
|
368
|
+
} catch {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async function whichReal(binName, options) {
|
|
373
|
+
const opts = { nothrow: true, ...options };
|
|
374
|
+
const result = await (0, import_which.default)(binName, opts);
|
|
375
|
+
if (opts?.all) {
|
|
376
|
+
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
377
|
+
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveRealBinSync(p)) : paths;
|
|
378
|
+
}
|
|
379
|
+
if (!result) {
|
|
380
|
+
return void 0;
|
|
381
|
+
}
|
|
382
|
+
return /* @__PURE__ */ resolveRealBinSync(result);
|
|
383
|
+
}
|
|
384
|
+
function whichRealSync(binName, options) {
|
|
385
|
+
const opts = { nothrow: true, ...options };
|
|
386
|
+
const result = whichSync(binName, opts);
|
|
387
|
+
if (opts.all) {
|
|
388
|
+
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
389
|
+
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveRealBinSync(p)) : paths;
|
|
390
|
+
}
|
|
391
|
+
if (!result) {
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
return /* @__PURE__ */ resolveRealBinSync(result);
|
|
395
|
+
}
|
|
396
|
+
function whichSync(binName, options) {
|
|
397
|
+
if ((0, import_normalize.isPath)(binName)) {
|
|
398
|
+
return binName;
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
const result = import_which.default.sync(binName, options);
|
|
402
|
+
return result;
|
|
408
403
|
} catch {
|
|
404
|
+
return null;
|
|
409
405
|
}
|
|
410
|
-
return (0, import_path.normalizePath)(binPath);
|
|
411
406
|
}
|
|
412
407
|
// Annotate the CommonJS export names for ESM import in node:
|
|
413
408
|
0 && (module.exports = {
|
|
@@ -417,9 +412,9 @@ function resolveBinPathSync(binPath) {
|
|
|
417
412
|
findRealPnpm,
|
|
418
413
|
findRealYarn,
|
|
419
414
|
isShadowBinPath,
|
|
420
|
-
|
|
415
|
+
resolveRealBinSync,
|
|
421
416
|
which,
|
|
422
|
-
|
|
423
|
-
|
|
417
|
+
whichReal,
|
|
418
|
+
whichRealSync,
|
|
424
419
|
whichSync
|
|
425
420
|
});
|
package/dist/cacache.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface RemoveOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Get the cacache module for cache operations.
|
|
35
35
|
*/
|
|
36
|
-
export declare function getCacache():
|
|
36
|
+
export declare function getCacache(): import("./external/cacache").CacacheInstance;
|
|
37
37
|
/**
|
|
38
38
|
* Clear entries from the Socket shared cache.
|
|
39
39
|
*
|
|
@@ -71,7 +71,10 @@ export declare function get(key: string, options?: GetOptions | undefined): Prom
|
|
|
71
71
|
*
|
|
72
72
|
* @throws {TypeError} If key contains wildcards (*)
|
|
73
73
|
*/
|
|
74
|
-
export declare function put(key: string, data: string | Buffer, options?: PutOptions | undefined): Promise<
|
|
74
|
+
export declare function put(key: string, data: string | Buffer, options?: PutOptions | undefined): Promise<{
|
|
75
|
+
integrity: string;
|
|
76
|
+
size: number;
|
|
77
|
+
}>;
|
|
75
78
|
/**
|
|
76
79
|
* Remove an entry from the Socket shared cache by key.
|
|
77
80
|
*
|
package/dist/cacache.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all)
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
var cacache_exports = {};
|
|
21
31
|
__export(cacache_exports, {
|
|
@@ -28,9 +38,10 @@ __export(cacache_exports, {
|
|
|
28
38
|
withTmp: () => withTmp
|
|
29
39
|
});
|
|
30
40
|
module.exports = __toCommonJS(cacache_exports);
|
|
31
|
-
var
|
|
41
|
+
var import_cacache = __toESM(require("./external/cacache"));
|
|
42
|
+
var import_socket = require("./paths/socket");
|
|
32
43
|
function getCacache() {
|
|
33
|
-
return
|
|
44
|
+
return import_cacache.default;
|
|
34
45
|
}
|
|
35
46
|
function patternToRegex(pattern) {
|
|
36
47
|
const escaped = pattern.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -46,11 +57,11 @@ function matchesPattern(key, pattern) {
|
|
|
46
57
|
}
|
|
47
58
|
async function clear(options) {
|
|
48
59
|
const opts = { __proto__: null, ...options };
|
|
49
|
-
const
|
|
50
|
-
const cacheDir = (0,
|
|
60
|
+
const cacache2 = getCacache();
|
|
61
|
+
const cacheDir = (0, import_socket.getSocketCacacheDir)();
|
|
51
62
|
if (!opts.prefix) {
|
|
52
63
|
try {
|
|
53
|
-
await
|
|
64
|
+
await cacache2.rm.all(cacheDir);
|
|
54
65
|
return;
|
|
55
66
|
} catch (e) {
|
|
56
67
|
if (e?.code !== "ENOTEMPTY") {
|
|
@@ -62,11 +73,11 @@ async function clear(options) {
|
|
|
62
73
|
const hasWildcard = opts.prefix.includes("*");
|
|
63
74
|
if (!hasWildcard) {
|
|
64
75
|
let removed2 = 0;
|
|
65
|
-
const stream2 =
|
|
76
|
+
const stream2 = cacache2.ls.stream(cacheDir);
|
|
66
77
|
for await (const entry of stream2) {
|
|
67
78
|
if (entry.key.startsWith(opts.prefix)) {
|
|
68
79
|
try {
|
|
69
|
-
await
|
|
80
|
+
await cacache2.rm.entry(cacheDir, entry.key);
|
|
70
81
|
removed2++;
|
|
71
82
|
} catch {
|
|
72
83
|
}
|
|
@@ -75,11 +86,11 @@ async function clear(options) {
|
|
|
75
86
|
return removed2;
|
|
76
87
|
}
|
|
77
88
|
let removed = 0;
|
|
78
|
-
const stream =
|
|
89
|
+
const stream = cacache2.ls.stream(cacheDir);
|
|
79
90
|
for await (const entry of stream) {
|
|
80
91
|
if (matchesPattern(entry.key, opts.prefix)) {
|
|
81
92
|
try {
|
|
82
|
-
await
|
|
93
|
+
await cacache2.rm.entry(cacheDir, entry.key);
|
|
83
94
|
removed++;
|
|
84
95
|
} catch {
|
|
85
96
|
}
|
|
@@ -93,8 +104,8 @@ async function get(key, options) {
|
|
|
93
104
|
'Cache key cannot contain wildcards (*). Wildcards are only supported in clear({ prefix: "pattern*" }).'
|
|
94
105
|
);
|
|
95
106
|
}
|
|
96
|
-
const
|
|
97
|
-
return await
|
|
107
|
+
const cacache2 = getCacache();
|
|
108
|
+
return await cacache2.get((0, import_socket.getSocketCacacheDir)(), key, options);
|
|
98
109
|
}
|
|
99
110
|
async function put(key, data, options) {
|
|
100
111
|
if (key.includes("*")) {
|
|
@@ -102,8 +113,8 @@ async function put(key, data, options) {
|
|
|
102
113
|
'Cache key cannot contain wildcards (*). Wildcards are only supported in clear({ prefix: "pattern*" }).'
|
|
103
114
|
);
|
|
104
115
|
}
|
|
105
|
-
const
|
|
106
|
-
return await
|
|
116
|
+
const cacache2 = getCacache();
|
|
117
|
+
return await cacache2.put((0, import_socket.getSocketCacacheDir)(), key, data, options);
|
|
107
118
|
}
|
|
108
119
|
async function remove(key) {
|
|
109
120
|
if (key.includes("*")) {
|
|
@@ -111,8 +122,8 @@ async function remove(key) {
|
|
|
111
122
|
'Cache key cannot contain wildcards (*). Use clear({ prefix: "pattern*" }) to remove multiple entries.'
|
|
112
123
|
);
|
|
113
124
|
}
|
|
114
|
-
const
|
|
115
|
-
return await
|
|
125
|
+
const cacache2 = getCacache();
|
|
126
|
+
return await cacache2.rm.entry((0, import_socket.getSocketCacacheDir)(), key);
|
|
116
127
|
}
|
|
117
128
|
async function safeGet(key, options) {
|
|
118
129
|
try {
|
|
@@ -122,9 +133,9 @@ async function safeGet(key, options) {
|
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
135
|
async function withTmp(callback) {
|
|
125
|
-
const
|
|
126
|
-
return await
|
|
127
|
-
(0,
|
|
136
|
+
const cacache2 = getCacache();
|
|
137
|
+
return await cacache2.tmp.withTmp(
|
|
138
|
+
(0, import_socket.getSocketCacacheDir)(),
|
|
128
139
|
{},
|
|
129
140
|
callback
|
|
130
141
|
);
|
package/dist/cache-with-ttl.js
CHANGED
|
@@ -114,7 +114,7 @@ function createTtlCache(options) {
|
|
|
114
114
|
results.set(originalKey, entry.data);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
const cacheDir = (await import("./paths")).getSocketCacacheDir();
|
|
117
|
+
const cacheDir = (await import("./paths/socket")).getSocketCacacheDir();
|
|
118
118
|
const cacacheModule = await import("./cacache");
|
|
119
119
|
const stream = cacacheModule.getCacache().ls.stream(cacheDir);
|
|
120
120
|
for await (const cacheEntry of stream) {
|