@socketsecurity/lib 5.2.1 → 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 +30 -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 +13 -5
- package/dist/debug.js +1 -1
- package/dist/dlx/binary.d.ts +1 -1
- package/dist/dlx/binary.js +49 -39
- package/dist/dlx/cache.js +10 -2
- package/dist/dlx/dir.js +1 -1
- package/dist/dlx/manifest.d.ts +2 -1
- package/dist/dlx/manifest.js +45 -41
- package/dist/dlx/package.js +39 -19
- package/dist/dlx/packages.js +1 -1
- package/dist/dlx/paths.js +1 -1
- 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/fs.js +3 -3
- package/dist/git.js +41 -38
- package/dist/http-request.js +12 -4
- package/dist/ipc.js +53 -29
- 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/packages/isolation.js +45 -23
- package/dist/packages/licenses.js +10 -2
- package/dist/paths/normalize.js +3 -3
- package/dist/paths/packages.js +1 -1
- package/dist/paths/socket.d.ts +2 -2
- package/dist/paths/socket.js +27 -21
- package/dist/process-lock.js +23 -14
- package/dist/promises.js +1 -1
- package/dist/releases/github.d.ts +82 -137
- package/dist/releases/github.js +91 -48
- package/dist/releases/socket-btm.d.ts +78 -192
- package/dist/releases/socket-btm.js +112 -50
- package/dist/signal-exit.js +1 -1
- package/dist/spawn.js +11 -4
- 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 +3 -2
|
@@ -1,221 +1,107 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Socket-btm release download utilities.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import { type Arch, type Libc, type Platform } from '../constants/platform.js';
|
|
5
|
+
import { type AssetPattern } from './github.js';
|
|
6
|
+
export type { Arch, Libc, Platform };
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export type Arch = 'arm64' | 'x64';
|
|
9
|
-
/**
|
|
10
|
-
* Linux libc variant.
|
|
11
|
-
*/
|
|
12
|
-
export type Libc = 'musl' | 'glibc';
|
|
13
|
-
/**
|
|
14
|
-
* Configuration for downloading socket-btm binary releases.
|
|
8
|
+
* Configuration for downloading socket-btm generic assets.
|
|
15
9
|
*/
|
|
16
|
-
export interface
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
export interface SocketBtmAssetConfig {
|
|
11
|
+
/** Asset name or pattern on GitHub. */
|
|
12
|
+
asset: string | AssetPattern;
|
|
13
|
+
/** @internal Discriminator fields */
|
|
14
|
+
bin?: never;
|
|
15
|
+
/** Working directory (defaults to process.cwd()). */
|
|
20
16
|
cwd?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Download destination directory.
|
|
23
|
-
* Can be absolute or relative to cwd.
|
|
24
|
-
* @default 'build/downloaded' (relative to cwd)
|
|
25
|
-
*
|
|
26
|
-
* Inspired by: gh release download --dir
|
|
27
|
-
*/
|
|
17
|
+
/** Download destination directory. @default 'build/downloaded' */
|
|
28
18
|
downloadDir?: string;
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
* Used for:
|
|
36
|
-
* - Directory path: {downloadDir}/{tool}/{platformArch}/
|
|
37
|
-
* - Finding release: Searches for tags starting with '{tool}-'
|
|
38
|
-
*/
|
|
39
|
-
tool: string;
|
|
40
|
-
/**
|
|
41
|
-
* Binary/executable name (without extension).
|
|
42
|
-
* Similar to: brew formula→binary mapping (postgresql→psql, imagemagick→magick)
|
|
43
|
-
*
|
|
44
|
-
* Examples: 'node', 'binject', 'psql', 'magick'
|
|
45
|
-
*
|
|
46
|
-
* Used to construct:
|
|
47
|
-
* - Asset pattern: {bin}-{platform}-{arch}[-musl][.exe]
|
|
48
|
-
* - Output filename: {bin} or {bin}.exe
|
|
49
|
-
*
|
|
50
|
-
* Presence of this field indicates binary download (vs asset download).
|
|
51
|
-
*
|
|
52
|
-
* @default tool (e.g., 'binject'→'binject', but 'node-smol'→'node-smol')
|
|
53
|
-
*/
|
|
54
|
-
bin?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Target platform (defaults to current platform).
|
|
57
|
-
*/
|
|
58
|
-
targetPlatform?: Platform;
|
|
59
|
-
/**
|
|
60
|
-
* Target architecture (defaults to current arch).
|
|
61
|
-
*/
|
|
62
|
-
targetArch?: Arch;
|
|
63
|
-
/**
|
|
64
|
-
* Linux libc variant (musl or glibc).
|
|
65
|
-
* Defaults to musl for Linux for broader compatibility.
|
|
66
|
-
* Ignored for non-Linux platforms.
|
|
67
|
-
*/
|
|
68
|
-
libc?: Libc;
|
|
69
|
-
/**
|
|
70
|
-
* Specific release tag to download.
|
|
71
|
-
* Inspired by: gh release download <tag>
|
|
72
|
-
*
|
|
73
|
-
* If not provided, downloads the latest release matching '{tool}-*' pattern.
|
|
74
|
-
*
|
|
75
|
-
* Examples: 'node-smol-20260105-c47753c', 'binject-20260106-1df5745'
|
|
76
|
-
*/
|
|
77
|
-
tag?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Suppress log messages.
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
19
|
+
/** @internal Discriminator fields */
|
|
20
|
+
libc?: never;
|
|
21
|
+
/** Output filename. @default resolved asset name */
|
|
22
|
+
output?: string;
|
|
23
|
+
/** Suppress log messages. @default false */
|
|
82
24
|
quiet?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Remove macOS quarantine attribute after download.
|
|
85
|
-
* Only applies when downloading on macOS for macOS binaries.
|
|
86
|
-
* @default true
|
|
87
|
-
*/
|
|
25
|
+
/** Remove macOS quarantine attribute after download. @default false */
|
|
88
26
|
removeMacOSQuarantine?: boolean;
|
|
89
|
-
|
|
90
|
-
|
|
27
|
+
/** Specific release tag to download. */
|
|
28
|
+
tag?: string;
|
|
29
|
+
/** @internal Discriminator fields */
|
|
30
|
+
targetArch?: never;
|
|
31
|
+
/** @internal Discriminator fields */
|
|
32
|
+
targetPlatform?: never;
|
|
33
|
+
/** Tool/package name for directory structure and release matching. */
|
|
34
|
+
tool: string;
|
|
91
35
|
}
|
|
92
36
|
/**
|
|
93
|
-
* Configuration for downloading socket-btm
|
|
37
|
+
* Configuration for downloading socket-btm binary releases.
|
|
94
38
|
*/
|
|
95
|
-
export interface
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
39
|
+
export interface SocketBtmBinaryConfig {
|
|
40
|
+
/** @internal Discriminator field */
|
|
41
|
+
asset?: never;
|
|
42
|
+
/** Binary/executable name (without extension). @default tool */
|
|
43
|
+
bin?: string;
|
|
44
|
+
/** Working directory (defaults to process.cwd()). */
|
|
99
45
|
cwd?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Download destination directory.
|
|
102
|
-
* Can be absolute or relative to cwd.
|
|
103
|
-
* @default 'build/downloaded' (relative to cwd)
|
|
104
|
-
*
|
|
105
|
-
* Inspired by: gh release download --dir
|
|
106
|
-
*/
|
|
46
|
+
/** Download destination directory. @default 'build/downloaded' */
|
|
107
47
|
downloadDir?: string;
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* Examples: 'yoga-layout', 'onnxruntime', 'models'
|
|
112
|
-
*
|
|
113
|
-
* Used for:
|
|
114
|
-
* - Directory path: {downloadDir}/{tool}/assets/
|
|
115
|
-
* - Finding release: Searches for tags starting with '{tool}-'
|
|
116
|
-
*/
|
|
117
|
-
tool: string;
|
|
118
|
-
/**
|
|
119
|
-
* Asset name pattern on GitHub.
|
|
120
|
-
* Inspired by: gh release download --pattern
|
|
121
|
-
*
|
|
122
|
-
* Examples: 'yoga-sync.mjs', 'ort-wasm-simd.wasm', '*.onnx'
|
|
123
|
-
*
|
|
124
|
-
* Presence of this field indicates asset download (vs binary download).
|
|
125
|
-
*/
|
|
126
|
-
asset: string;
|
|
127
|
-
/**
|
|
128
|
-
* Output filename (e.g., 'yoga-sync.mjs').
|
|
129
|
-
* Inspired by: gh release download --output
|
|
130
|
-
*
|
|
131
|
-
* @default asset (uses the asset name as-is)
|
|
132
|
-
*/
|
|
133
|
-
output?: string;
|
|
134
|
-
/**
|
|
135
|
-
* Specific release tag to download.
|
|
136
|
-
* Inspired by: gh release download <tag>
|
|
137
|
-
*
|
|
138
|
-
* If not provided, downloads the latest release matching '{tool}-*' pattern.
|
|
139
|
-
*
|
|
140
|
-
* Examples: 'yoga-layout-v20260106-a39285c', 'onnxruntime-v20260106-a39285c'
|
|
141
|
-
*/
|
|
142
|
-
tag?: string;
|
|
143
|
-
/**
|
|
144
|
-
* Suppress log messages.
|
|
145
|
-
* @default false
|
|
146
|
-
*/
|
|
48
|
+
/** Linux libc variant. Auto-detected if not specified. */
|
|
49
|
+
libc?: Libc;
|
|
50
|
+
/** Suppress log messages. @default false */
|
|
147
51
|
quiet?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Remove macOS quarantine attribute after download.
|
|
150
|
-
* @default false (not needed for non-executable assets)
|
|
151
|
-
*/
|
|
52
|
+
/** Remove macOS quarantine attribute after download. @default true */
|
|
152
53
|
removeMacOSQuarantine?: boolean;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
targetArch?:
|
|
157
|
-
|
|
54
|
+
/** Specific release tag to download. */
|
|
55
|
+
tag?: string;
|
|
56
|
+
/** Target architecture (defaults to current arch). */
|
|
57
|
+
targetArch?: Arch;
|
|
58
|
+
/** Target platform (defaults to current platform). */
|
|
59
|
+
targetPlatform?: Platform;
|
|
60
|
+
/** Tool/package name for directory structure and release matching. */
|
|
61
|
+
tool: string;
|
|
158
62
|
}
|
|
159
63
|
/**
|
|
160
64
|
* Configuration for downloading socket-btm releases (binary or asset).
|
|
161
65
|
*/
|
|
162
66
|
export type SocketBtmReleaseConfig = SocketBtmBinaryConfig | SocketBtmAssetConfig;
|
|
163
67
|
/**
|
|
164
|
-
*
|
|
68
|
+
* Detect the libc variant (musl or glibc) on Linux systems.
|
|
69
|
+
* Returns undefined for non-Linux platforms.
|
|
165
70
|
*
|
|
166
|
-
*
|
|
167
|
-
|
|
71
|
+
* @returns 'musl', 'glibc', or undefined (for non-Linux)
|
|
72
|
+
*/
|
|
73
|
+
export declare function detectLibc(): Libc | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Download a release from socket-btm.
|
|
168
76
|
*
|
|
169
77
|
* @param config - Download configuration
|
|
170
78
|
* @returns Path to the downloaded file
|
|
79
|
+
*/
|
|
80
|
+
export declare function downloadSocketBtmRelease(config: SocketBtmReleaseConfig): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Get asset name for a socket-btm binary.
|
|
171
83
|
*
|
|
172
|
-
* @
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*
|
|
181
|
-
* const binjectPath = await downloadSocketBtmRelease({
|
|
182
|
-
* tool: 'binject'
|
|
183
|
-
* })
|
|
184
|
-
*
|
|
185
|
-
* // Binary: cross-platform
|
|
186
|
-
* const binflatePath = await downloadSocketBtmRelease({
|
|
187
|
-
* tool: 'binflate',
|
|
188
|
-
* targetPlatform: 'linux',
|
|
189
|
-
* targetArch: 'x64',
|
|
190
|
-
* libc: 'musl'
|
|
191
|
-
* })
|
|
192
|
-
*
|
|
193
|
-
* // Asset: WASM file
|
|
194
|
-
* const yogaPath = await downloadSocketBtmRelease({
|
|
195
|
-
* tool: 'yoga-layout',
|
|
196
|
-
* asset: 'yoga-sync.mjs'
|
|
197
|
-
* })
|
|
198
|
-
*
|
|
199
|
-
* // Asset: with custom output name
|
|
200
|
-
* const ortPath = await downloadSocketBtmRelease({
|
|
201
|
-
* tool: 'onnxruntime',
|
|
202
|
-
* asset: 'ort-wasm-simd.wasm',
|
|
203
|
-
* output: 'ort.wasm'
|
|
204
|
-
* })
|
|
84
|
+
* @param binaryBaseName - Binary basename (e.g., 'binject', 'node')
|
|
85
|
+
* @param platform - Target platform
|
|
86
|
+
* @param arch - Target architecture
|
|
87
|
+
* @param libc - Linux libc variant (optional)
|
|
88
|
+
* @returns Asset name (e.g., 'binject-darwin-arm64', 'node-linux-x64-musl')
|
|
89
|
+
*/
|
|
90
|
+
export declare function getBinaryAssetName(binaryBaseName: string, platform: Platform, arch: Arch, libc?: Libc | undefined): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get binary filename for output.
|
|
205
93
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*
|
|
94
|
+
* @param binaryBaseName - Binary basename (e.g., 'node', 'binject')
|
|
95
|
+
* @param platform - Target platform
|
|
96
|
+
* @returns Binary filename (e.g., 'node', 'node.exe')
|
|
97
|
+
*/
|
|
98
|
+
export declare function getBinaryName(binaryBaseName: string, platform: Platform): string;
|
|
99
|
+
/**
|
|
100
|
+
* Get platform-arch identifier for directory structure.
|
|
213
101
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* })
|
|
219
|
-
* ```
|
|
102
|
+
* @param platform - Target platform
|
|
103
|
+
* @param arch - Target architecture
|
|
104
|
+
* @param libc - Linux libc variant (optional)
|
|
105
|
+
* @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl')
|
|
220
106
|
*/
|
|
221
|
-
export declare function
|
|
107
|
+
export declare function getPlatformArch(platform: Platform, arch: Arch, libc?: Libc | undefined): string;
|
|
@@ -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,54 +16,52 @@ 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_btm_exports = {};
|
|
31
21
|
__export(socket_btm_exports, {
|
|
32
|
-
|
|
22
|
+
detectLibc: () => detectLibc,
|
|
23
|
+
downloadSocketBtmRelease: () => downloadSocketBtmRelease,
|
|
24
|
+
getBinaryAssetName: () => getBinaryAssetName,
|
|
25
|
+
getBinaryName: () => getBinaryName,
|
|
26
|
+
getPlatformArch: () => getPlatformArch
|
|
33
27
|
});
|
|
34
28
|
module.exports = __toCommonJS(socket_btm_exports);
|
|
35
|
-
var
|
|
29
|
+
var import_platform = require("../constants/platform.js");
|
|
36
30
|
var import_github = require("./github.js");
|
|
37
31
|
const ARCH_MAP = {
|
|
32
|
+
__proto__: null,
|
|
38
33
|
arm64: "arm64",
|
|
39
34
|
x64: "x64"
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
47
|
-
const ext = platform === "win32" ? ".exe" : "";
|
|
48
|
-
if (platform === "darwin") {
|
|
49
|
-
return `${binaryBaseName}-darwin-${mappedArch}${ext}`;
|
|
50
|
-
}
|
|
51
|
-
if (platform === "linux") {
|
|
52
|
-
return `${binaryBaseName}-linux-${mappedArch}${muslSuffix}${ext}`;
|
|
53
|
-
}
|
|
54
|
-
if (platform === "win32") {
|
|
55
|
-
return `${binaryBaseName}-win-${mappedArch}${ext}`;
|
|
36
|
+
let _fs;
|
|
37
|
+
// @__NO_SIDE_EFFECTS__
|
|
38
|
+
function getFs() {
|
|
39
|
+
if (_fs === void 0) {
|
|
40
|
+
_fs = require("fs");
|
|
56
41
|
}
|
|
57
|
-
|
|
42
|
+
return _fs;
|
|
58
43
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
function detectLibc() {
|
|
45
|
+
if ((0, import_platform.getPlatform)() !== "linux") {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const fs = /* @__PURE__ */ getFs();
|
|
50
|
+
const muslPaths = [
|
|
51
|
+
"/lib/ld-musl-x86_64.so.1",
|
|
52
|
+
"/lib/ld-musl-aarch64.so.1",
|
|
53
|
+
"/usr/lib/ld-musl-x86_64.so.1",
|
|
54
|
+
"/usr/lib/ld-musl-aarch64.so.1"
|
|
55
|
+
];
|
|
56
|
+
for (const path of muslPaths) {
|
|
57
|
+
if (fs.existsSync(path)) {
|
|
58
|
+
return "musl";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return "glibc";
|
|
62
|
+
} catch {
|
|
63
|
+
return "glibc";
|
|
63
64
|
}
|
|
64
|
-
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
65
|
-
return `${platform}-${mappedArch}${muslSuffix}`;
|
|
66
|
-
}
|
|
67
|
-
function getBinaryName(binaryBaseName, platform) {
|
|
68
|
-
return platform === "win32" ? `${binaryBaseName}.exe` : binaryBaseName;
|
|
69
65
|
}
|
|
70
66
|
async function downloadSocketBtmRelease(config) {
|
|
71
67
|
const { cwd, downloadDir, quiet = false, tag, tool } = config;
|
|
@@ -77,7 +73,38 @@ async function downloadSocketBtmRelease(config) {
|
|
|
77
73
|
output,
|
|
78
74
|
removeMacOSQuarantine = false
|
|
79
75
|
} = config;
|
|
80
|
-
|
|
76
|
+
let resolvedAsset;
|
|
77
|
+
let resolvedTag = tag;
|
|
78
|
+
const isExactMatch = typeof asset === "string" && !asset.includes("*");
|
|
79
|
+
if (isExactMatch) {
|
|
80
|
+
resolvedAsset = asset;
|
|
81
|
+
} else {
|
|
82
|
+
if (tag) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
"Cannot use asset pattern with explicit tag. Either provide exact asset name or omit tag."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
resolvedTag = await (0, import_github.getLatestRelease)(toolPrefix, import_github.SOCKET_BTM_REPO, {
|
|
88
|
+
assetPattern: asset,
|
|
89
|
+
quiet
|
|
90
|
+
});
|
|
91
|
+
if (!resolvedTag) {
|
|
92
|
+
throw new Error(`No ${tool} release with matching asset pattern found`);
|
|
93
|
+
}
|
|
94
|
+
const assetUrl = await (0, import_github.getReleaseAssetUrl)(
|
|
95
|
+
resolvedTag,
|
|
96
|
+
asset,
|
|
97
|
+
import_github.SOCKET_BTM_REPO,
|
|
98
|
+
{
|
|
99
|
+
quiet
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
if (!assetUrl) {
|
|
103
|
+
throw new Error(`No matching asset found in release ${resolvedTag}`);
|
|
104
|
+
}
|
|
105
|
+
resolvedAsset = assetUrl.split("/").pop() || asset.toString();
|
|
106
|
+
}
|
|
107
|
+
const outputName = output || resolvedAsset;
|
|
81
108
|
const platformArch = "assets";
|
|
82
109
|
downloadConfig = {
|
|
83
110
|
owner: import_github.SOCKET_BTM_REPO.owner,
|
|
@@ -87,27 +114,29 @@ async function downloadSocketBtmRelease(config) {
|
|
|
87
114
|
toolName: tool,
|
|
88
115
|
platformArch,
|
|
89
116
|
binaryName: outputName,
|
|
90
|
-
assetName:
|
|
117
|
+
assetName: resolvedAsset,
|
|
91
118
|
toolPrefix,
|
|
92
|
-
tag,
|
|
119
|
+
tag: resolvedTag,
|
|
93
120
|
quiet,
|
|
94
121
|
removeMacOSQuarantine
|
|
95
122
|
};
|
|
96
123
|
} else {
|
|
97
124
|
const {
|
|
98
125
|
bin,
|
|
99
|
-
libc,
|
|
126
|
+
libc = detectLibc(),
|
|
100
127
|
removeMacOSQuarantine = true,
|
|
101
|
-
targetArch,
|
|
102
|
-
targetPlatform
|
|
128
|
+
targetArch = (0, import_platform.getArch)(),
|
|
129
|
+
targetPlatform = (0, import_platform.getPlatform)()
|
|
103
130
|
} = config;
|
|
104
131
|
const baseName = bin || tool;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
const assetName = getBinaryAssetName(
|
|
133
|
+
baseName,
|
|
134
|
+
targetPlatform,
|
|
135
|
+
targetArch,
|
|
136
|
+
libc
|
|
137
|
+
);
|
|
138
|
+
const platformArch = getPlatformArch(targetPlatform, targetArch, libc);
|
|
139
|
+
const binaryName = getBinaryName(baseName, targetPlatform);
|
|
111
140
|
downloadConfig = {
|
|
112
141
|
owner: import_github.SOCKET_BTM_REPO.owner,
|
|
113
142
|
repo: import_github.SOCKET_BTM_REPO.repo,
|
|
@@ -125,7 +154,40 @@ async function downloadSocketBtmRelease(config) {
|
|
|
125
154
|
}
|
|
126
155
|
return await (0, import_github.downloadGitHubRelease)(downloadConfig);
|
|
127
156
|
}
|
|
157
|
+
function getBinaryAssetName(binaryBaseName, platform, arch, libc) {
|
|
158
|
+
const mappedArch = ARCH_MAP[arch];
|
|
159
|
+
if (!mappedArch) {
|
|
160
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
161
|
+
}
|
|
162
|
+
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
163
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
164
|
+
if (platform === "darwin") {
|
|
165
|
+
return `${binaryBaseName}-darwin-${mappedArch}${ext}`;
|
|
166
|
+
}
|
|
167
|
+
if (platform === "linux") {
|
|
168
|
+
return `${binaryBaseName}-linux-${mappedArch}${muslSuffix}${ext}`;
|
|
169
|
+
}
|
|
170
|
+
if (platform === "win32") {
|
|
171
|
+
return `${binaryBaseName}-win-${mappedArch}${ext}`;
|
|
172
|
+
}
|
|
173
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
174
|
+
}
|
|
175
|
+
function getBinaryName(binaryBaseName, platform) {
|
|
176
|
+
return platform === "win32" ? `${binaryBaseName}.exe` : binaryBaseName;
|
|
177
|
+
}
|
|
178
|
+
function getPlatformArch(platform, arch, libc) {
|
|
179
|
+
const mappedArch = ARCH_MAP[arch];
|
|
180
|
+
if (!mappedArch) {
|
|
181
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
182
|
+
}
|
|
183
|
+
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
184
|
+
return `${platform}-${mappedArch}${muslSuffix}`;
|
|
185
|
+
}
|
|
128
186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
187
|
0 && (module.exports = {
|
|
130
|
-
|
|
188
|
+
detectLibc,
|
|
189
|
+
downloadSocketBtmRelease,
|
|
190
|
+
getBinaryAssetName,
|
|
191
|
+
getBinaryName,
|
|
192
|
+
getPlatformArch
|
|
131
193
|
});
|
package/dist/signal-exit.js
CHANGED
package/dist/spawn.js
CHANGED
|
@@ -37,13 +37,20 @@ __export(spawn_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(spawn_exports);
|
|
38
38
|
var import_process = require("./constants/process");
|
|
39
39
|
var import_promise_spawn = __toESM(require("./external/@npmcli/promise-spawn"));
|
|
40
|
-
var import_node_path = __toESM(require("node:path"));
|
|
41
40
|
var import_arrays = require("./arrays");
|
|
42
41
|
var import_bin = require("./bin");
|
|
43
42
|
var import_normalize = require("./paths/normalize");
|
|
44
43
|
var import_objects = require("./objects");
|
|
45
44
|
var import_spinner = require("./spinner");
|
|
46
45
|
var import_strings = require("./strings");
|
|
46
|
+
let _path;
|
|
47
|
+
// @__NO_SIDE_EFFECTS__
|
|
48
|
+
function getPath() {
|
|
49
|
+
if (_path === void 0) {
|
|
50
|
+
_path = require("path");
|
|
51
|
+
}
|
|
52
|
+
return _path;
|
|
53
|
+
}
|
|
47
54
|
const abortSignal = (0, import_process.getAbortSignal)();
|
|
48
55
|
const spinner = (0, import_spinner.getDefaultSpinner)();
|
|
49
56
|
const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
|
|
@@ -51,7 +58,7 @@ let _child_process;
|
|
|
51
58
|
// @__NO_SIDE_EFFECTS__
|
|
52
59
|
function getChildProcess() {
|
|
53
60
|
if (_child_process === void 0) {
|
|
54
|
-
_child_process = require("
|
|
61
|
+
_child_process = require("child_process");
|
|
55
62
|
}
|
|
56
63
|
return _child_process;
|
|
57
64
|
}
|
|
@@ -102,7 +109,7 @@ function spawn(cmd, args, options, extra) {
|
|
|
102
109
|
}
|
|
103
110
|
const WIN32 = process.platform === "win32";
|
|
104
111
|
if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
|
|
105
|
-
actualCmd =
|
|
112
|
+
actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
|
|
106
113
|
}
|
|
107
114
|
const wasSpinning = !!spinnerInstance?.isSpinning;
|
|
108
115
|
const shouldStopSpinner = wasSpinning && !/* @__PURE__ */ isStdioType(stdio, "ignore") && !/* @__PURE__ */ isStdioType(stdio, "pipe");
|
|
@@ -181,7 +188,7 @@ function spawnSync(cmd, args, options) {
|
|
|
181
188
|
const shell = (0, import_objects.getOwn)(options, "shell");
|
|
182
189
|
const WIN32 = process.platform === "win32";
|
|
183
190
|
if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
|
|
184
|
-
actualCmd =
|
|
191
|
+
actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
|
|
185
192
|
}
|
|
186
193
|
const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
|
|
187
194
|
__proto__: null,
|
package/dist/stdio/mask.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Interactive output masking utilities for CLI tools.
|
|
3
|
-
* Provides output control with keyboard toggling (ctrl+o).
|
|
4
|
-
*
|
|
5
|
-
* ANSI Escape Sequences Used:
|
|
6
|
-
* - '\r': Carriage return - moves cursor to beginning of current line.
|
|
7
|
-
* - '\x1b[K' or '\x1b[0K': CSI K (erase line) - clear from cursor to end of line.
|
|
8
|
-
* - '\x1b[2K': CSI 2K - erase entire line.
|
|
9
|
-
* - '\x1b[1A': CSI A - move cursor up 1 line.
|
|
10
|
-
*
|
|
11
|
-
* Terminal Control:
|
|
12
|
-
* - Raw mode (setRawMode(true)): Captures keypresses immediately without buffering.
|
|
13
|
-
* - TTY detection: Ensures terminal manipulation only occurs in interactive terminals.
|
|
14
|
-
*
|
|
15
|
-
* Key Features:
|
|
16
|
-
* - Output buffering: Stores up to 1000 lines when masked to prevent memory issues.
|
|
17
|
-
* - Graceful cleanup: Always restores terminal to normal mode on exit/error.
|
|
18
|
-
* - Visual feedback: Uses spinner to indicate process is running when output is masked.
|
|
19
|
-
*/
|
|
20
1
|
import type { ChildProcess, SpawnOptions } from 'child_process';
|
|
21
|
-
import readline from 'readline';
|
|
22
2
|
export interface OutputMaskOptions {
|
|
23
3
|
/**
|
|
24
4
|
* Current working directory for spawned process.
|
|
@@ -120,7 +100,11 @@ export declare function createOutputMask(options?: OutputMaskOptions): OutputMas
|
|
|
120
100
|
* - ctrl+c: Cancel the running process.
|
|
121
101
|
* The handler manipulates terminal state using ANSI escape sequences.
|
|
122
102
|
*/
|
|
123
|
-
|
|
103
|
+
type ReadlineKey = {
|
|
104
|
+
ctrl?: boolean;
|
|
105
|
+
name?: string;
|
|
106
|
+
};
|
|
107
|
+
export declare function createKeyboardHandler(mask: OutputMask, child: ChildProcess, options?: OutputMaskOptions): (_str: string, key: ReadlineKey) => void;
|
|
124
108
|
/**
|
|
125
109
|
* Attach output masking to a child process.
|
|
126
110
|
* Returns a promise that resolves with the exit code.
|
|
@@ -138,3 +122,4 @@ export declare function attachOutputMask(child: ChildProcess, options?: OutputMa
|
|
|
138
122
|
* stdin is inherited, stdout and stderr are piped for masking control.
|
|
139
123
|
*/
|
|
140
124
|
export declare function runWithMask(command: string, args?: string[], options?: OutputMaskOptions & SpawnOptions): Promise<number>;
|
|
125
|
+
export {};
|