@socketsecurity/lib 5.11.1 → 5.11.3
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 +20 -0
- package/dist/abort.js +1 -3
- package/dist/agent.js +12 -1
- package/dist/ansi.js +1 -1
- package/dist/archives.js +7 -6
- package/dist/argv/flags.d.ts +0 -7
- package/dist/argv/flags.js +12 -1
- package/dist/argv/parse.js +5 -9
- package/dist/bin.js +2 -1
- package/dist/cache-with-ttl.js +10 -3
- package/dist/constants/node.js +14 -3
- package/dist/cover/code.js +13 -2
- package/dist/cover/type.js +12 -1
- package/dist/dlx/binary.js +16 -5
- package/dist/dlx/manifest.js +22 -33
- package/dist/env/package-manager.js +12 -1
- package/dist/env/rewire.js +14 -3
- package/dist/external/@npmcli/package-json.js +5 -3
- package/dist/external/adm-zip.js +1 -0
- package/dist/external/debug.js +18 -10
- package/dist/external/external-pack.js +8 -2
- package/dist/external/libnpmexec.js +2 -2
- package/dist/external/npm-pack.js +380 -367
- package/dist/external/p-map.js +240 -0
- package/dist/external/pico-pack.js +245 -12
- package/dist/external/zod.js +1 -0
- package/dist/fs.d.ts +0 -4
- package/dist/fs.js +13 -2
- package/dist/git.js +12 -1
- package/dist/github.js +15 -6
- package/dist/http-request.d.ts +29 -0
- package/dist/http-request.js +23 -2
- package/dist/ipc.js +17 -5
- package/dist/json/edit.js +14 -3
- package/dist/logger.js +5 -4
- package/dist/memoization.js +46 -13
- package/dist/packages/isolation.js +9 -1
- package/dist/performance.js +13 -2
- package/dist/process-lock.js +16 -3
- package/dist/promise-queue.d.ts +2 -0
- package/dist/promise-queue.js +20 -9
- package/dist/promises.js +1 -3
- package/dist/releases/github.js +9 -4
- package/dist/sea.js +12 -1
- package/dist/shadow.js +14 -3
- package/dist/spawn.js +5 -4
- package/dist/spinner.d.ts +0 -4
- package/dist/spinner.js +2 -1
- package/dist/stdio/clear.d.ts +0 -21
- package/dist/stdio/clear.js +20 -9
- package/dist/stdio/mask.js +27 -16
- package/dist/stdio/progress.js +3 -2
- package/dist/stdio/stderr.d.ts +0 -13
- package/dist/stdio/stderr.js +12 -1
- package/dist/stdio/stdout.js +17 -6
- package/dist/suppress-warnings.d.ts +0 -9
- package/dist/suppress-warnings.js +17 -6
- package/dist/temporary-executor.js +14 -3
- package/dist/validation/json-parser.js +10 -12
- package/package.json +8 -6
package/dist/promise-queue.js
CHANGED
|
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(promise_queue_exports);
|
|
|
25
25
|
class PromiseQueue {
|
|
26
26
|
queue = [];
|
|
27
27
|
running = 0;
|
|
28
|
+
idleResolvers = [];
|
|
28
29
|
maxConcurrency;
|
|
29
30
|
maxQueueLength;
|
|
30
31
|
/**
|
|
@@ -47,7 +48,7 @@ class PromiseQueue {
|
|
|
47
48
|
async add(fn) {
|
|
48
49
|
return await new Promise((resolve, reject) => {
|
|
49
50
|
const task = { fn, resolve, reject };
|
|
50
|
-
if (this.maxQueueLength && this.queue.length >= this.maxQueueLength) {
|
|
51
|
+
if (this.maxQueueLength !== void 0 && this.queue.length >= this.maxQueueLength) {
|
|
51
52
|
const droppedTask = this.queue.shift();
|
|
52
53
|
if (droppedTask) {
|
|
53
54
|
droppedTask.reject(new Error("Task dropped: queue length exceeded"));
|
|
@@ -59,6 +60,7 @@ class PromiseQueue {
|
|
|
59
60
|
}
|
|
60
61
|
runNext() {
|
|
61
62
|
if (this.running >= this.maxConcurrency || this.queue.length === 0) {
|
|
63
|
+
this.notifyIdleIfNeeded();
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
64
66
|
const task = this.queue.shift();
|
|
@@ -71,19 +73,23 @@ class PromiseQueue {
|
|
|
71
73
|
this.runNext();
|
|
72
74
|
});
|
|
73
75
|
}
|
|
76
|
+
notifyIdleIfNeeded() {
|
|
77
|
+
if (this.running === 0 && this.queue.length === 0) {
|
|
78
|
+
for (const resolve of this.idleResolvers) {
|
|
79
|
+
resolve();
|
|
80
|
+
}
|
|
81
|
+
this.idleResolvers = [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
/**
|
|
75
85
|
* Wait for all queued and running tasks to complete
|
|
76
86
|
*/
|
|
77
87
|
async onIdle() {
|
|
88
|
+
if (this.running === 0 && this.queue.length === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
78
91
|
return await new Promise((resolve) => {
|
|
79
|
-
|
|
80
|
-
if (this.running === 0 && this.queue.length === 0) {
|
|
81
|
-
resolve();
|
|
82
|
-
} else {
|
|
83
|
-
setImmediate(check);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
check();
|
|
92
|
+
this.idleResolvers.push(resolve);
|
|
87
93
|
});
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
@@ -102,7 +108,12 @@ class PromiseQueue {
|
|
|
102
108
|
* Clear all pending tasks from the queue (does not affect running tasks)
|
|
103
109
|
*/
|
|
104
110
|
clear() {
|
|
111
|
+
const pending = this.queue;
|
|
105
112
|
this.queue = [];
|
|
113
|
+
for (const task of pending) {
|
|
114
|
+
task.reject(new Error("Task cancelled: queue cleared"));
|
|
115
|
+
}
|
|
116
|
+
this.notifyIdleIfNeeded();
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
119
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/promises.js
CHANGED
|
@@ -203,9 +203,7 @@ async function pRetry(callbackFn, options) {
|
|
|
203
203
|
try {
|
|
204
204
|
return await callbackFn(...args || [], { signal });
|
|
205
205
|
} catch (e) {
|
|
206
|
-
|
|
207
|
-
error = e;
|
|
208
|
-
}
|
|
206
|
+
error = e;
|
|
209
207
|
if (attempts < 0) {
|
|
210
208
|
break;
|
|
211
209
|
}
|
package/dist/releases/github.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(github_exports, {
|
|
|
40
40
|
getReleaseAssetUrl: () => getReleaseAssetUrl
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(github_exports);
|
|
43
|
+
var import_node_process = __toESM(require("node:process"));
|
|
43
44
|
var import_picomatch = __toESM(require("../external/picomatch.js"));
|
|
44
45
|
var import_archives = require("../archives.js");
|
|
45
46
|
var import_fs = require("../fs.js");
|
|
@@ -92,7 +93,7 @@ async function downloadGitHubRelease(config) {
|
|
|
92
93
|
const {
|
|
93
94
|
assetName,
|
|
94
95
|
binaryName,
|
|
95
|
-
cwd =
|
|
96
|
+
cwd = import_node_process.default.cwd(),
|
|
96
97
|
downloadDir = "build/downloaded",
|
|
97
98
|
owner,
|
|
98
99
|
platformArch,
|
|
@@ -147,7 +148,7 @@ async function downloadGitHubRelease(config) {
|
|
|
147
148
|
const isWindows = binaryName.endsWith(".exe");
|
|
148
149
|
if (!isWindows) {
|
|
149
150
|
fs.chmodSync(binaryPath, 493);
|
|
150
|
-
if (removeMacOSQuarantine &&
|
|
151
|
+
if (removeMacOSQuarantine && import_node_process.default.platform === "darwin" && platformArch.startsWith("darwin")) {
|
|
151
152
|
try {
|
|
152
153
|
await (0, import_spawn.spawn)("xattr", ["-d", "com.apple.quarantine", binaryPath], {
|
|
153
154
|
stdio: "ignore"
|
|
@@ -185,7 +186,7 @@ async function downloadReleaseAsset(tag, assetPattern, outputPath, repoConfig, o
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
function getAuthHeaders() {
|
|
188
|
-
const token =
|
|
189
|
+
const token = import_node_process.default.env["GH_TOKEN"] || import_node_process.default.env["GITHUB_TOKEN"];
|
|
189
190
|
const headers = {
|
|
190
191
|
Accept: "application/vnd.github+json",
|
|
191
192
|
"X-GitHub-Api-Version": "2022-11-28"
|
|
@@ -293,7 +294,11 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
|
|
|
293
294
|
{ cause }
|
|
294
295
|
);
|
|
295
296
|
}
|
|
296
|
-
const
|
|
297
|
+
const assets = release.assets;
|
|
298
|
+
if (!Array.isArray(assets)) {
|
|
299
|
+
throw new Error(`Release ${tag} has no assets`);
|
|
300
|
+
}
|
|
301
|
+
const asset = assets.find((a) => isMatch(a.name));
|
|
297
302
|
if (!asset) {
|
|
298
303
|
const patternDesc = typeof assetPattern === "string" ? assetPattern : "matching pattern";
|
|
299
304
|
throw new Error(`Asset ${patternDesc} not found in release ${tag}`);
|
package/dist/sea.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 sea_exports = {};
|
|
21
31
|
__export(sea_exports, {
|
|
@@ -23,10 +33,11 @@ __export(sea_exports, {
|
|
|
23
33
|
isSeaBinary: () => isSeaBinary
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(sea_exports);
|
|
36
|
+
var import_node_process = __toESM(require("node:process"));
|
|
26
37
|
var import_normalize = require("./paths/normalize");
|
|
27
38
|
let _isSea;
|
|
28
39
|
function getSeaBinaryPath() {
|
|
29
|
-
return isSeaBinary() &&
|
|
40
|
+
return isSeaBinary() && import_node_process.default.argv[0] ? (0, import_normalize.normalizePath)(import_node_process.default.argv[0]) : void 0;
|
|
30
41
|
}
|
|
31
42
|
function isSeaBinary() {
|
|
32
43
|
if (_isSea === void 0) {
|
package/dist/shadow.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,27 +18,36 @@ 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 shadow_exports = {};
|
|
21
31
|
__export(shadow_exports, {
|
|
22
32
|
shouldSkipShadow: () => shouldSkipShadow
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(shadow_exports);
|
|
35
|
+
var import_node_process = __toESM(require("node:process"));
|
|
25
36
|
var import_normalize = require("./paths/normalize");
|
|
26
37
|
function shouldSkipShadow(binPath, options) {
|
|
27
|
-
const { cwd =
|
|
38
|
+
const { cwd = import_node_process.default.cwd(), win32 = false } = {
|
|
28
39
|
__proto__: null,
|
|
29
40
|
...options
|
|
30
41
|
};
|
|
31
42
|
if (win32 && binPath) {
|
|
32
43
|
return true;
|
|
33
44
|
}
|
|
34
|
-
const userAgent =
|
|
45
|
+
const userAgent = import_node_process.default.env["npm_config_user_agent"];
|
|
35
46
|
if (userAgent?.includes("exec") || userAgent?.includes("npx") || userAgent?.includes("dlx")) {
|
|
36
47
|
return true;
|
|
37
48
|
}
|
|
38
49
|
const normalizedCwd = (0, import_normalize.normalizePath)(cwd);
|
|
39
|
-
const npmCache =
|
|
50
|
+
const npmCache = import_node_process.default.env["npm_config_cache"];
|
|
40
51
|
if (npmCache && normalizedCwd.includes((0, import_normalize.normalizePath)(npmCache))) {
|
|
41
52
|
return true;
|
|
42
53
|
}
|
package/dist/spawn.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(spawn_exports, {
|
|
|
36
36
|
spawnSync: () => spawnSync
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(spawn_exports);
|
|
39
|
+
var import_node_process = __toESM(require("node:process"));
|
|
39
40
|
var import_process = require("./constants/process");
|
|
40
41
|
var import_errors = require("./errors");
|
|
41
42
|
var import_promise_spawn = __toESM(require("./external/@npmcli/promise-spawn"));
|
|
@@ -204,7 +205,7 @@ function spawn(cmd, args, options, extra) {
|
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
const WIN32 =
|
|
208
|
+
const WIN32 = import_node_process.default.platform === "win32";
|
|
208
209
|
if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
|
|
209
210
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
210
211
|
actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
|
|
@@ -218,9 +219,9 @@ function spawn(cmd, args, options, extra) {
|
|
|
218
219
|
}
|
|
219
220
|
const envToUse = env ? {
|
|
220
221
|
__proto__: null,
|
|
221
|
-
...
|
|
222
|
+
...import_node_process.default.env,
|
|
222
223
|
...env
|
|
223
|
-
} :
|
|
224
|
+
} : import_node_process.default.env;
|
|
224
225
|
const promiseSpawnOpts = {
|
|
225
226
|
__proto__: null,
|
|
226
227
|
cwd: typeof spawnOptions.cwd === "string" ? spawnOptions.cwd : void 0,
|
|
@@ -290,7 +291,7 @@ function spawnSync(cmd, args, options) {
|
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
const shell = (0, import_objects.getOwn)(options, "shell");
|
|
293
|
-
const WIN32 =
|
|
294
|
+
const WIN32 = import_node_process.default.platform === "win32";
|
|
294
295
|
if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
|
|
295
296
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
296
297
|
actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
|
package/dist/spinner.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI spinner utilities for long-running operations.
|
|
3
|
-
* Provides animated progress indicators with CI environment detection.
|
|
4
|
-
*/
|
|
5
1
|
import type { Writable } from 'stream';
|
|
6
2
|
import type { ColorInherit, ColorRgb, ColorValue } from './colors';
|
|
7
3
|
import type { ShimmerColorGradient, ShimmerConfig, ShimmerDirection, ShimmerState } from './effects/text-shimmer';
|
package/dist/spinner.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(spinner_exports, {
|
|
|
38
38
|
withSpinnerSync: () => withSpinnerSync
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(spinner_exports);
|
|
41
|
+
var import_node_process = __toESM(require("node:process"));
|
|
41
42
|
var import_yoctocolors_cjs = __toESM(require("./external/yoctocolors-cjs"));
|
|
42
43
|
var import_colors = require("./colors");
|
|
43
44
|
var import_process = require("./constants/process");
|
|
@@ -881,7 +882,7 @@ async function withSpinner(options) {
|
|
|
881
882
|
const wasSpinning = spinner.isSpinning;
|
|
882
883
|
spinner.stop();
|
|
883
884
|
if (wasSpinning) {
|
|
884
|
-
|
|
885
|
+
import_node_process.default.stderr.write("\r\x1B[2K");
|
|
885
886
|
}
|
|
886
887
|
if (savedColor !== void 0) {
|
|
887
888
|
spinner.color = savedColor;
|
package/dist/stdio/clear.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Terminal clearing and cursor utilities.
|
|
3
|
-
* Provides functions for clearing lines, screens, and managing cursor position.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Clear the current line in the terminal.
|
|
7
|
-
* Uses native TTY methods when available, falls back to ANSI escape codes.
|
|
8
|
-
*
|
|
9
|
-
* ANSI Sequences:
|
|
10
|
-
* - `\r`: Carriage return (move to line start)
|
|
11
|
-
* - `\x1b[K`: Clear from cursor to end of line
|
|
12
|
-
*
|
|
13
|
-
* @param stream - Output stream to clear
|
|
14
|
-
* @default stream process.stdout
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* clearLine() // Clear current line on stdout
|
|
19
|
-
* clearLine(process.stderr) // Clear on stderr
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
1
|
export declare function clearLine(stream?: NodeJS.WriteStream): void;
|
|
23
2
|
/**
|
|
24
3
|
* Clear multiple lines above the current cursor position.
|
package/dist/stdio/clear.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 clear_exports = {};
|
|
21
31
|
__export(clear_exports, {
|
|
@@ -30,7 +40,8 @@ __export(clear_exports, {
|
|
|
30
40
|
showCursor: () => showCursor
|
|
31
41
|
});
|
|
32
42
|
module.exports = __toCommonJS(clear_exports);
|
|
33
|
-
|
|
43
|
+
var import_node_process = __toESM(require("node:process"));
|
|
44
|
+
function clearLine(stream = import_node_process.default.stdout) {
|
|
34
45
|
if (stream.isTTY) {
|
|
35
46
|
stream.cursorTo(0);
|
|
36
47
|
stream.clearLine(0);
|
|
@@ -38,36 +49,36 @@ function clearLine(stream = process.stdout) {
|
|
|
38
49
|
stream.write("\r\x1B[K");
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
|
-
function clearLines(count, stream =
|
|
52
|
+
function clearLines(count, stream = import_node_process.default.stdout) {
|
|
42
53
|
for (let i = 0; i < count; i++) {
|
|
43
54
|
stream.write("\x1B[1A\x1B[2K");
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
|
-
function clearScreen(stream =
|
|
57
|
+
function clearScreen(stream = import_node_process.default.stdout) {
|
|
47
58
|
if (stream.isTTY) {
|
|
48
59
|
stream.write("\x1Bc");
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
|
-
function clearVisible(stream =
|
|
62
|
+
function clearVisible(stream = import_node_process.default.stdout) {
|
|
52
63
|
clearScreen(stream);
|
|
53
64
|
}
|
|
54
|
-
function cursorToStart(stream =
|
|
65
|
+
function cursorToStart(stream = import_node_process.default.stdout) {
|
|
55
66
|
if (stream.isTTY) {
|
|
56
67
|
stream.cursorTo(0);
|
|
57
68
|
} else {
|
|
58
69
|
stream.write("\r");
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
|
-
function hideCursor(stream =
|
|
72
|
+
function hideCursor(stream = import_node_process.default.stdout) {
|
|
62
73
|
stream.write("\x1B[?25l");
|
|
63
74
|
}
|
|
64
|
-
function showCursor(stream =
|
|
75
|
+
function showCursor(stream = import_node_process.default.stdout) {
|
|
65
76
|
stream.write("\x1B[?25h");
|
|
66
77
|
}
|
|
67
|
-
function saveCursor(stream =
|
|
78
|
+
function saveCursor(stream = import_node_process.default.stdout) {
|
|
68
79
|
stream.write("\x1B7");
|
|
69
80
|
}
|
|
70
|
-
function restoreCursor(stream =
|
|
81
|
+
function restoreCursor(stream = import_node_process.default.stdout) {
|
|
71
82
|
stream.write("\x1B8");
|
|
72
83
|
}
|
|
73
84
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/stdio/mask.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 mask_exports = {};
|
|
21
31
|
__export(mask_exports, {
|
|
@@ -25,6 +35,7 @@ __export(mask_exports, {
|
|
|
25
35
|
runWithMask: () => runWithMask
|
|
26
36
|
});
|
|
27
37
|
module.exports = __toCommonJS(mask_exports);
|
|
38
|
+
var import_node_process = __toESM(require("node:process"));
|
|
28
39
|
var import_spinner = require("../spinner.js");
|
|
29
40
|
var import_clear = require("./clear.js");
|
|
30
41
|
var import_stdout = require("./stdout.js");
|
|
@@ -76,7 +87,7 @@ function createKeyboardHandler(mask, child, options = {}) {
|
|
|
76
87
|
if (mask.outputBuffer.length > 0) {
|
|
77
88
|
const lineCount = mask.outputBuffer.join("").split("\n").length + 1;
|
|
78
89
|
for (let i = 0; i < lineCount; i += 1) {
|
|
79
|
-
|
|
90
|
+
import_node_process.default.stdout.write("\x1B[1A\x1B[2K");
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
(0, import_clear.clearLine)();
|
|
@@ -88,8 +99,8 @@ function createKeyboardHandler(mask, child, options = {}) {
|
|
|
88
99
|
}
|
|
89
100
|
} else if (key?.ctrl && key.name === "c") {
|
|
90
101
|
child.kill("SIGTERM");
|
|
91
|
-
if (
|
|
92
|
-
|
|
102
|
+
if (import_node_process.default.stdin.isTTY) {
|
|
103
|
+
import_node_process.default.stdin.setRawMode(false);
|
|
93
104
|
}
|
|
94
105
|
throw new Error("Process cancelled by user");
|
|
95
106
|
}
|
|
@@ -99,20 +110,20 @@ function attachOutputMask(child, options = {}) {
|
|
|
99
110
|
return new Promise((resolve, reject) => {
|
|
100
111
|
const { message = "Running\u2026" } = options;
|
|
101
112
|
const mask = createOutputMask(options);
|
|
102
|
-
if (mask.isSpinning &&
|
|
113
|
+
if (mask.isSpinning && import_node_process.default.stdout.isTTY) {
|
|
103
114
|
spinner.start(
|
|
104
115
|
`${message} (ctrl+o ${options.toggleText || "to see full output"})`
|
|
105
116
|
);
|
|
106
117
|
}
|
|
107
|
-
if (
|
|
108
|
-
(/* @__PURE__ */ getReadline()).emitKeypressEvents(
|
|
109
|
-
|
|
118
|
+
if (import_node_process.default.stdin.isTTY) {
|
|
119
|
+
(/* @__PURE__ */ getReadline()).emitKeypressEvents(import_node_process.default.stdin);
|
|
120
|
+
import_node_process.default.stdin.setRawMode(true);
|
|
110
121
|
const keypressHandler = createKeyboardHandler(mask, child, options);
|
|
111
|
-
|
|
122
|
+
import_node_process.default.stdin.on("keypress", keypressHandler);
|
|
112
123
|
child.on("exit", () => {
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
if (import_node_process.default.stdin.isTTY) {
|
|
125
|
+
import_node_process.default.stdin.setRawMode(false);
|
|
126
|
+
import_node_process.default.stdin.removeListener("keypress", keypressHandler);
|
|
116
127
|
}
|
|
117
128
|
});
|
|
118
129
|
}
|
|
@@ -143,7 +154,7 @@ function attachOutputMask(child, options = {}) {
|
|
|
143
154
|
return void 0;
|
|
144
155
|
}
|
|
145
156
|
if (mask.verbose) {
|
|
146
|
-
|
|
157
|
+
import_node_process.default.stderr.write(text);
|
|
147
158
|
} else {
|
|
148
159
|
mask.outputBuffer.push(text);
|
|
149
160
|
}
|
|
@@ -151,8 +162,8 @@ function attachOutputMask(child, options = {}) {
|
|
|
151
162
|
});
|
|
152
163
|
}
|
|
153
164
|
child.on("exit", (code) => {
|
|
154
|
-
if (
|
|
155
|
-
|
|
165
|
+
if (import_node_process.default.stdin.isTTY) {
|
|
166
|
+
import_node_process.default.stdin.setRawMode(false);
|
|
156
167
|
}
|
|
157
168
|
let finalCode = code || 0;
|
|
158
169
|
if (options.overrideExitCode) {
|
|
@@ -181,8 +192,8 @@ function attachOutputMask(child, options = {}) {
|
|
|
181
192
|
resolve(finalCode);
|
|
182
193
|
});
|
|
183
194
|
child.on("error", (error) => {
|
|
184
|
-
if (
|
|
185
|
-
|
|
195
|
+
if (import_node_process.default.stdin.isTTY) {
|
|
196
|
+
import_node_process.default.stdin.setRawMode(false);
|
|
186
197
|
}
|
|
187
198
|
if (mask.isSpinning) {
|
|
188
199
|
spinner.failAndStop(`${message} error`);
|
package/dist/stdio/progress.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(progress_exports, {
|
|
|
33
33
|
createProgressIndicator: () => createProgressIndicator
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(progress_exports);
|
|
36
|
+
var import_node_process = __toESM(require("node:process"));
|
|
36
37
|
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
|
|
37
38
|
var import_strings = require("../strings");
|
|
38
39
|
class ProgressBar {
|
|
@@ -62,7 +63,7 @@ class ProgressBar {
|
|
|
62
63
|
constructor(total, options) {
|
|
63
64
|
this.total = total;
|
|
64
65
|
this.startTime = Date.now();
|
|
65
|
-
this.stream = options?.stream ||
|
|
66
|
+
this.stream = options?.stream || import_node_process.default.stderr;
|
|
66
67
|
this.options = {
|
|
67
68
|
width: 40,
|
|
68
69
|
format: ":bar :percent :current/:total",
|
|
@@ -195,7 +196,7 @@ class ProgressBar {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
function createProgressIndicator(current, total, label) {
|
|
198
|
-
const percent = Math.floor(current / total * 100);
|
|
199
|
+
const percent = total === 0 ? 0 : Math.floor(current / total * 100);
|
|
199
200
|
const progress = `${current}/${total}`;
|
|
200
201
|
let output = "";
|
|
201
202
|
if (label) {
|
package/dist/stdio/stderr.d.ts
CHANGED
|
@@ -4,19 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// Get the actual stderr stream
|
|
6
6
|
declare const stderr: NodeJS.WriteStream;
|
|
7
|
-
/**
|
|
8
|
-
* Write a line to stderr with trailing newline.
|
|
9
|
-
* Used for error messages, warnings, and diagnostic output.
|
|
10
|
-
*
|
|
11
|
-
* @param text - Text to write
|
|
12
|
-
* @default text ''
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* writeErrorLine('Error: File not found')
|
|
17
|
-
* writeErrorLine() // Write empty line
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
7
|
export declare function writeErrorLine(text?: string): void;
|
|
21
8
|
/**
|
|
22
9
|
* Write text to stderr without adding a newline.
|
package/dist/stdio/stderr.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 stderr_exports = {};
|
|
21
31
|
__export(stderr_exports, {
|
|
@@ -32,7 +42,8 @@ __export(stderr_exports, {
|
|
|
32
42
|
writeWarning: () => writeWarning
|
|
33
43
|
});
|
|
34
44
|
module.exports = __toCommonJS(stderr_exports);
|
|
35
|
-
|
|
45
|
+
var import_node_process = __toESM(require("node:process"));
|
|
46
|
+
const stderr = import_node_process.default.stderr;
|
|
36
47
|
function writeErrorLine(text = "") {
|
|
37
48
|
stderr.write(`${text}
|
|
38
49
|
`);
|
package/dist/stdio/stdout.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 stdout_exports = {};
|
|
21
31
|
__export(stdout_exports, {
|
|
@@ -33,8 +43,9 @@ __export(stdout_exports, {
|
|
|
33
43
|
writeLine: () => writeLine
|
|
34
44
|
});
|
|
35
45
|
module.exports = __toCommonJS(stdout_exports);
|
|
46
|
+
var import_node_process = __toESM(require("node:process"));
|
|
36
47
|
var import_tty = require("tty");
|
|
37
|
-
const stdout =
|
|
48
|
+
const stdout = import_node_process.default.stdout;
|
|
38
49
|
function writeLine(text = "") {
|
|
39
50
|
stdout.write(`${text}
|
|
40
51
|
`);
|
|
@@ -78,14 +89,14 @@ function showCursor() {
|
|
|
78
89
|
}
|
|
79
90
|
}
|
|
80
91
|
function ensureCursorOnExit() {
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
import_node_process.default.on("exit", showCursor);
|
|
93
|
+
import_node_process.default.on("SIGINT", () => {
|
|
83
94
|
showCursor();
|
|
84
|
-
|
|
95
|
+
import_node_process.default.exit(130);
|
|
85
96
|
});
|
|
86
|
-
|
|
97
|
+
import_node_process.default.on("SIGTERM", () => {
|
|
87
98
|
showCursor();
|
|
88
|
-
|
|
99
|
+
import_node_process.default.exit(143);
|
|
89
100
|
});
|
|
90
101
|
}
|
|
91
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Suppress MaxListenersExceededWarning messages.
|
|
3
|
-
* This is useful in tests or scripts where multiple listeners are expected.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* import { suppressMaxListenersWarning } from '@socketsecurity/lib/suppress-warnings'
|
|
7
|
-
*
|
|
8
|
-
* suppressMaxListenersWarning()
|
|
9
|
-
*/
|
|
10
1
|
export declare function suppressMaxListenersWarning(): void;
|
|
11
2
|
/**
|
|
12
3
|
* Suppress all process warnings of a specific type.
|