@socketsecurity/lib 3.0.1 → 3.0.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 +24 -0
- package/dist/abort.js +60 -1
- package/dist/abort.js.map +2 -2
- package/dist/agent.js +289 -1
- package/dist/agent.js.map +2 -2
- package/dist/ansi.js +60 -1
- package/dist/ansi.js.map +2 -2
- package/dist/argv/flags.js +282 -1
- package/dist/argv/flags.js.map +2 -2
- package/dist/argv/parse.js +171 -1
- package/dist/argv/parse.js.map +2 -2
- package/dist/arrays.js +85 -1
- package/dist/arrays.js.map +2 -2
- package/dist/bin.js +419 -5
- package/dist/bin.js.map +2 -2
- package/dist/cacache.js +139 -1
- package/dist/cacache.js.map +2 -2
- package/dist/cache-with-ttl.js +223 -1
- package/dist/cache-with-ttl.js.map +2 -2
- package/dist/constants/agents.js +126 -1
- package/dist/constants/agents.js.map +2 -2
- package/dist/constants/core.d.ts +1 -1
- package/dist/constants/core.js +57 -2
- package/dist/constants/core.js.map +3 -3
- package/dist/constants/encoding.js +48 -1
- package/dist/constants/encoding.js.map +2 -2
- package/dist/constants/github.js +30 -1
- package/dist/constants/github.js.map +2 -2
- package/dist/constants/licenses.js +66 -1
- package/dist/constants/licenses.js.map +2 -2
- package/dist/constants/node.js +185 -1
- package/dist/constants/node.js.map +2 -2
- package/dist/constants/packages.js +128 -1
- package/dist/constants/packages.js.map +2 -2
- package/dist/constants/paths.js +150 -1
- package/dist/constants/paths.js.map +2 -2
- package/dist/constants/platform.js +41 -1
- package/dist/constants/platform.js.map +2 -2
- package/dist/constants/process.js +52 -1
- package/dist/constants/process.js.map +2 -2
- package/dist/constants/socket.js +102 -1
- package/dist/constants/socket.js.map +2 -2
- package/dist/constants/testing.js +36 -1
- package/dist/constants/testing.js.map +2 -2
- package/dist/constants/time.js +39 -1
- package/dist/constants/time.js.map +2 -2
- package/dist/constants/typescript.js +54 -1
- package/dist/constants/typescript.js.map +2 -2
- package/dist/cover/code.js +135 -1
- package/dist/cover/code.js.map +2 -2
- package/dist/cover/formatters.js +101 -11
- package/dist/cover/formatters.js.map +2 -2
- package/dist/cover/type.js +63 -1
- package/dist/cover/type.js.map +2 -2
- package/dist/cover/types.js +15 -1
- package/dist/cover/types.js.map +2 -2
- package/dist/debug.js +337 -2
- package/dist/debug.js.map +2 -2
- package/dist/dlx-binary.js +408 -7
- package/dist/dlx-binary.js.map +2 -2
- package/dist/dlx-package.js +278 -7
- package/dist/dlx-package.js.map +2 -2
- package/dist/dlx.js +214 -7
- package/dist/dlx.js.map +3 -3
- package/dist/effects/pulse-frames.js +64 -1
- package/dist/effects/pulse-frames.js.map +2 -2
- package/dist/effects/text-shimmer.js +174 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/effects/types.js +15 -1
- package/dist/effects/types.js.map +2 -2
- package/dist/effects/ultra.js +61 -1
- package/dist/effects/ultra.js.map +2 -2
- package/dist/env/ci.js +31 -1
- package/dist/env/ci.js.map +2 -2
- package/dist/env/debug.js +30 -1
- package/dist/env/debug.js.map +2 -2
- package/dist/env/github.js +65 -1
- package/dist/env/github.js.map +2 -2
- package/dist/env/helpers.js +47 -1
- package/dist/env/helpers.js.map +2 -2
- package/dist/env/home.js +30 -1
- package/dist/env/home.js.map +2 -2
- package/dist/env/locale.js +40 -1
- package/dist/env/locale.js.map +2 -2
- package/dist/env/node-auth-token.js +30 -1
- package/dist/env/node-auth-token.js.map +2 -2
- package/dist/env/node-env.js +30 -1
- package/dist/env/node-env.js.map +2 -2
- package/dist/env/npm.js +50 -1
- package/dist/env/npm.js.map +2 -2
- package/dist/env/package-manager.js +73 -1
- package/dist/env/package-manager.js.map +2 -2
- package/dist/env/path.js +30 -1
- package/dist/env/path.js.map +2 -2
- package/dist/env/pre-commit.js +31 -1
- package/dist/env/pre-commit.js.map +2 -2
- package/dist/env/rewire.js +72 -1
- package/dist/env/rewire.js.map +2 -2
- package/dist/env/shell.js +30 -1
- package/dist/env/shell.js.map +2 -2
- package/dist/env/socket-cli-shadow.js +51 -1
- package/dist/env/socket-cli-shadow.js.map +2 -2
- package/dist/env/socket-cli.js +86 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/env/socket.js +101 -1
- package/dist/env/socket.js.map +2 -2
- package/dist/env/temp-dir.js +40 -1
- package/dist/env/temp-dir.js.map +2 -2
- package/dist/env/term.js +30 -1
- package/dist/env/term.js.map +2 -2
- package/dist/env/test.js +43 -1
- package/dist/env/test.js.map +2 -2
- package/dist/env/windows.js +45 -1
- package/dist/env/windows.js.map +2 -2
- package/dist/env/xdg.js +40 -1
- package/dist/env/xdg.js.map +2 -2
- package/dist/env.js +170 -1
- package/dist/env.js.map +2 -2
- package/dist/fs.js +670 -7
- package/dist/fs.js.map +2 -2
- package/dist/functions.js +68 -1
- package/dist/functions.js.map +2 -2
- package/dist/git.js +329 -2
- package/dist/git.js.map +2 -2
- package/dist/github.js +202 -1
- package/dist/github.js.map +2 -2
- package/dist/globs.js +149 -1
- package/dist/globs.js.map +3 -3
- package/dist/http-request.js +335 -3
- package/dist/http-request.js.map +2 -2
- package/dist/index.js +69 -1
- package/dist/index.js.map +2 -2
- package/dist/ipc.js +244 -1
- package/dist/ipc.js.map +2 -2
- package/dist/json.js +73 -1
- package/dist/json.js.map +2 -2
- package/dist/links/index.js +60 -1
- package/dist/links/index.js.map +2 -2
- package/dist/logger.js +1384 -1
- package/dist/logger.js.map +2 -2
- package/dist/maintained-node-versions.js +35 -1
- package/dist/maintained-node-versions.js.map +2 -2
- package/dist/memoization.js +210 -1
- package/dist/memoization.js.map +2 -2
- package/dist/objects.js +311 -1
- package/dist/objects.js.map +2 -2
- package/dist/packages/editable.js +356 -9
- package/dist/packages/editable.js.map +2 -2
- package/dist/packages/exports.js +162 -1
- package/dist/packages/exports.js.map +2 -2
- package/dist/packages/isolation.js +187 -1
- package/dist/packages/isolation.js.map +2 -2
- package/dist/packages/licenses.js +214 -1
- package/dist/packages/licenses.js.map +2 -2
- package/dist/packages/manifest.js +190 -1
- package/dist/packages/manifest.js.map +2 -2
- package/dist/packages/normalize.js +132 -1
- package/dist/packages/normalize.js.map +2 -2
- package/dist/packages/operations.js +320 -1
- package/dist/packages/operations.js.map +2 -2
- package/dist/packages/paths.js +53 -1
- package/dist/packages/paths.js.map +2 -2
- package/dist/packages/provenance.js +178 -1
- package/dist/packages/provenance.js.map +2 -2
- package/dist/packages/specs.js +83 -1
- package/dist/packages/specs.js.map +2 -2
- package/dist/packages/validation.js +51 -1
- package/dist/packages/validation.js.map +2 -2
- package/dist/packages.js +129 -1
- package/dist/packages.js.map +2 -2
- package/dist/path.js +446 -1
- package/dist/path.js.map +2 -2
- package/dist/paths/rewire.js +79 -1
- package/dist/paths/rewire.js.map +2 -2
- package/dist/paths.js +190 -1
- package/dist/paths.js.map +2 -2
- package/dist/performance.js +216 -15
- package/dist/performance.js.map +2 -2
- package/dist/process-lock.js +287 -8
- package/dist/process-lock.js.map +2 -2
- package/dist/promise-queue.js +109 -1
- package/dist/promise-queue.js.map +2 -2
- package/dist/promises.js +267 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.js +45 -1
- package/dist/prompts/index.js.map +2 -2
- package/dist/prompts.js +58 -1
- package/dist/prompts.js.map +2 -2
- package/dist/regexps.js +30 -1
- package/dist/regexps.js.map +2 -2
- package/dist/sea.js +44 -1
- package/dist/sea.js.map +2 -2
- package/dist/shadow.js +58 -1
- package/dist/shadow.js.map +2 -2
- package/dist/signal-exit.js +248 -1
- package/dist/signal-exit.js.map +3 -3
- package/dist/sorts.js +94 -1
- package/dist/sorts.js.map +3 -3
- package/dist/spawn.js +200 -1
- package/dist/spawn.js.map +2 -2
- package/dist/spinner.js +961 -1
- package/dist/spinner.js.map +2 -2
- package/dist/ssri.js +71 -1
- package/dist/ssri.js.map +2 -2
- package/dist/stdio/clear.js +82 -1
- package/dist/stdio/clear.js.map +2 -2
- package/dist/stdio/divider.js +89 -3
- package/dist/stdio/divider.js.map +2 -2
- package/dist/stdio/footer.js +94 -2
- package/dist/stdio/footer.js.map +2 -2
- package/dist/stdio/header.js +100 -2
- package/dist/stdio/header.js.map +2 -2
- package/dist/stdio/mask.js +207 -5
- package/dist/stdio/mask.js.map +2 -2
- package/dist/stdio/progress.js +209 -2
- package/dist/stdio/progress.js.map +2 -2
- package/dist/stdio/prompts.js +88 -1
- package/dist/stdio/prompts.js.map +2 -2
- package/dist/stdio/stderr.js +89 -2
- package/dist/stdio/stderr.js.map +2 -2
- package/dist/stdio/stdout.js +103 -2
- package/dist/stdio/stdout.js.map +2 -2
- package/dist/streams.js +78 -1
- package/dist/streams.js.map +2 -2
- package/dist/strings.js +251 -3
- package/dist/strings.js.map +2 -2
- package/dist/suppress-warnings.js +98 -1
- package/dist/suppress-warnings.js.map +2 -2
- package/dist/tables.js +128 -3
- package/dist/tables.js.map +2 -2
- package/dist/temporary-executor.js +53 -1
- package/dist/temporary-executor.js.map +2 -2
- package/dist/themes/context.js +71 -1
- package/dist/themes/context.js.map +2 -2
- package/dist/themes/index.js +57 -1
- package/dist/themes/index.js.map +2 -2
- package/dist/themes/themes.js +195 -1
- package/dist/themes/themes.js.map +2 -2
- package/dist/themes/types.js +15 -1
- package/dist/themes/types.js.map +2 -2
- package/dist/themes/utils.js +116 -1
- package/dist/themes/utils.js.map +2 -2
- package/dist/types.js +59 -1
- package/dist/types.js.map +2 -2
- package/dist/url.js +142 -1
- package/dist/url.js.map +2 -2
- package/dist/utils/get-ipc.js +58 -1
- package/dist/utils/get-ipc.js.map +2 -2
- package/dist/validation/json-parser.js +127 -1
- package/dist/validation/json-parser.js.map +2 -2
- package/dist/validation/types.js +15 -1
- package/dist/validation/types.js.map +2 -2
- package/dist/versions.js +154 -1
- package/dist/versions.js.map +2 -2
- package/dist/words.js +50 -1
- package/dist/words.js.map +2 -2
- package/dist/zod.js +27 -1
- package/dist/zod.js.map +2 -2
- package/package.json +1 -1
package/dist/arrays.js
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var arrays_exports = {};
|
|
20
|
+
__export(arrays_exports, {
|
|
21
|
+
arrayChunk: () => arrayChunk,
|
|
22
|
+
arrayUnique: () => arrayUnique,
|
|
23
|
+
isArray: () => isArray,
|
|
24
|
+
joinAnd: () => joinAnd,
|
|
25
|
+
joinOr: () => joinOr
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(arrays_exports);
|
|
28
|
+
let _conjunctionFormatter;
|
|
29
|
+
// @__NO_SIDE_EFFECTS__
|
|
30
|
+
function getConjunctionFormatter() {
|
|
31
|
+
if (_conjunctionFormatter === void 0) {
|
|
32
|
+
_conjunctionFormatter = new Intl.ListFormat("en", {
|
|
33
|
+
style: "long",
|
|
34
|
+
// "and" lists.
|
|
35
|
+
type: "conjunction"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return _conjunctionFormatter;
|
|
39
|
+
}
|
|
40
|
+
let _disjunctionFormatter;
|
|
41
|
+
// @__NO_SIDE_EFFECTS__
|
|
42
|
+
function getDisjunctionFormatter() {
|
|
43
|
+
if (_disjunctionFormatter === void 0) {
|
|
44
|
+
_disjunctionFormatter = new Intl.ListFormat("en", {
|
|
45
|
+
style: "long",
|
|
46
|
+
// "or" lists.
|
|
47
|
+
type: "disjunction"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return _disjunctionFormatter;
|
|
51
|
+
}
|
|
52
|
+
// @__NO_SIDE_EFFECTS__
|
|
53
|
+
function arrayChunk(arr, size) {
|
|
54
|
+
const chunkSize = size ?? 2;
|
|
55
|
+
if (chunkSize <= 0) {
|
|
56
|
+
throw new Error("Chunk size must be greater than 0");
|
|
57
|
+
}
|
|
58
|
+
const { length } = arr;
|
|
59
|
+
const actualChunkSize = Math.min(length, chunkSize);
|
|
60
|
+
const chunks = [];
|
|
61
|
+
for (let i = 0; i < length; i += actualChunkSize) {
|
|
62
|
+
chunks.push(arr.slice(i, i + actualChunkSize));
|
|
63
|
+
}
|
|
64
|
+
return chunks;
|
|
65
|
+
}
|
|
66
|
+
// @__NO_SIDE_EFFECTS__
|
|
67
|
+
function arrayUnique(arr) {
|
|
68
|
+
return [...new Set(arr)];
|
|
69
|
+
}
|
|
70
|
+
const isArray = Array.isArray;
|
|
71
|
+
// @__NO_SIDE_EFFECTS__
|
|
72
|
+
function joinAnd(arr) {
|
|
73
|
+
return (/* @__PURE__ */ getConjunctionFormatter()).format(arr);
|
|
74
|
+
}
|
|
75
|
+
// @__NO_SIDE_EFFECTS__
|
|
76
|
+
function joinOr(arr) {
|
|
77
|
+
return (/* @__PURE__ */ getDisjunctionFormatter()).format(arr);
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
arrayChunk,
|
|
82
|
+
arrayUnique,
|
|
83
|
+
isArray,
|
|
84
|
+
joinAnd,
|
|
85
|
+
joinOr
|
|
86
|
+
});
|
|
3
87
|
//# sourceMappingURL=arrays.js.map
|
package/dist/arrays.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/arrays.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * @fileoverview Array utility functions for formatting lists and collections.\n * Provides conjunction and disjunction formatters using Intl.ListFormat.\n */\n\nlet _conjunctionFormatter: Intl.ListFormat | undefined\n/**\n * Get a cached Intl.ListFormat instance for conjunction (and) formatting.\n *\n * Creates a singleton formatter for English \"and\" lists using the long style.\n * The formatter is lazily initialized on first use and reused for performance.\n *\n * @returns Cached Intl.ListFormat instance configured for conjunction formatting\n *\n * @example\n * ```ts\n * const formatter = getConjunctionFormatter()\n * formatter.format(['apple', 'banana', 'cherry'])\n * // Returns: \"apple, banana, and cherry\"\n * ```\n *\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getConjunctionFormatter() {\n if (_conjunctionFormatter === undefined) {\n _conjunctionFormatter = new Intl.ListFormat('en', {\n style: 'long',\n // \"and\" lists.\n type: 'conjunction',\n })\n }\n return _conjunctionFormatter\n}\n\nlet _disjunctionFormatter: Intl.ListFormat | undefined\n/**\n * Get a cached Intl.ListFormat instance for disjunction (or) formatting.\n *\n * Creates a singleton formatter for English \"or\" lists using the long style.\n * The formatter is lazily initialized on first use and reused for performance.\n *\n * @returns Cached Intl.ListFormat instance configured for disjunction formatting\n *\n * @example\n * ```ts\n * const formatter = getDisjunctionFormatter()\n * formatter.format(['red', 'blue', 'green'])\n * // Returns: \"red, blue, or green\"\n * ```\n *\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDisjunctionFormatter() {\n if (_disjunctionFormatter === undefined) {\n _disjunctionFormatter = new Intl.ListFormat('en', {\n style: 'long',\n // \"or\" lists.\n type: 'disjunction',\n })\n }\n return _disjunctionFormatter\n}\n\n/**\n * Split an array into chunks of a specified size.\n *\n * Divides an array into smaller arrays of the specified chunk size.\n * The last chunk may contain fewer elements if the array length is not\n * evenly divisible by the chunk size.\n *\n * @param arr - The array to split into chunks (can be readonly)\n * @param size - Size of each chunk. Must be greater than 0.\n * @default 2\n * @returns Array of chunks, where each chunk is an array of elements\n * @throws {Error} If chunk size is less than or equal to 0\n *\n * @example\n * ```ts\n * // Split into pairs (default)\n * arrayChunk([1, 2, 3, 4, 5])\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * // Split into groups of 3\n * arrayChunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3)\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n *\n * // Works with readonly arrays\n * const readonlyArr = [1, 2, 3] as const\n * arrayChunk(readonlyArr)\n * // Returns: [[1, 2], [3]]\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function arrayChunk<T>(\n arr: T[] | readonly T[],\n size?: number | undefined,\n): T[][] {\n const chunkSize = size ?? 2\n if (chunkSize <= 0) {\n throw new Error('Chunk size must be greater than 0')\n }\n const { length } = arr\n const actualChunkSize = Math.min(length, chunkSize)\n const chunks = []\n for (let i = 0; i < length; i += actualChunkSize) {\n chunks.push(arr.slice(i, i + actualChunkSize) as T[])\n }\n return chunks\n}\n\n/**\n * Get unique values from an array.\n *\n * Returns a new array containing only the unique values from the input array.\n * Uses `Set` internally for efficient deduplication. Order of first occurrence\n * is preserved.\n *\n * @param arr - The array to deduplicate (can be readonly)\n * @returns New array with duplicate values removed\n *\n * @example\n * ```ts\n * // Remove duplicate numbers\n * arrayUnique([1, 2, 2, 3, 1, 4])\n * // Returns: [1, 2, 3, 4]\n *\n * // Remove duplicate strings\n * arrayUnique(['apple', 'banana', 'apple', 'cherry'])\n * // Returns: ['apple', 'banana', 'cherry']\n *\n * // Works with readonly arrays\n * const readonlyArr = [1, 1, 2] as const\n * arrayUnique(readonlyArr)\n * // Returns: [1, 2]\n *\n * // Empty arrays return empty\n * arrayUnique([])\n * // Returns: []\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function arrayUnique<T>(arr: T[] | readonly T[]): T[] {\n return [...new Set(arr)]\n}\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\n\n/**\n * Alias for native Array.isArray.\n * Determines whether the passed value is an array.\n *\n * This is a direct reference to the native `Array.isArray` method,\n * providing a type guard that narrows the type to an array type.\n * Exported for consistency with other array utilities in this module.\n *\n * @param value - The value to check\n * @returns `true` if the value is an array, `false` otherwise\n *\n * @example\n * ```ts\n * // Check if value is an array\n * isArray([1, 2, 3])\n * // Returns: true\n *\n * isArray('not an array')\n * // Returns: false\n *\n * isArray(null)\n * // Returns: false\n *\n * // Type guard usage\n * function processValue(value: unknown) {\n * if (isArray(value)) {\n * // TypeScript knows value is an array here\n * console.log(value.length)\n * }\n * }\n * ```\n */\nexport const isArray = Array.isArray\n\n/**\n * Join array elements with proper \"and\" conjunction formatting.\n *\n * Formats an array of strings into a grammatically correct list using\n * \"and\" as the conjunction. Uses `Intl.ListFormat` for proper English\n * formatting with Oxford comma support.\n *\n * @param arr - Array of strings to join (can be readonly)\n * @returns Formatted string with proper \"and\" conjunction\n *\n * @example\n * ```ts\n * // Two items\n * joinAnd(['apples', 'oranges'])\n * // Returns: \"apples and oranges\"\n *\n * // Three or more items (Oxford comma)\n * joinAnd(['apples', 'oranges', 'bananas'])\n * // Returns: \"apples, oranges, and bananas\"\n *\n * // Single item\n * joinAnd(['apples'])\n * // Returns: \"apples\"\n *\n * // Empty array\n * joinAnd([])\n * // Returns: \"\"\n *\n * // Usage in messages\n * const items = ['React', 'Vue', 'Angular']\n * console.log(`You can choose ${joinAnd(items)}`)\n * // Outputs: \"You can choose React, Vue, and Angular\"\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function joinAnd(arr: string[] | readonly string[]): string {\n return getConjunctionFormatter().format(arr)\n}\n\n/**\n * Join array elements with proper \"or\" disjunction formatting.\n *\n * Formats an array of strings into a grammatically correct list using\n * \"or\" as the disjunction. Uses `Intl.ListFormat` for proper English\n * formatting with Oxford comma support.\n *\n * @param arr - Array of strings to join (can be readonly)\n * @returns Formatted string with proper \"or\" disjunction\n *\n * @example\n * ```ts\n * // Two items\n * joinOr(['yes', 'no'])\n * // Returns: \"yes or no\"\n *\n * // Three or more items (Oxford comma)\n * joinOr(['red', 'green', 'blue'])\n * // Returns: \"red, green, or blue\"\n *\n * // Single item\n * joinOr(['maybe'])\n * // Returns: \"maybe\"\n *\n * // Empty array\n * joinOr([])\n * // Returns: \"\"\n *\n * // Usage in prompts\n * const options = ['npm', 'yarn', 'pnpm']\n * console.log(`Choose a package manager: ${joinOr(options)}`)\n * // Outputs: \"Choose a package manager: npm, yarn, or pnpm\"\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function joinOr(arr: string[] | readonly string[]): string {\n return getDisjunctionFormatter().format(arr)\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAI;AAAA;AAmBJ,SAAS,0BAA0B;AACjC,MAAI,0BAA0B,QAAW;AACvC,4BAAwB,IAAI,KAAK,WAAW,MAAM;AAAA,MAChD,OAAO;AAAA;AAAA,MAEP,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAmBJ,SAAS,0BAA0B;AACjC,MAAI,0BAA0B,QAAW;AACvC,4BAAwB,IAAI,KAAK,WAAW,MAAM;AAAA,MAChD,OAAO;AAAA;AAAA,MAEP,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAAA;AAgCO,SAAS,WACd,KACA,MACO;AACP,QAAM,YAAY,QAAQ;AAC1B,MAAI,aAAa,GAAG;AAClB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AACA,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,kBAAkB,KAAK,IAAI,QAAQ,SAAS;AAClD,QAAM,SAAS,CAAC;AAChB,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK,iBAAiB;AAChD,WAAO,KAAK,IAAI,MAAM,GAAG,IAAI,eAAe,CAAQ;AAAA,EACtD;AACA,SAAO;AACT;AAAA;AAiCO,SAAS,YAAe,KAA8B;AAC3D,SAAO,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC;AACzB;AAuCO,MAAM,UAAU,MAAM;AAAA;AAqCtB,SAAS,QAAQ,KAA2C;AACjE,UAAO,wCAAwB,GAAE,OAAO,GAAG;AAC7C;AAAA;AAqCO,SAAS,OAAO,KAA2C;AAChE,UAAO,wCAAwB,GAAE,OAAO,GAAG;AAC7C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/bin.js
CHANGED
|
@@ -1,11 +1,425 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var bin_exports = {};
|
|
20
|
+
__export(bin_exports, {
|
|
21
|
+
execBin: () => execBin,
|
|
22
|
+
findRealBin: () => findRealBin,
|
|
23
|
+
findRealNpm: () => findRealNpm,
|
|
24
|
+
findRealPnpm: () => findRealPnpm,
|
|
25
|
+
findRealYarn: () => findRealYarn,
|
|
26
|
+
isShadowBinPath: () => isShadowBinPath,
|
|
27
|
+
resolveBinPathSync: () => resolveBinPathSync,
|
|
28
|
+
which: () => which,
|
|
29
|
+
whichBin: () => whichBin,
|
|
30
|
+
whichBinSync: () => whichBinSync,
|
|
31
|
+
whichSync: () => whichSync
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(bin_exports);
|
|
34
|
+
var import_home = require("#env/home");
|
|
35
|
+
var import_windows = require("#env/windows");
|
|
36
|
+
var import_xdg = require("#env/xdg");
|
|
37
|
+
var import_platform = require("#constants/platform");
|
|
38
|
+
var import_fs = require("./fs");
|
|
39
|
+
var import_path = require("./path");
|
|
40
|
+
var import_spawn = require("./spawn");
|
|
41
|
+
let _fs;
|
|
42
|
+
// @__NO_SIDE_EFFECTS__
|
|
43
|
+
function getFs() {
|
|
44
|
+
if (_fs === void 0) {
|
|
45
|
+
_fs = require("node:fs");
|
|
46
|
+
}
|
|
47
|
+
return _fs;
|
|
48
|
+
}
|
|
49
|
+
let _path;
|
|
50
|
+
// @__NO_SIDE_EFFECTS__
|
|
51
|
+
function getPath() {
|
|
52
|
+
if (_path === void 0) {
|
|
53
|
+
_path = require("node:path");
|
|
54
|
+
}
|
|
55
|
+
return _path;
|
|
56
|
+
}
|
|
57
|
+
let _which;
|
|
58
|
+
// @__NO_SIDE_EFFECTS__
|
|
59
|
+
function getWhich() {
|
|
60
|
+
if (_which === void 0) {
|
|
61
|
+
_which = require("./external/which");
|
|
62
|
+
}
|
|
63
|
+
return _which;
|
|
64
|
+
}
|
|
65
|
+
// @__NO_SIDE_EFFECTS__
|
|
66
|
+
async function execBin(binPath, args, options) {
|
|
67
|
+
const resolvedPath = (0, import_path.isPath)(binPath) ? /* @__PURE__ */ resolveBinPathSync(binPath) : await whichBin(binPath);
|
|
68
|
+
if (!resolvedPath) {
|
|
69
|
+
const error = new Error(
|
|
70
|
+
`Binary not found: ${binPath}
|
|
3
71
|
Possible causes:
|
|
4
|
-
- Binary "${
|
|
72
|
+
- Binary "${binPath}" is not installed or not in PATH
|
|
5
73
|
- Binary name is incorrect or misspelled
|
|
6
74
|
- Installation directory is not in system PATH
|
|
7
75
|
To resolve:
|
|
8
|
-
1. Verify "${
|
|
9
|
-
2. Install the binary if missing, ex: npm install -g ${
|
|
10
|
-
3. Check PATH environment variable includes the binary location`
|
|
76
|
+
1. Verify "${binPath}" is installed: which ${binPath} (Unix) or where ${binPath} (Windows)
|
|
77
|
+
2. Install the binary if missing, ex: npm install -g ${binPath}
|
|
78
|
+
3. Check PATH environment variable includes the binary location`
|
|
79
|
+
);
|
|
80
|
+
error.code = "ENOENT";
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
const binCommand = Array.isArray(resolvedPath) ? resolvedPath[0] : resolvedPath;
|
|
84
|
+
return await (0, import_spawn.spawn)(binCommand, args ?? [], {
|
|
85
|
+
shell: import_platform.WIN32,
|
|
86
|
+
...options
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async function which(binName, options) {
|
|
90
|
+
return await (/* @__PURE__ */ getWhich())(binName, options);
|
|
91
|
+
}
|
|
92
|
+
function whichSync(binName, options) {
|
|
93
|
+
return (/* @__PURE__ */ getWhich()).sync(binName, options);
|
|
94
|
+
}
|
|
95
|
+
async function whichBin(binName, options) {
|
|
96
|
+
const which2 = /* @__PURE__ */ getWhich();
|
|
97
|
+
const opts = { nothrow: true, ...options };
|
|
98
|
+
const result = await which2(binName, opts);
|
|
99
|
+
if (opts?.all) {
|
|
100
|
+
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
101
|
+
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
|
|
102
|
+
}
|
|
103
|
+
if (!result) {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ resolveBinPathSync(result);
|
|
107
|
+
}
|
|
108
|
+
function whichBinSync(binName, options) {
|
|
109
|
+
const opts = { nothrow: true, ...options };
|
|
110
|
+
const result = whichSync(binName, opts);
|
|
111
|
+
if (opts.all) {
|
|
112
|
+
const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
|
|
113
|
+
return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
|
|
114
|
+
}
|
|
115
|
+
if (!result) {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
return /* @__PURE__ */ resolveBinPathSync(result);
|
|
119
|
+
}
|
|
120
|
+
function isShadowBinPath(dirPath) {
|
|
121
|
+
if (!dirPath) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const normalized = dirPath.replace(/\\/g, "/");
|
|
125
|
+
return normalized.includes("node_modules/.bin");
|
|
126
|
+
}
|
|
127
|
+
function findRealBin(binName, commonPaths = []) {
|
|
128
|
+
const fs = /* @__PURE__ */ getFs();
|
|
129
|
+
const path = /* @__PURE__ */ getPath();
|
|
130
|
+
const which2 = /* @__PURE__ */ getWhich();
|
|
131
|
+
for (const binPath2 of commonPaths) {
|
|
132
|
+
if (fs?.existsSync(binPath2)) {
|
|
133
|
+
return binPath2;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const binPath = which2?.sync(binName, { nothrow: true });
|
|
137
|
+
if (binPath) {
|
|
138
|
+
const binDir = path?.dirname(binPath);
|
|
139
|
+
if (isShadowBinPath(binDir)) {
|
|
140
|
+
const allPaths = which2?.sync(binName, { all: true, nothrow: true }) || [];
|
|
141
|
+
const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
|
|
142
|
+
for (const altPath of pathsArray) {
|
|
143
|
+
const altDir = path?.dirname(altPath);
|
|
144
|
+
if (!isShadowBinPath(altDir)) {
|
|
145
|
+
return altPath;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return binPath;
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
function findRealNpm() {
|
|
154
|
+
const fs = /* @__PURE__ */ getFs();
|
|
155
|
+
const path = /* @__PURE__ */ getPath();
|
|
156
|
+
const nodeDir = path?.dirname(process.execPath);
|
|
157
|
+
const npmInNodeDir = path?.join(nodeDir, "npm");
|
|
158
|
+
if (fs?.existsSync(npmInNodeDir)) {
|
|
159
|
+
return npmInNodeDir;
|
|
160
|
+
}
|
|
161
|
+
const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
|
|
162
|
+
const result = findRealBin("npm", commonPaths);
|
|
163
|
+
if (result && fs?.existsSync(result)) {
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
const npmPath = whichBinSync("npm", { nothrow: true });
|
|
167
|
+
if (npmPath && typeof npmPath === "string" && fs?.existsSync(npmPath)) {
|
|
168
|
+
return npmPath;
|
|
169
|
+
}
|
|
170
|
+
return "npm";
|
|
171
|
+
}
|
|
172
|
+
function findRealPnpm() {
|
|
173
|
+
const path = /* @__PURE__ */ getPath();
|
|
174
|
+
const commonPaths = import_platform.WIN32 ? [
|
|
175
|
+
// Windows common paths.
|
|
176
|
+
path?.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
|
|
177
|
+
path?.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
|
|
178
|
+
path?.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
|
|
179
|
+
path?.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
|
|
180
|
+
"C:\\Program Files\\nodejs\\pnpm.cmd",
|
|
181
|
+
"C:\\Program Files\\nodejs\\pnpm"
|
|
182
|
+
].filter(Boolean) : [
|
|
183
|
+
// Unix common paths.
|
|
184
|
+
"/usr/local/bin/pnpm",
|
|
185
|
+
"/usr/bin/pnpm",
|
|
186
|
+
path?.join(
|
|
187
|
+
(0, import_xdg.getXdgDataHome)() || `${(0, import_home.getHome)()}/.local/share`,
|
|
188
|
+
"pnpm/pnpm"
|
|
189
|
+
),
|
|
190
|
+
path?.join((0, import_home.getHome)(), ".pnpm/pnpm")
|
|
191
|
+
].filter(Boolean);
|
|
192
|
+
return findRealBin("pnpm", commonPaths) ?? "";
|
|
193
|
+
}
|
|
194
|
+
function findRealYarn() {
|
|
195
|
+
const path = /* @__PURE__ */ getPath();
|
|
196
|
+
const commonPaths = [
|
|
197
|
+
"/usr/local/bin/yarn",
|
|
198
|
+
"/usr/bin/yarn",
|
|
199
|
+
path?.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
|
|
200
|
+
path?.join(
|
|
201
|
+
(0, import_home.getHome)(),
|
|
202
|
+
".config/yarn/global/node_modules/.bin/yarn"
|
|
203
|
+
)
|
|
204
|
+
].filter(Boolean);
|
|
205
|
+
return findRealBin("yarn", commonPaths) ?? "";
|
|
206
|
+
}
|
|
207
|
+
// @__NO_SIDE_EFFECTS__
|
|
208
|
+
function resolveBinPathSync(binPath) {
|
|
209
|
+
const fs = /* @__PURE__ */ getFs();
|
|
210
|
+
const path = /* @__PURE__ */ getPath();
|
|
211
|
+
if (!path?.isAbsolute(binPath)) {
|
|
212
|
+
try {
|
|
213
|
+
const resolved = whichBinSync(binPath);
|
|
214
|
+
if (resolved) {
|
|
215
|
+
binPath = resolved;
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
binPath = (0, import_path.normalizePath)(binPath);
|
|
221
|
+
if (binPath === ".") {
|
|
222
|
+
return binPath;
|
|
223
|
+
}
|
|
224
|
+
const ext = path?.extname(binPath);
|
|
225
|
+
const extLowered = ext.toLowerCase();
|
|
226
|
+
const basename = path?.basename(binPath, ext);
|
|
227
|
+
const voltaIndex = basename === "node" ? -1 : /(?<=\/)\.volta\//i.exec(binPath)?.index ?? -1;
|
|
228
|
+
if (voltaIndex !== -1) {
|
|
229
|
+
const voltaPath = binPath.slice(0, voltaIndex);
|
|
230
|
+
const voltaToolsPath = path?.join(voltaPath, "tools");
|
|
231
|
+
const voltaImagePath = path?.join(voltaToolsPath, "image");
|
|
232
|
+
const voltaUserPath = path?.join(voltaToolsPath, "user");
|
|
233
|
+
const voltaPlatform = (0, import_fs.readJsonSync)(
|
|
234
|
+
path?.join(voltaUserPath, "platform.json"),
|
|
235
|
+
{ throws: false }
|
|
236
|
+
);
|
|
237
|
+
const voltaNodeVersion = voltaPlatform?.node?.runtime;
|
|
238
|
+
const voltaNpmVersion = voltaPlatform?.node?.npm;
|
|
239
|
+
let voltaBinPath = "";
|
|
240
|
+
if (basename === "npm" || basename === "npx") {
|
|
241
|
+
if (voltaNpmVersion) {
|
|
242
|
+
const relCliPath = `bin/${basename}-cli.js`;
|
|
243
|
+
voltaBinPath = path?.join(
|
|
244
|
+
voltaImagePath,
|
|
245
|
+
`npm/${voltaNpmVersion}/${relCliPath}`
|
|
246
|
+
);
|
|
247
|
+
if (voltaNodeVersion && !fs?.existsSync(voltaBinPath)) {
|
|
248
|
+
voltaBinPath = path?.join(
|
|
249
|
+
voltaImagePath,
|
|
250
|
+
`node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`
|
|
251
|
+
);
|
|
252
|
+
if (!fs?.existsSync(voltaBinPath)) {
|
|
253
|
+
voltaBinPath = "";
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
const voltaUserBinPath = path?.join(voltaUserPath, "bin");
|
|
259
|
+
const binInfo = (0, import_fs.readJsonSync)(
|
|
260
|
+
path?.join(voltaUserBinPath, `${basename}.json`),
|
|
261
|
+
{ throws: false }
|
|
262
|
+
);
|
|
263
|
+
const binPackage = binInfo?.package;
|
|
264
|
+
if (binPackage) {
|
|
265
|
+
voltaBinPath = path?.join(
|
|
266
|
+
voltaImagePath,
|
|
267
|
+
`packages/${binPackage}/bin/${basename}`
|
|
268
|
+
);
|
|
269
|
+
if (!fs?.existsSync(voltaBinPath)) {
|
|
270
|
+
voltaBinPath = `${voltaBinPath}.cmd`;
|
|
271
|
+
if (!fs?.existsSync(voltaBinPath)) {
|
|
272
|
+
voltaBinPath = "";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (voltaBinPath) {
|
|
278
|
+
try {
|
|
279
|
+
return (0, import_path.normalizePath)(fs?.realpathSync.native(voltaBinPath));
|
|
280
|
+
} catch {
|
|
281
|
+
}
|
|
282
|
+
return voltaBinPath;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (import_platform.WIN32) {
|
|
286
|
+
const hasKnownExt = extLowered === "" || extLowered === ".cmd" || extLowered === ".exe" || extLowered === ".ps1";
|
|
287
|
+
const isNpmOrNpx = basename === "npm" || basename === "npx";
|
|
288
|
+
const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
|
|
289
|
+
if (hasKnownExt && isNpmOrNpx) {
|
|
290
|
+
const quickPath = path?.join(
|
|
291
|
+
path?.dirname(binPath),
|
|
292
|
+
`node_modules/npm/bin/${basename}-cli.js`
|
|
293
|
+
);
|
|
294
|
+
if (fs?.existsSync(quickPath)) {
|
|
295
|
+
try {
|
|
296
|
+
return fs?.realpathSync.native(quickPath);
|
|
297
|
+
} catch {
|
|
298
|
+
}
|
|
299
|
+
return quickPath;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
let relPath = "";
|
|
303
|
+
if (hasKnownExt && // Only parse shell scripts and batch files, not actual executables.
|
|
304
|
+
// .exe files are already executables and don't need path resolution from wrapper scripts.
|
|
305
|
+
extLowered !== ".exe" && // Check if file exists before attempting to read it to avoid ENOENT errors.
|
|
306
|
+
fs?.existsSync(binPath)) {
|
|
307
|
+
const source = fs?.readFileSync(binPath, "utf8");
|
|
308
|
+
if (isNpmOrNpx) {
|
|
309
|
+
if (extLowered === ".cmd") {
|
|
310
|
+
relPath = basename === "npm" ? /(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "" : /(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "";
|
|
311
|
+
} else if (extLowered === "") {
|
|
312
|
+
relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
|
|
313
|
+
} else if (extLowered === ".ps1") {
|
|
314
|
+
relPath = basename === "npm" ? /(?<=\$NPM_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(
|
|
315
|
+
source
|
|
316
|
+
)?.[0] || "" : /(?<=\$NPX_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(
|
|
317
|
+
source
|
|
318
|
+
)?.[0] || "";
|
|
319
|
+
}
|
|
320
|
+
} else if (isPnpmOrYarn) {
|
|
321
|
+
if (extLowered === ".cmd") {
|
|
322
|
+
relPath = /(?<=node\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(source)?.[1] || "";
|
|
323
|
+
if (!relPath) {
|
|
324
|
+
relPath = /(?<="%~dp0\\[^"]*node[^"]*"\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(
|
|
325
|
+
source
|
|
326
|
+
)?.[1] || "";
|
|
327
|
+
}
|
|
328
|
+
if (!relPath) {
|
|
329
|
+
relPath = /(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(source)?.[0] || "";
|
|
330
|
+
}
|
|
331
|
+
} else if (extLowered === "") {
|
|
332
|
+
relPath = /(?<="\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(
|
|
333
|
+
source
|
|
334
|
+
)?.[0] || "";
|
|
335
|
+
if (!relPath) {
|
|
336
|
+
relPath = /(?<=exec\s+node\s+"\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(
|
|
337
|
+
source
|
|
338
|
+
)?.[0] || "";
|
|
339
|
+
}
|
|
340
|
+
if (!relPath) {
|
|
341
|
+
relPath = /(?<="\$basedir\/).*(?=" "\$@"\n)/.exec(source)?.[0] || "";
|
|
342
|
+
}
|
|
343
|
+
} else if (extLowered === ".ps1") {
|
|
344
|
+
relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
|
|
345
|
+
}
|
|
346
|
+
} else if (extLowered === ".cmd") {
|
|
347
|
+
relPath = /(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(source)?.[0] || "";
|
|
348
|
+
} else if (extLowered === "") {
|
|
349
|
+
relPath = /(?<="$basedir\/).*(?=" "\$@"\n)/.exec(source)?.[0] || "";
|
|
350
|
+
} else if (extLowered === ".ps1") {
|
|
351
|
+
relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
|
|
352
|
+
}
|
|
353
|
+
if (relPath) {
|
|
354
|
+
binPath = (0, import_path.normalizePath)(path?.resolve(path?.dirname(binPath), relPath));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
let hasNoExt = extLowered === "";
|
|
359
|
+
const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
|
|
360
|
+
const isNpmOrNpx = basename === "npm" || basename === "npx";
|
|
361
|
+
if (isPnpmOrYarn && binPath.includes("/.bin/pnpm/bin/")) {
|
|
362
|
+
const binIndex = binPath.indexOf("/.bin/pnpm");
|
|
363
|
+
if (binIndex !== -1) {
|
|
364
|
+
const baseBinPath = binPath.slice(0, binIndex + "/.bin/pnpm".length);
|
|
365
|
+
try {
|
|
366
|
+
const stats = fs?.statSync(baseBinPath);
|
|
367
|
+
if (stats.isFile()) {
|
|
368
|
+
binPath = (0, import_path.normalizePath)(baseBinPath);
|
|
369
|
+
hasNoExt = !path?.extname(binPath);
|
|
370
|
+
}
|
|
371
|
+
} catch {
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (hasNoExt && (isPnpmOrYarn || isNpmOrNpx) && // For extensionless files (Unix shell scripts), verify existence before reading.
|
|
376
|
+
// This prevents ENOENT errors when the bin path doesn't exist.
|
|
377
|
+
fs?.existsSync(binPath)) {
|
|
378
|
+
const source = fs?.readFileSync(binPath, "utf8");
|
|
379
|
+
let relPath = "";
|
|
380
|
+
if (isPnpmOrYarn) {
|
|
381
|
+
relPath = /(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
|
|
382
|
+
if (!relPath) {
|
|
383
|
+
relPath = /(?<="\$basedir\/)[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
|
|
384
|
+
}
|
|
385
|
+
if (!relPath) {
|
|
386
|
+
const match = /exec\s+node\s+"?\$basedir\/([^"]+)"?\s+"\$@"/.exec(
|
|
387
|
+
source
|
|
388
|
+
);
|
|
389
|
+
if (match) {
|
|
390
|
+
relPath = match[1] || "";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (relPath && basename === "pnpm" && relPath.startsWith("pnpm/")) {
|
|
394
|
+
relPath = `../${relPath}`;
|
|
395
|
+
}
|
|
396
|
+
} else if (isNpmOrNpx) {
|
|
397
|
+
relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
|
|
398
|
+
}
|
|
399
|
+
if (relPath) {
|
|
400
|
+
binPath = (0, import_path.normalizePath)(path?.resolve(path?.dirname(binPath), relPath));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
const realPath = fs?.realpathSync.native(binPath);
|
|
406
|
+
return (0, import_path.normalizePath)(realPath);
|
|
407
|
+
} catch {
|
|
408
|
+
}
|
|
409
|
+
return (0, import_path.normalizePath)(binPath);
|
|
410
|
+
}
|
|
411
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
412
|
+
0 && (module.exports = {
|
|
413
|
+
execBin,
|
|
414
|
+
findRealBin,
|
|
415
|
+
findRealNpm,
|
|
416
|
+
findRealPnpm,
|
|
417
|
+
findRealYarn,
|
|
418
|
+
isShadowBinPath,
|
|
419
|
+
resolveBinPathSync,
|
|
420
|
+
which,
|
|
421
|
+
whichBin,
|
|
422
|
+
whichBinSync,
|
|
423
|
+
whichSync
|
|
424
|
+
});
|
|
11
425
|
//# sourceMappingURL=bin.js.map
|