@socketsecurity/lib 5.26.0 → 5.27.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 +371 -1185
- package/README.md +1 -1
- package/dist/abort.js +7 -6
- package/dist/agent.js +16 -15
- package/dist/ansi.js +3 -2
- package/dist/archives.js +18 -17
- package/dist/argv/flags.js +29 -28
- package/dist/argv/parse.js +4 -3
- package/dist/arrays.js +3 -2
- package/dist/bin.js +12 -11
- package/dist/cacache.js +16 -11
- package/dist/cache-with-ttl.js +26 -21
- package/dist/colors.js +2 -1
- package/dist/constants/licenses.js +2 -1
- package/dist/constants/lifecycle-script-names.js +2 -1
- package/dist/constants/maintained-node-versions.js +2 -1
- package/dist/constants/node.js +4 -3
- package/dist/constants/package-default-socket-categories.js +2 -1
- package/dist/constants/packages.js +4 -3
- package/dist/constants/socket.js +1 -1
- package/dist/cover/code.js +9 -8
- package/dist/cover/formatters.js +12 -11
- package/dist/cover/type.js +5 -4
- package/dist/crypto.d.ts +36 -0
- package/dist/{effects/ultra.js → crypto.js} +26 -37
- package/dist/debug.js +12 -15
- package/dist/dlx/arborist.js +10 -9
- package/dist/dlx/binary.js +27 -24
- package/dist/dlx/cache.js +2 -10
- package/dist/dlx/detect.js +6 -5
- package/dist/dlx/integrity.js +13 -11
- package/dist/dlx/lockfile.js +7 -6
- package/dist/dlx/manifest.js +6 -5
- package/dist/dlx/package.js +17 -16
- package/dist/dlx/packages.js +6 -5
- package/dist/dlx/paths.d.ts +1 -1
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +4 -3
- package/dist/effects/shimmer-keyframes.d.ts +62 -0
- package/dist/effects/shimmer-keyframes.js +55 -0
- package/dist/effects/shimmer-terminal.d.ts +66 -0
- package/dist/effects/shimmer-terminal.js +57 -0
- package/dist/effects/shimmer.d.ts +293 -0
- package/dist/effects/shimmer.js +180 -0
- package/dist/env/rewire.js +4 -3
- package/dist/env.js +5 -4
- package/dist/errors.js +1 -1
- package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
- package/dist/external/@npmcli/package-json.js +372 -372
- package/dist/external/@npmcli/promise-spawn.js +24 -24
- package/dist/external/@socketregistry/packageurl-js.js +19 -18
- package/dist/external/@socketregistry/yocto-spinner.js +4 -3
- package/dist/external/@yarnpkg/extensions.js +2 -1
- package/dist/external/adm-zip.js +71 -71
- package/dist/external/debug.js +22 -22
- package/dist/external/external-pack.js +45 -45
- package/dist/external/fast-sort.js +5 -5
- package/dist/external/libnpmexec.js +4 -3
- package/dist/external/npm-pack.js +369 -369
- package/dist/external/p-map.js +9 -9
- package/dist/external/pico-pack.js +190 -190
- package/dist/external/pony-cause.js +2 -1
- package/dist/external/spdx-pack.js +11 -10
- package/dist/external/tar-fs.js +58 -58
- package/dist/external/which.js +13 -13
- package/dist/external/yargs-parser.js +71 -71
- package/dist/fs.js +50 -68
- package/dist/git.js +14 -13
- package/dist/github.d.ts +34 -0
- package/dist/github.js +248 -23
- package/dist/globs.d.ts +20 -0
- package/dist/globs.js +134 -25
- package/dist/http-request.d.ts +4 -3
- package/dist/http-request.js +39 -32
- package/dist/ipc-cli.js +2 -1
- package/dist/ipc.js +5 -4
- package/dist/json/edit.js +4 -3
- package/dist/json/format.js +3 -2
- package/dist/json/parse.js +7 -6
- package/dist/links.js +2 -1
- package/dist/logger.js +21 -14
- package/dist/memoization.js +16 -15
- package/dist/node/async-hooks.d.ts +6 -0
- package/dist/node/async-hooks.js +34 -0
- package/dist/node/child-process.d.ts +11 -0
- package/dist/node/child-process.js +34 -0
- package/dist/node/crypto.d.ts +6 -0
- package/dist/node/crypto.js +34 -0
- package/dist/node/events.d.ts +6 -0
- package/dist/node/events.js +34 -0
- package/dist/node/fs-promises.d.ts +6 -0
- package/dist/node/fs-promises.js +34 -0
- package/dist/node/fs.d.ts +14 -0
- package/dist/node/fs.js +34 -0
- package/dist/node/http.d.ts +6 -0
- package/dist/node/http.js +34 -0
- package/dist/node/https.d.ts +6 -0
- package/dist/node/https.js +34 -0
- package/dist/node/os.d.ts +6 -0
- package/dist/node/os.js +34 -0
- package/dist/node/path.d.ts +6 -0
- package/dist/node/path.js +34 -0
- package/dist/node/timers-promises.d.ts +6 -0
- package/dist/node/timers-promises.js +34 -0
- package/dist/node/url.d.ts +6 -0
- package/dist/node/url.js +34 -0
- package/dist/node/util.d.ts +6 -0
- package/dist/node/util.js +34 -0
- package/dist/objects.js +2 -2
- package/dist/packages/edit.js +8 -7
- package/dist/packages/exports.js +17 -16
- package/dist/packages/isolation.js +20 -13
- package/dist/packages/licenses.js +6 -3
- package/dist/packages/manifest.js +2 -1
- package/dist/packages/normalize.js +8 -4
- package/dist/packages/operations.js +5 -4
- package/dist/packages/provenance.js +7 -6
- package/dist/packages/specs.js +2 -1
- package/dist/packages/validation.js +2 -1
- package/dist/paths/normalize.js +32 -40
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.js +3 -2
- package/dist/performance.js +19 -18
- package/dist/primordials.d.ts +85 -2
- package/dist/primordials.js +311 -23
- package/dist/process-lock.js +14 -13
- package/dist/promise-queue.js +17 -9
- package/dist/promises.d.ts +29 -6
- package/dist/promises.js +19 -15
- package/dist/regexps.js +9 -8
- package/dist/releases/github-api.d.ts +56 -0
- package/dist/releases/github-api.js +275 -0
- package/dist/releases/github-archives.d.ts +60 -0
- package/dist/releases/github-archives.js +136 -0
- package/dist/releases/github-assets.d.ts +21 -0
- package/dist/releases/github-assets.js +52 -0
- package/dist/releases/github-auth.d.ts +16 -0
- package/dist/releases/github-auth.js +51 -0
- package/dist/releases/github-downloads.d.ts +42 -0
- package/dist/releases/github-downloads.js +155 -0
- package/dist/releases/github-types.d.ts +66 -0
- package/dist/{effects/types.js → releases/github-types.js} +2 -2
- package/dist/releases/socket-btm.d.ts +1 -1
- package/dist/releases/socket-btm.js +17 -17
- package/dist/schema/parse.js +2 -1
- package/dist/schema/validate.js +6 -5
- package/dist/sea/util.d.ts +43 -0
- package/dist/{sea.js → sea/util.js} +7 -7
- package/dist/shadow.js +2 -1
- package/dist/signal-exit.js +2 -2
- package/dist/smol/primordial.d.ts +80 -0
- package/dist/smol/primordial.js +46 -0
- package/dist/smol/util.d.ts +87 -0
- package/dist/smol/util.js +59 -0
- package/dist/smol/versions.d.ts +46 -0
- package/dist/smol/versions.js +46 -0
- package/dist/spawn.js +58 -63
- package/dist/spinner.d.ts +13 -6
- package/dist/spinner.js +75 -57
- package/dist/ssri.js +8 -7
- package/dist/stdio/footer.js +13 -12
- package/dist/stdio/header.js +5 -4
- package/dist/stdio/progress.js +13 -12
- package/dist/strings.js +19 -18
- package/dist/suppress-warnings.js +2 -2
- package/dist/tables.js +16 -13
- package/dist/temporary-executor.js +2 -1
- package/dist/themes/context.js +2 -1
- package/dist/themes/types.d.ts +1 -1
- package/dist/themes/utils.d.ts +8 -3
- package/dist/themes/utils.js +29 -5
- package/dist/url.js +4 -3
- package/dist/versions.js +27 -22
- package/package.json +120 -26
- package/dist/effects/text-shimmer.d.ts +0 -58
- package/dist/effects/text-shimmer.js +0 -192
- package/dist/effects/types.d.ts +0 -47
- package/dist/effects/ultra.d.ts +0 -22
- package/dist/releases/github.d.ts +0 -234
- package/dist/releases/github.js +0 -417
- package/dist/sea.d.ts +0 -30
- package/dist/themes/index.d.ts +0 -49
- package/dist/themes/index.js +0 -60
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Smol detection + lazy-loader for `node:smol-util`.
|
|
3
|
+
*
|
|
4
|
+
* Two responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* 1. `isSmol()` — memoized boolean detector for socket-btm's smol
|
|
7
|
+
* Node binary. Mirrors `isSeaBinary()` from `src/sea.ts`. Probes
|
|
8
|
+
* via `node:module.isBuiltin('node:smol-util')` since only the
|
|
9
|
+
* smol binary registers any `node:smol-*` builtins.
|
|
10
|
+
*
|
|
11
|
+
* 2. `getSmolUtil()` — lazy-loader for the `node:smol-util` binding,
|
|
12
|
+
* which provides native `uncurryThis` and `applyBind` (single
|
|
13
|
+
* V8 dispatch via `args.Data()` + `v8::Function::Call`, skipping
|
|
14
|
+
* the BoundFunction adapter + `Function.prototype.call` trampoline
|
|
15
|
+
* that the JS form `bind.bind(call)(fn)` hits twice per invocation).
|
|
16
|
+
* ~2x faster on hot uncurried-call sites.
|
|
17
|
+
*
|
|
18
|
+
* `getSmolUtil()` returns `undefined` on stock Node + non-Node
|
|
19
|
+
* runtimes. Result is cached across calls; the lazy-loader follows
|
|
20
|
+
* the same shape as `src/node/fs.ts` etc.
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/SocketDev/socket-btm — socket-btm builds
|
|
23
|
+
* the smol binary that exposes the `node:smol-util` binding.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Detect if the current process is running on socket-btm's smol Node
|
|
27
|
+
* binary. Memoized on first call.
|
|
28
|
+
*
|
|
29
|
+
* Defensive across runtimes: returns `false` on stock Node, browsers
|
|
30
|
+
* (no `node:module`), Deno / Bun (different module resolution), and
|
|
31
|
+
* worker threads (each has its own builtin table).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { isSmol } from '@socketsecurity/lib/smol/util'
|
|
36
|
+
*
|
|
37
|
+
* if (isSmol()) {
|
|
38
|
+
* // running on the smol binary; native fast paths available
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function isSmol(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Surface of `node:smol-util`. See socket-btm's
|
|
45
|
+
* additions/source-patched/lib/smol-util.js for the canonical shape.
|
|
46
|
+
*/
|
|
47
|
+
export interface SmolUtilBinding {
|
|
48
|
+
/**
|
|
49
|
+
* Native equivalent of `Function.prototype.bind.bind(apply)(fn)`.
|
|
50
|
+
*/
|
|
51
|
+
applyBind: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R;
|
|
52
|
+
/**
|
|
53
|
+
* Native equivalent of:
|
|
54
|
+
* `(self, args) => { try { return fn.apply(self, args) } catch {} }`.
|
|
55
|
+
* Returns a function that swallows synchronous throws and returns
|
|
56
|
+
* `undefined`. Avoids JS-level throw construction on the swallow
|
|
57
|
+
* path — useful for logger sinks, debug hooks, abort handlers, etc.
|
|
58
|
+
*/
|
|
59
|
+
applySafe: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Native equivalent of:
|
|
62
|
+
* `(...newArgs) => fn.call(thisArg, ...presetArgs, ...newArgs)`.
|
|
63
|
+
* Same shape as `Function.prototype.bind` but with a single C++
|
|
64
|
+
* dispatch instead of going through V8's BoundFunction adapter.
|
|
65
|
+
* Useful where `bind` would be hot — captured callbacks fed to
|
|
66
|
+
* `setImmediate`/`setTimeout`/promise continuations.
|
|
67
|
+
*/
|
|
68
|
+
bindCall: <T, P extends readonly unknown[], A extends readonly unknown[], R>(fn: (this: T, ...args: [...P, ...A]) => R, thisArg: T, ...presetArgs: P) => (...newArgs: A) => R;
|
|
69
|
+
/**
|
|
70
|
+
* Native equivalent of `Function.prototype.bind.bind(call)(fn)`.
|
|
71
|
+
* Single C++ dispatch via `args.Data()` + `v8::Function::Call`.
|
|
72
|
+
*/
|
|
73
|
+
uncurryThis: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, ...args: A) => R;
|
|
74
|
+
/**
|
|
75
|
+
* Native equivalent of:
|
|
76
|
+
* `try { return new WeakRef(target) } catch { return undefined }`.
|
|
77
|
+
* Returns `undefined` for non-Object, non-Symbol inputs that would
|
|
78
|
+
* make the constructor throw. The Safe suffix follows the project's
|
|
79
|
+
* non-throwing-wrapper convention.
|
|
80
|
+
*/
|
|
81
|
+
weakRefSafe: <T extends object | symbol>(target: T) => WeakRef<T> | undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns `node:smol-util` when running on the smol Node binary,
|
|
85
|
+
* otherwise `undefined`. Result is cached across calls.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getSmolUtil(): SmolUtilBinding | undefined;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var util_exports = {};
|
|
22
|
+
__export(util_exports, {
|
|
23
|
+
getSmolUtil: () => getSmolUtil,
|
|
24
|
+
isSmol: () => isSmol
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(util_exports);
|
|
27
|
+
let _isSmol;
|
|
28
|
+
function isSmol() {
|
|
29
|
+
if (_isSmol === void 0) {
|
|
30
|
+
try {
|
|
31
|
+
const mod = require("node:module");
|
|
32
|
+
_isSmol = typeof mod.isBuiltin === "function" && mod.isBuiltin("node:smol-util");
|
|
33
|
+
} catch {
|
|
34
|
+
_isSmol = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return _isSmol ?? false;
|
|
38
|
+
}
|
|
39
|
+
let _smolUtil;
|
|
40
|
+
// @__NO_SIDE_EFFECTS__
|
|
41
|
+
function getSmolUtil() {
|
|
42
|
+
if (_smolUtil === void 0) {
|
|
43
|
+
if (isSmol()) {
|
|
44
|
+
try {
|
|
45
|
+
_smolUtil = require("node:smol-util");
|
|
46
|
+
} catch {
|
|
47
|
+
_smolUtil = null;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
_smolUtil = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return _smolUtil ?? void 0;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
getSmolUtil,
|
|
58
|
+
isSmol
|
|
59
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lazy-loader for socket-btm's `node:smol-versions`.
|
|
3
|
+
*
|
|
4
|
+
* `node:smol-versions` is the multi-ecosystem version helper exposed
|
|
5
|
+
* by socket-btm's smol Node binary. It supports npm/maven/pypi/nuget/
|
|
6
|
+
* gem version comparison + range satisfies with internal C++
|
|
7
|
+
* acceleration on the npm hot path.
|
|
8
|
+
*
|
|
9
|
+
* Returns `undefined` on stock Node + non-Node runtimes. Result is
|
|
10
|
+
* cached across calls.
|
|
11
|
+
*
|
|
12
|
+
* @internal — used by `src/versions.ts` to resolve smol-aware version
|
|
13
|
+
* ops. Most callers should use the standard `versions` exports,
|
|
14
|
+
* which already route through this when smol is present.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Surface of `node:smol-versions`. See socket-btm's
|
|
18
|
+
* additions/source-patched/lib/smol-versions.js for the canonical
|
|
19
|
+
* shape. Each entry takes an optional `ecosystem` (default `'npm'`)
|
|
20
|
+
* — pass it for non-npm versions; npm callers can omit.
|
|
21
|
+
*/
|
|
22
|
+
export interface SmolVersionsBinding {
|
|
23
|
+
compare(a: string, b: string, ecosystem?: string): -1 | 0 | 1;
|
|
24
|
+
eq(a: string, b: string, ecosystem?: string): boolean;
|
|
25
|
+
gt(a: string, b: string, ecosystem?: string): boolean;
|
|
26
|
+
gte(a: string, b: string, ecosystem?: string): boolean;
|
|
27
|
+
inc(version: string, release: 'major' | 'minor' | 'patch' | 'prerelease', ecosystem?: string, identifier?: string): string | undefined;
|
|
28
|
+
lt(a: string, b: string, ecosystem?: string): boolean;
|
|
29
|
+
lte(a: string, b: string, ecosystem?: string): boolean;
|
|
30
|
+
max(versions: readonly string[], ecosystem?: string): string | undefined;
|
|
31
|
+
maxSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
|
|
32
|
+
min(versions: readonly string[], ecosystem?: string): string | undefined;
|
|
33
|
+
minSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
|
|
34
|
+
neq(a: string, b: string, ecosystem?: string): boolean;
|
|
35
|
+
rsort(versions: readonly string[], ecosystem?: string): string[];
|
|
36
|
+
satisfies(version: string, range: string, ecosystem?: string): boolean;
|
|
37
|
+
sort(versions: readonly string[], ecosystem?: string): string[];
|
|
38
|
+
valid(version: string, ecosystem?: string): string | undefined;
|
|
39
|
+
filter(versions: readonly string[], range: string, ecosystem?: string): string[];
|
|
40
|
+
coerce(version: string, ecosystem?: string): string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns `node:smol-versions` when running on the smol Node binary,
|
|
44
|
+
* otherwise `undefined`. Result is cached across calls.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSmolVersions(): SmolVersionsBinding | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var versions_exports = {};
|
|
22
|
+
__export(versions_exports, {
|
|
23
|
+
getSmolVersions: () => getSmolVersions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(versions_exports);
|
|
26
|
+
var import_util = require("./util");
|
|
27
|
+
let _smolVersions;
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
function getSmolVersions() {
|
|
30
|
+
if (_smolVersions === void 0) {
|
|
31
|
+
if ((0, import_util.isSmol)()) {
|
|
32
|
+
try {
|
|
33
|
+
_smolVersions = require("node:smol-versions");
|
|
34
|
+
} catch {
|
|
35
|
+
_smolVersions = null;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
_smolVersions = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return _smolVersions ?? void 0;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
getSmolVersions
|
|
46
|
+
});
|
package/dist/spawn.js
CHANGED
|
@@ -42,33 +42,20 @@ var import_arrays = require("./arrays");
|
|
|
42
42
|
var import_bin = require("./bin");
|
|
43
43
|
var import_process = require("./constants/process");
|
|
44
44
|
var import_errors = require("./errors");
|
|
45
|
+
var import_child_process = require("./node/child-process");
|
|
46
|
+
var import_fs = require("./node/fs");
|
|
47
|
+
var import_path = require("./node/path");
|
|
45
48
|
var import_objects = require("./objects");
|
|
46
49
|
var import_normalize = require("./paths/normalize");
|
|
47
50
|
var import_spinner = require("./spinner");
|
|
48
51
|
var import_strings = require("./strings");
|
|
52
|
+
var import_primordials = require("./primordials");
|
|
49
53
|
const abortSignal = (0, import_process.getAbortSignal)();
|
|
50
54
|
const spinner = (0, import_spinner.getDefaultSpinner)();
|
|
51
|
-
const stackCache =
|
|
52
|
-
const spawnBinPathCache =
|
|
55
|
+
const stackCache = new import_primordials.WeakMapCtor();
|
|
56
|
+
const spawnBinPathCache = new import_primordials.MapCtor();
|
|
53
57
|
const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
|
|
54
58
|
let _npmCliPromiseSpawn;
|
|
55
|
-
let _path;
|
|
56
|
-
let _fs;
|
|
57
|
-
let _child_process;
|
|
58
|
-
// @__NO_SIDE_EFFECTS__
|
|
59
|
-
function getChildProcess() {
|
|
60
|
-
if (_child_process === void 0) {
|
|
61
|
-
_child_process = require("node:child_process");
|
|
62
|
-
}
|
|
63
|
-
return _child_process;
|
|
64
|
-
}
|
|
65
|
-
// @__NO_SIDE_EFFECTS__
|
|
66
|
-
function getFs() {
|
|
67
|
-
if (_fs === void 0) {
|
|
68
|
-
_fs = require("node:fs");
|
|
69
|
-
}
|
|
70
|
-
return _fs;
|
|
71
|
-
}
|
|
72
59
|
// @__NO_SIDE_EFFECTS__
|
|
73
60
|
function getNpmCliPromiseSpawn() {
|
|
74
61
|
if (_npmCliPromiseSpawn === void 0) {
|
|
@@ -77,13 +64,6 @@ function getNpmCliPromiseSpawn() {
|
|
|
77
64
|
return _npmCliPromiseSpawn;
|
|
78
65
|
}
|
|
79
66
|
// @__NO_SIDE_EFFECTS__
|
|
80
|
-
function getPath() {
|
|
81
|
-
if (_path === void 0) {
|
|
82
|
-
_path = require("node:path");
|
|
83
|
-
}
|
|
84
|
-
return _path;
|
|
85
|
-
}
|
|
86
|
-
// @__NO_SIDE_EFFECTS__
|
|
87
67
|
function stripAnsiFromSpawnResult(result) {
|
|
88
68
|
const res = result;
|
|
89
69
|
const { stderr, stdout } = res;
|
|
@@ -133,7 +113,7 @@ ${firstLine.slice(0, 197)}...`;
|
|
|
133
113
|
}
|
|
134
114
|
const isSynthetic = err.message === "command failed";
|
|
135
115
|
if (isSynthetic) {
|
|
136
|
-
|
|
116
|
+
(0, import_primordials.ObjectDefineProperty)(err, "message", {
|
|
137
117
|
__proto__: null,
|
|
138
118
|
value: enhancedMessage,
|
|
139
119
|
writable: true,
|
|
@@ -142,14 +122,14 @@ ${firstLine.slice(0, 197)}...`;
|
|
|
142
122
|
});
|
|
143
123
|
return err;
|
|
144
124
|
}
|
|
145
|
-
const enhancedError = new
|
|
125
|
+
const enhancedError = new import_primordials.ErrorCtor(enhancedMessage, {
|
|
146
126
|
cause: err
|
|
147
127
|
});
|
|
148
|
-
const descriptors =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
128
|
+
const descriptors = (0, import_primordials.ObjectGetOwnPropertyDescriptors)(err);
|
|
129
|
+
(0, import_primordials.ReflectDeleteProperty)(descriptors, "message");
|
|
130
|
+
(0, import_primordials.ReflectDeleteProperty)(descriptors, "stack");
|
|
131
|
+
(0, import_primordials.ObjectDefineProperties)(enhancedError, descriptors);
|
|
132
|
+
(0, import_primordials.ObjectDefineProperty)(enhancedError, "stack", {
|
|
153
133
|
__proto__: null,
|
|
154
134
|
configurable: true,
|
|
155
135
|
enumerable: false,
|
|
@@ -196,7 +176,7 @@ function spawn(cmd, args, options, extra) {
|
|
|
196
176
|
const cwd = spawnOptions.cwd ? String(spawnOptions.cwd) : void 0;
|
|
197
177
|
let actualCmd = cmd;
|
|
198
178
|
if (!(0, import_normalize.isPath)(cmd)) {
|
|
199
|
-
const fs =
|
|
179
|
+
const fs = (0, import_fs.getNodeFs)();
|
|
200
180
|
const cached = spawnBinPathCache.get(cmd);
|
|
201
181
|
if (cached) {
|
|
202
182
|
if (fs.existsSync(cached)) {
|
|
@@ -214,9 +194,12 @@ function spawn(cmd, args, options, extra) {
|
|
|
214
194
|
}
|
|
215
195
|
}
|
|
216
196
|
const WIN32 = import_node_process.default.platform === "win32";
|
|
217
|
-
if (WIN32 && shell &&
|
|
197
|
+
if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
|
|
218
198
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
219
|
-
actualCmd = (
|
|
199
|
+
actualCmd = (0, import_path.getNodePath)().basename(
|
|
200
|
+
actualCmd,
|
|
201
|
+
(0, import_path.getNodePath)().extname(actualCmd)
|
|
202
|
+
);
|
|
220
203
|
}
|
|
221
204
|
}
|
|
222
205
|
const wasSpinning = !!spinnerInstance?.isSpinning;
|
|
@@ -253,35 +236,44 @@ function spawn(cmd, args, options, extra) {
|
|
|
253
236
|
const oldSpawnPromise = spawnPromise;
|
|
254
237
|
let newSpawnPromise;
|
|
255
238
|
if (shouldStripAnsi && stdioString) {
|
|
256
|
-
newSpawnPromise =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
;
|
|
260
|
-
|
|
239
|
+
newSpawnPromise = (async () => {
|
|
240
|
+
try {
|
|
241
|
+
const result = await spawnPromise;
|
|
242
|
+
const strippedResult = /* @__PURE__ */ stripAnsiFromSpawnResult(result);
|
|
243
|
+
if ("code" in strippedResult) {
|
|
244
|
+
;
|
|
245
|
+
strippedResult.exitCode = strippedResult.code;
|
|
246
|
+
}
|
|
247
|
+
return strippedResult;
|
|
248
|
+
} catch (error) {
|
|
249
|
+
const strippedError = /* @__PURE__ */ stripAnsiFromSpawnResult(error);
|
|
250
|
+
throw /* @__PURE__ */ enhanceSpawnError(strippedError);
|
|
261
251
|
}
|
|
262
|
-
|
|
263
|
-
}).catch((error) => {
|
|
264
|
-
const strippedError = /* @__PURE__ */ stripAnsiFromSpawnResult(error);
|
|
265
|
-
const enhancedError = /* @__PURE__ */ enhanceSpawnError(strippedError);
|
|
266
|
-
throw enhancedError;
|
|
267
|
-
});
|
|
252
|
+
})();
|
|
268
253
|
} else {
|
|
269
|
-
newSpawnPromise =
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
254
|
+
newSpawnPromise = (async () => {
|
|
255
|
+
try {
|
|
256
|
+
const result = await spawnPromise;
|
|
257
|
+
if (result !== null && typeof result === "object" && "code" in result) {
|
|
258
|
+
const res = result;
|
|
259
|
+
res.exitCode = res.code;
|
|
260
|
+
return res;
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
} catch (error) {
|
|
264
|
+
throw /* @__PURE__ */ enhanceSpawnError(error);
|
|
274
265
|
}
|
|
275
|
-
|
|
276
|
-
}).catch((error) => {
|
|
277
|
-
const enhancedError = /* @__PURE__ */ enhanceSpawnError(error);
|
|
278
|
-
throw enhancedError;
|
|
279
|
-
});
|
|
266
|
+
})();
|
|
280
267
|
}
|
|
281
268
|
if (shouldRestartSpinner) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
269
|
+
const prevPromise = newSpawnPromise;
|
|
270
|
+
newSpawnPromise = (async () => {
|
|
271
|
+
try {
|
|
272
|
+
return await prevPromise;
|
|
273
|
+
} finally {
|
|
274
|
+
spinnerInstance.start();
|
|
275
|
+
}
|
|
276
|
+
})();
|
|
285
277
|
}
|
|
286
278
|
;
|
|
287
279
|
newSpawnPromise.process = oldSpawnPromise.process;
|
|
@@ -301,9 +293,12 @@ function spawnSync(cmd, args, options) {
|
|
|
301
293
|
}
|
|
302
294
|
const shell = (0, import_objects.getOwn)(options, "shell");
|
|
303
295
|
const WIN32 = import_node_process.default.platform === "win32";
|
|
304
|
-
if (WIN32 && shell &&
|
|
296
|
+
if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
|
|
305
297
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
306
|
-
actualCmd = (
|
|
298
|
+
actualCmd = (0, import_path.getNodePath)().basename(
|
|
299
|
+
actualCmd,
|
|
300
|
+
(0, import_path.getNodePath)().extname(actualCmd)
|
|
301
|
+
);
|
|
307
302
|
}
|
|
308
303
|
}
|
|
309
304
|
const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
|
|
@@ -317,7 +312,7 @@ function spawnSync(cmd, args, options) {
|
|
|
317
312
|
...rawSpawnOptions
|
|
318
313
|
};
|
|
319
314
|
const stdioString = spawnOptions.encoding !== "buffer";
|
|
320
|
-
const result = (
|
|
315
|
+
const result = (0, import_child_process.getNodeChildProcess)().spawnSync(actualCmd, args, spawnOptions);
|
|
321
316
|
if (stdioString) {
|
|
322
317
|
const { stderr, stdout } = result;
|
|
323
318
|
if (stdout) {
|
package/dist/spinner.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Writable } from 'node:stream';
|
|
6
6
|
import type { ColorInherit, ColorRgb, ColorValue } from './colors';
|
|
7
|
-
import type {
|
|
7
|
+
import type { Palette, ShimmerConfig, ShimmerDirection } from './effects/shimmer';
|
|
8
8
|
/**
|
|
9
9
|
* Symbol types for status messages.
|
|
10
10
|
* Maps to log symbols: fail (✗), info (ℹ), skip (↻), success (✓), warn (⚠).
|
|
@@ -23,12 +23,19 @@ export type ProgressInfo = {
|
|
|
23
23
|
unit?: string | undefined;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* Internal shimmer state
|
|
27
|
-
*
|
|
26
|
+
* Internal shimmer runtime state. Holds the user-facing config plus a
|
|
27
|
+
* monotonic frame counter; the spinner advances `frame` on each animation
|
|
28
|
+
* tick and feeds the current frame to the shimmer engine.
|
|
28
29
|
*/
|
|
29
|
-
export type ShimmerInfo =
|
|
30
|
-
/**
|
|
31
|
-
color: ColorInherit | ColorValue |
|
|
30
|
+
export type ShimmerInfo = {
|
|
31
|
+
/** User-facing color reference (inherit, explicit value, or palette). */
|
|
32
|
+
color: ColorInherit | ColorValue | Palette;
|
|
33
|
+
/** Current direction (driven by config, snapshotted here for getters). */
|
|
34
|
+
direction: ShimmerDirection;
|
|
35
|
+
/** Steps per frame. */
|
|
36
|
+
speed: number;
|
|
37
|
+
/** Monotonic frame counter — advanced on each animation tick. */
|
|
38
|
+
frame: number;
|
|
32
39
|
};
|
|
33
40
|
/**
|
|
34
41
|
* Spinner instance for displaying animated loading indicators.
|