@socketsecurity/lib 5.3.0 → 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 +16 -0
- package/dist/cover/code.js +12 -4
- package/dist/dlx/cache.js +10 -2
- package/dist/dlx/manifest.js +45 -41
- 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/http-request.js +10 -2
- package/dist/ipc.js +53 -29
- package/dist/packages/isolation.js +45 -23
- package/dist/packages/licenses.js +10 -2
- package/dist/paths/socket.d.ts +2 -2
- package/dist/paths/socket.js +27 -21
- package/dist/process-lock.js +23 -14
- package/dist/releases/github.d.ts +67 -41
- package/dist/releases/github.js +142 -100
- package/dist/releases/socket-btm.d.ts +40 -33
- package/dist/releases/socket-btm.js +45 -5
- package/dist/spawn.js +10 -3
- 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 +2 -1
|
@@ -1,105 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Bundled from validate-npm-package-name
|
|
4
|
-
* This is a zero-dependency bundle created by esbuild.
|
|
5
|
-
*/
|
|
6
|
-
"use strict";
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
1
|
+
'use strict'
|
|
13
2
|
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"use strict";
|
|
18
|
-
var { builtinModules: builtins } = require("module");
|
|
19
|
-
var scopedPackagePattern = new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
|
|
20
|
-
var exclusionList = [
|
|
21
|
-
"node_modules",
|
|
22
|
-
"favicon.ico"
|
|
23
|
-
];
|
|
24
|
-
function validate(name) {
|
|
25
|
-
var warnings = [];
|
|
26
|
-
var errors = [];
|
|
27
|
-
if (name === null) {
|
|
28
|
-
errors.push("name cannot be null");
|
|
29
|
-
return done(warnings, errors);
|
|
30
|
-
}
|
|
31
|
-
if (name === void 0) {
|
|
32
|
-
errors.push("name cannot be undefined");
|
|
33
|
-
return done(warnings, errors);
|
|
34
|
-
}
|
|
35
|
-
if (typeof name !== "string") {
|
|
36
|
-
errors.push("name must be a string");
|
|
37
|
-
return done(warnings, errors);
|
|
38
|
-
}
|
|
39
|
-
if (!name.length) {
|
|
40
|
-
errors.push("name length must be greater than zero");
|
|
41
|
-
}
|
|
42
|
-
if (name.startsWith(".")) {
|
|
43
|
-
errors.push("name cannot start with a period");
|
|
44
|
-
}
|
|
45
|
-
if (name.match(/^_/)) {
|
|
46
|
-
errors.push("name cannot start with an underscore");
|
|
47
|
-
}
|
|
48
|
-
if (name.trim() !== name) {
|
|
49
|
-
errors.push("name cannot contain leading or trailing spaces");
|
|
50
|
-
}
|
|
51
|
-
exclusionList.forEach(function(excludedName) {
|
|
52
|
-
if (name.toLowerCase() === excludedName) {
|
|
53
|
-
errors.push(excludedName + " is not a valid package name");
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
if (builtins.includes(name.toLowerCase())) {
|
|
57
|
-
warnings.push(name + " is a core module name");
|
|
58
|
-
}
|
|
59
|
-
if (name.length > 214) {
|
|
60
|
-
warnings.push("name can no longer contain more than 214 characters");
|
|
61
|
-
}
|
|
62
|
-
if (name.toLowerCase() !== name) {
|
|
63
|
-
warnings.push("name can no longer contain capital letters");
|
|
64
|
-
}
|
|
65
|
-
if (/[~'!()*]/.test(name.split("/").slice(-1)[0])) {
|
|
66
|
-
warnings.push(`name can no longer contain special characters ("~'!()*")`);
|
|
67
|
-
}
|
|
68
|
-
if (encodeURIComponent(name) !== name) {
|
|
69
|
-
var nameMatch = name.match(scopedPackagePattern);
|
|
70
|
-
if (nameMatch) {
|
|
71
|
-
var user = nameMatch[1];
|
|
72
|
-
var pkg = nameMatch[2];
|
|
73
|
-
if (pkg.startsWith(".")) {
|
|
74
|
-
errors.push("name cannot start with a period");
|
|
75
|
-
}
|
|
76
|
-
if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
|
|
77
|
-
return done(warnings, errors);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
errors.push("name can only contain URL-friendly characters");
|
|
81
|
-
}
|
|
82
|
-
return done(warnings, errors);
|
|
83
|
-
}
|
|
84
|
-
__name(validate, "validate");
|
|
85
|
-
var done = /* @__PURE__ */ __name(function(warnings, errors) {
|
|
86
|
-
var result = {
|
|
87
|
-
validForNewPackages: errors.length === 0 && warnings.length === 0,
|
|
88
|
-
validForOldPackages: errors.length === 0,
|
|
89
|
-
warnings,
|
|
90
|
-
errors
|
|
91
|
-
};
|
|
92
|
-
if (!result.warnings.length) {
|
|
93
|
-
delete result.warnings;
|
|
94
|
-
}
|
|
95
|
-
if (!result.errors.length) {
|
|
96
|
-
delete result.errors;
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}, "done");
|
|
100
|
-
module2.exports = validate;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// src/external/validate-npm-package-name.js
|
|
105
|
-
module.exports = require_lib();
|
|
3
|
+
// Re-export from npm-core bundle for better deduplication.
|
|
4
|
+
const { validateNpmPackageName } = require('./npm-core')
|
|
5
|
+
module.exports = validateNpmPackageName
|
package/dist/http-request.js
CHANGED
|
@@ -25,7 +25,14 @@ __export(http_request_exports, {
|
|
|
25
25
|
httpRequest: () => httpRequest
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(http_request_exports);
|
|
28
|
-
|
|
28
|
+
let _fs;
|
|
29
|
+
// @__NO_SIDE_EFFECTS__
|
|
30
|
+
function getFs() {
|
|
31
|
+
if (_fs === void 0) {
|
|
32
|
+
_fs = require("fs");
|
|
33
|
+
}
|
|
34
|
+
return _fs;
|
|
35
|
+
}
|
|
29
36
|
let _http;
|
|
30
37
|
let _https;
|
|
31
38
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -252,6 +259,7 @@ async function httpDownloadAttempt(url, destPath, options) {
|
|
|
252
259
|
port: parsedUrl.port,
|
|
253
260
|
timeout
|
|
254
261
|
};
|
|
262
|
+
const { createWriteStream } = /* @__PURE__ */ getFs();
|
|
255
263
|
let fileStream;
|
|
256
264
|
let streamClosed = false;
|
|
257
265
|
const closeStream = () => {
|
|
@@ -298,7 +306,7 @@ async function httpDownloadAttempt(url, destPath, options) {
|
|
|
298
306
|
10
|
|
299
307
|
);
|
|
300
308
|
let downloadedSize = 0;
|
|
301
|
-
fileStream =
|
|
309
|
+
fileStream = createWriteStream(destPath);
|
|
302
310
|
fileStream.on("error", (error) => {
|
|
303
311
|
closeStream();
|
|
304
312
|
const err = new Error(`Failed to write file: ${error.message}`, {
|
package/dist/ipc.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
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
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var ipc_exports = {};
|
|
31
21
|
__export(ipc_exports, {
|
|
@@ -43,12 +33,33 @@ __export(ipc_exports, {
|
|
|
43
33
|
writeIpcStub: () => writeIpcStub
|
|
44
34
|
});
|
|
45
35
|
module.exports = __toCommonJS(ipc_exports);
|
|
46
|
-
var
|
|
47
|
-
var import_fs = require("fs");
|
|
48
|
-
var import_path = __toESM(require("path"));
|
|
49
|
-
var import_fs2 = require("./fs");
|
|
36
|
+
var import_fs = require("./fs");
|
|
50
37
|
var import_socket = require("./paths/socket");
|
|
51
38
|
var import_zod = require("./zod");
|
|
39
|
+
let _crypto;
|
|
40
|
+
// @__NO_SIDE_EFFECTS__
|
|
41
|
+
function getCrypto() {
|
|
42
|
+
if (_crypto === void 0) {
|
|
43
|
+
_crypto = require("crypto");
|
|
44
|
+
}
|
|
45
|
+
return _crypto;
|
|
46
|
+
}
|
|
47
|
+
let _fs;
|
|
48
|
+
// @__NO_SIDE_EFFECTS__
|
|
49
|
+
function getFs() {
|
|
50
|
+
if (_fs === void 0) {
|
|
51
|
+
_fs = require("fs");
|
|
52
|
+
}
|
|
53
|
+
return _fs;
|
|
54
|
+
}
|
|
55
|
+
let _path;
|
|
56
|
+
// @__NO_SIDE_EFFECTS__
|
|
57
|
+
function getPath() {
|
|
58
|
+
if (_path === void 0) {
|
|
59
|
+
_path = require("path");
|
|
60
|
+
}
|
|
61
|
+
return _path;
|
|
62
|
+
}
|
|
52
63
|
const IpcMessageSchema = import_zod.z.object({
|
|
53
64
|
/** Unique identifier for message tracking and response correlation. */
|
|
54
65
|
id: import_zod.z.string().min(1),
|
|
@@ -81,16 +92,20 @@ const IpcStubSchema = import_zod.z.object({
|
|
|
81
92
|
data: import_zod.z.unknown()
|
|
82
93
|
});
|
|
83
94
|
function createIpcChannelId(prefix = "socket") {
|
|
84
|
-
|
|
95
|
+
const crypto = /* @__PURE__ */ getCrypto();
|
|
96
|
+
return `${prefix}-${process.pid}-${crypto.randomBytes(8).toString("hex")}`;
|
|
85
97
|
}
|
|
86
98
|
function getIpcStubPath(appName) {
|
|
87
99
|
const tempDir = (0, import_socket.getOsTmpDir)();
|
|
88
|
-
const
|
|
89
|
-
|
|
100
|
+
const path = /* @__PURE__ */ getPath();
|
|
101
|
+
const stubDir = path.join(tempDir, ".socket-ipc", appName);
|
|
102
|
+
return path.join(stubDir, `stub-${process.pid}.json`);
|
|
90
103
|
}
|
|
91
104
|
async function ensureIpcDirectory(filePath) {
|
|
92
|
-
const
|
|
93
|
-
|
|
105
|
+
const fs = /* @__PURE__ */ getFs();
|
|
106
|
+
const path = /* @__PURE__ */ getPath();
|
|
107
|
+
const dir = path.dirname(filePath);
|
|
108
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
94
109
|
}
|
|
95
110
|
async function writeIpcStub(appName, data) {
|
|
96
111
|
const stubPath = getIpcStubPath(appName);
|
|
@@ -101,19 +116,25 @@ async function writeIpcStub(appName, data) {
|
|
|
101
116
|
timestamp: Date.now()
|
|
102
117
|
};
|
|
103
118
|
const validated = IpcStubSchema.parse(ipcData);
|
|
104
|
-
|
|
119
|
+
const fs = /* @__PURE__ */ getFs();
|
|
120
|
+
await fs.promises.writeFile(
|
|
121
|
+
stubPath,
|
|
122
|
+
JSON.stringify(validated, null, 2),
|
|
123
|
+
"utf8"
|
|
124
|
+
);
|
|
105
125
|
return stubPath;
|
|
106
126
|
}
|
|
107
127
|
async function readIpcStub(stubPath) {
|
|
108
128
|
try {
|
|
109
|
-
const
|
|
129
|
+
const fs = /* @__PURE__ */ getFs();
|
|
130
|
+
const content = await fs.promises.readFile(stubPath, "utf8");
|
|
110
131
|
const parsed = JSON.parse(content);
|
|
111
132
|
const validated = IpcStubSchema.parse(parsed);
|
|
112
133
|
const ageMs = Date.now() - validated.timestamp;
|
|
113
134
|
const maxAgeMs = 5 * 60 * 1e3;
|
|
114
135
|
if (ageMs > maxAgeMs) {
|
|
115
136
|
try {
|
|
116
|
-
(0,
|
|
137
|
+
(0, import_fs.safeDeleteSync)(stubPath, { force: true });
|
|
117
138
|
} catch {
|
|
118
139
|
}
|
|
119
140
|
return null;
|
|
@@ -125,21 +146,23 @@ async function readIpcStub(stubPath) {
|
|
|
125
146
|
}
|
|
126
147
|
async function cleanupIpcStubs(appName) {
|
|
127
148
|
const tempDir = (0, import_socket.getOsTmpDir)();
|
|
128
|
-
const
|
|
149
|
+
const fs = /* @__PURE__ */ getFs();
|
|
150
|
+
const path = /* @__PURE__ */ getPath();
|
|
151
|
+
const stubDir = path.join(tempDir, ".socket-ipc", appName);
|
|
129
152
|
try {
|
|
130
|
-
const files = await
|
|
153
|
+
const files = await fs.promises.readdir(stubDir);
|
|
131
154
|
const now = Date.now();
|
|
132
155
|
const maxAgeMs = 5 * 60 * 1e3;
|
|
133
156
|
await Promise.allSettled(
|
|
134
157
|
files.map(async (file) => {
|
|
135
158
|
if (file.startsWith("stub-") && file.endsWith(".json")) {
|
|
136
|
-
const filePath =
|
|
159
|
+
const filePath = path.join(stubDir, file);
|
|
137
160
|
try {
|
|
138
|
-
const stats = await
|
|
161
|
+
const stats = await fs.promises.stat(filePath);
|
|
139
162
|
const mtimeAge = now - stats.mtimeMs;
|
|
140
163
|
let isStale = mtimeAge > maxAgeMs;
|
|
141
164
|
try {
|
|
142
|
-
const content = await
|
|
165
|
+
const content = await fs.promises.readFile(filePath, "utf8");
|
|
143
166
|
const parsed = JSON.parse(content);
|
|
144
167
|
const validated = IpcStubSchema.parse(parsed);
|
|
145
168
|
const contentAge = now - validated.timestamp;
|
|
@@ -147,7 +170,7 @@ async function cleanupIpcStubs(appName) {
|
|
|
147
170
|
} catch {
|
|
148
171
|
}
|
|
149
172
|
if (isStale) {
|
|
150
|
-
(0,
|
|
173
|
+
(0, import_fs.safeDeleteSync)(filePath, { force: true });
|
|
151
174
|
}
|
|
152
175
|
} catch {
|
|
153
176
|
}
|
|
@@ -209,8 +232,9 @@ function waitForIpc(messageType, options = {}) {
|
|
|
209
232
|
});
|
|
210
233
|
}
|
|
211
234
|
function createIpcMessage(type, data) {
|
|
235
|
+
const crypto = /* @__PURE__ */ getCrypto();
|
|
212
236
|
return {
|
|
213
|
-
id:
|
|
237
|
+
id: crypto.randomBytes(16).toString("hex"),
|
|
214
238
|
timestamp: Date.now(),
|
|
215
239
|
type,
|
|
216
240
|
data
|
|
@@ -32,14 +32,28 @@ __export(isolation_exports, {
|
|
|
32
32
|
isolatePackage: () => isolatePackage
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(isolation_exports);
|
|
35
|
-
var import_fs = require("fs");
|
|
36
35
|
var import_platform = require("../constants/platform");
|
|
37
|
-
var import_node_path = __toESM(require("node:path"));
|
|
38
36
|
var import_npm_package_arg = __toESM(require("../external/npm-package-arg"));
|
|
39
37
|
var import_spawn = require("../spawn");
|
|
40
38
|
var import_normalize = require("../paths/normalize");
|
|
41
39
|
var import_operations = require("./operations");
|
|
42
40
|
var import_socket = require("../paths/socket");
|
|
41
|
+
let _fs;
|
|
42
|
+
// @__NO_SIDE_EFFECTS__
|
|
43
|
+
function getFs() {
|
|
44
|
+
if (_fs === void 0) {
|
|
45
|
+
_fs = require("fs");
|
|
46
|
+
}
|
|
47
|
+
return _fs;
|
|
48
|
+
}
|
|
49
|
+
let _path;
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function getPath() {
|
|
52
|
+
if (_path === void 0) {
|
|
53
|
+
_path = require("path");
|
|
54
|
+
}
|
|
55
|
+
return _path;
|
|
56
|
+
}
|
|
43
57
|
const FS_CP_OPTIONS = {
|
|
44
58
|
dereference: true,
|
|
45
59
|
errorOnExist: false,
|
|
@@ -49,14 +63,19 @@ const FS_CP_OPTIONS = {
|
|
|
49
63
|
...import_platform.WIN32 ? { maxRetries: 3, retryDelay: 100 } : {}
|
|
50
64
|
};
|
|
51
65
|
async function resolveRealPath(pathStr) {
|
|
52
|
-
|
|
66
|
+
const fs = /* @__PURE__ */ getFs();
|
|
67
|
+
const path = /* @__PURE__ */ getPath();
|
|
68
|
+
return await fs.promises.realpath(pathStr).catch(() => path.resolve(pathStr));
|
|
53
69
|
}
|
|
54
70
|
async function mergePackageJson(pkgJsonPath, originalPkgJson) {
|
|
55
|
-
const
|
|
71
|
+
const fs = /* @__PURE__ */ getFs();
|
|
72
|
+
const pkgJson = JSON.parse(await fs.promises.readFile(pkgJsonPath, "utf8"));
|
|
56
73
|
const mergedPkgJson = originalPkgJson ? { ...originalPkgJson, ...pkgJson } : pkgJson;
|
|
57
74
|
return mergedPkgJson;
|
|
58
75
|
}
|
|
59
76
|
async function isolatePackage(packageSpec, options) {
|
|
77
|
+
const fs = /* @__PURE__ */ getFs();
|
|
78
|
+
const path = /* @__PURE__ */ getPath();
|
|
60
79
|
const opts = { __proto__: null, ...options };
|
|
61
80
|
const { imports, install, onPackageJson, sourcePath: optSourcePath } = opts;
|
|
62
81
|
let sourcePath = optSourcePath;
|
|
@@ -65,8 +84,8 @@ async function isolatePackage(packageSpec, options) {
|
|
|
65
84
|
if ((0, import_normalize.isPath)(packageSpec)) {
|
|
66
85
|
const trimmedPath = (0, import_normalize.trimLeadingDotSlash)(packageSpec);
|
|
67
86
|
const pathToResolve = (0, import_normalize.isAbsolute)(trimmedPath) ? trimmedPath : packageSpec;
|
|
68
|
-
sourcePath =
|
|
69
|
-
if (!
|
|
87
|
+
sourcePath = path.resolve(pathToResolve);
|
|
88
|
+
if (!fs.existsSync(sourcePath)) {
|
|
70
89
|
throw new Error(`Source path does not exist: ${sourcePath}`);
|
|
71
90
|
}
|
|
72
91
|
const pkgJson = await (0, import_operations.readPackageJson)(sourcePath, { normalize: true });
|
|
@@ -79,7 +98,7 @@ async function isolatePackage(packageSpec, options) {
|
|
|
79
98
|
packageName = parsed.name;
|
|
80
99
|
if (parsed.type === "directory" || parsed.type === "file") {
|
|
81
100
|
sourcePath = parsed.fetchSpec;
|
|
82
|
-
if (!sourcePath || !
|
|
101
|
+
if (!sourcePath || !fs.existsSync(sourcePath)) {
|
|
83
102
|
throw new Error(`Source path does not exist: ${sourcePath}`);
|
|
84
103
|
}
|
|
85
104
|
if (!packageName) {
|
|
@@ -97,16 +116,16 @@ async function isolatePackage(packageSpec, options) {
|
|
|
97
116
|
throw new Error(`Could not determine package name from: ${packageSpec}`);
|
|
98
117
|
}
|
|
99
118
|
const sanitizedName = packageName.replace(/[@/]/g, "-");
|
|
100
|
-
const tempDir = await
|
|
101
|
-
|
|
119
|
+
const tempDir = await fs.promises.mkdtemp(
|
|
120
|
+
path.join((0, import_socket.getOsTmpDir)(), `socket-test-${sanitizedName}-`)
|
|
102
121
|
);
|
|
103
|
-
const packageTempDir =
|
|
104
|
-
await
|
|
122
|
+
const packageTempDir = path.join(tempDir, sanitizedName);
|
|
123
|
+
await fs.promises.mkdir(packageTempDir, { recursive: true });
|
|
105
124
|
let installedPath;
|
|
106
125
|
let originalPackageJson;
|
|
107
126
|
if (spec) {
|
|
108
|
-
await
|
|
109
|
-
|
|
127
|
+
await fs.promises.writeFile(
|
|
128
|
+
path.join(packageTempDir, "package.json"),
|
|
110
129
|
JSON.stringify(
|
|
111
130
|
{
|
|
112
131
|
name: "test-temp",
|
|
@@ -127,7 +146,7 @@ async function isolatePackage(packageSpec, options) {
|
|
|
127
146
|
stdio: "pipe"
|
|
128
147
|
});
|
|
129
148
|
}
|
|
130
|
-
installedPath =
|
|
149
|
+
installedPath = path.join(packageTempDir, "node_modules", packageName);
|
|
131
150
|
originalPackageJson = await (0, import_operations.readPackageJson)(installedPath, {
|
|
132
151
|
normalize: true
|
|
133
152
|
});
|
|
@@ -135,30 +154,33 @@ async function isolatePackage(packageSpec, options) {
|
|
|
135
154
|
const realInstalledPath = await resolveRealPath(installedPath);
|
|
136
155
|
const realSourcePath = await resolveRealPath(sourcePath);
|
|
137
156
|
if (realSourcePath !== realInstalledPath) {
|
|
138
|
-
await
|
|
157
|
+
await fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
|
|
139
158
|
}
|
|
140
159
|
}
|
|
141
160
|
} else {
|
|
142
161
|
if (!sourcePath) {
|
|
143
162
|
throw new Error("sourcePath is required when no version spec provided");
|
|
144
163
|
}
|
|
145
|
-
const scopedPath = packageName.startsWith("@") ?
|
|
164
|
+
const scopedPath = packageName.startsWith("@") ? path.join(
|
|
146
165
|
packageTempDir,
|
|
147
166
|
"node_modules",
|
|
148
167
|
packageName.split("/")[0] ?? ""
|
|
149
|
-
) :
|
|
150
|
-
await
|
|
151
|
-
installedPath =
|
|
152
|
-
await
|
|
168
|
+
) : path.join(packageTempDir, "node_modules");
|
|
169
|
+
await fs.promises.mkdir(scopedPath, { recursive: true });
|
|
170
|
+
installedPath = path.join(packageTempDir, "node_modules", packageName);
|
|
171
|
+
await fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
|
|
153
172
|
}
|
|
154
173
|
if (onPackageJson || originalPackageJson) {
|
|
155
|
-
const pkgJsonPath =
|
|
174
|
+
const pkgJsonPath = path.join(installedPath, "package.json");
|
|
156
175
|
const mergedPkgJson = await mergePackageJson(
|
|
157
176
|
pkgJsonPath,
|
|
158
177
|
originalPackageJson
|
|
159
178
|
);
|
|
160
179
|
const finalPkgJson = onPackageJson ? await onPackageJson(mergedPkgJson) : mergedPkgJson;
|
|
161
|
-
await
|
|
180
|
+
await fs.promises.writeFile(
|
|
181
|
+
pkgJsonPath,
|
|
182
|
+
JSON.stringify(finalPkgJson, null, 2)
|
|
183
|
+
);
|
|
162
184
|
}
|
|
163
185
|
if (install) {
|
|
164
186
|
await install(installedPath);
|
|
@@ -172,7 +194,7 @@ async function isolatePackage(packageSpec, options) {
|
|
|
172
194
|
const exports2 = imports ? { __proto__: null } : void 0;
|
|
173
195
|
if (imports) {
|
|
174
196
|
for (const { 0: key, 1: specifier } of Object.entries(imports)) {
|
|
175
|
-
const fullPath =
|
|
197
|
+
const fullPath = path.join(installedPath, specifier);
|
|
176
198
|
exports2[key] = require(fullPath);
|
|
177
199
|
}
|
|
178
200
|
}
|
|
@@ -41,12 +41,19 @@ __export(licenses_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(licenses_exports);
|
|
42
42
|
var import_core = require("../constants/core");
|
|
43
43
|
var import_licenses = require("../constants/licenses");
|
|
44
|
-
var import_node_path = __toESM(require("node:path"));
|
|
45
44
|
var import_spdx_correct = __toESM(require("../external/spdx-correct"));
|
|
46
45
|
var import_spdx_expression_parse = __toESM(require("../external/spdx-expression-parse"));
|
|
47
46
|
var import_objects = require("../objects");
|
|
48
47
|
var import_normalize = require("../paths/normalize");
|
|
49
48
|
const copyLeftLicenses = (0, import_licenses.getCopyLeftLicenses)();
|
|
49
|
+
let _path;
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function getPath() {
|
|
52
|
+
if (_path === void 0) {
|
|
53
|
+
_path = require("path");
|
|
54
|
+
}
|
|
55
|
+
return _path;
|
|
56
|
+
}
|
|
50
57
|
const BINARY_OPERATION_NODE_TYPE = "BinaryOperation";
|
|
51
58
|
const LICENSE_NODE_TYPE = "License";
|
|
52
59
|
const fileReferenceRegExp = /^SEE LICEN[CS]E IN (.+)$/;
|
|
@@ -133,10 +140,11 @@ function resolvePackageLicenses(licenseFieldValue, where) {
|
|
|
133
140
|
}
|
|
134
141
|
const match = fileReferenceRegExp.exec(licenseFieldValue);
|
|
135
142
|
if (match) {
|
|
143
|
+
const path = /* @__PURE__ */ getPath();
|
|
136
144
|
return [
|
|
137
145
|
{
|
|
138
146
|
license: licenseFieldValue,
|
|
139
|
-
inFile: (0, import_normalize.normalizePath)(
|
|
147
|
+
inFile: (0, import_normalize.normalizePath)(path.relative(where, match[1] || ""))
|
|
140
148
|
}
|
|
141
149
|
];
|
|
142
150
|
}
|
package/dist/paths/socket.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare function getSocketRegistryGithubCacheDir(): string;
|
|
|
81
81
|
* Priority order:
|
|
82
82
|
* 1. HOME environment variable (Unix)
|
|
83
83
|
* 2. USERPROFILE environment variable (Windows)
|
|
84
|
-
* 3.
|
|
85
|
-
* 4. Fallback:
|
|
84
|
+
* 3. getOs().homedir()
|
|
85
|
+
* 4. Fallback: getOs().tmpdir() (rarely used, for restricted environments)
|
|
86
86
|
*/
|
|
87
87
|
export declare function getUserHomeDir(): string;
|
package/dist/paths/socket.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
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
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var socket_exports = {};
|
|
31
21
|
__export(socket_exports, {
|
|
@@ -44,8 +34,6 @@ __export(socket_exports, {
|
|
|
44
34
|
getUserHomeDir: () => getUserHomeDir
|
|
45
35
|
});
|
|
46
36
|
module.exports = __toCommonJS(socket_exports);
|
|
47
|
-
var os = __toESM(require("os"));
|
|
48
|
-
var path = __toESM(require("path"));
|
|
49
37
|
var import_github = require("../constants/github");
|
|
50
38
|
var import_socket = require("../constants/socket");
|
|
51
39
|
var import_home = require("../env/home");
|
|
@@ -54,11 +42,27 @@ var import_windows = require("../env/windows");
|
|
|
54
42
|
var import_dirnames = require("./dirnames");
|
|
55
43
|
var import_normalize = require("./normalize");
|
|
56
44
|
var import_rewire = require("./rewire");
|
|
45
|
+
let _os;
|
|
46
|
+
// @__NO_SIDE_EFFECTS__
|
|
47
|
+
function getOs() {
|
|
48
|
+
if (_os === void 0) {
|
|
49
|
+
_os = require("os");
|
|
50
|
+
}
|
|
51
|
+
return _os;
|
|
52
|
+
}
|
|
53
|
+
let _path;
|
|
54
|
+
// @__NO_SIDE_EFFECTS__
|
|
55
|
+
function getPath() {
|
|
56
|
+
if (_path === void 0) {
|
|
57
|
+
_path = require("path");
|
|
58
|
+
}
|
|
59
|
+
return _path;
|
|
60
|
+
}
|
|
57
61
|
function getOsHomeDir() {
|
|
58
|
-
return (0, import_rewire.getPathValue)("homedir", () =>
|
|
62
|
+
return (0, import_rewire.getPathValue)("homedir", () => (/* @__PURE__ */ getOs()).homedir());
|
|
59
63
|
}
|
|
60
64
|
function getOsTmpDir() {
|
|
61
|
-
return (0, import_rewire.getPathValue)("tmpdir", () =>
|
|
65
|
+
return (0, import_rewire.getPathValue)("tmpdir", () => (/* @__PURE__ */ getOs()).tmpdir());
|
|
62
66
|
}
|
|
63
67
|
function getSocketHomePath() {
|
|
64
68
|
return getSocketUserDir();
|
|
@@ -69,12 +73,12 @@ function getSocketUserDir() {
|
|
|
69
73
|
if (socketHome) {
|
|
70
74
|
return (0, import_normalize.normalizePath)(socketHome);
|
|
71
75
|
}
|
|
72
|
-
return (0, import_normalize.normalizePath)(
|
|
76
|
+
return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
79
|
function getSocketAppDir(appName) {
|
|
76
80
|
return (0, import_normalize.normalizePath)(
|
|
77
|
-
|
|
81
|
+
(/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
|
|
78
82
|
);
|
|
79
83
|
}
|
|
80
84
|
function getSocketCacacheDir() {
|
|
@@ -83,7 +87,7 @@ function getSocketCacacheDir() {
|
|
|
83
87
|
return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDir)());
|
|
84
88
|
}
|
|
85
89
|
return (0, import_normalize.normalizePath)(
|
|
86
|
-
|
|
90
|
+
(/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
|
|
87
91
|
);
|
|
88
92
|
});
|
|
89
93
|
}
|
|
@@ -93,7 +97,7 @@ function getSocketDlxDir() {
|
|
|
93
97
|
return (0, import_normalize.normalizePath)((0, import_socket2.getSocketDlxDirEnv)());
|
|
94
98
|
}
|
|
95
99
|
return (0, import_normalize.normalizePath)(
|
|
96
|
-
|
|
100
|
+
(/* @__PURE__ */ getPath()).join(
|
|
97
101
|
getSocketUserDir(),
|
|
98
102
|
`${import_socket.SOCKET_APP_PREFIX}${import_socket.SOCKET_DLX_APP_NAME}`
|
|
99
103
|
)
|
|
@@ -101,10 +105,12 @@ function getSocketDlxDir() {
|
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
107
|
function getSocketAppCacheDir(appName) {
|
|
104
|
-
return (0, import_normalize.normalizePath)(
|
|
108
|
+
return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
|
|
105
109
|
}
|
|
106
110
|
function getSocketAppCacheTtlDir(appName) {
|
|
107
|
-
return (0, import_normalize.normalizePath)(
|
|
111
|
+
return (0, import_normalize.normalizePath)(
|
|
112
|
+
(/* @__PURE__ */ getPath()).join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR)
|
|
113
|
+
);
|
|
108
114
|
}
|
|
109
115
|
function getSocketCliDir() {
|
|
110
116
|
return getSocketAppDir(import_socket.SOCKET_CLI_APP_NAME);
|
|
@@ -114,7 +120,7 @@ function getSocketRegistryDir() {
|
|
|
114
120
|
}
|
|
115
121
|
function getSocketRegistryGithubCacheDir() {
|
|
116
122
|
return (0, import_normalize.normalizePath)(
|
|
117
|
-
|
|
123
|
+
(/* @__PURE__ */ getPath()).join(
|
|
118
124
|
getSocketAppCacheTtlDir(import_socket.SOCKET_REGISTRY_APP_NAME),
|
|
119
125
|
import_github.CACHE_GITHUB_DIR
|
|
120
126
|
)
|