node-version-use 2.4.1 → 2.4.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/assets/installBinaries.cjs +5 -3
- package/dist/cjs/assets/installBinaries.cjs +5 -3
- package/dist/cjs/assets/installBinaries.cjs.map +1 -1
- package/dist/cjs/commands/which.js +15 -0
- package/dist/cjs/commands/which.js.map +1 -1
- package/dist/cjs/compat.d.cts +1 -0
- package/dist/cjs/compat.d.ts +1 -0
- package/dist/cjs/compat.js +17 -3
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/lib/loadNodeVersionInstall.js +1 -1
- package/dist/cjs/lib/loadNodeVersionInstall.js.map +1 -1
- package/dist/cjs/lib/resolveSystemBinary.d.cts +10 -0
- package/dist/cjs/lib/resolveSystemBinary.d.ts +10 -0
- package/dist/cjs/lib/resolveSystemBinary.js +96 -0
- package/dist/cjs/lib/resolveSystemBinary.js.map +1 -0
- package/dist/cjs/worker.js +53 -56
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/assets/installBinaries.cjs +5 -3
- package/dist/esm/assets/installBinaries.cjs.map +1 -1
- package/dist/esm/commands/which.js +15 -0
- package/dist/esm/commands/which.js.map +1 -1
- package/dist/esm/compat.d.ts +1 -0
- package/dist/esm/compat.js +16 -5
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/lib/loadNodeVersionInstall.js +1 -1
- package/dist/esm/lib/loadNodeVersionInstall.js.map +1 -1
- package/dist/esm/lib/resolveSystemBinary.d.ts +10 -0
- package/dist/esm/lib/resolveSystemBinary.js +78 -0
- package/dist/esm/lib/resolveSystemBinary.js.map +1 -0
- package/dist/esm/worker.js +58 -11
- package/dist/esm/worker.js.map +1 -1
- package/package.json +3 -2
- package/assets/bin/node +0 -0
package/dist/cjs/worker.js
CHANGED
|
@@ -20,64 +20,12 @@ var _spawnterm = require("spawn-term");
|
|
|
20
20
|
var _compatts = require("./compat.js");
|
|
21
21
|
var _constantsts = require("./constants.js");
|
|
22
22
|
var _loadNodeVersionInstallts = /*#__PURE__*/ _interop_require_default(require("./lib/loadNodeVersionInstall.js"));
|
|
23
|
-
|
|
24
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
25
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
26
|
-
return arr2;
|
|
27
|
-
}
|
|
28
|
-
function _array_without_holes(arr) {
|
|
29
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
30
|
-
}
|
|
31
|
-
function _define_property(obj, key, value) {
|
|
32
|
-
if (key in obj) {
|
|
33
|
-
Object.defineProperty(obj, key, {
|
|
34
|
-
value: value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
23
|
+
var _resolveSystemBinaryts = require("./lib/resolveSystemBinary.js");
|
|
44
24
|
function _interop_require_default(obj) {
|
|
45
25
|
return obj && obj.__esModule ? obj : {
|
|
46
26
|
default: obj
|
|
47
27
|
};
|
|
48
28
|
}
|
|
49
|
-
function _iterable_to_array(iter) {
|
|
50
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
51
|
-
}
|
|
52
|
-
function _non_iterable_spread() {
|
|
53
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}
|
|
55
|
-
function _object_spread(target) {
|
|
56
|
-
for(var i = 1; i < arguments.length; i++){
|
|
57
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
58
|
-
var ownKeys = Object.keys(source);
|
|
59
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
60
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
61
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
ownKeys.forEach(function(key) {
|
|
65
|
-
_define_property(target, key, source[key]);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
function _to_consumable_array(arr) {
|
|
71
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
72
|
-
}
|
|
73
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
74
|
-
if (!o) return;
|
|
75
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
76
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
78
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
79
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
80
|
-
}
|
|
81
29
|
var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
82
30
|
var NODE = isWindows ? 'node.exe' : 'node';
|
|
83
31
|
// Parse npm-generated .cmd wrapper to extract the JS script path
|
|
@@ -112,7 +60,7 @@ function resolveCommand(command, args) {
|
|
|
112
60
|
command: NODE,
|
|
113
61
|
args: [
|
|
114
62
|
scriptPath
|
|
115
|
-
].concat(
|
|
63
|
+
].concat(args)
|
|
116
64
|
};
|
|
117
65
|
}
|
|
118
66
|
}
|
|
@@ -123,7 +71,7 @@ function resolveCommand(command, args) {
|
|
|
123
71
|
command: NODE,
|
|
124
72
|
args: [
|
|
125
73
|
binPath
|
|
126
|
-
].concat(
|
|
74
|
+
].concat(args)
|
|
127
75
|
};
|
|
128
76
|
} catch (_e) {
|
|
129
77
|
// Not an npm package bin, use original command
|
|
@@ -134,6 +82,11 @@ function resolveCommand(command, args) {
|
|
|
134
82
|
};
|
|
135
83
|
}
|
|
136
84
|
function worker(versionExpression, command, args, options, callback) {
|
|
85
|
+
// Handle "system" as a special version that uses system binaries directly
|
|
86
|
+
if (versionExpression === 'system') {
|
|
87
|
+
runWithSystemBinaries(command, args, options, callback);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
137
90
|
// Load node-version-install lazily
|
|
138
91
|
(0, _loadNodeVersionInstallts.default)(function(loadErr, installVersion) {
|
|
139
92
|
if (loadErr) return callback(loadErr);
|
|
@@ -143,7 +96,7 @@ function worker(versionExpression, command, args, options, callback) {
|
|
|
143
96
|
callback(new Error("No versions found from expression: ".concat(versionExpression)));
|
|
144
97
|
return;
|
|
145
98
|
}
|
|
146
|
-
var installOptions =
|
|
99
|
+
var installOptions = (0, _compatts.objectAssign)({
|
|
147
100
|
storagePath: _constantsts.storagePath
|
|
148
101
|
}, options);
|
|
149
102
|
var streamingOptions = options;
|
|
@@ -218,4 +171,48 @@ function worker(versionExpression, command, args, options, callback) {
|
|
|
218
171
|
});
|
|
219
172
|
});
|
|
220
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Run command using system binaries (bypassing nvu version management)
|
|
176
|
+
* This handles the "system" version specifier
|
|
177
|
+
*/ function runWithSystemBinaries(command, args, options, callback) {
|
|
178
|
+
// Find the system binary for the command
|
|
179
|
+
var systemBinary = (0, _resolveSystemBinaryts.resolveSystemBinary)(command);
|
|
180
|
+
if (!systemBinary) {
|
|
181
|
+
callback(new Error("System ".concat(command, " not found in PATH")));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
// Create spawn options with PATH excluding ~/.nvu/bin
|
|
185
|
+
// This ensures any child processes also use system binaries
|
|
186
|
+
var cleanPath = (0, _resolveSystemBinaryts.getPathWithoutNvuBin)();
|
|
187
|
+
var spawnOptions = (0, _compatts.objectAssign)({}, options);
|
|
188
|
+
spawnOptions.env = (0, _compatts.objectAssign)({}, process.env);
|
|
189
|
+
spawnOptions.env.PATH = cleanPath;
|
|
190
|
+
spawnOptions.stdio = options.stdio || 'inherit';
|
|
191
|
+
// On Windows, resolve npm bin commands to bypass .cmd wrappers
|
|
192
|
+
var resolved = resolveCommand(command, args);
|
|
193
|
+
// For system, use the resolved system binary path
|
|
194
|
+
var finalCommand = resolved.command === command ? systemBinary : resolved.command;
|
|
195
|
+
var finalArgs = resolved.command === command ? args : resolved.args;
|
|
196
|
+
if (!options.silent) {
|
|
197
|
+
console.log("$ ".concat((0, _spawnterm.formatArguments)([
|
|
198
|
+
finalCommand
|
|
199
|
+
].concat(finalArgs)).join(' ')));
|
|
200
|
+
}
|
|
201
|
+
(0, _crossspawncb.default)(finalCommand, finalArgs, spawnOptions, function(err, res) {
|
|
202
|
+
if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {
|
|
203
|
+
res = err;
|
|
204
|
+
err = null;
|
|
205
|
+
}
|
|
206
|
+
var result = {
|
|
207
|
+
install: null,
|
|
208
|
+
command: command,
|
|
209
|
+
version: 'system',
|
|
210
|
+
error: err,
|
|
211
|
+
result: res
|
|
212
|
+
};
|
|
213
|
+
callback(err, [
|
|
214
|
+
result
|
|
215
|
+
]);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
221
218
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
package/dist/cjs/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath, ...args] };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath, ...args] };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = { storagePath, ...options } as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n"],"names":["worker","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","fs","readFileSync","match","relativePath","cmdDir","path","dirname","join","_e","resolveCommand","command","args","stringEndsWith","toLowerCase","scriptPath","binPath","resolveBin","versionExpression","options","callback","loadNodeVersionInstall","loadErr","installVersion","resolveVersions","err","versions","length","Error","installOptions","storagePath","streamingOptions","results","queue","Queue","interactive","session","createSession","streaming","header","showStatusBar","forEach","version","defer","cb","installs","next","res","message","indexOf","push","install","error","result","JSON","stringify","spawnOptions","createSpawnOptions","installPath","prefix","resolved","silent","console","log","formatArguments","concat","spawn","group","expanded","spawnStreaming","await","waitAndClose"],"mappings":";;;;+BA6DA;;;eAAwBA;;;mEA7DiB;yDAC1B;0EACsC;gCAEF;2DAClC;8DACC;qEACK;qEACI;yBACoB;wBAChB;2BACH;+EACO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAInC,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,OAAON,YAAY,aAAa;AAEtC,iEAAiE;AACjE,SAASO,mBAAmBC,OAAe;IACzC,IAAI;QACF,IAAMC,UAAUC,WAAE,CAACC,YAAY,CAACH,SAAS;QACzC,uDAAuD;QACvD,8CAA8C;QAC9C,IAAMI,QAAQH,QAAQG,KAAK,CAAC;QAC5B,IAAIA,OAAO;YACT,IAAMC,eAAeD,KAAK,CAAC,EAAE;YAC7B,IAAME,SAASC,aAAI,CAACC,OAAO,CAACR;YAC5B,OAAOO,aAAI,CAACE,IAAI,CAACH,QAAQD;QAC3B;IACF,EAAE,OAAOK,IAAI;IACX,SAAS;IACX;IACA,OAAO;AACT;AAEA,wFAAwF;AACxF,yFAAyF;AACzF,SAASC,eAAeC,OAAe,EAAEC,IAAc;IACrD,IAAI,CAACrB,WAAW,OAAO;QAAEoB,SAAAA;QAASC,MAAAA;IAAK;IAEvC,sCAAsC;IACtC,IAAIC,IAAAA,wBAAc,EAACF,QAAQG,WAAW,IAAI,SAAS;QACjD,IAAMC,aAAajB,mBAAmBa;QACtC,IAAII,YAAY;YACd,OAAO;gBA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c;4BAAEW,OAAOR;4BAAQS,UAAUrC,iBAAiBqC,QAAQ;wBAAC,GAAGtB;6BAC7HuB,IAAAA,uBAAc,EAACT,SAASjD,OAAO,EAAEiD,SAAShD,IAAI,EAAE4C,cAAc;4BAAEG,QAAAA;wBAAO,GAAGb;oBACjF;gBACF;YACF;YACAb,MAAMqC,KAAK,CAAC,SAAC7C;gBACX,IAAIW,SAAS;oBACXA,QAAQmC,YAAY,CAAC;wBACnB9C,MAAML,SAASK,OAAOL,SAAS,MAAMY;oBACvC;gBACF,OAAO;oBACLP,MAAML,SAASK,OAAOL,SAAS,MAAMY;gBACvC;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { objectAssign, stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\nimport { getPathWithoutNvuBin, resolveSystemBinary } from './lib/resolveSystemBinary.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath].concat(args) };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath].concat(args) };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Handle \"system\" as a special version that uses system binaries directly\n if (versionExpression === 'system') {\n runWithSystemBinaries(command, args, options, callback);\n return;\n }\n\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = objectAssign({ storagePath: storagePath }, options) as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n\n/**\n * Run command using system binaries (bypassing nvu version management)\n * This handles the \"system\" version specifier\n */\nfunction runWithSystemBinaries(command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Find the system binary for the command\n const systemBinary = resolveSystemBinary(command);\n if (!systemBinary) {\n callback(new Error(`System ${command} not found in PATH`));\n return;\n }\n\n // Create spawn options with PATH excluding ~/.nvu/bin\n // This ensures any child processes also use system binaries\n const cleanPath = getPathWithoutNvuBin();\n const spawnOptions: SpawnOptions = objectAssign({}, options as SpawnOptions);\n spawnOptions.env = objectAssign({}, process.env);\n spawnOptions.env.PATH = cleanPath;\n spawnOptions.stdio = options.stdio || 'inherit';\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n // For system, use the resolved system binary path\n const finalCommand = resolved.command === command ? systemBinary : resolved.command;\n const finalArgs = resolved.command === command ? args : resolved.args;\n\n if (!options.silent) {\n console.log(`$ ${formatArguments([finalCommand].concat(finalArgs)).join(' ')}`);\n }\n\n spawn(finalCommand, finalArgs, spawnOptions, (err?, res?) => {\n if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n\n const result: UseResult = {\n install: null,\n command,\n version: 'system',\n error: err,\n result: res,\n };\n\n callback(err, [result]);\n });\n}\n"],"names":["worker","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","fs","readFileSync","match","relativePath","cmdDir","path","dirname","join","_e","resolveCommand","command","args","stringEndsWith","toLowerCase","scriptPath","concat","binPath","resolveBin","versionExpression","options","callback","runWithSystemBinaries","loadNodeVersionInstall","loadErr","installVersion","resolveVersions","err","versions","length","Error","installOptions","objectAssign","storagePath","streamingOptions","results","queue","Queue","interactive","session","createSession","streaming","header","showStatusBar","forEach","version","defer","cb","installs","next","res","message","indexOf","push","install","error","result","JSON","stringify","spawnOptions","createSpawnOptions","installPath","prefix","resolved","silent","console","log","formatArguments","spawn","group","expanded","spawnStreaming","await","waitAndClose","systemBinary","resolveSystemBinary","cleanPath","getPathWithoutNvuBin","PATH","stdio","finalCommand","finalArgs"],"mappings":";;;;+BA8DA;;;eAAwBA;;;mEA9DiB;yDAC1B;0EACsC;gCAEF;2DAClC;8DACC;qEACK;qEACI;yBACoB;wBACF;2BACjB;+EACO;qCACuB;;;;;;AAI1D,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,OAAON,YAAY,aAAa;AAEtC,iEAAiE;AACjE,SAASO,mBAAmBC,OAAe;IACzC,IAAI;QACF,IAAMC,UAAUC,WAAE,CAACC,YAAY,CAACH,SAAS;QACzC,uDAAuD;QACvD,8CAA8C;QAC9C,IAAMI,QAAQH,QAAQG,KAAK,CAAC;QAC5B,I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;IAEA,sDAAsD;IACtD,4DAA4D;IAC5D,IAAMiE,YAAYC,IAAAA,2CAAoB;IACtC,IAAMlB,eAA6B3B,IAAAA,sBAAY,EAAC,CAAC,GAAGZ;IACpDuC,aAAahE,GAAG,GAAGqC,IAAAA,sBAAY,EAAC,CAAC,GAAGxC,QAAQG,GAAG;IAC/CgE,aAAahE,GAAG,CAACmF,IAAI,GAAGF;IACxBjB,aAAaoB,KAAK,GAAG3D,QAAQ2D,KAAK,IAAI;IAEtC,+DAA+D;IAC/D,IAAMhB,WAAWrD,eAAeC,SAASC;IAEzC,kDAAkD;IAClD,IAAMoE,eAAejB,SAASpD,OAAO,KAAKA,UAAU+D,eAAeX,SAASpD,OAAO;IACnF,IAAMsE,YAAYlB,SAASpD,OAAO,KAAKA,UAAUC,OAAOmD,SAASnD,IAAI;IAErE,IAAI,CAACQ,QAAQ4C,MAAM,EAAE;QACnBC,QAAQC,GAAG,CAAC,AAAC,KAAgE,OAA5DC,IAAAA,0BAAe,EAAC;YAACa;SAAa,CAAChE,MAAM,CAACiE,YAAYzE,IAAI,CAAC;IAC1E;IAEA4D,IAAAA,qBAAK,EAACY,cAAcC,WAAWtB,cAAc,SAAChC,KAAMuB;QAClD,IAAIvB,OAAOA,IAAIwB,OAAO,IAAIxB,IAAIwB,OAAO,CAACC,OAAO,CAAC,0BAA0B,GAAG;YACzEF,MAAMvB;YACNA,MAAM;QACR;QAEA,IAAM6B,SAAoB;YACxBF,SAAS;YACT3C,SAAAA;YACAkC,SAAS;YACTU,OAAO5B;YACP6B,QAAQN;QACV;QAEA7B,SAASM,KAAK;YAAC6B;SAAO;IACxB;AACF"}
|
|
@@ -7,6 +7,7 @@ const os = require('os');
|
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const Queue = require('queue-cb');
|
|
9
9
|
const moduleRoot = require('module-root-sync');
|
|
10
|
+
const cpuArch = require('cpu-arch');
|
|
10
11
|
const root = moduleRoot(__dirname);
|
|
11
12
|
// Configuration
|
|
12
13
|
const GITHUB_REPO = 'kmalakoff/node-version-use';
|
|
@@ -77,7 +78,8 @@ function removeIfExistsSync(filePath) {
|
|
|
77
78
|
/**
|
|
78
79
|
* Get the platform-specific archive base name (without extension)
|
|
79
80
|
*/ function getArchiveBaseName() {
|
|
80
|
-
const { platform
|
|
81
|
+
const { platform } = process;
|
|
82
|
+
const arch = cpuArch();
|
|
81
83
|
const platformMap = {
|
|
82
84
|
darwin: 'darwin',
|
|
83
85
|
linux: 'linux',
|
|
@@ -349,12 +351,12 @@ function removeIfExistsSync(filePath) {
|
|
|
349
351
|
return;
|
|
350
352
|
}
|
|
351
353
|
// Download to temp file
|
|
352
|
-
console.log(`Downloading binary for ${
|
|
354
|
+
console.log(`Downloading binary for ${archiveBaseName}...`);
|
|
353
355
|
const tempPath = path.join(tmpdir(), `nvu-binary-${Date.now()}${isWindows ? '.zip' : '.tar.gz'}`);
|
|
354
356
|
getFile(downloadUrl, tempPath, (err)=>{
|
|
355
357
|
if (err) {
|
|
356
358
|
removeIfExistsSync(tempPath);
|
|
357
|
-
callback(new Error(`No prebuilt binary available for ${
|
|
359
|
+
callback(new Error(`No prebuilt binary available for ${archiveBaseName}. Download: ${downloadUrl}. Error: ${err.message}`));
|
|
358
360
|
return;
|
|
359
361
|
}
|
|
360
362
|
// Copy to cache for future use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/assets/installBinaries.cts"],"sourcesContent":["const envPathKey = require('env-path-key');\nconst fs = require('fs');\nconst { safeRmSync } = require('fs-remove-compat');\nconst getFile = require('get-file-compat');\nconst mkdirp = require('mkdirp-classic');\nconst os = require('os');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst moduleRoot = require('module-root-sync');\n\nconst root = moduleRoot(__dirname);\n\n// Configuration\nconst GITHUB_REPO = 'kmalakoff/node-version-use';\nconst BINARY_VERSION = require(path.join(root, 'package.json')).binaryVersion;\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\ntype Callback = (err?: Error | null) => void;\n\ninterface PlatformMap {\n [key: string]: string;\n}\n\nconst hasHomedir = typeof os.homedir === 'function';\nfunction homedir(): string {\n if (hasHomedir) return os.homedir();\n const home = require('homedir-polyfill');\n return home();\n}\n\n// Allow NVU_HOME override for testing\nconst storagePath = (process.env.NVU_HOME || path.join(homedir(), '.nvu')) as string;\n\nconst hasTmpdir = typeof os.tmpdir === 'function';\nfunction tmpdir(): string {\n if (hasTmpdir) return os.tmpdir();\n const osShim = require('os-shim');\n return osShim.tmpdir();\n}\n\nfunction removeIfExistsSync(filePath: string): void {\n if (fs.existsSync(filePath)) {\n try {\n fs.unlinkSync(filePath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n}\n\n/**\n * Move a file out of the way (works even if running on Windows)\n * First tries to unlink; if that fails (Windows locked), rename to .old-timestamp\n */\nfunction moveOutOfWay(filePath: string): void {\n if (!fs.existsSync(filePath)) return;\n\n // First try to unlink (works on Unix, fails on Windows if running)\n try {\n fs.unlinkSync(filePath);\n return;\n } catch (_e) {\n // Unlink failed (likely Windows locked file), try rename\n }\n\n // Rename to .old-timestamp as fallback\n const timestamp = Date.now();\n const oldPath = `${filePath}.old-${timestamp}`;\n\n try {\n fs.renameSync(filePath, oldPath);\n } catch (_e2) {\n // Both unlink and rename failed - will fail on atomic rename instead\n }\n}\n\n/**\n * Clean up old .old-* files from previous installs\n */\nfunction cleanupOldFiles(dir: string): void {\n try {\n const entries = fs.readdirSync(dir);\n for (const entry of entries) {\n if (entry.includes('.old-')) {\n try {\n fs.unlinkSync(path.join(dir, entry));\n } catch (_e) {\n // ignore - file may still be in use\n }\n }\n }\n } catch (_e) {\n // ignore if dir doesn't exist\n }\n}\n\n/**\n * Get the platform-specific archive base name (without extension)\n */\nfunction getArchiveBaseName(): string | null {\n const { platform, arch } = process;\n\n const platformMap: PlatformMap = {\n darwin: 'darwin',\n linux: 'linux',\n win32: 'win32',\n };\n\n const archMap: PlatformMap = {\n x64: 'x64',\n arm64: 'arm64',\n amd64: 'x64',\n };\n\n const platformName = platformMap[platform];\n const archName = archMap[arch];\n\n if (!platformName || !archName) return null;\n return `nvu-binary-${platformName}-${archName}`;\n}\n\n/**\n * Copy file\n */\nfunction copyFileSync(src: string, dest: string): void {\n const content = fs.readFileSync(src);\n fs.writeFileSync(dest, content);\n}\n\n/**\n * Sync all shims by copying the nvu binary to all other files in the bin directory\n * All shims (node, npm, npx, corepack, eslint, etc.) are copies of the same binary\n */\nmodule.exports.syncAllShims = function syncAllShims(binDir: string): void {\n const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n const ext = isWindows ? '.exe' : '';\n\n // Source: nvu binary\n const nvuSource = path.join(binDir, `nvu${ext}`);\n if (!fs.existsSync(nvuSource)) return;\n\n try {\n const entries = fs.readdirSync(binDir);\n for (const name of entries) {\n // Skip nvu itself and nvu.json\n if (name === `nvu${ext}` || name === 'nvu.json') continue;\n\n // On Windows, only process .exe files\n if (isWindows && !name.endsWith('.exe')) continue;\n\n const shimPath = path.join(binDir, name);\n const stat = fs.statSync(shimPath);\n if (!stat.isFile()) continue;\n\n // Move existing file out of the way (Windows compatibility)\n moveOutOfWay(shimPath);\n\n // Copy nvu binary to shim\n copyFileSync(nvuSource, shimPath);\n\n // Make executable on Unix\n if (!isWindows) {\n fs.chmodSync(shimPath, 0o755);\n }\n }\n } catch (_e) {\n // Ignore errors - shim sync is best effort\n }\n};\n\n/**\n * Atomic rename with fallback to copy+delete for cross-device moves\n */\nfunction atomicRename(src: string, dest: string, callback: Callback) {\n fs.rename(src, dest, (err) => {\n if (!err) return callback(null);\n\n // Cross-device link error - fall back to copy + delete\n if ((err as NodeJS.ErrnoException).code === 'EXDEV') {\n try {\n copyFileSync(src, dest);\n fs.unlinkSync(src);\n callback(null);\n } catch (copyErr) {\n callback(copyErr as Error);\n }\n return;\n }\n\n callback(err);\n });\n}\n\n/**\n * Extract archive to a directory (callback-based)\n */\nfunction extractArchive(archivePath: string, dest: string, callback: Callback) {\n const Iterator = isWindows ? require('zip-iterator') : require('tar-iterator');\n const stream = isWindows ? fs.createReadStream(archivePath) : fs.createReadStream(archivePath).pipe(require('zlib').createGunzip());\n let iterator = new Iterator(stream);\n\n // one by one\n const links = [];\n iterator.forEach(\n (entry, callback) => {\n if (entry.type === 'link') {\n links.unshift(entry);\n callback();\n } else if (entry.type === 'symlink') {\n links.push(entry);\n callback();\n } else entry.create(dest, callback);\n },\n { callbacks: true, concurrency: 1 },\n (_err) => {\n // create links after directories and files\n const queue = new Queue();\n for (let index = 0; index < links.length; index++) {\n const entry = links[index];\n queue.defer(entry.create.bind(entry, dest));\n }\n queue.await((err) => {\n iterator.destroy();\n iterator = null;\n callback(err);\n });\n }\n );\n}\n\n/**\n * Install binaries using atomic rename pattern\n * 1. Extract to temp directory\n * 2. Copy binary to temp files in destination directory\n * 3. Atomic rename temp files to final names\n */\nfunction extractAndInstall(archivePath: string, destDir: string, binaryName: string, callback: Callback) {\n const ext = isWindows ? '.exe' : '';\n\n // Create temp extraction directory\n const tempExtractDir = path.join(tmpdir(), `nvu-extract-${Date.now()}`);\n mkdirp.sync(tempExtractDir);\n\n extractArchive(archivePath, tempExtractDir, (err) => {\n if (err) {\n safeRmSync(tempExtractDir);\n callback(err);\n return;\n }\n\n const extractedPath = path.join(tempExtractDir, binaryName);\n if (!fs.existsSync(extractedPath)) {\n safeRmSync(tempExtractDir);\n callback(new Error(`Extracted binary not found: ${binaryName}. ${archivePath} ${tempExtractDir}`));\n return;\n }\n\n // Binary names to install\n const binaries = ['node', 'npm', 'npx', 'corepack'];\n const timestamp = Date.now();\n let installError: Error | null = null;\n\n // Step 1: Copy extracted binary to temp files in destination directory\n // This ensures the temp files are on the same filesystem for atomic rename\n for (let i = 0; i < binaries.length; i++) {\n const name = binaries[i];\n const tempDest = path.join(destDir, `${name}.tmp-${timestamp}${ext}`);\n\n try {\n // Copy to temp file in destination directory\n copyFileSync(extractedPath, tempDest);\n\n // Set permissions on Unix\n if (!isWindows) fs.chmodSync(tempDest, 0o755);\n } catch (err) {\n installError = err as Error;\n break;\n }\n }\n\n if (installError) {\n // Clean up any temp files we created\n for (let j = 0; j < binaries.length; j++) {\n const tempPath = path.join(destDir, `${binaries[j]}.tmp-${timestamp}${ext}`);\n removeIfExistsSync(tempPath);\n }\n safeRmSync(tempExtractDir);\n callback(installError);\n return;\n }\n\n // Step 2: Atomic rename temp files to final names\n let renameError: Error | null = null;\n\n function doRename(index: number): void {\n if (index >= binaries.length) {\n // All renames complete\n safeRmSync(tempExtractDir);\n callback(renameError);\n return;\n }\n\n const name = binaries[index];\n const tempDest = path.join(destDir, `${name}.tmp-${timestamp}${ext}`);\n const finalDest = path.join(destDir, `${name}${ext}`);\n\n // Move existing file out of the way (works even if running on Windows)\n moveOutOfWay(finalDest);\n\n atomicRename(tempDest, finalDest, (err) => {\n if (err && !renameError) {\n renameError = err;\n }\n doRename(index + 1);\n });\n }\n\n doRename(0);\n });\n}\n\n/**\n * Print setup instructions\n */\nmodule.exports.printInstructions = function printInstructions(): void {\n const _nvuBinPath = path.join(storagePath, 'bin');\n\n console.log('nvu binaries installed in ~/.nvu/bin/');\n\n const pathKey = envPathKey();\n const envPath = process.env[pathKey] || '';\n if (envPath.indexOf('.nvu/bin') >= 0) return; // path exists\n\n // provide instructions for path setup\n console.log('');\n console.log('============================================================');\n console.log(' Global node setup');\n console.log('============================================================');\n console.log('');\n if (isWindows) {\n console.log(' # Edit your PowerShell profile');\n console.log(' # Open with: notepad $PROFILE');\n console.log(' # Add this line:');\n console.log(' $env:PATH = \"$HOME\\\\.nvu\\\\bin;$env:APPDATA\\\\npm;$env:PATH\"');\n console.log('');\n console.log(' # This adds:');\n console.log(' # ~/.nvu/bin - node/npm version switching shims');\n console.log(' # %APPDATA%/npm - globally installed npm packages (like nvu)');\n } else {\n console.log(' # For bash (~/.bashrc):');\n console.log(' echo \\'export PATH=\"$HOME/.nvu/bin:$PATH\"\\' >> ~/.bashrc');\n console.log('');\n console.log(' # For zsh (~/.zshrc):');\n console.log(' echo \\'export PATH=\"$HOME/.nvu/bin:$PATH\"\\' >> ~/.zshrc');\n console.log('');\n console.log(' # For fish (~/.config/fish/config.fish):');\n console.log(\" echo 'set -gx PATH $HOME/.nvu/bin $PATH' >> ~/.config/fish/config.fish\");\n }\n\n console.log('');\n console.log('Then restart your terminal or source your shell profile.');\n console.log('');\n console.log(\"Without this, 'nvu 18 npm test' still works - you just won't have\");\n console.log(\"transparent 'node' command override.\");\n console.log('============================================================');\n};\n\n/**\n * Main installation function\n */\nmodule.exports.installBinaries = function installBinaries(options, callback): void {\n const archiveBaseName = getArchiveBaseName();\n\n if (!archiveBaseName) {\n callback(new Error('Unsupported platform/architecture for binary.'));\n return;\n }\n\n const extractedBinaryName = `${archiveBaseName}${isWindows ? '.exe' : ''}`;\n const binDir = path.join(storagePath, 'bin');\n const nvuJsonPath = path.join(binDir, 'nvu.json');\n\n // check if we need to upgrade\n if (!options.force) {\n try {\n // already installed - read nvu.json\n const nvuJson = JSON.parse(fs.readFileSync(nvuJsonPath, 'utf8'));\n if (nvuJson.binaryVersion === BINARY_VERSION) {\n callback(null, false);\n return;\n }\n } catch (_err) {}\n }\n\n // Create directories\n mkdirp.sync(storagePath);\n mkdirp.sync(binDir);\n mkdirp.sync(path.join(storagePath, 'cache'));\n\n // Clean up old .old-* files from previous installs\n cleanupOldFiles(binDir);\n\n const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/binary-v${BINARY_VERSION}/${archiveBaseName}${isWindows ? '.zip' : '.tar.gz'}`;\n const cachePath = path.join(storagePath, 'cache', `${archiveBaseName}${isWindows ? '.zip' : '.tar.gz'}`);\n\n // Check cache first\n if (fs.existsSync(cachePath)) {\n console.log('Using cached binary...');\n\n // Use cached file\n extractAndInstall(cachePath, binDir, extractedBinaryName, (err) => {\n if (err) return callback(err);\n\n // save binary version for upgrade checks\n fs.writeFileSync(nvuJsonPath, JSON.stringify({ binaryVersion: BINARY_VERSION }, null, 2), 'utf8');\n console.log('Binary installed successfully!');\n callback(null, true);\n });\n return;\n }\n\n // Download to temp file\n console.log(`Downloading binary for ${process.platform}-${process.arch}...`);\n const tempPath = path.join(tmpdir(), `nvu-binary-${Date.now()}${isWindows ? '.zip' : '.tar.gz'}`);\n\n getFile(downloadUrl, tempPath, (err) => {\n if (err) {\n removeIfExistsSync(tempPath);\n callback(new Error(`No prebuilt binary available for ${process.platform}-${process.arch}. Download: ${downloadUrl}. Error: ${err.message}`));\n return;\n }\n\n // Copy to cache for future use\n try {\n copyFileSync(tempPath, cachePath);\n } catch (_e) {\n // Cache write failed, continue anyway\n }\n\n extractAndInstall(tempPath, binDir, extractedBinaryName, (err) => {\n removeIfExistsSync(tempPath);\n if (err) return callback(err);\n\n // save binary version for upgrade checks\n fs.writeFileSync(nvuJsonPath, JSON.stringify({ binaryVersion: BINARY_VERSION }, null, 2), 'utf8');\n console.log('Binary installed successfully!');\n callback(null, true);\n });\n });\n};\n"],"names":["envPathKey","require","fs","safeRmSync","getFile","mkdirp","os","path","Queue","moduleRoot","root","__dirname","GITHUB_REPO","BINARY_VERSION","join","binaryVersion","isWindows","process","platform","test","env","OSTYPE","hasHomedir","homedir","home","storagePath","NVU_HOME","hasTmpdir","tmpdir","osShim","removeIfExistsSync","filePath","existsSync","unlinkSync","_e","moveOutOfWay","timestamp","Date","now","oldPath","renameSync","_e2","cleanupOldFiles","dir","entries","readdirSync","entry","includes","getArchiveBaseName","arch","platformMap","darwin","linux","win32","archMap","x64","arm64","amd64","platformName","archName","copyFileSync","src","dest","content","readFileSync","writeFileSync","module","exports","syncAllShims","binDir","ext","nvuSource","name","endsWith","shimPath","stat","statSync","isFile","chmodSync","atomicRename","callback","rename","err","code","copyErr","extractArchive","archivePath","Iterator","stream","createReadStream","pipe","createGunzip","iterator","links","forEach","type","unshift","push","create","callbacks","concurrency","_err","queue","index","length","defer","bind","await","destroy","extractAndInstall","destDir","binaryName","tempExtractDir","sync","extractedPath","Error","binaries","installError","i","tempDest","j","tempPath","renameError","doRename","finalDest","printInstructions","_nvuBinPath","console","log","pathKey","envPath","indexOf","installBinaries","options","archiveBaseName","extractedBinaryName","nvuJsonPath","force","nvuJson","JSON","parse","downloadUrl","cachePath","stringify","message"],"mappings":"AAAA,MAAMA,aAAaC,QAAQ;AAC3B,MAAMC,KAAKD,QAAQ;AACnB,MAAM,EAAEE,UAAU,EAAE,GAAGF,QAAQ;AAC/B,MAAMG,UAAUH,QAAQ;AACxB,MAAMI,SAASJ,QAAQ;AACvB,MAAMK,KAAKL,QAAQ;AACnB,MAAMM,OAAON,QAAQ;AACrB,MAAMO,QAAQP,QAAQ;AACtB,MAAMQ,aAAaR,QAAQ;AAE3B,MAAMS,OAAOD,WAAWE;AAExB,gBAAgB;AAChB,MAAMC,cAAc;AACpB,MAAMC,iBAAiBZ,QAAQM,KAAKO,IAAI,CAACJ,MAAM,iBAAiBK,aAAa;AAE7E,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAQ3F,MAAMC,aAAa,OAAOhB,GAAGiB,OAAO,KAAK;AACzC,SAASA;IACP,IAAID,YAAY,OAAOhB,GAAGiB,OAAO;IACjC,MAAMC,OAAOvB,QAAQ;IACrB,OAAOuB;AACT;AAEA,sCAAsC;AACtC,MAAMC,cAAeR,QAAQG,GAAG,CAACM,QAAQ,IAAInB,KAAKO,IAAI,CAACS,WAAW;AAElE,MAAMI,YAAY,OAAOrB,GAAGsB,MAAM,KAAK;AACvC,SAASA;IACP,IAAID,WAAW,OAAOrB,GAAGsB,MAAM;IAC/B,MAAMC,SAAS5B,QAAQ;IACvB,OAAO4B,OAAOD,MAAM;AACtB;AAEA,SAASE,mBAAmBC,QAAgB;IAC1C,IAAI7B,GAAG8B,UAAU,CAACD,WAAW;QAC3B,IAAI;YACF7B,GAAG+B,UAAU,CAACF;QAChB,EAAE,OAAOG,IA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AKI,SAAS,CAAC;gBAAEhI,eAAeF;YAAe,GAAG,MAAM,IAAI;YAC1FkH,QAAQC,GAAG,CAAC;YACZhD,SAAS,MAAM;QACjB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/assets/installBinaries.cts"],"sourcesContent":["const envPathKey = require('env-path-key');\nconst fs = require('fs');\nconst { safeRmSync } = require('fs-remove-compat');\nconst getFile = require('get-file-compat');\nconst mkdirp = require('mkdirp-classic');\nconst os = require('os');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst moduleRoot = require('module-root-sync');\nconst cpuArch = require('cpu-arch');\n\nconst root = moduleRoot(__dirname);\n\n// Configuration\nconst GITHUB_REPO = 'kmalakoff/node-version-use';\nconst BINARY_VERSION = require(path.join(root, 'package.json')).binaryVersion;\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\ntype Callback = (err?: Error | null) => void;\n\ninterface PlatformMap {\n [key: string]: string;\n}\n\nconst hasHomedir = typeof os.homedir === 'function';\nfunction homedir(): string {\n if (hasHomedir) return os.homedir();\n const home = require('homedir-polyfill');\n return home();\n}\n\n// Allow NVU_HOME override for testing\nconst storagePath = (process.env.NVU_HOME || path.join(homedir(), '.nvu')) as string;\n\nconst hasTmpdir = typeof os.tmpdir === 'function';\nfunction tmpdir(): string {\n if (hasTmpdir) return os.tmpdir();\n const osShim = require('os-shim');\n return osShim.tmpdir();\n}\n\nfunction removeIfExistsSync(filePath: string): void {\n if (fs.existsSync(filePath)) {\n try {\n fs.unlinkSync(filePath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n}\n\n/**\n * Move a file out of the way (works even if running on Windows)\n * First tries to unlink; if that fails (Windows locked), rename to .old-timestamp\n */\nfunction moveOutOfWay(filePath: string): void {\n if (!fs.existsSync(filePath)) return;\n\n // First try to unlink (works on Unix, fails on Windows if running)\n try {\n fs.unlinkSync(filePath);\n return;\n } catch (_e) {\n // Unlink failed (likely Windows locked file), try rename\n }\n\n // Rename to .old-timestamp as fallback\n const timestamp = Date.now();\n const oldPath = `${filePath}.old-${timestamp}`;\n\n try {\n fs.renameSync(filePath, oldPath);\n } catch (_e2) {\n // Both unlink and rename failed - will fail on atomic rename instead\n }\n}\n\n/**\n * Clean up old .old-* files from previous installs\n */\nfunction cleanupOldFiles(dir: string): void {\n try {\n const entries = fs.readdirSync(dir);\n for (const entry of entries) {\n if (entry.includes('.old-')) {\n try {\n fs.unlinkSync(path.join(dir, entry));\n } catch (_e) {\n // ignore - file may still be in use\n }\n }\n }\n } catch (_e) {\n // ignore if dir doesn't exist\n }\n}\n\n/**\n * Get the platform-specific archive base name (without extension)\n */\nfunction getArchiveBaseName(): string | null {\n const { platform } = process;\n const arch = cpuArch();\n\n const platformMap: PlatformMap = {\n darwin: 'darwin',\n linux: 'linux',\n win32: 'win32',\n };\n\n const archMap: PlatformMap = {\n x64: 'x64',\n arm64: 'arm64',\n amd64: 'x64',\n };\n\n const platformName = platformMap[platform];\n const archName = archMap[arch];\n\n if (!platformName || !archName) return null;\n return `nvu-binary-${platformName}-${archName}`;\n}\n\n/**\n * Copy file\n */\nfunction copyFileSync(src: string, dest: string): void {\n const content = fs.readFileSync(src);\n fs.writeFileSync(dest, content);\n}\n\n/**\n * Sync all shims by copying the nvu binary to all other files in the bin directory\n * All shims (node, npm, npx, corepack, eslint, etc.) are copies of the same binary\n */\nmodule.exports.syncAllShims = function syncAllShims(binDir: string): void {\n const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n const ext = isWindows ? '.exe' : '';\n\n // Source: nvu binary\n const nvuSource = path.join(binDir, `nvu${ext}`);\n if (!fs.existsSync(nvuSource)) return;\n\n try {\n const entries = fs.readdirSync(binDir);\n for (const name of entries) {\n // Skip nvu itself and nvu.json\n if (name === `nvu${ext}` || name === 'nvu.json') continue;\n\n // On Windows, only process .exe files\n if (isWindows && !name.endsWith('.exe')) continue;\n\n const shimPath = path.join(binDir, name);\n const stat = fs.statSync(shimPath);\n if (!stat.isFile()) continue;\n\n // Move existing file out of the way (Windows compatibility)\n moveOutOfWay(shimPath);\n\n // Copy nvu binary to shim\n copyFileSync(nvuSource, shimPath);\n\n // Make executable on Unix\n if (!isWindows) {\n fs.chmodSync(shimPath, 0o755);\n }\n }\n } catch (_e) {\n // Ignore errors - shim sync is best effort\n }\n};\n\n/**\n * Atomic rename with fallback to copy+delete for cross-device moves\n */\nfunction atomicRename(src: string, dest: string, callback: Callback) {\n fs.rename(src, dest, (err) => {\n if (!err) return callback(null);\n\n // Cross-device link error - fall back to copy + delete\n if ((err as NodeJS.ErrnoException).code === 'EXDEV') {\n try {\n copyFileSync(src, dest);\n fs.unlinkSync(src);\n callback(null);\n } catch (copyErr) {\n callback(copyErr as Error);\n }\n return;\n }\n\n callback(err);\n });\n}\n\n/**\n * Extract archive to a directory (callback-based)\n */\nfunction extractArchive(archivePath: string, dest: string, callback: Callback) {\n const Iterator = isWindows ? require('zip-iterator') : require('tar-iterator');\n const stream = isWindows ? fs.createReadStream(archivePath) : fs.createReadStream(archivePath).pipe(require('zlib').createGunzip());\n let iterator = new Iterator(stream);\n\n // one by one\n const links = [];\n iterator.forEach(\n (entry, callback) => {\n if (entry.type === 'link') {\n links.unshift(entry);\n callback();\n } else if (entry.type === 'symlink') {\n links.push(entry);\n callback();\n } else entry.create(dest, callback);\n },\n { callbacks: true, concurrency: 1 },\n (_err) => {\n // create links after directories and files\n const queue = new Queue();\n for (let index = 0; index < links.length; index++) {\n const entry = links[index];\n queue.defer(entry.create.bind(entry, dest));\n }\n queue.await((err) => {\n iterator.destroy();\n iterator = null;\n callback(err);\n });\n }\n );\n}\n\n/**\n * Install binaries using atomic rename pattern\n * 1. Extract to temp directory\n * 2. Copy binary to temp files in destination directory\n * 3. Atomic rename temp files to final names\n */\nfunction extractAndInstall(archivePath: string, destDir: string, binaryName: string, callback: Callback) {\n const ext = isWindows ? '.exe' : '';\n\n // Create temp extraction directory\n const tempExtractDir = path.join(tmpdir(), `nvu-extract-${Date.now()}`);\n mkdirp.sync(tempExtractDir);\n\n extractArchive(archivePath, tempExtractDir, (err) => {\n if (err) {\n safeRmSync(tempExtractDir);\n callback(err);\n return;\n }\n\n const extractedPath = path.join(tempExtractDir, binaryName);\n if (!fs.existsSync(extractedPath)) {\n safeRmSync(tempExtractDir);\n callback(new Error(`Extracted binary not found: ${binaryName}. ${archivePath} ${tempExtractDir}`));\n return;\n }\n\n // Binary names to install\n const binaries = ['node', 'npm', 'npx', 'corepack'];\n const timestamp = Date.now();\n let installError: Error | null = null;\n\n // Step 1: Copy extracted binary to temp files in destination directory\n // This ensures the temp files are on the same filesystem for atomic rename\n for (let i = 0; i < binaries.length; i++) {\n const name = binaries[i];\n const tempDest = path.join(destDir, `${name}.tmp-${timestamp}${ext}`);\n\n try {\n // Copy to temp file in destination directory\n copyFileSync(extractedPath, tempDest);\n\n // Set permissions on Unix\n if (!isWindows) fs.chmodSync(tempDest, 0o755);\n } catch (err) {\n installError = err as Error;\n break;\n }\n }\n\n if (installError) {\n // Clean up any temp files we created\n for (let j = 0; j < binaries.length; j++) {\n const tempPath = path.join(destDir, `${binaries[j]}.tmp-${timestamp}${ext}`);\n removeIfExistsSync(tempPath);\n }\n safeRmSync(tempExtractDir);\n callback(installError);\n return;\n }\n\n // Step 2: Atomic rename temp files to final names\n let renameError: Error | null = null;\n\n function doRename(index: number): void {\n if (index >= binaries.length) {\n // All renames complete\n safeRmSync(tempExtractDir);\n callback(renameError);\n return;\n }\n\n const name = binaries[index];\n const tempDest = path.join(destDir, `${name}.tmp-${timestamp}${ext}`);\n const finalDest = path.join(destDir, `${name}${ext}`);\n\n // Move existing file out of the way (works even if running on Windows)\n moveOutOfWay(finalDest);\n\n atomicRename(tempDest, finalDest, (err) => {\n if (err && !renameError) {\n renameError = err;\n }\n doRename(index + 1);\n });\n }\n\n doRename(0);\n });\n}\n\n/**\n * Print setup instructions\n */\nmodule.exports.printInstructions = function printInstructions(): void {\n const _nvuBinPath = path.join(storagePath, 'bin');\n\n console.log('nvu binaries installed in ~/.nvu/bin/');\n\n const pathKey = envPathKey();\n const envPath = process.env[pathKey] || '';\n if (envPath.indexOf('.nvu/bin') >= 0) return; // path exists\n\n // provide instructions for path setup\n console.log('');\n console.log('============================================================');\n console.log(' Global node setup');\n console.log('============================================================');\n console.log('');\n if (isWindows) {\n console.log(' # Edit your PowerShell profile');\n console.log(' # Open with: notepad $PROFILE');\n console.log(' # Add this line:');\n console.log(' $env:PATH = \"$HOME\\\\.nvu\\\\bin;$env:APPDATA\\\\npm;$env:PATH\"');\n console.log('');\n console.log(' # This adds:');\n console.log(' # ~/.nvu/bin - node/npm version switching shims');\n console.log(' # %APPDATA%/npm - globally installed npm packages (like nvu)');\n } else {\n console.log(' # For bash (~/.bashrc):');\n console.log(' echo \\'export PATH=\"$HOME/.nvu/bin:$PATH\"\\' >> ~/.bashrc');\n console.log('');\n console.log(' # For zsh (~/.zshrc):');\n console.log(' echo \\'export PATH=\"$HOME/.nvu/bin:$PATH\"\\' >> ~/.zshrc');\n console.log('');\n console.log(' # For fish (~/.config/fish/config.fish):');\n console.log(\" echo 'set -gx PATH $HOME/.nvu/bin $PATH' >> ~/.config/fish/config.fish\");\n }\n\n console.log('');\n console.log('Then restart your terminal or source your shell profile.');\n console.log('');\n console.log(\"Without this, 'nvu 18 npm test' still works - you just won't have\");\n console.log(\"transparent 'node' command override.\");\n console.log('============================================================');\n};\n\n/**\n * Main installation function\n */\nmodule.exports.installBinaries = function installBinaries(options, callback): void {\n const archiveBaseName = getArchiveBaseName();\n\n if (!archiveBaseName) {\n callback(new Error('Unsupported platform/architecture for binary.'));\n return;\n }\n\n const extractedBinaryName = `${archiveBaseName}${isWindows ? '.exe' : ''}`;\n const binDir = path.join(storagePath, 'bin');\n const nvuJsonPath = path.join(binDir, 'nvu.json');\n\n // check if we need to upgrade\n if (!options.force) {\n try {\n // already installed - read nvu.json\n const nvuJson = JSON.parse(fs.readFileSync(nvuJsonPath, 'utf8'));\n if (nvuJson.binaryVersion === BINARY_VERSION) {\n callback(null, false);\n return;\n }\n } catch (_err) {}\n }\n\n // Create directories\n mkdirp.sync(storagePath);\n mkdirp.sync(binDir);\n mkdirp.sync(path.join(storagePath, 'cache'));\n\n // Clean up old .old-* files from previous installs\n cleanupOldFiles(binDir);\n\n const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/binary-v${BINARY_VERSION}/${archiveBaseName}${isWindows ? '.zip' : '.tar.gz'}`;\n const cachePath = path.join(storagePath, 'cache', `${archiveBaseName}${isWindows ? '.zip' : '.tar.gz'}`);\n\n // Check cache first\n if (fs.existsSync(cachePath)) {\n console.log('Using cached binary...');\n\n // Use cached file\n extractAndInstall(cachePath, binDir, extractedBinaryName, (err) => {\n if (err) return callback(err);\n\n // save binary version for upgrade checks\n fs.writeFileSync(nvuJsonPath, JSON.stringify({ binaryVersion: BINARY_VERSION }, null, 2), 'utf8');\n console.log('Binary installed successfully!');\n callback(null, true);\n });\n return;\n }\n\n // Download to temp file\n console.log(`Downloading binary for ${archiveBaseName}...`);\n const tempPath = path.join(tmpdir(), `nvu-binary-${Date.now()}${isWindows ? '.zip' : '.tar.gz'}`);\n\n getFile(downloadUrl, tempPath, (err) => {\n if (err) {\n removeIfExistsSync(tempPath);\n callback(new Error(`No prebuilt binary available for ${archiveBaseName}. Download: ${downloadUrl}. Error: ${err.message}`));\n return;\n }\n\n // Copy to cache for future use\n try {\n copyFileSync(tempPath, cachePath);\n } catch (_e) {\n // Cache write failed, continue anyway\n }\n\n extractAndInstall(tempPath, binDir, extractedBinaryName, (err) => {\n removeIfExistsSync(tempPath);\n if (err) return callback(err);\n\n // save binary version for upgrade checks\n fs.writeFileSync(nvuJsonPath, JSON.stringify({ binaryVersion: BINARY_VERSION }, null, 2), 'utf8');\n console.log('Binary installed successfully!');\n callback(null, true);\n });\n });\n};\n"],"names":["envPathKey","require","fs","safeRmSync","getFile","mkdirp","os","path","Queue","moduleRoot","cpuArch","root","__dirname","GITHUB_REPO","BINARY_VERSION","join","binaryVersion","isWindows","process","platform","test","env","OSTYPE","hasHomedir","homedir","home","storagePath","NVU_HOME","hasTmpdir","tmpdir","osShim","removeIfExistsSync","filePath","existsSync","unlinkSync","_e","moveOutOfWay","timestamp","Date","now","oldPath","renameSync","_e2","cleanupOldFiles","dir","entries","readdirSync","entry","includes","getArchiveBaseName","arch","platformMap","darwin","linux","win32","archMap","x64","arm64","amd64","platformName","archName","copyFileSync","src","dest","content","readFileSync","writeFileSync","module","exports","syncAllShims","binDir","ext","nvuSource","name","endsWith","shimPath","stat","statSync","isFile","chmodSync","atomicRename","callback","rename","err","code","copyErr","extractArchive","archivePath","Iterator","stream","createReadStream","pipe","createGunzip","iterator","links","forEach","type","unshift","push","create","callbacks","concurrency","_err","queue","index","length","defer","bind","await","destroy","extractAndInstall","destDir","binaryName","tempExtractDir","sync","extractedPath","Error","binaries","installError","i","tempDest","j","tempPath","renameError","doRename","finalDest","printInstructions","_nvuBinPath","console","log","pathKey","envPath","indexOf","installBinaries","options","archiveBaseName","extractedBinaryName","nvuJsonPath","force","nvuJson","JSON","parse","downloadUrl","cachePath","stringify","message"],"mappings":"AAAA,MAAMA,aAAaC,QAAQ;AAC3B,MAAMC,KAAKD,QAAQ;AACnB,MAAM,EAAEE,UAAU,EAAE,GAAGF,QAAQ;AAC/B,MAAMG,UAAUH,QAAQ;AACxB,MAAMI,SAASJ,QAAQ;AACvB,MAAMK,KAAKL,QAAQ;AACnB,MAAMM,OAAON,QAAQ;AACrB,MAAMO,QAAQP,QAAQ;AACtB,MAAMQ,aAAaR,QAAQ;AAC3B,MAAMS,UAAUT,QAAQ;AAExB,MAAMU,OAAOF,WAAWG;AAExB,gBAAgB;AAChB,MAAMC,cAAc;AACpB,MAAMC,iBAAiBb,QAAQM,KAAKQ,IAAI,CAACJ,MAAM,iBAAiBK,aAAa;AAE7E,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAk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AU,CAAC,WAAW,EAAES,KAAKC,GAAG,KAAKtB,YAAY,SAAS,WAAW;IAEhGb,QAAQ0I,aAAapB,UAAU,CAACvC;QAC9B,IAAIA,KAAK;YACPpD,mBAAmB2F;YACnBzC,SAAS,IAAImC,MAAM,CAAC,iCAAiC,EAAEmB,gBAAgB,YAAY,EAAEO,YAAY,SAAS,EAAE3D,IAAI8D,OAAO,EAAE;YACzH;QACF;QAEA,+BAA+B;QAC/B,IAAI;YACFpF,aAAa6D,UAAUqB;QACzB,EAAE,OAAO5G,IAAI;QACX,sCAAsC;QACxC;QAEA2E,kBAAkBY,UAAUpD,QAAQkE,qBAAqB,CAACrD;YACxDpD,mBAAmB2F;YACnB,IAAIvC,KAAK,OAAOF,SAASE;YAEzB,yCAAyC;YACzCjF,GAAGgE,aAAa,CAACuE,aAAaG,KAAKI,SAAS,CAAC;gBAAEhI,eAAeF;YAAe,GAAG,MAAM,IAAI;YAC1FkH,QAAQC,GAAG,CAAC;YACZhD,SAAS,MAAM;QACjB;IACF;AACF"}
|
|
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { storagePath } from '../constants.js';
|
|
5
5
|
import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
6
|
+
import { resolveSystemBinary } from '../lib/resolveSystemBinary.js';
|
|
6
7
|
/**
|
|
7
8
|
* nvu which
|
|
8
9
|
*
|
|
@@ -21,6 +22,20 @@ import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
|
21
22
|
exit(1);
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
25
|
+
// Handle "system" version specially
|
|
26
|
+
if (version === 'system') {
|
|
27
|
+
console.log('Version: system');
|
|
28
|
+
console.log(`Source: ${getVersionSource(cwd)}`);
|
|
29
|
+
const systemNode = resolveSystemBinary('node');
|
|
30
|
+
console.log(`Binary: ${systemNode || 'not found'}`);
|
|
31
|
+
if (systemNode) {
|
|
32
|
+
console.log('Status: Available');
|
|
33
|
+
} else {
|
|
34
|
+
console.log('Status: Not found (install Node.js on your system)');
|
|
35
|
+
}
|
|
36
|
+
exit(0);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
24
39
|
// Resolve partial version to exact installed version
|
|
25
40
|
const versionsPath = path.join(storagePath, 'installed');
|
|
26
41
|
const matches = findInstalledVersions(versionsPath, version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["exit","fs","path","storagePath","findInstalledVersions","whichCmd","_args","cwd","process","version","resolveVersion","console","log","versionsPath","join","matches","resolvedVersion","length","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\nimport { resolveSystemBinary } from '../lib/resolveSystemBinary.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Handle \"system\" version specially\n if (version === 'system') {\n console.log('Version: system');\n console.log(`Source: ${getVersionSource(cwd)}`);\n const systemNode = resolveSystemBinary('node');\n console.log(`Binary: ${systemNode || 'not found'}`);\n if (systemNode) {\n console.log('Status: Available');\n } else {\n console.log('Status: Not found (install Node.js on your system)');\n }\n exit(0);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["exit","fs","path","storagePath","findInstalledVersions","resolveSystemBinary","whichCmd","_args","cwd","process","version","resolveVersion","console","log","getVersionSource","systemNode","versionsPath","join","matches","resolvedVersion","length","actualVersionPath","nodePath","existsSync","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,gCAAgC;AAEpE;;;;;CAKC,GACD,eAAe,SAASC,SAASC,KAAe;IAC9C,MAAMC,MAAMC,QAAQD,GAAG;IAEvB,yDAAyD;IACzD,MAAME,UAAUC,eAAeH;IAE/B,IAAI,CAACE,SAAS;QACZE,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,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AGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
|
package/dist/esm/compat.d.ts
CHANGED
package/dist/esm/compat.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Compatibility Layer for Node.js 0.8+
|
|
3
3
|
* Local to this package - contains only needed functions.
|
|
4
4
|
*/ import fs from 'fs';
|
|
5
|
-
import
|
|
5
|
+
import Module from 'module';
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
// Use existing require in CJS, or createRequire in ESM (Node 12.2+)
|
|
9
|
-
const _require = typeof require === 'undefined' ?
|
|
9
|
+
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
10
10
|
export function homedir() {
|
|
11
11
|
return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();
|
|
12
12
|
}
|
|
@@ -19,9 +19,7 @@ export function tmpdir() {
|
|
|
19
19
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
20
20
|
*/ const hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
21
21
|
export function stringEndsWith(str, search, position) {
|
|
22
|
-
if (hasEndsWith)
|
|
23
|
-
return str.endsWith(search, position);
|
|
24
|
-
}
|
|
22
|
+
if (hasEndsWith) return str.endsWith(search, position);
|
|
25
23
|
const len = position === undefined ? str.length : position;
|
|
26
24
|
return str.lastIndexOf(search) === len - search.length;
|
|
27
25
|
}
|
|
@@ -57,3 +55,16 @@ export function readdirWithTypes(dir) {
|
|
|
57
55
|
};
|
|
58
56
|
});
|
|
59
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Object.assign wrapper for Node.js 0.8+
|
|
60
|
+
* - Uses native Object.assign on Node 4.0+
|
|
61
|
+
* - Falls back to manual property copy on Node 0.8-3.x
|
|
62
|
+
*/ const hasObjectAssign = typeof Object.assign === 'function';
|
|
63
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
64
|
+
export function objectAssign(target, source) {
|
|
65
|
+
if (hasObjectAssign) return Object.assign(target, source);
|
|
66
|
+
for(const key in source){
|
|
67
|
+
if (_hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
68
|
+
}
|
|
69
|
+
return target;
|
|
70
|
+
}
|
package/dist/esm/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport Module from 'module';\nimport os from 'os';\nimport path from 'path';\n\n// Use existing require in CJS, or createRequire in ESM (Node 12.2+)\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nexport function homedir(): string {\n return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();\n}\n\nexport function tmpdir(): string {\n return typeof os.tmpdir === 'function' ? os.tmpdir() : require('os-shim').tmpdir();\n}\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Recursive mkdir for Node.js 0.8+\n */\nexport function mkdirpSync(dir: string): void {\n const mkdirp = _require('mkdirp-classic');\n mkdirp.sync(dir);\n}\n\n/**\n * Recursive rm for Node.js 0.8+\n */\nexport function rmSync(dir: string): void {\n const safeRmSync = _require('fs-remove-compat').safeRmSync;\n safeRmSync(dir);\n}\n\n/**\n * Read directory entries with types for Node.js 0.8+\n * Returns array of {name, isDirectory()}\n */\nexport interface DirEntry {\n name: string;\n isDirectory(): boolean;\n}\n\nexport function readdirWithTypes(dir: string): DirEntry[] {\n const names = fs.readdirSync(dir);\n return names.map((name) => {\n const fullPath = path.join(dir, name);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(fullPath);\n } catch (_e) {\n // If stat fails, treat as non-directory\n return { name: name, isDirectory: () => false };\n }\n return {\n name: name,\n isDirectory: () => stat.isDirectory(),\n };\n });\n}\n\n/**\n * Object.assign wrapper for Node.js 0.8+\n * - Uses native Object.assign on Node 4.0+\n * - Falls back to manual property copy on Node 0.8-3.x\n */\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) return Object.assign(target, source);\n\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) (target as Record<string, unknown>)[key] = source[key];\n }\n return target as T & U;\n}\n"],"names":["fs","Module","os","path","_require","require","createRequire","url","homedir","tmpdir","hasEndsWith","String","prototype","endsWith","stringEndsWith","str","search","position","len","undefined","length","lastIndexOf","mkdirpSync","dir","mkdirp","sync","rmSync","safeRmSync","readdirWithTypes","names","readdirSync","map","name","fullPath","join","stat","statSync","_e","isDirectory","hasObjectAssign","Object","assign","_hasOwnProperty","hasOwnProperty","objectAssign","target","source","key","call"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,QAAQ,KAAK;AACpB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB,oEAAoE;AACpE,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,OAAOK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,OAAO,SAASG;IACd,OAAO,OAAON,GAAGM,OAAO,KAAK,aAAaN,GAAGM,OAAO,KAAKH,QAAQ;AACnE;AAEA,OAAO,SAASI;IAC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,IAAK,MAAMC,OAAOD,OAAQ;QACxB,IAAIJ,gBAAgBM,IAAI,CAACF,QAAQC,MAAM,AAACF,MAAkC,CAACE,IAAI,GAAGD,MAAM,CAACC,IAAI;IAC/F;IACA,OAAOF;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import installModule from 'install-module-linked';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import url from 'url';
|
|
4
|
-
const _dirname = path.dirname(typeof
|
|
4
|
+
const _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
5
5
|
const nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');
|
|
6
6
|
const moduleName = 'node-version-install';
|
|
7
7
|
let cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\nconst moduleName = 'node-version-install';\n\ntype InstallCallback = (err?: Error, results?: InstallResult[]) => void;\ntype InstallVersionFn = (version: string, options: InstallOptions, callback: InstallCallback) => void;\n\nlet cached: InstallVersionFn | undefined;\n\nfunction loadModule(moduleName, callback) {\n if (typeof require === 'undefined') {\n import(moduleName)\n .then((mod) => {\n callback(null, mod?.default ?? null);\n })\n .catch(callback);\n } else {\n try {\n callback(null, require(moduleName));\n } catch (err) {\n callback(err, null);\n }\n }\n}\n\nexport default function loadNodeVersionInstall(callback: (err: Error | null, installVersion: InstallVersionFn) => void): void {\n if (cached !== undefined) return callback(null, cached);\n\n installModule(moduleName, nodeModules, {}, (err) => {\n if (err) return callback(err, null);\n loadModule(moduleName, (err, _cached: InstallVersionFn) => {\n if (err) return callback(err, null);\n cached = _cached;\n callback(null, cached);\n });\n });\n}\n"],"names":["installModule","path","url","_dirname","dirname","__filename","fileURLToPath","nodeModules","join","moduleName","cached","loadModule","callback","require","then","mod","default","catch","err","loadNodeVersionInstall","undefined","_cached"],"mappings":"AAAA,OAAOA,mBAAmB,wBAAwB;AAElD,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,MAAMC,WAAWF,KAAKG,OAAO,CAAC,OAAOC,eAAe,cAAcH,IAAII,aAAa,CAAC,YAAYJ,GAAG,IAAIG;AACvG,MAAME,cAAcN,KAAKO,IAAI,CAACL,UAAU,MAAM,MAAM,MAAM;AAC1D,MAAMM,aAAa;AAKnB,IAAIC;AAEJ,SAASC,WAAWF,UAAU,EAAEG,QAAQ;IACtC,IAAI,OAAOC,YAAY,aAAa;QAClC,MAAM,CAACJ,YACJK,IAAI,CAAC,CAACC;;YACLH,SAAS,cAAMG,gBAAAA,0BAAAA,IAAKC,OAAO,uCAAI;QACjC,GACCC,KAAK,CAACL;IACX,OAAO;QACL,IAAI;YACFA,SAAS,MAAMC,QAAQJ;QACzB,EAAE,OAAOS,KAAK;YACZN,SAASM,KAAK;QAChB;IACF;AACF;AAEA,eAAe,SAASC,uBAAuBP,QAAuE;IACpH,IAAIF,WAAWU,WAAW,OAAOR,SAAS,MAAMF;IAEhDV,cAAcS,YAAYF,aAAa,CAAC,GAAG,CAACW;QAC1C,IAAIA,KAAK,OAAON,SAASM,KAAK;QAC9BP,WAAWF,YAAY,CAACS,KAAKG;YAC3B,IAAIH,KAAK,OAAON,SAASM,KAAK;YAC9BR,SAASW;YACTT,SAAS,MAAMF;QACjB;IACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find a system binary by searching PATH, excluding ~/.nvu/bin
|
|
3
|
+
* Returns the full path to the binary, or null if not found
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveSystemBinary(name: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get PATH with ~/.nvu/bin removed
|
|
8
|
+
* Used to create an environment for spawning system commands
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPathWithoutNvuBin(): string;
|