node-version-use 2.1.4 → 2.1.6
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/{dist/cjs/scripts/postinstall.js → assets/postinstall.cjs} +73 -76
- package/dist/cjs/assets/postinstall.cjs +425 -0
- package/dist/cjs/assets/postinstall.cjs.map +1 -0
- package/dist/cjs/commands/default.js.map +1 -1
- package/dist/cjs/commands/list.js.map +1 -1
- package/dist/cjs/commands/setup.js.map +1 -1
- package/dist/cjs/commands/uninstall.js.map +1 -1
- package/dist/cjs/commands/which.js.map +1 -1
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/lib/findInstalledVersions.js.map +1 -1
- package/dist/esm/{scripts/postinstall.js → assets/postinstall.cjs} +18 -13
- package/dist/esm/assets/postinstall.cjs.map +1 -0
- package/dist/esm/commands/default.js +8 -8
- package/dist/esm/commands/default.js.map +1 -1
- package/dist/esm/commands/list.js +3 -3
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/setup.js +20 -20
- package/dist/esm/commands/setup.js.map +1 -1
- package/dist/esm/commands/uninstall.js +12 -12
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/which.js +5 -5
- package/dist/esm/commands/which.js.map +1 -1
- package/dist/esm/compat.js +10 -10
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/lib/findInstalledVersions.js +19 -19
- package/dist/esm/lib/findInstalledVersions.js.map +1 -1
- package/package.json +19 -19
- package/dist/cjs/scripts/postinstall.js.map +0 -1
- package/dist/esm/scripts/postinstall.d.ts +0 -12
- package/dist/esm/scripts/postinstall.js.map +0 -1
- package/scripts/ensure-test-binaries.ts +0 -27
- package/scripts/postinstall.cjs +0 -9
- /package/dist/cjs/{scripts → assets}/postinstall.d.cts +0 -0
- /package/dist/{cjs/scripts/postinstall.d.ts → esm/assets/postinstall.d.cts} +0 -0
|
@@ -22,9 +22,9 @@ import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
// Resolve partial version to exact installed version
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const versionsPath = path.join(storagePath, 'installed');
|
|
26
|
+
const matches = findInstalledVersions(versionsPath, version);
|
|
27
|
+
const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;
|
|
28
28
|
// Display version (show resolution if different)
|
|
29
29
|
if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {
|
|
30
30
|
console.log(`Version: ${version} \u2192 ${resolvedVersion}`);
|
|
@@ -33,8 +33,8 @@ import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
|
33
33
|
}
|
|
34
34
|
console.log(`Source: ${getVersionSource(cwd)}`);
|
|
35
35
|
if (resolvedVersion) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const actualVersionPath = path.join(versionsPath, resolvedVersion);
|
|
37
|
+
const nodePath = path.join(actualVersionPath, 'bin', 'node');
|
|
38
38
|
console.log(`Binary: ${nodePath}`);
|
|
39
39
|
if (fs.existsSync(nodePath)) {
|
|
40
40
|
console.log('Status: Installed');
|
|
@@ -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
|
|
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","getVersionSource","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;AAExE;;;;;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,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QAC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C,IAAIrB,GAAGoB,UAAU,CAACK,YAAY;YAC5B,OAAOzB,GAAGuB,YAAY,CAACE,WAAW,QAAQD,IAAI;QAChD;QAEA,iBAAiB;QACjB,MAAME,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,uBAAuB;IACvB,MAAME,cAAc3B,KAAKY,IAAI,CAACX,aAAa;IAC3C,IAAIF,GAAGoB,UAAU,CAACQ,cAAc;QAC9B,OAAO5B,GAAGuB,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASP,iBAAiBX,GAAW;IACnC,IAAIe,MAAMf;IACV,MAAO,KAAM;QACX,MAAMgB,YAAYrB,KAAKY,IAAI,CAACQ,KAAK;QACjC,IAAIrB,GAAGoB,UAAU,CAACE,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMG,YAAYxB,KAAKY,IAAI,CAACQ,KAAK;QACjC,IAAIrB,GAAGoB,UAAU,CAACK,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMC,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,MAAME,cAAc3B,KAAKY,IAAI,CAACX,aAAa;IAC3C,IAAIF,GAAGoB,UAAU,CAACQ,cAAc;QAC9B,OAAO,GAAGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
|
package/dist/esm/compat.js
CHANGED
|
@@ -6,44 +6,44 @@ 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
|
-
|
|
10
|
-
|
|
9
|
+
const _require = typeof require === 'undefined' ? _Module.createRequire(import.meta.url) : require;
|
|
10
|
+
const hasHomedir = typeof os.homedir === 'function';
|
|
11
11
|
export function homedir() {
|
|
12
12
|
if (hasHomedir) {
|
|
13
13
|
return os.homedir();
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
const home = _require('homedir-polyfill');
|
|
16
16
|
return home();
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* String.prototype.endsWith wrapper for Node.js 0.8+
|
|
20
20
|
* - Uses native endsWith on Node 4.0+ / ES2015+
|
|
21
21
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
22
|
-
*/
|
|
22
|
+
*/ const hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
23
23
|
export function stringEndsWith(str, search, position) {
|
|
24
24
|
if (hasEndsWith) {
|
|
25
25
|
return str.endsWith(search, position);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
const len = position === undefined ? str.length : position;
|
|
28
28
|
return str.lastIndexOf(search) === len - search.length;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Recursive mkdir for Node.js 0.8+
|
|
32
32
|
*/ export function mkdirpSync(dir) {
|
|
33
|
-
|
|
33
|
+
const mkdirp = _require('mkdirp-classic');
|
|
34
34
|
mkdirp.sync(dir);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Recursive rm for Node.js 0.8+
|
|
38
38
|
*/ export function rmSync(dir) {
|
|
39
|
-
|
|
39
|
+
const safeRmSync = _require('fs-remove-compat').safeRmSync;
|
|
40
40
|
safeRmSync(dir);
|
|
41
41
|
}
|
|
42
42
|
export function readdirWithTypes(dir) {
|
|
43
|
-
|
|
43
|
+
const names = fs.readdirSync(dir);
|
|
44
44
|
return names.map((name)=>{
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const fullPath = path.join(dir, name);
|
|
46
|
+
let stat;
|
|
47
47
|
try {
|
|
48
48
|
stat = fs.statSync(fullPath);
|
|
49
49
|
} catch (_e) {
|
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 _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+)\
|
|
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\nconst hasHomedir = typeof os.homedir === 'function';\n\nexport function homedir(): string {\n if (hasHomedir) {\n return os.homedir();\n }\n const home = _require('homedir-polyfill');\n return home();\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';\n\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) {\n return str.endsWith(search, position);\n }\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"],"names":["fs","_Module","os","path","_require","require","createRequire","url","hasHomedir","homedir","home","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"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,QAAQ,KAAK;AACpB,OAAOC,aAAa,SAAS;AAC7B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB,oEAAoE;AACpE,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,QAAQK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE3F,MAAMG,aAAa,OAAON,GAAGO,OAAO,KAAK;AAEzC,OAAO,SAASA;IACd,IAAID,YAAY;QACd,OAAON,GAAGO,OAAO;IACnB;IACA,MAAMC,OAAON,SAAS;IACtB,OAAOM;AACT;AAEA;;;;CAIC,GACD,MAAMC,cAAc,OAAOC,OAAOC,SAAS,CAACC,QAAQ,KAAK;AAEzD,OAAO,SAASC,eAAeC,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIP,aAAa;QACf,OAAOK,IAAIF,QAAQ,CAACG,QAAQC;IAC9B;IACA,MAAMC,MAAMD,aAAaE,YAAYJ,IAAIK,MAAM,GAAGH;IAClD,OAAOF,IAAIM,WAAW,CAACL,YAAYE,MAAMF,OAAOI,MAAM;AACxD;AAEA;;CAEC,GACD,OAAO,SAASE,WAAWC,GAAW;IACpC,MAAMC,SAASrB,SAAS;IACxBqB,OAAOC,IAAI,CAACF;AACd;AAEA;;CAEC,GACD,OAAO,SAASG,OAAOH,GAAW;IAChC,MAAMI,aAAaxB,SAAS,oBAAoBwB,UAAU;IAC1DA,WAAWJ;AACb;AAWA,OAAO,SAASK,iBAAiBL,GAAW;IAC1C,MAAMM,QAAQ9B,GAAG+B,WAAW,CAACP;IAC7B,OAAOM,MAAME,GAAG,CAAC,CAACC;QAChB,MAAMC,WAAW/B,KAAKgC,IAAI,CAACX,KAAKS;QAChC,IAAIG;QACJ,IAAI;YACFA,OAAOpC,GAAGqC,QAAQ,CAACH;QACrB,EAAE,OAAOI,IAAI;YACX,wCAAwC;YACxC,OAAO;gBAAEL,MAAMA;gBAAMM,aAAa,IAAM;YAAM;QAChD;QACA,OAAO;YACLN,MAAMA;YACNM,aAAa,IAAMH,KAAKG,WAAW;QACrC;IACF;AACF"}
|
|
@@ -5,12 +5,12 @@ import { readdirWithTypes } from '../compat.js';
|
|
|
5
5
|
* Compare two semver version strings (e.g., "20.19.0" vs "20.9.1")
|
|
6
6
|
* Returns: negative if a < b, positive if a > b, 0 if equal
|
|
7
7
|
*/ function compareVersions(a, b) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
for(
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const aParts = a.replace(/^v/, '').split('.');
|
|
9
|
+
const bParts = b.replace(/^v/, '').split('.');
|
|
10
|
+
const len = Math.max(aParts.length, bParts.length);
|
|
11
|
+
for(let i = 0; i < len; i++){
|
|
12
|
+
const aNum = parseInt(aParts[i], 10) || 0;
|
|
13
|
+
const bNum = parseInt(bParts[i], 10) || 0;
|
|
14
14
|
if (aNum !== bNum) {
|
|
15
15
|
return aNum - bNum;
|
|
16
16
|
}
|
|
@@ -24,17 +24,17 @@ import { readdirWithTypes } from '../compat.js';
|
|
|
24
24
|
if (!fs.existsSync(versionsPath)) {
|
|
25
25
|
return [];
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const normalizedVersion = version.replace(/^v/, '');
|
|
28
|
+
const matches = [];
|
|
29
29
|
// Try exact matches first
|
|
30
|
-
|
|
30
|
+
const exactMatches = [
|
|
31
31
|
version,
|
|
32
32
|
`v${normalizedVersion}`,
|
|
33
33
|
normalizedVersion
|
|
34
34
|
];
|
|
35
|
-
for(
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
for(let i = 0; i < exactMatches.length; i++){
|
|
36
|
+
const v = exactMatches[i];
|
|
37
|
+
const versionPath = path.join(versionsPath, v);
|
|
38
38
|
if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {
|
|
39
39
|
if (matches.indexOf(v) === -1) {
|
|
40
40
|
matches.push(v);
|
|
@@ -46,11 +46,11 @@ import { readdirWithTypes } from '../compat.js';
|
|
|
46
46
|
return matches;
|
|
47
47
|
}
|
|
48
48
|
// Try partial match (e.g., "20" matches "v20.19.6")
|
|
49
|
-
|
|
50
|
-
for(
|
|
51
|
-
|
|
49
|
+
const entries = readdirWithTypes(versionsPath);
|
|
50
|
+
for(let j = 0; j < entries.length; j++){
|
|
51
|
+
const entry = entries[j];
|
|
52
52
|
if (!entry.isDirectory()) continue;
|
|
53
|
-
|
|
53
|
+
const dirVersion = entry.name.replace(/^v/, '');
|
|
54
54
|
if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {
|
|
55
55
|
matches.push(entry.name);
|
|
56
56
|
}
|
|
@@ -65,9 +65,9 @@ import { readdirWithTypes } from '../compat.js';
|
|
|
65
65
|
if (!fs.existsSync(versionsPath)) {
|
|
66
66
|
return [];
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for(
|
|
68
|
+
const entries = readdirWithTypes(versionsPath);
|
|
69
|
+
const versions = [];
|
|
70
|
+
for(let i = 0; i < entries.length; i++){
|
|
71
71
|
if (entries[i].isDirectory()) {
|
|
72
72
|
versions.push(entries[i].name);
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/findInstalledVersions.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\n\n/**\n * Compare two semver version strings (e.g., \"20.19.0\" vs \"20.9.1\")\n * Returns: negative if a < b, positive if a > b, 0 if equal\n */\nfunction compareVersions(a: string, b: string): number {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/findInstalledVersions.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\n\n/**\n * Compare two semver version strings (e.g., \"20.19.0\" vs \"20.9.1\")\n * Returns: negative if a < b, positive if a > b, 0 if equal\n */\nfunction compareVersions(a: string, b: string): number {\n const aParts = a.replace(/^v/, '').split('.');\n const bParts = b.replace(/^v/, '').split('.');\n const len = Math.max(aParts.length, bParts.length);\n\n for (let i = 0; i < len; i++) {\n const aNum = parseInt(aParts[i], 10) || 0;\n const bNum = parseInt(bParts[i], 10) || 0;\n if (aNum !== bNum) {\n return aNum - bNum;\n }\n }\n return 0;\n}\n\n/**\n * Find all installed versions matching the given version string\n * Results are sorted in ascending semver order (lowest first, highest last)\n */\nexport function findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n const normalizedVersion = version.replace(/^v/, '');\n const matches: string[] = [];\n\n // Try exact matches first\n const exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (let i = 0; i < exactMatches.length; i++) {\n const v = exactMatches[i];\n const versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n const entries = readdirWithTypes(versionsPath);\n for (let j = 0; j < entries.length; j++) {\n const entry = entries[j];\n if (!entry.isDirectory()) continue;\n const dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n // Sort by semver (ascending) so highest version is last\n matches.sort(compareVersions);\n\n return matches;\n}\n\n/**\n * Get all installed versions\n */\nexport function getAllInstalledVersions(versionsPath: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n const entries = readdirWithTypes(versionsPath);\n const versions: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n return versions;\n}\n"],"names":["fs","path","readdirWithTypes","compareVersions","a","b","aParts","replace","split","bParts","len","Math","max","length","i","aNum","parseInt","bNum","findInstalledVersions","versionsPath","version","existsSync","normalizedVersion","matches","exactMatches","v","versionPath","join","statSync","isDirectory","indexOf","push","entries","j","entry","dirVersion","name","sort","getAllInstalledVersions","versions"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAEhD;;;CAGC,GACD,SAASC,gBAAgBC,CAAS,EAAEC,CAAS;IAC3C,MAAMC,SAASF,EAAEG,OAAO,CAAC,MAAM,IAAIC,KAAK,CAAC;IACzC,MAAMC,SAASJ,EAAEE,OAAO,CAAC,MAAM,IAAIC,KAAK,CAAC;IACzC,MAAME,MAAMC,KAAKC,GAAG,CAACN,OAAOO,MAAM,EAAEJ,OAAOI,MAAM;IAEjD,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,KAAKI,IAAK;QAC5B,MAAMC,OAAOC,SAASV,MAAM,CAACQ,EAAE,EAAE,OAAO;QACxC,MAAMG,OAAOD,SAASP,MAAM,CAACK,EAAE,EAAE,OAAO;QACxC,IAAIC,SAASE,MAAM;YACjB,OAAOF,OAAOE;QAChB;IACF;IACA,OAAO;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,sBAAsBC,YAAoB,EAAEC,OAAe;IACzE,IAAI,CAACpB,GAAGqB,UAAU,CAACF,eAAe;QAChC,OAAO,EAAE;IACX;IAEA,MAAMG,oBAAoBF,QAAQb,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ACvC,IAAIkB,OAAO,CAAClB,EAAE,CAACe,WAAW,IAAI;YAC5BU,SAASR,IAAI,CAACC,OAAO,CAAClB,EAAE,CAACsB,IAAI;QAC/B;IACF;IAEA,OAAOG;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-version-use",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -34,48 +34,48 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"bin",
|
|
36
36
|
"dist",
|
|
37
|
-
"
|
|
37
|
+
"assets"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsds build",
|
|
41
|
+
"build:assets": "tsds build && mkdir -p assets && cp -R dist/cjs/assets/*.cjs assets/",
|
|
41
42
|
"clean": "rm -rf .tmp dist",
|
|
42
43
|
"format": "tsds format",
|
|
43
|
-
"postinstall": "node
|
|
44
|
+
"postinstall": "node assets/postinstall.cjs",
|
|
44
45
|
"prepublishOnly": "tsds validate",
|
|
45
|
-
"pretest": "node scripts/ensure-test-binaries.ts",
|
|
46
46
|
"test": "tsds test:node --no-timeouts",
|
|
47
47
|
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
48
48
|
"version": "tsds version"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"cross-spawn-cb": "^2.4.
|
|
52
|
-
"exit-compat": "^1.0.
|
|
53
|
-
"fs-remove-compat": "^0.2.
|
|
51
|
+
"cross-spawn-cb": "^2.4.14",
|
|
52
|
+
"exit-compat": "^1.0.3",
|
|
53
|
+
"fs-remove-compat": "^0.2.3",
|
|
54
54
|
"getopts-compat": "^2.2.6",
|
|
55
55
|
"homedir-polyfill": "^1.0.3",
|
|
56
|
-
"install-module-linked": "^1.3.
|
|
56
|
+
"install-module-linked": "^1.3.16",
|
|
57
57
|
"mkdirp-classic": "^0.5.3",
|
|
58
58
|
"node-resolve-versions": "^1.3.11",
|
|
59
|
-
"node-version-utils": "^1.3.
|
|
60
|
-
"queue-cb": "^1.6.
|
|
61
|
-
"resolve-bin-sync": "^1.0.
|
|
62
|
-
"spawn-streaming": "^1.1.
|
|
63
|
-
"spawn-term": "^3.3.
|
|
59
|
+
"node-version-utils": "^1.3.17",
|
|
60
|
+
"queue-cb": "^1.6.3",
|
|
61
|
+
"resolve-bin-sync": "^1.0.12",
|
|
62
|
+
"spawn-streaming": "^1.1.15",
|
|
63
|
+
"spawn-term": "^3.3.5"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/mocha": "^10.0.10",
|
|
67
67
|
"@types/node": "^25.0.1",
|
|
68
68
|
"cr": "^0.1.0",
|
|
69
|
-
"fs-copy-compat": "^0.1.
|
|
70
|
-
"fs-remove-compat": "^0.2.
|
|
71
|
-
"is-version": "^1.0.
|
|
69
|
+
"fs-copy-compat": "^0.1.5",
|
|
70
|
+
"fs-remove-compat": "^0.2.3",
|
|
71
|
+
"is-version": "^1.0.9",
|
|
72
72
|
"mkdirp-classic": "^0.5.3",
|
|
73
|
-
"node-version-install": "^1.5.
|
|
74
|
-
"node-version-use": "^2.1.
|
|
73
|
+
"node-version-install": "^1.5.2",
|
|
74
|
+
"node-version-use": "^2.1.5",
|
|
75
75
|
"os-shim": "^0.1.3",
|
|
76
76
|
"pinkie-promise": "^2.0.1",
|
|
77
77
|
"ts-dev-stack": "^1.21.3",
|
|
78
|
-
"tsds-config": "^0.2.
|
|
78
|
+
"tsds-config": "^0.2.1"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=0.8"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/scripts/postinstall.ts"],"sourcesContent":["/**\n * Postinstall script for node-version-use\n *\n * Downloads the platform-specific binary and installs it to ~/.nvu/bin/\n * This enables transparent Node version switching.\n *\n * Uses safe atomic download pattern:\n * 1. Download to temp file\n * 2. Extract to temp directory\n * 3. Atomic rename to final location\n */\n\nimport { spawn } from 'child_process';\nimport exit from 'exit-compat';\nimport fs from 'fs';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport os from 'os';\nimport path from 'path';\nimport url from 'url';\nimport { homedir } from '../compat.ts';\n\n// CJS/ESM compatibility\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Configuration\nconst GITHUB_REPO = 'kmalakoff/node-version-use';\n// Path is relative to dist/cjs/scripts/ at runtime\nconst BINARY_VERSION = _require(path.join(__dirname, '..', '..', '..', 'package.json')).binaryVersion;\n\ntype Callback = (err?: Error | null) => void;\n\ninterface PlatformMap {\n [key: string]: string;\n}\n\n/**\n * Get the platform-specific archive base name (without extension)\n */\nfunction getArchiveBaseName(): string | null {\n const platform = os.platform();\n const arch = os.arch();\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) {\n return null;\n }\n\n return `nvu-binary-${platformName}-${archName}`;\n}\n\n/**\n * Get the extracted binary name (includes .exe on Windows)\n */\nfunction getExtractedBinaryName(archiveBaseName: string): string {\n const ext = os.platform() === 'win32' ? '.exe' : '';\n return archiveBaseName + ext;\n}\n\n/**\n * Get the download URL for the binary archive\n */\nfunction getDownloadUrl(archiveBaseName: string): string {\n const ext = os.platform() === 'win32' ? '.zip' : '.tar.gz';\n return `https://github.com/${GITHUB_REPO}/releases/download/binary-v${BINARY_VERSION}/${archiveBaseName}${ext}`;\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 * Atomic rename with fallback to copy+delete for cross-device moves\n */\nfunction atomicRename(src: string, dest: string, callback: Callback): void {\n fs.rename(src, dest, (err) => {\n if (!err) {\n callback(null);\n return;\n }\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 * Remove directory recursively\n */\nfunction rmRecursive(dir: string): void {\n if (!fs.existsSync(dir)) return;\n\n const files = fs.readdirSync(dir);\n for (let i = 0; i < files.length; i++) {\n const filePath = path.join(dir, files[i]);\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n rmRecursive(filePath);\n } else {\n fs.unlinkSync(filePath);\n }\n }\n fs.rmdirSync(dir);\n}\n\n/**\n * Get temp directory\n */\nfunction getTmpDir(): string {\n return typeof os.tmpdir === 'function' ? os.tmpdir() : process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp';\n}\n\n/**\n * Download using curl (macOS, Linux, Windows 10+)\n */\nfunction downloadWithCurl(downloadUrl: string, destPath: string, callback: Callback): void {\n const curl = spawn('curl', ['-L', '-f', '-s', '-o', destPath, downloadUrl]);\n\n curl.on('close', (code) => {\n if (code !== 0) {\n // curl exit codes: 22 = HTTP error (4xx/5xx), 56 = receive error (often 404 with -f)\n if (code === 22 || code === 56) {\n callback(new Error('HTTP 404'));\n } else {\n callback(new Error(`curl failed with exit code ${code}`));\n }\n return;\n }\n callback(null);\n });\n\n curl.on('error', (err) => {\n callback(err);\n });\n}\n\n/**\n * Download using PowerShell (Windows 7+ fallback)\n */\nfunction downloadWithPowerShell(downloadUrl: string, destPath: string, callback: Callback): void {\n const psCommand = `Invoke-WebRequest -Uri \"${downloadUrl}\" -OutFile \"${destPath}\" -UseBasicParsing`;\n const ps = spawn('powershell', ['-NoProfile', '-Command', psCommand]);\n\n ps.on('close', (code) => {\n if (code !== 0) {\n callback(new Error(`PowerShell download failed with exit code ${code}`));\n return;\n }\n callback(null);\n });\n\n ps.on('error', (err) => {\n callback(err);\n });\n}\n\n/**\n * Download a file - tries curl first, falls back to PowerShell on Windows\n * Node 0.8's OpenSSL doesn't support TLS 1.2+ required by GitHub\n */\nfunction downloadFile(downloadUrl: string, destPath: string, callback: Callback): void {\n downloadWithCurl(downloadUrl, destPath, (err) => {\n if (!err) {\n callback(null);\n return;\n }\n\n // If curl failed and we're on Windows, try PowerShell\n if (os.platform() === 'win32' && err?.message?.indexOf('ENOENT') >= 0) {\n downloadWithPowerShell(downloadUrl, destPath, callback);\n return;\n }\n\n callback(err);\n });\n}\n\n/**\n * Extract archive to a directory (callback-based)\n */\nfunction extractArchive(archivePath: string, destDir: string, callback: Callback): void {\n const platform = os.platform();\n\n if (platform === 'win32') {\n // Windows: extract zip using PowerShell\n const ps = spawn('powershell', ['-Command', `Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force`]);\n ps.on('close', (code) => {\n if (code !== 0) {\n callback(new Error('Failed to extract archive'));\n return;\n }\n callback(null);\n });\n } else {\n // Unix: extract tar.gz\n const tar = spawn('tar', ['-xzf', archivePath, '-C', destDir]);\n tar.on('close', (code) => {\n if (code !== 0) {\n callback(new Error('Failed to extract archive'));\n return;\n }\n callback(null);\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): void {\n const platform = os.platform();\n const isWindows = platform === 'win32';\n const ext = isWindows ? '.exe' : '';\n\n // Create temp extraction directory\n const tempExtractDir = path.join(getTmpDir(), `nvu-extract-${Date.now()}`);\n mkdirp.sync(tempExtractDir);\n\n extractArchive(archivePath, tempExtractDir, (extractErr) => {\n if (extractErr) {\n rmRecursive(tempExtractDir);\n callback(extractErr);\n return;\n }\n\n const extractedPath = path.join(tempExtractDir, binaryName);\n if (!fs.existsSync(extractedPath)) {\n rmRecursive(tempExtractDir);\n callback(new Error(`Extracted binary not found: ${binaryName}`));\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) {\n fs.chmodSync(tempDest, 0o755);\n }\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 if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n }\n rmRecursive(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 rmRecursive(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 // Remove existing file if present (for atomic replacement)\n if (fs.existsSync(finalDest)) {\n try {\n fs.unlinkSync(finalDest);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\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 */\nfunction printInstructions(installed: boolean): void {\n const homedirPath = homedir();\n const nvuBinPath = path.join(homedirPath, '.nvu', 'bin');\n const platform = os.platform();\n\n console.log('');\n console.log('============================================================');\n if (installed) {\n console.log(' nvu binaries installed to ~/.nvu/bin/');\n } else {\n console.log(' nvu installed (binaries not yet available)');\n }\n console.log('============================================================');\n console.log('');\n console.log('To enable transparent Node version switching, add to your shell profile:');\n console.log('');\n\n if (platform === 'win32') {\n console.log(' PowerShell (add to $PROFILE):');\n console.log(` $env:PATH = \"${nvuBinPath};$env:PATH\"`);\n console.log('');\n console.log(' CMD (run as administrator):');\n console.log(` setx PATH \"${nvuBinPath};%PATH%\"`);\n } else {\n console.log(' # For bash (~/.bashrc):');\n console.log(' export PATH=\"$HOME/.nvu/bin:$PATH\"');\n console.log('');\n console.log(' # For zsh (~/.zshrc):');\n console.log(' export PATH=\"$HOME/.nvu/bin:$PATH\"');\n console.log('');\n console.log(' # For fish (~/.config/fish/config.fish):');\n console.log(' set -gx PATH $HOME/.nvu/bin $PATH');\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 */\nfunction main(): void {\n const archiveBaseName = getArchiveBaseName();\n\n if (!archiveBaseName) {\n console.log('postinstall: Unsupported platform/architecture for binary.');\n console.log(`Platform: ${os.platform()}, Arch: ${os.arch()}`);\n console.log('Binary not installed. You can still use nvu with explicit versions: nvu 18 npm test');\n exit(0);\n return;\n }\n\n const extractedBinaryName = getExtractedBinaryName(archiveBaseName);\n\n const homedirPath = homedir();\n const nvuDir = path.join(homedirPath, '.nvu');\n const binDir = path.join(nvuDir, 'bin');\n\n // Create directories\n mkdirp.sync(nvuDir);\n mkdirp.sync(binDir);\n\n const downloadUrl = getDownloadUrl(archiveBaseName);\n const ext = os.platform() === 'win32' ? '.zip' : '.tar.gz';\n const tempPath = path.join(getTmpDir(), `nvu-binary-${Date.now()}${ext}`);\n\n console.log(`postinstall: Downloading binary for ${os.platform()}-${os.arch()}...`);\n\n downloadFile(downloadUrl, tempPath, (downloadErr) => {\n if (downloadErr) {\n // Clean up temp file if it exists\n if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n\n if (downloadErr.message?.indexOf('404') >= 0) {\n console.log('postinstall: Binaries not yet published to GitHub releases.');\n console.log('');\n console.log('To build and install binaries locally:');\n console.log(' cd node_modules/node-version-use/binary');\n console.log(' make install');\n console.log('');\n console.log('Or wait for the next release which will include pre-built binaries.');\n } else {\n console.log(`postinstall warning: Failed to install binary: ${downloadErr.message || downloadErr}`);\n console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n console.log('To install binaries manually: cd node_modules/node-version-use/binary && make install');\n }\n printInstructions(false);\n exit(0);\n return;\n }\n\n console.log('postinstall: Extracting binary...');\n\n extractAndInstall(tempPath, binDir, extractedBinaryName, (extractErr) => {\n // Clean up temp file\n if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n\n if (extractErr) {\n console.log(`postinstall warning: Failed to extract binary: ${extractErr.message || extractErr}`);\n console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n printInstructions(false);\n exit(0);\n return;\n }\n\n console.log('postinstall: Binary installed successfully!');\n printInstructions(true);\n exit(0);\n });\n });\n}\n\nmain();\n"],"names":["_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","GITHUB_REPO","BINARY_VERSION","join","binaryVersion","getArchiveBaseName","platform","os","arch","platformMap","darwin","linux","win32","archMap","x64","arm64","amd64","platformName","archName","getExtractedBinaryName","archiveBaseName","ext","getDownloadUrl","copyFileSync","src","dest","content","fs","readFileSync","writeFileSync","atomicRename","callback","rename","err","code","unlinkSync","copyErr","rmRecursive","dir","existsSync","files","readdirSync","i","length","filePath","stat","statSync","isDirectory","rmdirSync","getTmpDir","tmpdir","process","env","TMPDIR","TMP","TEMP","downloadWithCurl","downloadUrl","destPath","curl","spawn","on","Error","downloadWithPowerShell","psCommand","ps","downloadFile","message","indexOf","extractArchive","archivePath","destDir","tar","extractAndInstall","binaryName","isWindows","tempExtractDir","Date","now","mkdirp","sync","extractErr","extractedPath","binaries","timestamp","installError","name","tempDest","chmodSync","j","tempPath","_e","renameError","doRename","index","finalDest","printInstructions","installed","homedirPath","homedir","nvuBinPath","console","log","main","exit","extractedBinaryName","nvuDir","binDir","downloadErr"],"mappings":"AAAA;;;;;;;;;;CAUC;;;;6BAEqB;iEACL;yDACF;oEACI;6DACA;yDACJ;2DACE;0DACD;wBACQ;;;;;;AAExB,wBAAwB;AACxB,IAAMA,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,gBAAgB;AAChB,IAAMC,cAAc;AACpB,mDAAmD;AACnD,IAAMC,iBAAiBX,SAASK,aAAI,CAACO,IAAI,CAACR,WAAW,MAAM,MAAM,MAAM,iBAAiBS,aAAa;AAQrG;;CAEC,GACD,SAASC;IACP,IAAMC,WAAWC,WAAE,CAACD,QAAQ;IAC5B,IAAME,OAAOD,WAAE,CAACC,IAAI;IAEpB,IAAMC,cAA2B;QAC/BC,QAAQ;QACRC,OAAO;QACPC,OAAO;IACT;IAEA,IAAMC,UAAuB;QAC3BC,KAAK;QACLC,OAAO;QACPC,OAAO;IACT;IAEA,IAAMC,eAAeR,WAAW,CAACH,SAAS;IAC1C,IAAMY,WAAWL,OAAO,CAACL,KAAK;IAE9B,IAAI,CAACS,gBAAgB,CAACC,UAAU;QAC9B,OAAO;IACT;IAEA,OAAO,AAAC,cAA6BA,OAAhBD,cAAa,KAAY,OAATC;AACvC;AAEA;;CAEC,GACD,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Y;gBACdoB,QAAQC,GAAG,CAAC,AAAC,kDAAkF,OAAjCrB,WAAWd,OAAO,IAAIc;gBACpFoB,QAAQC,GAAG,CAAC;gBACZN,kBAAkB;gBAClBQ,IAAAA,mBAAI,EAAC;gBACL;YACF;YAEAH,QAAQC,GAAG,CAAC;YACZN,kBAAkB;YAClBQ,IAAAA,mBAAI,EAAC;QACP;IACF;AACF;AAEAD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Postinstall script for node-version-use
|
|
3
|
-
*
|
|
4
|
-
* Downloads the platform-specific binary and installs it to ~/.nvu/bin/
|
|
5
|
-
* This enables transparent Node version switching.
|
|
6
|
-
*
|
|
7
|
-
* Uses safe atomic download pattern:
|
|
8
|
-
* 1. Download to temp file
|
|
9
|
-
* 2. Extract to temp directory
|
|
10
|
-
* 3. Atomic rename to final location
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/scripts/postinstall.ts"],"sourcesContent":["/**\n * Postinstall script for node-version-use\n *\n * Downloads the platform-specific binary and installs it to ~/.nvu/bin/\n * This enables transparent Node version switching.\n *\n * Uses safe atomic download pattern:\n * 1. Download to temp file\n * 2. Extract to temp directory\n * 3. Atomic rename to final location\n */\n\nimport { spawn } from 'child_process';\nimport exit from 'exit-compat';\nimport fs from 'fs';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport os from 'os';\nimport path from 'path';\nimport url from 'url';\nimport { homedir } from '../compat.ts';\n\n// CJS/ESM compatibility\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Configuration\nconst GITHUB_REPO = 'kmalakoff/node-version-use';\n// Path is relative to dist/cjs/scripts/ at runtime\nconst BINARY_VERSION = _require(path.join(__dirname, '..', '..', '..', 'package.json')).binaryVersion;\n\ntype Callback = (err?: Error | null) => void;\n\ninterface PlatformMap {\n [key: string]: string;\n}\n\n/**\n * Get the platform-specific archive base name (without extension)\n */\nfunction getArchiveBaseName(): string | null {\n const platform = os.platform();\n const arch = os.arch();\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) {\n return null;\n }\n\n return `nvu-binary-${platformName}-${archName}`;\n}\n\n/**\n * Get the extracted binary name (includes .exe on Windows)\n */\nfunction getExtractedBinaryName(archiveBaseName: string): string {\n const ext = os.platform() === 'win32' ? '.exe' : '';\n return archiveBaseName + ext;\n}\n\n/**\n * Get the download URL for the binary archive\n */\nfunction getDownloadUrl(archiveBaseName: string): string {\n const ext = os.platform() === 'win32' ? '.zip' : '.tar.gz';\n return `https://github.com/${GITHUB_REPO}/releases/download/binary-v${BINARY_VERSION}/${archiveBaseName}${ext}`;\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 * Atomic rename with fallback to copy+delete for cross-device moves\n */\nfunction atomicRename(src: string, dest: string, callback: Callback): void {\n fs.rename(src, dest, (err) => {\n if (!err) {\n callback(null);\n return;\n }\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 * Remove directory recursively\n */\nfunction rmRecursive(dir: string): void {\n if (!fs.existsSync(dir)) return;\n\n const files = fs.readdirSync(dir);\n for (let i = 0; i < files.length; i++) {\n const filePath = path.join(dir, files[i]);\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n rmRecursive(filePath);\n } else {\n fs.unlinkSync(filePath);\n }\n }\n fs.rmdirSync(dir);\n}\n\n/**\n * Get temp directory\n */\nfunction getTmpDir(): string {\n return typeof os.tmpdir === 'function' ? os.tmpdir() : process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp';\n}\n\n/**\n * Download using curl (macOS, Linux, Windows 10+)\n */\nfunction downloadWithCurl(downloadUrl: string, destPath: string, callback: Callback): void {\n const curl = spawn('curl', ['-L', '-f', '-s', '-o', destPath, downloadUrl]);\n\n curl.on('close', (code) => {\n if (code !== 0) {\n // curl exit codes: 22 = HTTP error (4xx/5xx), 56 = receive error (often 404 with -f)\n if (code === 22 || code === 56) {\n callback(new Error('HTTP 404'));\n } else {\n callback(new Error(`curl failed with exit code ${code}`));\n }\n return;\n }\n callback(null);\n });\n\n curl.on('error', (err) => {\n callback(err);\n });\n}\n\n/**\n * Download using PowerShell (Windows 7+ fallback)\n */\nfunction downloadWithPowerShell(downloadUrl: string, destPath: string, callback: Callback): void {\n const psCommand = `Invoke-WebRequest -Uri \"${downloadUrl}\" -OutFile \"${destPath}\" -UseBasicParsing`;\n const ps = spawn('powershell', ['-NoProfile', '-Command', psCommand]);\n\n ps.on('close', (code) => {\n if (code !== 0) {\n callback(new Error(`PowerShell download failed with exit code ${code}`));\n return;\n }\n callback(null);\n });\n\n ps.on('error', (err) => {\n callback(err);\n });\n}\n\n/**\n * Download a file - tries curl first, falls back to PowerShell on Windows\n * Node 0.8's OpenSSL doesn't support TLS 1.2+ required by GitHub\n */\nfunction downloadFile(downloadUrl: string, destPath: string, callback: Callback): void {\n downloadWithCurl(downloadUrl, destPath, (err) => {\n if (!err) {\n callback(null);\n return;\n }\n\n // If curl failed and we're on Windows, try PowerShell\n if (os.platform() === 'win32' && err?.message?.indexOf('ENOENT') >= 0) {\n downloadWithPowerShell(downloadUrl, destPath, callback);\n return;\n }\n\n callback(err);\n });\n}\n\n/**\n * Extract archive to a directory (callback-based)\n */\nfunction extractArchive(archivePath: string, destDir: string, callback: Callback): void {\n const platform = os.platform();\n\n if (platform === 'win32') {\n // Windows: extract zip using PowerShell\n const ps = spawn('powershell', ['-Command', `Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force`]);\n ps.on('close', (code) => {\n if (code !== 0) {\n callback(new Error('Failed to extract archive'));\n return;\n }\n callback(null);\n });\n } else {\n // Unix: extract tar.gz\n const tar = spawn('tar', ['-xzf', archivePath, '-C', destDir]);\n tar.on('close', (code) => {\n if (code !== 0) {\n callback(new Error('Failed to extract archive'));\n return;\n }\n callback(null);\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): void {\n const platform = os.platform();\n const isWindows = platform === 'win32';\n const ext = isWindows ? '.exe' : '';\n\n // Create temp extraction directory\n const tempExtractDir = path.join(getTmpDir(), `nvu-extract-${Date.now()}`);\n mkdirp.sync(tempExtractDir);\n\n extractArchive(archivePath, tempExtractDir, (extractErr) => {\n if (extractErr) {\n rmRecursive(tempExtractDir);\n callback(extractErr);\n return;\n }\n\n const extractedPath = path.join(tempExtractDir, binaryName);\n if (!fs.existsSync(extractedPath)) {\n rmRecursive(tempExtractDir);\n callback(new Error(`Extracted binary not found: ${binaryName}`));\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) {\n fs.chmodSync(tempDest, 0o755);\n }\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 if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n }\n rmRecursive(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 rmRecursive(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 // Remove existing file if present (for atomic replacement)\n if (fs.existsSync(finalDest)) {\n try {\n fs.unlinkSync(finalDest);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\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 */\nfunction printInstructions(installed: boolean): void {\n const homedirPath = homedir();\n const nvuBinPath = path.join(homedirPath, '.nvu', 'bin');\n const platform = os.platform();\n\n console.log('');\n console.log('============================================================');\n if (installed) {\n console.log(' nvu binaries installed to ~/.nvu/bin/');\n } else {\n console.log(' nvu installed (binaries not yet available)');\n }\n console.log('============================================================');\n console.log('');\n console.log('To enable transparent Node version switching, add to your shell profile:');\n console.log('');\n\n if (platform === 'win32') {\n console.log(' PowerShell (add to $PROFILE):');\n console.log(` $env:PATH = \"${nvuBinPath};$env:PATH\"`);\n console.log('');\n console.log(' CMD (run as administrator):');\n console.log(` setx PATH \"${nvuBinPath};%PATH%\"`);\n } else {\n console.log(' # For bash (~/.bashrc):');\n console.log(' export PATH=\"$HOME/.nvu/bin:$PATH\"');\n console.log('');\n console.log(' # For zsh (~/.zshrc):');\n console.log(' export PATH=\"$HOME/.nvu/bin:$PATH\"');\n console.log('');\n console.log(' # For fish (~/.config/fish/config.fish):');\n console.log(' set -gx PATH $HOME/.nvu/bin $PATH');\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 */\nfunction main(): void {\n const archiveBaseName = getArchiveBaseName();\n\n if (!archiveBaseName) {\n console.log('postinstall: Unsupported platform/architecture for binary.');\n console.log(`Platform: ${os.platform()}, Arch: ${os.arch()}`);\n console.log('Binary not installed. You can still use nvu with explicit versions: nvu 18 npm test');\n exit(0);\n return;\n }\n\n const extractedBinaryName = getExtractedBinaryName(archiveBaseName);\n\n const homedirPath = homedir();\n const nvuDir = path.join(homedirPath, '.nvu');\n const binDir = path.join(nvuDir, 'bin');\n\n // Create directories\n mkdirp.sync(nvuDir);\n mkdirp.sync(binDir);\n\n const downloadUrl = getDownloadUrl(archiveBaseName);\n const ext = os.platform() === 'win32' ? '.zip' : '.tar.gz';\n const tempPath = path.join(getTmpDir(), `nvu-binary-${Date.now()}${ext}`);\n\n console.log(`postinstall: Downloading binary for ${os.platform()}-${os.arch()}...`);\n\n downloadFile(downloadUrl, tempPath, (downloadErr) => {\n if (downloadErr) {\n // Clean up temp file if it exists\n if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n\n if (downloadErr.message?.indexOf('404') >= 0) {\n console.log('postinstall: Binaries not yet published to GitHub releases.');\n console.log('');\n console.log('To build and install binaries locally:');\n console.log(' cd node_modules/node-version-use/binary');\n console.log(' make install');\n console.log('');\n console.log('Or wait for the next release which will include pre-built binaries.');\n } else {\n console.log(`postinstall warning: Failed to install binary: ${downloadErr.message || downloadErr}`);\n console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n console.log('To install binaries manually: cd node_modules/node-version-use/binary && make install');\n }\n printInstructions(false);\n exit(0);\n return;\n }\n\n console.log('postinstall: Extracting binary...');\n\n extractAndInstall(tempPath, binDir, extractedBinaryName, (extractErr) => {\n // Clean up temp file\n if (fs.existsSync(tempPath)) {\n try {\n fs.unlinkSync(tempPath);\n } catch (_e) {\n // ignore cleanup errors\n }\n }\n\n if (extractErr) {\n console.log(`postinstall warning: Failed to extract binary: ${extractErr.message || extractErr}`);\n console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n printInstructions(false);\n exit(0);\n return;\n }\n\n console.log('postinstall: Binary installed successfully!');\n printInstructions(true);\n exit(0);\n });\n });\n}\n\nmain();\n"],"names":["spawn","exit","fs","mkdirp","Module","os","path","url","homedir","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","GITHUB_REPO","BINARY_VERSION","join","binaryVersion","getArchiveBaseName","platform","arch","platformMap","darwin","linux","win32","archMap","x64","arm64","amd64","platformName","archName","getExtractedBinaryName","archiveBaseName","ext","getDownloadUrl","copyFileSync","src","dest","content","readFileSync","writeFileSync","atomicRename","callback","rename","err","code","unlinkSync","copyErr","rmRecursive","dir","existsSync","files","readdirSync","i","length","filePath","stat","statSync","isDirectory","rmdirSync","getTmpDir","tmpdir","process","env","TMPDIR","TMP","TEMP","downloadWithCurl","downloadUrl","destPath","curl","on","Error","downloadWithPowerShell","psCommand","ps","downloadFile","message","indexOf","extractArchive","archivePath","destDir","tar","extractAndInstall","binaryName","isWindows","tempExtractDir","Date","now","sync","extractErr","extractedPath","binaries","timestamp","installError","name","tempDest","chmodSync","j","tempPath","_e","renameError","doRename","index","finalDest","printInstructions","installed","homedirPath","nvuBinPath","console","log","main","extractedBinaryName","nvuDir","binDir","downloadErr"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,SAASA,KAAK,QAAQ,gBAAgB;AACtC,OAAOC,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,YAAY,SAAS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C,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;YACd,OAAO;gBACLD,QAAQC,GAAG,CAAC,CAAC,+CAA+C,EAAEK,YAAYtC,OAAO,IAAIsC,aAAa;gBAClGN,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC;YACd;YACAL,kBAAkB;YAClB1G,KAAK;YACL;QACF;QAEA8G,QAAQC,GAAG,CAAC;QAEZ3B,kBAAkBgB,UAAUe,QAAQF,qBAAqB,CAACtB;YACxD,qBAAqB;YACrB,IAAI1F,GAAGkD,UAAU,CAACiD,WAAW;gBAC3B,IAAI;oBACFnG,GAAG8C,UAAU,CAACqD;gBAChB,EAAE,OAAOC,IAAI;gBACX,wBAAwB;gBAC1B;YACF;YAEA,IAAIV,YAAY;gBACdmB,QAAQC,GAAG,CAAC,CAAC,+CAA+C,EAAEpB,WAAWb,OAAO,IAAIa,YAAY;gBAChGmB,QAAQC,GAAG,CAAC;gBACZL,kBAAkB;gBAClB1G,KAAK;gBACL;YACF;YAEA8G,QAAQC,GAAG,CAAC;YACZL,kBAAkB;YAClB1G,KAAK;QACP;IACF;AACF;AAEAgH"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates that binaries were downloaded by postinstall.
|
|
3
|
-
* Called as pretest hook - fails if binaries are missing.
|
|
4
|
-
*/
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { storagePath } from '../src/constants.ts';
|
|
8
|
-
|
|
9
|
-
var BIN_DIR = path.join(storagePath, 'bin');
|
|
10
|
-
|
|
11
|
-
// Check for platform-specific binary name
|
|
12
|
-
var BINARY_NAME = process.platform === 'win32' ? 'node.exe' : 'node';
|
|
13
|
-
var NODE_BINARY = path.join(BIN_DIR, BINARY_NAME);
|
|
14
|
-
|
|
15
|
-
function main(): void {
|
|
16
|
-
if (!fs.existsSync(NODE_BINARY)) {
|
|
17
|
-
console.error('Error: nvu binaries not found at', BIN_DIR);
|
|
18
|
-
console.error('');
|
|
19
|
-
console.error('Binaries should have been downloaded by postinstall.');
|
|
20
|
-
console.error('Try running: npm install');
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
console.log('Binaries found at', BIN_DIR);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
main();
|
package/scripts/postinstall.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var path = require('path');
|
|
4
|
-
var compiled = path.join(__dirname, '..', 'dist', 'cjs', 'scripts', 'postinstall.js');
|
|
5
|
-
if (fs.existsSync(compiled)) {
|
|
6
|
-
require(compiled);
|
|
7
|
-
} else {
|
|
8
|
-
console.log('postinstall: Skipping (dist/ not built yet - run npm run build)');
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|