@socketsecurity/lib 5.2.0 → 5.3.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 +23 -0
- package/dist/bin.d.ts +0 -9
- package/dist/bin.js +70 -48
- package/dist/constants/agents.js +2 -2
- package/dist/constants/platform.d.ts +21 -0
- package/dist/constants/platform.js +30 -6
- package/dist/cover/code.js +1 -1
- package/dist/debug.js +1 -1
- package/dist/dlx/binary.d.ts +1 -1
- package/dist/dlx/binary.js +49 -39
- package/dist/dlx/dir.js +1 -1
- package/dist/dlx/manifest.d.ts +2 -1
- package/dist/dlx/package.js +39 -19
- package/dist/dlx/packages.js +1 -1
- package/dist/dlx/paths.js +1 -1
- package/dist/fs.js +3 -3
- package/dist/git.js +41 -38
- package/dist/http-request.js +2 -2
- package/dist/json/edit.js +1 -1
- package/dist/json/format.js +1 -1
- package/dist/logger.js +1 -1
- package/dist/packages/edit.js +3 -3
- package/dist/paths/normalize.js +3 -3
- package/dist/paths/packages.js +1 -1
- package/dist/promises.js +1 -1
- package/dist/releases/github.d.ts +54 -135
- package/dist/releases/github.js +107 -106
- package/dist/releases/socket-btm.d.ts +54 -175
- package/dist/releases/socket-btm.js +70 -48
- package/dist/signal-exit.js +1 -1
- package/dist/spawn.js +1 -1
- package/package.json +3 -3
package/dist/dlx/binary.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 binary_exports = {};
|
|
31
21
|
__export(binary_exports, {
|
|
@@ -37,9 +27,6 @@ __export(binary_exports, {
|
|
|
37
27
|
listDlxCache: () => listDlxCache
|
|
38
28
|
});
|
|
39
29
|
module.exports = __toCommonJS(binary_exports);
|
|
40
|
-
var import_crypto = require("crypto");
|
|
41
|
-
var import_os = __toESM(require("os"));
|
|
42
|
-
var import_path = __toESM(require("path"));
|
|
43
30
|
var import_platform = require("../constants/platform");
|
|
44
31
|
var import_time = require("../constants/time");
|
|
45
32
|
var import_cache = require("./cache");
|
|
@@ -51,16 +38,32 @@ var import_normalize = require("../paths/normalize");
|
|
|
51
38
|
var import_socket = require("../paths/socket");
|
|
52
39
|
var import_process_lock = require("../process-lock");
|
|
53
40
|
var import_spawn = require("../spawn");
|
|
41
|
+
let _crypto;
|
|
42
|
+
// @__NO_SIDE_EFFECTS__
|
|
43
|
+
function getCrypto() {
|
|
44
|
+
if (_crypto === void 0) {
|
|
45
|
+
_crypto = require("crypto");
|
|
46
|
+
}
|
|
47
|
+
return _crypto;
|
|
48
|
+
}
|
|
54
49
|
let _fs;
|
|
55
50
|
// @__NO_SIDE_EFFECTS__
|
|
56
51
|
function getFs() {
|
|
57
52
|
if (_fs === void 0) {
|
|
58
|
-
_fs = require("
|
|
53
|
+
_fs = require("fs");
|
|
59
54
|
}
|
|
60
55
|
return _fs;
|
|
61
56
|
}
|
|
57
|
+
let _path;
|
|
58
|
+
// @__NO_SIDE_EFFECTS__
|
|
59
|
+
function getPath() {
|
|
60
|
+
if (_path === void 0) {
|
|
61
|
+
_path = require("path");
|
|
62
|
+
}
|
|
63
|
+
return _path;
|
|
64
|
+
}
|
|
62
65
|
function getMetadataPath(cacheEntryPath) {
|
|
63
|
-
return
|
|
66
|
+
return (/* @__PURE__ */ getPath()).join(cacheEntryPath, ".dlx-metadata.json");
|
|
64
67
|
}
|
|
65
68
|
async function isCacheValid(cacheEntryPath, cacheTtl) {
|
|
66
69
|
const fs = /* @__PURE__ */ getFs();
|
|
@@ -85,17 +88,19 @@ async function isCacheValid(cacheEntryPath, cacheTtl) {
|
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
async function downloadBinaryFile(url, destPath, checksum) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
91
|
+
const crypto = /* @__PURE__ */ getCrypto();
|
|
92
|
+
const fs = /* @__PURE__ */ getFs();
|
|
93
|
+
const path = /* @__PURE__ */ getPath();
|
|
94
|
+
const cacheEntryDir = path.dirname(destPath);
|
|
95
|
+
const lockPath = path.join(cacheEntryDir, "concurrency.lock");
|
|
90
96
|
return await import_process_lock.processLock.withLock(
|
|
91
97
|
lockPath,
|
|
92
98
|
async () => {
|
|
93
|
-
const fs = /* @__PURE__ */ getFs();
|
|
94
99
|
if (fs.existsSync(destPath)) {
|
|
95
100
|
const stats = await fs.promises.stat(destPath);
|
|
96
101
|
if (stats.size > 0) {
|
|
97
102
|
const fileBuffer2 = await fs.promises.readFile(destPath);
|
|
98
|
-
const hasher2 =
|
|
103
|
+
const hasher2 = crypto.createHash("sha256");
|
|
99
104
|
hasher2.update(fileBuffer2);
|
|
100
105
|
return hasher2.digest("hex");
|
|
101
106
|
}
|
|
@@ -111,7 +116,7 @@ Check your internet connection or verify the URL is accessible.`,
|
|
|
111
116
|
);
|
|
112
117
|
}
|
|
113
118
|
const fileBuffer = await fs.promises.readFile(destPath);
|
|
114
|
-
const hasher =
|
|
119
|
+
const hasher = crypto.createHash("sha256");
|
|
115
120
|
hasher.update(fileBuffer);
|
|
116
121
|
const actualChecksum = hasher.digest("hex");
|
|
117
122
|
if (checksum && actualChecksum !== checksum) {
|
|
@@ -140,8 +145,8 @@ async function writeMetadata(cacheEntryPath, cacheKey, url, binaryName, checksum
|
|
|
140
145
|
timestamp: Date.now(),
|
|
141
146
|
checksum,
|
|
142
147
|
checksum_algorithm: "sha256",
|
|
143
|
-
platform:
|
|
144
|
-
arch:
|
|
148
|
+
platform: (0, import_platform.getPlatform)(),
|
|
149
|
+
arch: (0, import_platform.getArch)(),
|
|
145
150
|
size,
|
|
146
151
|
source: {
|
|
147
152
|
type: "download",
|
|
@@ -154,9 +159,9 @@ async function writeMetadata(cacheEntryPath, cacheKey, url, binaryName, checksum
|
|
|
154
159
|
const spec = `${url}:${binaryName}`;
|
|
155
160
|
await import_manifest.dlxManifest.setBinaryEntry(spec, cacheKey, {
|
|
156
161
|
checksum,
|
|
157
|
-
checksum_algorithm:
|
|
158
|
-
platform:
|
|
159
|
-
arch:
|
|
162
|
+
checksum_algorithm: metadata.checksum_algorithm,
|
|
163
|
+
platform: metadata.platform,
|
|
164
|
+
arch: metadata.arch,
|
|
160
165
|
size,
|
|
161
166
|
source: {
|
|
162
167
|
type: "download",
|
|
@@ -174,9 +179,10 @@ async function cleanDlxCache(maxAge = import_time.DLX_BINARY_CACHE_TTL) {
|
|
|
174
179
|
}
|
|
175
180
|
let cleaned = 0;
|
|
176
181
|
const now = Date.now();
|
|
182
|
+
const path = /* @__PURE__ */ getPath();
|
|
177
183
|
const entries = await fs.promises.readdir(cacheDir);
|
|
178
184
|
for (const entry of entries) {
|
|
179
|
-
const entryPath =
|
|
185
|
+
const entryPath = path.join(cacheDir, entry);
|
|
180
186
|
const metaPath = getMetadataPath(entryPath);
|
|
181
187
|
try {
|
|
182
188
|
if (!await (0, import_fs.isDir)(entryPath)) {
|
|
@@ -215,14 +221,15 @@ async function dlxBinary(args, options, spawnExtra) {
|
|
|
215
221
|
url,
|
|
216
222
|
yes
|
|
217
223
|
} = { __proto__: null, ...options };
|
|
224
|
+
const fs = /* @__PURE__ */ getFs();
|
|
225
|
+
const path = /* @__PURE__ */ getPath();
|
|
218
226
|
const force = yes === true ? true : userForce;
|
|
219
227
|
const cacheDir = getDlxCachePath();
|
|
220
|
-
const binaryName = name || `binary-${process.platform}-${
|
|
228
|
+
const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
|
|
221
229
|
const spec = `${url}:${binaryName}`;
|
|
222
230
|
const cacheKey = (0, import_cache.generateCacheKey)(spec);
|
|
223
|
-
const cacheEntryDir =
|
|
224
|
-
const binaryPath = (0, import_normalize.normalizePath)(
|
|
225
|
-
const fs = /* @__PURE__ */ getFs();
|
|
231
|
+
const cacheEntryDir = path.join(cacheDir, cacheKey);
|
|
232
|
+
const binaryPath = (0, import_normalize.normalizePath)(path.join(cacheEntryDir, binaryName));
|
|
226
233
|
let downloaded = false;
|
|
227
234
|
let computedChecksum = checksum;
|
|
228
235
|
if (!force && fs.existsSync(cacheEntryDir) && await isCacheValid(cacheEntryDir, cacheTtl)) {
|
|
@@ -280,7 +287,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
|
|
|
280
287
|
...spawnOptions,
|
|
281
288
|
env: {
|
|
282
289
|
...spawnOptions?.env,
|
|
283
|
-
PATH: `${cacheEntryDir}${
|
|
290
|
+
PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${process.env["PATH"] || ""}`
|
|
284
291
|
},
|
|
285
292
|
shell: true
|
|
286
293
|
} : spawnOptions;
|
|
@@ -299,13 +306,14 @@ async function downloadBinary(options) {
|
|
|
299
306
|
name,
|
|
300
307
|
url
|
|
301
308
|
} = { __proto__: null, ...options };
|
|
309
|
+
const fs = /* @__PURE__ */ getFs();
|
|
310
|
+
const path = /* @__PURE__ */ getPath();
|
|
302
311
|
const cacheDir = getDlxCachePath();
|
|
303
|
-
const binaryName = name || `binary-${process.platform}-${
|
|
312
|
+
const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
|
|
304
313
|
const spec = `${url}:${binaryName}`;
|
|
305
314
|
const cacheKey = (0, import_cache.generateCacheKey)(spec);
|
|
306
|
-
const cacheEntryDir =
|
|
307
|
-
const binaryPath = (0, import_normalize.normalizePath)(
|
|
308
|
-
const fs = /* @__PURE__ */ getFs();
|
|
315
|
+
const cacheEntryDir = path.join(cacheDir, cacheKey);
|
|
316
|
+
const binaryPath = (0, import_normalize.normalizePath)(path.join(cacheEntryDir, binaryName));
|
|
309
317
|
let downloaded = false;
|
|
310
318
|
if (!force && fs.existsSync(cacheEntryDir) && await isCacheValid(cacheEntryDir, cacheTtl)) {
|
|
311
319
|
downloaded = false;
|
|
@@ -352,12 +360,13 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
|
|
|
352
360
|
}
|
|
353
361
|
function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
|
|
354
362
|
const needsShell = import_platform.WIN32 && /\.(?:bat|cmd|ps1)$/i.test(binaryPath);
|
|
355
|
-
const
|
|
363
|
+
const path = /* @__PURE__ */ getPath();
|
|
364
|
+
const cacheEntryDir = path.dirname(binaryPath);
|
|
356
365
|
const finalSpawnOptions = needsShell ? {
|
|
357
366
|
...spawnOptions,
|
|
358
367
|
env: {
|
|
359
368
|
...spawnOptions?.env,
|
|
360
|
-
PATH: `${cacheEntryDir}${
|
|
369
|
+
PATH: `${cacheEntryDir}${path.delimiter}${process.env["PATH"] || ""}`
|
|
361
370
|
},
|
|
362
371
|
shell: true
|
|
363
372
|
} : spawnOptions;
|
|
@@ -374,9 +383,10 @@ async function listDlxCache() {
|
|
|
374
383
|
}
|
|
375
384
|
const results = [];
|
|
376
385
|
const now = Date.now();
|
|
386
|
+
const path = /* @__PURE__ */ getPath();
|
|
377
387
|
const entries = await fs.promises.readdir(cacheDir);
|
|
378
388
|
for (const entry of entries) {
|
|
379
|
-
const entryPath =
|
|
389
|
+
const entryPath = path.join(cacheDir, entry);
|
|
380
390
|
try {
|
|
381
391
|
if (!await (0, import_fs.isDir)(entryPath)) {
|
|
382
392
|
continue;
|
|
@@ -392,7 +402,7 @@ async function listDlxCache() {
|
|
|
392
402
|
const files = await fs.promises.readdir(entryPath);
|
|
393
403
|
const binaryFile = files.find((f) => !f.startsWith("."));
|
|
394
404
|
if (binaryFile) {
|
|
395
|
-
const binaryPath =
|
|
405
|
+
const binaryPath = path.join(entryPath, binaryFile);
|
|
396
406
|
const binaryStats = await fs.promises.stat(binaryPath);
|
|
397
407
|
results.push({
|
|
398
408
|
age: now - (metaObj["timestamp"] || 0),
|
package/dist/dlx/dir.js
CHANGED
package/dist/dlx/manifest.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface PackageDetails {
|
|
|
15
15
|
*/
|
|
16
16
|
export interface BinaryDetails {
|
|
17
17
|
checksum: string;
|
|
18
|
-
checksum_algorithm:
|
|
18
|
+
checksum_algorithm: ChecksumAlgorithm;
|
|
19
19
|
platform: string;
|
|
20
20
|
arch: string;
|
|
21
21
|
size: number;
|
|
@@ -24,6 +24,7 @@ export interface BinaryDetails {
|
|
|
24
24
|
url: string;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
export type ChecksumAlgorithm = 'sha256' | 'sha512';
|
|
27
28
|
/**
|
|
28
29
|
* Unified manifest entry for all cached items (packages and binaries).
|
|
29
30
|
* Shared fields at root, type-specific fields in details.
|
package/dist/dlx/package.js
CHANGED
|
@@ -34,8 +34,6 @@ __export(package_exports, {
|
|
|
34
34
|
executePackage: () => executePackage
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(package_exports);
|
|
37
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
39
37
|
var import_platform = require("../constants/platform");
|
|
40
38
|
var import_packages = require("../constants/packages");
|
|
41
39
|
var import_cache = require("./cache");
|
|
@@ -48,6 +46,22 @@ var import_normalize = require("../paths/normalize");
|
|
|
48
46
|
var import_socket = require("../paths/socket");
|
|
49
47
|
var import_process_lock = require("../process-lock");
|
|
50
48
|
var import_spawn = require("../spawn");
|
|
49
|
+
let _fs;
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function getFs() {
|
|
52
|
+
if (_fs === void 0) {
|
|
53
|
+
_fs = require("fs");
|
|
54
|
+
}
|
|
55
|
+
return _fs;
|
|
56
|
+
}
|
|
57
|
+
let _path;
|
|
58
|
+
// @__NO_SIDE_EFFECTS__
|
|
59
|
+
function getPath() {
|
|
60
|
+
if (_path === void 0) {
|
|
61
|
+
_path = require("path");
|
|
62
|
+
}
|
|
63
|
+
return _path;
|
|
64
|
+
}
|
|
51
65
|
const rangeOperatorsRegExp = /[~^><=xX* ]|\|\|/;
|
|
52
66
|
function parsePackageSpec(spec) {
|
|
53
67
|
try {
|
|
@@ -69,10 +83,12 @@ function parsePackageSpec(spec) {
|
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
async function ensurePackageInstalled(packageName, packageSpec, force) {
|
|
86
|
+
const fs = /* @__PURE__ */ getFs();
|
|
87
|
+
const path = /* @__PURE__ */ getPath();
|
|
72
88
|
const cacheKey = (0, import_cache.generateCacheKey)(packageSpec);
|
|
73
|
-
const packageDir = (0, import_normalize.normalizePath)(
|
|
89
|
+
const packageDir = (0, import_normalize.normalizePath)(path.join((0, import_socket.getSocketDlxDir)(), cacheKey));
|
|
74
90
|
const installedDir = (0, import_normalize.normalizePath)(
|
|
75
|
-
|
|
91
|
+
path.join(packageDir, "node_modules", packageName)
|
|
76
92
|
);
|
|
77
93
|
try {
|
|
78
94
|
await (0, import_fs.safeMkdir)(packageDir);
|
|
@@ -96,13 +112,13 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
|
|
|
96
112
|
cause: e
|
|
97
113
|
});
|
|
98
114
|
}
|
|
99
|
-
const lockPath =
|
|
115
|
+
const lockPath = path.join(packageDir, "concurrency.lock");
|
|
100
116
|
return await import_process_lock.processLock.withLock(
|
|
101
117
|
lockPath,
|
|
102
118
|
async () => {
|
|
103
|
-
if (!force &&
|
|
104
|
-
const pkgJsonPath =
|
|
105
|
-
if (
|
|
119
|
+
if (!force && fs.existsSync(installedDir)) {
|
|
120
|
+
const pkgJsonPath = path.join(installedDir, "package.json");
|
|
121
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
106
122
|
return { installed: false, packageDir };
|
|
107
123
|
}
|
|
108
124
|
}
|
|
@@ -110,11 +126,11 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
|
|
|
110
126
|
try {
|
|
111
127
|
await import_pacote.default.extract(packageSpec, installedDir, {
|
|
112
128
|
// Use consistent pacote cache path (respects npm cache locations when available).
|
|
113
|
-
cache: pacoteCachePath ||
|
|
129
|
+
cache: pacoteCachePath || path.join(packageDir, ".cache")
|
|
114
130
|
});
|
|
115
131
|
const arb = new import_arborist.default({
|
|
116
132
|
path: installedDir,
|
|
117
|
-
cache: pacoteCachePath ||
|
|
133
|
+
cache: pacoteCachePath || path.join(packageDir, ".cache"),
|
|
118
134
|
// Skip devDependencies (production-only like npx).
|
|
119
135
|
omit: ["dev"],
|
|
120
136
|
// Security: Skip install/preinstall/postinstall scripts to prevent arbitrary code execution.
|
|
@@ -167,20 +183,22 @@ function resolveBinaryPath(basePath) {
|
|
|
167
183
|
if (!import_platform.WIN32) {
|
|
168
184
|
return basePath;
|
|
169
185
|
}
|
|
186
|
+
const fs = /* @__PURE__ */ getFs();
|
|
170
187
|
const extensions = [".cmd", ".bat", ".ps1", ".exe", ""];
|
|
171
188
|
for (const ext of extensions) {
|
|
172
189
|
const testPath = basePath + ext;
|
|
173
|
-
if (
|
|
190
|
+
if (fs.existsSync(testPath)) {
|
|
174
191
|
return testPath;
|
|
175
192
|
}
|
|
176
193
|
}
|
|
177
194
|
return basePath;
|
|
178
195
|
}
|
|
179
196
|
function findBinaryPath(packageDir, packageName, binaryName) {
|
|
197
|
+
const path = /* @__PURE__ */ getPath();
|
|
180
198
|
const installedDir = (0, import_normalize.normalizePath)(
|
|
181
|
-
|
|
199
|
+
path.join(packageDir, "node_modules", packageName)
|
|
182
200
|
);
|
|
183
|
-
const pkgJsonPath =
|
|
201
|
+
const pkgJsonPath = path.join(installedDir, "package.json");
|
|
184
202
|
const pkgJson = (0, import_fs.readJsonSync)(pkgJsonPath);
|
|
185
203
|
const bin = pkgJson["bin"];
|
|
186
204
|
let binName;
|
|
@@ -226,7 +244,7 @@ function findBinaryPath(packageDir, packageName, binaryName) {
|
|
|
226
244
|
if (!binPath) {
|
|
227
245
|
throw new Error(`No binary found for package "${packageName}"`);
|
|
228
246
|
}
|
|
229
|
-
const rawPath = (0, import_normalize.normalizePath)(
|
|
247
|
+
const rawPath = (0, import_normalize.normalizePath)(path.join(installedDir, binPath));
|
|
230
248
|
return resolveBinaryPath(rawPath);
|
|
231
249
|
}
|
|
232
250
|
async function dlxPackage(args, options, spawnExtra) {
|
|
@@ -246,10 +264,12 @@ function makePackageBinsExecutable(packageDir, packageName) {
|
|
|
246
264
|
if (import_platform.WIN32) {
|
|
247
265
|
return;
|
|
248
266
|
}
|
|
267
|
+
const fs = /* @__PURE__ */ getFs();
|
|
268
|
+
const path = /* @__PURE__ */ getPath();
|
|
249
269
|
const installedDir = (0, import_normalize.normalizePath)(
|
|
250
|
-
|
|
270
|
+
path.join(packageDir, "node_modules", packageName)
|
|
251
271
|
);
|
|
252
|
-
const pkgJsonPath =
|
|
272
|
+
const pkgJsonPath = path.join(installedDir, "package.json");
|
|
253
273
|
try {
|
|
254
274
|
const pkgJson = (0, import_fs.readJsonSync)(pkgJsonPath);
|
|
255
275
|
const bin = pkgJson["bin"];
|
|
@@ -264,10 +284,10 @@ function makePackageBinsExecutable(packageDir, packageName) {
|
|
|
264
284
|
binPaths.push(...Object.values(binObj));
|
|
265
285
|
}
|
|
266
286
|
for (const binPath of binPaths) {
|
|
267
|
-
const fullPath = (0, import_normalize.normalizePath)(
|
|
268
|
-
if (
|
|
287
|
+
const fullPath = (0, import_normalize.normalizePath)(path.join(installedDir, binPath));
|
|
288
|
+
if (fs.existsSync(fullPath)) {
|
|
269
289
|
try {
|
|
270
|
-
|
|
290
|
+
fs.chmodSync(fullPath, 493);
|
|
271
291
|
} catch {
|
|
272
292
|
}
|
|
273
293
|
}
|
package/dist/dlx/packages.js
CHANGED
package/dist/dlx/paths.js
CHANGED
package/dist/fs.js
CHANGED
|
@@ -84,7 +84,7 @@ let _buffer;
|
|
|
84
84
|
// @__NO_SIDE_EFFECTS__
|
|
85
85
|
function getBuffer() {
|
|
86
86
|
if (_buffer === void 0) {
|
|
87
|
-
_buffer = require("
|
|
87
|
+
_buffer = require("buffer");
|
|
88
88
|
}
|
|
89
89
|
return _buffer;
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ let _fs;
|
|
|
92
92
|
// @__NO_SIDE_EFFECTS__
|
|
93
93
|
function getFs() {
|
|
94
94
|
if (_fs === void 0) {
|
|
95
|
-
_fs = require("
|
|
95
|
+
_fs = require("fs");
|
|
96
96
|
}
|
|
97
97
|
return _fs;
|
|
98
98
|
}
|
|
@@ -100,7 +100,7 @@ let _path;
|
|
|
100
100
|
// @__NO_SIDE_EFFECTS__
|
|
101
101
|
function getPath() {
|
|
102
102
|
if (_path === void 0) {
|
|
103
|
-
_path = require("
|
|
103
|
+
_path = require("path");
|
|
104
104
|
}
|
|
105
105
|
return _path;
|
|
106
106
|
}
|
package/dist/git.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 git_exports = {};
|
|
31
21
|
__export(git_exports, {
|
|
@@ -44,18 +34,16 @@ __export(git_exports, {
|
|
|
44
34
|
isUnstagedSync: () => isUnstagedSync
|
|
45
35
|
});
|
|
46
36
|
module.exports = __toCommonJS(git_exports);
|
|
47
|
-
var import_path = __toESM(require("path"));
|
|
48
37
|
var import_debug = require("./debug");
|
|
49
38
|
var import_globs = require("./globs");
|
|
50
39
|
var import_normalize = require("./paths/normalize");
|
|
51
40
|
var import_spawn = require("./spawn");
|
|
52
41
|
var import_strings = require("./strings");
|
|
53
|
-
const gitDiffCache = /* @__PURE__ */ new Map();
|
|
54
42
|
let _fs;
|
|
55
43
|
// @__NO_SIDE_EFFECTS__
|
|
56
44
|
function getFs() {
|
|
57
45
|
if (_fs === void 0) {
|
|
58
|
-
_fs = require("
|
|
46
|
+
_fs = require("fs");
|
|
59
47
|
}
|
|
60
48
|
return _fs;
|
|
61
49
|
}
|
|
@@ -63,10 +51,11 @@ let _path;
|
|
|
63
51
|
// @__NO_SIDE_EFFECTS__
|
|
64
52
|
function getPath() {
|
|
65
53
|
if (_path === void 0) {
|
|
66
|
-
_path = require("
|
|
54
|
+
_path = require("path");
|
|
67
55
|
}
|
|
68
56
|
return _path;
|
|
69
57
|
}
|
|
58
|
+
const gitDiffCache = /* @__PURE__ */ new Map();
|
|
70
59
|
function getGitPath() {
|
|
71
60
|
return "git";
|
|
72
61
|
}
|
|
@@ -161,17 +150,17 @@ function innerDiffSync(args, options) {
|
|
|
161
150
|
}
|
|
162
151
|
function findGitRoot(startPath) {
|
|
163
152
|
const fs = /* @__PURE__ */ getFs();
|
|
164
|
-
const
|
|
153
|
+
const path = /* @__PURE__ */ getPath();
|
|
165
154
|
let currentPath = startPath;
|
|
166
155
|
while (true) {
|
|
167
156
|
try {
|
|
168
|
-
const gitPath =
|
|
157
|
+
const gitPath = path.join(currentPath, ".git");
|
|
169
158
|
if (fs.existsSync(gitPath)) {
|
|
170
159
|
return currentPath;
|
|
171
160
|
}
|
|
172
161
|
} catch {
|
|
173
162
|
}
|
|
174
|
-
const parentPath =
|
|
163
|
+
const parentPath = path.dirname(currentPath);
|
|
175
164
|
if (parentPath === currentPath) {
|
|
176
165
|
return startPath;
|
|
177
166
|
}
|
|
@@ -186,7 +175,9 @@ function parseGitDiffStdout(stdout, options, spawnCwd) {
|
|
|
186
175
|
porcelain = false,
|
|
187
176
|
...matcherOptions
|
|
188
177
|
} = { __proto__: null, ...options };
|
|
189
|
-
const
|
|
178
|
+
const fs = /* @__PURE__ */ getFs();
|
|
179
|
+
const path = /* @__PURE__ */ getPath();
|
|
180
|
+
const cwd = cwdOption === defaultRoot ? defaultRoot : fs.realpathSync(cwdOption);
|
|
190
181
|
const rootPath = defaultRoot;
|
|
191
182
|
let rawFiles = stdout ? (0, import_strings.stripAnsi)(stdout).split("\n").map((line) => line.trimEnd()).filter((line) => line) : [];
|
|
192
183
|
if (porcelain) {
|
|
@@ -194,11 +185,11 @@ function parseGitDiffStdout(stdout, options, spawnCwd) {
|
|
|
194
185
|
return line.length > 3 ? line.substring(3) : line;
|
|
195
186
|
});
|
|
196
187
|
}
|
|
197
|
-
const files = absolute ? rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(
|
|
188
|
+
const files = absolute ? rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(path.join(rootPath, relPath2))) : rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(relPath2));
|
|
198
189
|
if (cwd === rootPath) {
|
|
199
190
|
return files;
|
|
200
191
|
}
|
|
201
|
-
const relPath = (0, import_normalize.normalizePath)(
|
|
192
|
+
const relPath = (0, import_normalize.normalizePath)(path.relative(rootPath, cwd));
|
|
202
193
|
const matcher = (0, import_globs.getGlobMatcher)([`${relPath}/**`], {
|
|
203
194
|
...matcherOptions,
|
|
204
195
|
absolute,
|
|
@@ -250,9 +241,11 @@ async function isChanged(pathname, options) {
|
|
|
250
241
|
...options,
|
|
251
242
|
absolute: false
|
|
252
243
|
});
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
const
|
|
244
|
+
const fs = /* @__PURE__ */ getFs();
|
|
245
|
+
const path = /* @__PURE__ */ getPath();
|
|
246
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
247
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
248
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
256
249
|
return files.includes(relativePath);
|
|
257
250
|
}
|
|
258
251
|
function isChangedSync(pathname, options) {
|
|
@@ -261,9 +254,11 @@ function isChangedSync(pathname, options) {
|
|
|
261
254
|
...options,
|
|
262
255
|
absolute: false
|
|
263
256
|
});
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
257
|
+
const fs = /* @__PURE__ */ getFs();
|
|
258
|
+
const path = /* @__PURE__ */ getPath();
|
|
259
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
260
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
261
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
267
262
|
return files.includes(relativePath);
|
|
268
263
|
}
|
|
269
264
|
async function isUnstaged(pathname, options) {
|
|
@@ -272,9 +267,11 @@ async function isUnstaged(pathname, options) {
|
|
|
272
267
|
...options,
|
|
273
268
|
absolute: false
|
|
274
269
|
});
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
const
|
|
270
|
+
const fs = /* @__PURE__ */ getFs();
|
|
271
|
+
const path = /* @__PURE__ */ getPath();
|
|
272
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
273
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
274
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
278
275
|
return files.includes(relativePath);
|
|
279
276
|
}
|
|
280
277
|
function isUnstagedSync(pathname, options) {
|
|
@@ -283,9 +280,11 @@ function isUnstagedSync(pathname, options) {
|
|
|
283
280
|
...options,
|
|
284
281
|
absolute: false
|
|
285
282
|
});
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
283
|
+
const fs = /* @__PURE__ */ getFs();
|
|
284
|
+
const path = /* @__PURE__ */ getPath();
|
|
285
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
286
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
287
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
289
288
|
return files.includes(relativePath);
|
|
290
289
|
}
|
|
291
290
|
async function isStaged(pathname, options) {
|
|
@@ -294,9 +293,11 @@ async function isStaged(pathname, options) {
|
|
|
294
293
|
...options,
|
|
295
294
|
absolute: false
|
|
296
295
|
});
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
const
|
|
296
|
+
const fs = /* @__PURE__ */ getFs();
|
|
297
|
+
const path = /* @__PURE__ */ getPath();
|
|
298
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
299
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
300
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
300
301
|
return files.includes(relativePath);
|
|
301
302
|
}
|
|
302
303
|
function isStagedSync(pathname, options) {
|
|
@@ -305,9 +306,11 @@ function isStagedSync(pathname, options) {
|
|
|
305
306
|
...options,
|
|
306
307
|
absolute: false
|
|
307
308
|
});
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const
|
|
309
|
+
const fs = /* @__PURE__ */ getFs();
|
|
310
|
+
const path = /* @__PURE__ */ getPath();
|
|
311
|
+
const resolvedPathname = fs.realpathSync(pathname);
|
|
312
|
+
const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
|
|
313
|
+
const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
|
|
311
314
|
return files.includes(relativePath);
|
|
312
315
|
}
|
|
313
316
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/http-request.js
CHANGED
|
@@ -31,14 +31,14 @@ let _https;
|
|
|
31
31
|
// @__NO_SIDE_EFFECTS__
|
|
32
32
|
function getHttp() {
|
|
33
33
|
if (_http === void 0) {
|
|
34
|
-
_http = require("
|
|
34
|
+
_http = require("http");
|
|
35
35
|
}
|
|
36
36
|
return _http;
|
|
37
37
|
}
|
|
38
38
|
// @__NO_SIDE_EFFECTS__
|
|
39
39
|
function getHttps() {
|
|
40
40
|
if (_https === void 0) {
|
|
41
|
-
_https = require("
|
|
41
|
+
_https = require("https");
|
|
42
42
|
}
|
|
43
43
|
return _https;
|
|
44
44
|
}
|
package/dist/json/edit.js
CHANGED
package/dist/json/format.js
CHANGED
|
@@ -98,7 +98,7 @@ function shouldSave(currentContent, originalContent, originalFileContent, option
|
|
|
98
98
|
const sortedContent = sortFn ? sortFn(content) : sort ? sortKeys(content) : content;
|
|
99
99
|
const origContent = originalContent ? stripFormattingSymbols(originalContent) : {};
|
|
100
100
|
if (ignoreWhitespace) {
|
|
101
|
-
const util = require("
|
|
101
|
+
const util = require("util");
|
|
102
102
|
return !util.isDeepStrictEqual(sortedContent, origContent);
|
|
103
103
|
}
|
|
104
104
|
const formatting = getFormattingFromContent(currentContent);
|