node-version-use 1.9.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -23
- package/dist/cjs/cli.js +25 -6
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/default.d.cts +7 -0
- package/dist/cjs/commands/default.d.ts +7 -0
- package/dist/cjs/commands/default.js +57 -0
- package/dist/cjs/commands/default.js.map +1 -0
- package/dist/cjs/commands/index.d.cts +3 -0
- package/dist/cjs/commands/index.d.ts +3 -0
- package/dist/cjs/commands/index.js +54 -0
- package/dist/cjs/commands/index.js.map +1 -0
- package/dist/cjs/commands/install.d.cts +6 -0
- package/dist/cjs/commands/install.d.ts +6 -0
- package/dist/cjs/commands/install.js +69 -0
- package/dist/cjs/commands/install.js.map +1 -0
- package/dist/cjs/commands/list.d.cts +6 -0
- package/dist/cjs/commands/list.d.ts +6 -0
- package/dist/cjs/commands/list.js +93 -0
- package/dist/cjs/commands/list.js.map +1 -0
- package/dist/cjs/commands/local.d.cts +7 -0
- package/dist/cjs/commands/local.d.ts +7 -0
- package/dist/cjs/commands/local.js +69 -0
- package/dist/cjs/commands/local.js.map +1 -0
- package/dist/cjs/commands/setup.d.cts +7 -0
- package/dist/cjs/commands/setup.d.ts +7 -0
- package/dist/cjs/commands/setup.js +55 -0
- package/dist/cjs/commands/setup.js.map +1 -0
- package/dist/cjs/commands/teardown.d.cts +6 -0
- package/dist/cjs/commands/teardown.d.ts +6 -0
- package/dist/cjs/commands/teardown.js +66 -0
- package/dist/cjs/commands/teardown.js.map +1 -0
- package/dist/cjs/commands/uninstall.d.cts +6 -0
- package/dist/cjs/commands/uninstall.d.ts +6 -0
- package/dist/cjs/commands/uninstall.js +148 -0
- package/dist/cjs/commands/uninstall.js.map +1 -0
- package/dist/cjs/commands/which.d.cts +7 -0
- package/dist/cjs/commands/which.d.ts +7 -0
- package/dist/cjs/commands/which.js +117 -0
- package/dist/cjs/commands/which.js.map +1 -0
- package/dist/cjs/compat.d.cts +17 -0
- package/dist/cjs/compat.d.ts +17 -0
- package/dist/cjs/compat.js +47 -1
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/cli.js +23 -4
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/default.d.ts +7 -0
- package/dist/esm/commands/default.js +41 -0
- package/dist/esm/commands/default.js.map +1 -0
- package/dist/esm/commands/index.d.ts +3 -0
- package/dist/esm/commands/index.js +27 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/commands/install.d.ts +6 -0
- package/dist/esm/commands/install.js +53 -0
- package/dist/esm/commands/install.js.map +1 -0
- package/dist/esm/commands/list.d.ts +6 -0
- package/dist/esm/commands/list.js +52 -0
- package/dist/esm/commands/list.js.map +1 -0
- package/dist/esm/commands/local.d.ts +7 -0
- package/dist/esm/commands/local.js +51 -0
- package/dist/esm/commands/local.js.map +1 -0
- package/dist/esm/commands/setup.d.ts +7 -0
- package/dist/esm/commands/setup.js +39 -0
- package/dist/esm/commands/setup.js.map +1 -0
- package/dist/esm/commands/teardown.d.ts +6 -0
- package/dist/esm/commands/teardown.js +33 -0
- package/dist/esm/commands/teardown.js.map +1 -0
- package/dist/esm/commands/uninstall.d.ts +6 -0
- package/dist/esm/commands/uninstall.js +132 -0
- package/dist/esm/commands/uninstall.js.map +1 -0
- package/dist/esm/commands/which.d.ts +7 -0
- package/dist/esm/commands/which.js +101 -0
- package/dist/esm/commands/which.js.map +1 -0
- package/dist/esm/compat.d.ts +17 -0
- package/dist/esm/compat.js +39 -2
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/constants.js +2 -1
- package/dist/esm/constants.js.map +1 -1
- package/package.json +11 -4
- package/scripts/postinstall.cjs +273 -0
- package/shim/Makefile +58 -0
- package/shim/go.mod +3 -0
- package/shim/main.go +302 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import exit from 'exit';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { storagePath } from '../constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* nvu teardown
|
|
7
|
+
*
|
|
8
|
+
* Remove nvu shims from ~/.nvu/bin
|
|
9
|
+
*/ export default function teardownCmd(_args) {
|
|
10
|
+
const binDir = path.join(storagePath, 'bin');
|
|
11
|
+
const shims = [
|
|
12
|
+
'node',
|
|
13
|
+
'npm',
|
|
14
|
+
'npx'
|
|
15
|
+
];
|
|
16
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
17
|
+
let removed = 0;
|
|
18
|
+
for (const shim of shims){
|
|
19
|
+
const shimPath = path.join(binDir, shim + ext);
|
|
20
|
+
if (fs.existsSync(shimPath)) {
|
|
21
|
+
fs.unlinkSync(shimPath);
|
|
22
|
+
removed++;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (removed > 0) {
|
|
26
|
+
console.log(`Removed ${removed} shim(s) from ${binDir}`);
|
|
27
|
+
console.log('');
|
|
28
|
+
console.log('You may also want to remove ~/.nvu/bin from your PATH.');
|
|
29
|
+
} else {
|
|
30
|
+
console.log('No shims found to remove.');
|
|
31
|
+
}
|
|
32
|
+
exit(0);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu shims from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const shims = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (const shim of shims) {\n const shimPath = path.join(binDir, shim + ext);\n if (fs.existsSync(shimPath)) {\n fs.unlinkSync(shimPath);\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} shim(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No shims found to remove.');\n }\n\n exit(0);\n}\n"],"names":["exit","fs","path","storagePath","teardownCmd","_args","binDir","join","shims","ext","process","platform","removed","shim","shimPath","existsSync","unlinkSync","console","log"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,YAAYC,KAAe;IACjD,MAAMC,SAASJ,KAAKK,IAAI,CAACJ,aAAa;IAEtC,MAAMK,QAAQ;QAAC;QAAQ;QAAO;KAAM;IACpC,MAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;IACd,KAAK,MAAMC,QAAQL,MAAO;QACxB,MAAMM,WAAWZ,KAAKK,IAAI,CAACD,QAAQO,OAAOJ;QAC1C,IAAIR,GAAGc,UAAU,CAACD,WAAW;YAC3Bb,GAAGe,UAAU,CAACF;YACdF;QACF;IACF;IAEA,IAAIA,UAAU,GAAG;QACfK,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEN,QAAQ,cAAc,EAAEN,QAAQ;QACvDW,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEAlB,KAAK;AACP"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import exit from 'exit';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { readdirWithTypes, rmSync } from '../compat.js';
|
|
5
|
+
import { storagePath } from '../constants.js';
|
|
6
|
+
/**
|
|
7
|
+
* nvu uninstall <version>
|
|
8
|
+
*
|
|
9
|
+
* Remove an installed Node version.
|
|
10
|
+
*/ export default function uninstallCmd(args) {
|
|
11
|
+
if (args.length === 0) {
|
|
12
|
+
console.log('Usage: nvu uninstall <version>');
|
|
13
|
+
console.log('Example: nvu uninstall 20');
|
|
14
|
+
console.log(' nvu uninstall v20.19.6');
|
|
15
|
+
exit(1);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var version = args[0].trim();
|
|
19
|
+
var versionsPath = path.join(storagePath, 'versions');
|
|
20
|
+
// Find all matching installed versions
|
|
21
|
+
var matches = findInstalledVersions(versionsPath, version);
|
|
22
|
+
if (matches.length === 0) {
|
|
23
|
+
console.log(`Node ${version} is not installed.`);
|
|
24
|
+
console.log('');
|
|
25
|
+
console.log('Installed versions:');
|
|
26
|
+
listInstalledVersions(versionsPath);
|
|
27
|
+
exit(1);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (matches.length > 1) {
|
|
31
|
+
console.log(`Multiple versions match "${version}":`);
|
|
32
|
+
for(var i = 0; i < matches.length; i++){
|
|
33
|
+
console.log(` ${matches[i]}`);
|
|
34
|
+
}
|
|
35
|
+
console.log('');
|
|
36
|
+
console.log('Please specify the exact version to uninstall.');
|
|
37
|
+
exit(1);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var installedVersion = matches[0];
|
|
41
|
+
var versionPath = path.join(versionsPath, installedVersion);
|
|
42
|
+
// Check if this is the current default
|
|
43
|
+
var defaultPath = path.join(storagePath, 'default');
|
|
44
|
+
var isDefault = false;
|
|
45
|
+
if (fs.existsSync(defaultPath)) {
|
|
46
|
+
var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();
|
|
47
|
+
var normalizedDefault = defaultVersion.replace(/^v/, '');
|
|
48
|
+
var normalizedInstalled = installedVersion.replace(/^v/, '');
|
|
49
|
+
// Check if default matches this version
|
|
50
|
+
if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {
|
|
51
|
+
isDefault = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Remove the version directory
|
|
55
|
+
try {
|
|
56
|
+
rmSync(versionPath);
|
|
57
|
+
console.log(`Removed Node ${installedVersion}`);
|
|
58
|
+
if (isDefault) {
|
|
59
|
+
// Clear the default since it's no longer installed
|
|
60
|
+
fs.unlinkSync(defaultPath);
|
|
61
|
+
console.log('');
|
|
62
|
+
console.log('Note: This was your default version. Set a new default with:');
|
|
63
|
+
console.log(' nvu default <version>');
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.error(`Failed to remove Node ${installedVersion}:`, err.message);
|
|
67
|
+
exit(1);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
exit(0);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Find all installed versions matching the given version string
|
|
74
|
+
*/ function findInstalledVersions(versionsPath, version) {
|
|
75
|
+
if (!fs.existsSync(versionsPath)) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
var normalizedVersion = version.replace(/^v/, '');
|
|
79
|
+
var matches = [];
|
|
80
|
+
// Try exact matches first
|
|
81
|
+
var exactMatches = [
|
|
82
|
+
version,
|
|
83
|
+
`v${normalizedVersion}`,
|
|
84
|
+
normalizedVersion
|
|
85
|
+
];
|
|
86
|
+
for(var i = 0; i < exactMatches.length; i++){
|
|
87
|
+
var v = exactMatches[i];
|
|
88
|
+
var versionPath = path.join(versionsPath, v);
|
|
89
|
+
if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {
|
|
90
|
+
if (matches.indexOf(v) === -1) {
|
|
91
|
+
matches.push(v);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// If we have an exact match, return just that
|
|
96
|
+
if (matches.length > 0) {
|
|
97
|
+
return matches;
|
|
98
|
+
}
|
|
99
|
+
// Try partial match (e.g., "20" matches "v20.19.6")
|
|
100
|
+
var entries = readdirWithTypes(versionsPath);
|
|
101
|
+
for(var j = 0; j < entries.length; j++){
|
|
102
|
+
var entry = entries[j];
|
|
103
|
+
if (!entry.isDirectory()) continue;
|
|
104
|
+
var dirVersion = entry.name.replace(/^v/, '');
|
|
105
|
+
if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {
|
|
106
|
+
matches.push(entry.name);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return matches;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* List installed versions for user reference
|
|
113
|
+
*/ function listInstalledVersions(versionsPath) {
|
|
114
|
+
if (!fs.existsSync(versionsPath)) {
|
|
115
|
+
console.log(' (none)');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var entries = readdirWithTypes(versionsPath);
|
|
119
|
+
var versions = [];
|
|
120
|
+
for(var i = 0; i < entries.length; i++){
|
|
121
|
+
if (entries[i].isDirectory()) {
|
|
122
|
+
versions.push(entries[i].name);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (versions.length === 0) {
|
|
126
|
+
console.log(' (none)');
|
|
127
|
+
} else {
|
|
128
|
+
for(var j = 0; j < versions.length; j++){
|
|
129
|
+
console.log(` ${versions[j]}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'versions');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var 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 var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["exit","fs","path","readdirWithTypes","rmSync","storagePath","uninstallCmd","args","length","console","log","version","trim","versionsPath","join","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","j","entry","dirVersion","name","versions"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,EAAEC,MAAM,QAAQ,eAAe;AACxD,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZV,KAAK;QACL;IACF;IAEA,IAAIW,UAAUJ,IAAI,CAAC,EAAE,CAACK,IAAI;IAC1B,IAAIC,eAAeX,KAAKY,IAAI,CAACT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AC1C,IAAIgB,WAAWd,OAAO,CAAC,GAAGK,kBAAkB,CAAC,CAAC,MAAM,GAAG;YACrDnB,QAAQwB,IAAI,CAACG,MAAME,IAAI;QACzB;IACF;IAEA,OAAO7B;AACT;AAEA;;CAEC,GACD,SAASE,sBAAsBJ,YAAoB;IACjD,IAAI,CAACZ,GAAGsB,UAAU,CAACV,eAAe;QAChCJ,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAI8B,UAAUrC,iBAAiBU;IAC/B,IAAIgC,WAAqB,EAAE;IAC3B,IAAK,IAAI3B,IAAI,GAAGA,IAAIsB,QAAQhC,MAAM,EAAEU,IAAK;QACvC,IAAIsB,OAAO,CAACtB,EAAE,CAACoB,WAAW,IAAI;YAC5BO,SAASN,IAAI,CAACC,OAAO,CAACtB,EAAE,CAAC0B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAASrC,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAI+B,IAAI,GAAGA,IAAII,SAASrC,MAAM,EAAEiC,IAAK;YACxChC,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAEmC,QAAQ,CAACJ,EAAE,EAAE;QAChC;IACF;AACF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import exit from 'exit';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { storagePath } from '../constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* nvu which
|
|
7
|
+
*
|
|
8
|
+
* Show which Node binary would be used based on current directory.
|
|
9
|
+
* This simulates what the shim would do.
|
|
10
|
+
*/ export default function whichCmd(_args) {
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
// Resolve version using the same logic as the shim
|
|
13
|
+
const version = resolveVersion(cwd);
|
|
14
|
+
if (!version) {
|
|
15
|
+
console.log('No Node version configured for this directory.');
|
|
16
|
+
console.log('');
|
|
17
|
+
console.log('To configure a version:');
|
|
18
|
+
console.log(' nvu local <version> - Set version for this project');
|
|
19
|
+
console.log(' nvu default <version> - Set global default');
|
|
20
|
+
exit(1);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Check if the version is installed
|
|
24
|
+
const versionsPath = path.join(storagePath, 'versions');
|
|
25
|
+
const versionPath = path.join(versionsPath, version);
|
|
26
|
+
const versionPathWithV = path.join(versionsPath, `v${version}`);
|
|
27
|
+
const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));
|
|
28
|
+
let actualVersionPath = '';
|
|
29
|
+
if (fs.existsSync(versionPath)) {
|
|
30
|
+
actualVersionPath = versionPath;
|
|
31
|
+
} else if (fs.existsSync(versionPathWithV)) {
|
|
32
|
+
actualVersionPath = versionPathWithV;
|
|
33
|
+
} else if (fs.existsSync(versionPathWithoutV)) {
|
|
34
|
+
actualVersionPath = versionPathWithoutV;
|
|
35
|
+
}
|
|
36
|
+
console.log(`Version: ${version}`);
|
|
37
|
+
console.log(`Source: ${getVersionSource(cwd)}`);
|
|
38
|
+
if (actualVersionPath) {
|
|
39
|
+
const nodePath = path.join(actualVersionPath, 'bin', 'node');
|
|
40
|
+
console.log(`Binary: ${nodePath}`);
|
|
41
|
+
if (fs.existsSync(nodePath)) {
|
|
42
|
+
console.log('Status: Installed');
|
|
43
|
+
} else {
|
|
44
|
+
console.log('Status: Directory exists but binary not found');
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
console.log(`Status: Not installed (run: nvu install ${version})`);
|
|
48
|
+
}
|
|
49
|
+
exit(0);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve version from config files (mirrors shim logic)
|
|
53
|
+
*/ function resolveVersion(cwd) {
|
|
54
|
+
// Walk up directories looking for .nvurc or .nvmrc
|
|
55
|
+
let dir = cwd;
|
|
56
|
+
while(true){
|
|
57
|
+
// Check .nvurc first
|
|
58
|
+
const nvurcPath = path.join(dir, '.nvurc');
|
|
59
|
+
if (fs.existsSync(nvurcPath)) {
|
|
60
|
+
return fs.readFileSync(nvurcPath, 'utf8').trim();
|
|
61
|
+
}
|
|
62
|
+
// Check .nvmrc
|
|
63
|
+
const nvmrcPath = path.join(dir, '.nvmrc');
|
|
64
|
+
if (fs.existsSync(nvmrcPath)) {
|
|
65
|
+
return fs.readFileSync(nvmrcPath, 'utf8').trim();
|
|
66
|
+
}
|
|
67
|
+
// Move to parent
|
|
68
|
+
const parent = path.dirname(dir);
|
|
69
|
+
if (parent === dir) break;
|
|
70
|
+
dir = parent;
|
|
71
|
+
}
|
|
72
|
+
// Check global default
|
|
73
|
+
const defaultPath = path.join(storagePath, 'default');
|
|
74
|
+
if (fs.existsSync(defaultPath)) {
|
|
75
|
+
return fs.readFileSync(defaultPath, 'utf8').trim();
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Determine the source of the version (for display)
|
|
81
|
+
*/ function getVersionSource(cwd) {
|
|
82
|
+
let dir = cwd;
|
|
83
|
+
while(true){
|
|
84
|
+
const nvurcPath = path.join(dir, '.nvurc');
|
|
85
|
+
if (fs.existsSync(nvurcPath)) {
|
|
86
|
+
return nvurcPath;
|
|
87
|
+
}
|
|
88
|
+
const nvmrcPath = path.join(dir, '.nvmrc');
|
|
89
|
+
if (fs.existsSync(nvmrcPath)) {
|
|
90
|
+
return nvmrcPath;
|
|
91
|
+
}
|
|
92
|
+
const parent = path.dirname(dir);
|
|
93
|
+
if (parent === dir) break;
|
|
94
|
+
dir = parent;
|
|
95
|
+
}
|
|
96
|
+
const defaultPath = path.join(storagePath, 'default');
|
|
97
|
+
if (fs.existsSync(defaultPath)) {
|
|
98
|
+
return `${defaultPath} (global default)`;
|
|
99
|
+
}
|
|
100
|
+
return 'none';
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the shim 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 shim\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 // Check if the version is installed\n const versionsPath = path.join(storagePath, 'versions');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\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 shim 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","whichCmd","_args","cwd","process","version","resolveVersion","console","log","versionsPath","join","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","existsSync","getVersionSource","nodePath","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;;CAKC,GACD,eAAe,SAASC,SAASC,KAAe;IAC9C,MAAMC,MAAMC,QAAQD,GAAG;IAEvB,mDAAmD;IACnD,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;QACZX,KAAK;QACL;IACF;IAEA,oCAAoC;IACpC,MAAMY,eAAeV,KAAKW,IAAI,CAACV,aAAa;IAC5C,MAAMW,cAAcZ,KAAKW,IAAI,CAACD,cAAcJ;IAC5C,MAAMO,mBAAm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BAAiB;QACjB,MAAME,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,uBAAuB;IACvB,MAAME,cAAc3B,KAAKW,IAAI,CAACV,aAAa;IAC3C,IAAIF,GAAGkB,UAAU,CAACU,cAAc;QAC9B,OAAO5B,GAAGuB,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASL,iBAAiBd,GAAW;IACnC,IAAIgB,MAAMhB;IACV,MAAO,KAAM;QACX,MAAMiB,YAAYrB,KAAKW,IAAI,CAACS,KAAK;QACjC,IAAIrB,GAAGkB,UAAU,CAACI,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMG,YAAYxB,KAAKW,IAAI,CAACS,KAAK;QACjC,IAAIrB,GAAGkB,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMC,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,MAAME,cAAc3B,KAAKW,IAAI,CAACV,aAAa;IAC3C,IAAIF,GAAGkB,UAAU,CAACU,cAAc;QAC9B,OAAO,GAAGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
|
package/dist/esm/compat.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
export declare function homedir(): string;
|
|
2
2
|
export declare function stringEndsWith(str: string, search: string, position?: number): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Recursive mkdir for Node.js 0.8+
|
|
5
|
+
*/
|
|
6
|
+
export declare function mkdirpSync(dir: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Recursive rm for Node.js 0.8+
|
|
9
|
+
*/
|
|
10
|
+
export declare function rmSync(dir: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Read directory entries with types for Node.js 0.8+
|
|
13
|
+
* Returns array of {name, isDirectory()}
|
|
14
|
+
*/
|
|
15
|
+
export interface DirEntry {
|
|
16
|
+
name: string;
|
|
17
|
+
isDirectory(): boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function readdirWithTypes(dir: string): DirEntry[];
|
package/dist/esm/compat.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compatibility Layer for Node.js 0.8+
|
|
3
3
|
* Local to this package - contains only needed functions.
|
|
4
|
-
*/ import
|
|
4
|
+
*/ import fs from 'fs';
|
|
5
|
+
import _Module from 'module';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
// Use existing require in CJS, or createRequire in ESM (Node 12.2+)
|
|
9
|
+
var _require = typeof require === 'undefined' ? _Module.createRequire(import.meta.url) : require;
|
|
5
10
|
var hasHomedir = typeof os.homedir === 'function';
|
|
6
11
|
export function homedir() {
|
|
7
12
|
if (hasHomedir) {
|
|
8
13
|
return os.homedir();
|
|
9
14
|
}
|
|
10
|
-
var home =
|
|
15
|
+
var home = _require('homedir-polyfill');
|
|
11
16
|
return home();
|
|
12
17
|
}
|
|
13
18
|
/**
|
|
@@ -22,3 +27,35 @@ export function stringEndsWith(str, search, position) {
|
|
|
22
27
|
var len = position === undefined ? str.length : position;
|
|
23
28
|
return str.lastIndexOf(search) === len - search.length;
|
|
24
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Recursive mkdir for Node.js 0.8+
|
|
32
|
+
*/ export function mkdirpSync(dir) {
|
|
33
|
+
var mkdirp = _require('mkdirp-classic');
|
|
34
|
+
mkdirp.sync(dir);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Recursive rm for Node.js 0.8+
|
|
38
|
+
*/ export function rmSync(dir) {
|
|
39
|
+
var safeRmSync = _require('fs-remove-compat').safeRmSync;
|
|
40
|
+
safeRmSync(dir);
|
|
41
|
+
}
|
|
42
|
+
export function readdirWithTypes(dir) {
|
|
43
|
+
var names = fs.readdirSync(dir);
|
|
44
|
+
return names.map((name)=>{
|
|
45
|
+
var fullPath = path.join(dir, name);
|
|
46
|
+
var stat;
|
|
47
|
+
try {
|
|
48
|
+
stat = fs.statSync(fullPath);
|
|
49
|
+
} catch (_e) {
|
|
50
|
+
// If stat fails, treat as non-directory
|
|
51
|
+
return {
|
|
52
|
+
name: name,
|
|
53
|
+
isDirectory: ()=>false
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
name: name,
|
|
58
|
+
isDirectory: ()=>stat.isDirectory()
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
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 os from 'os';\n\nvar hasHomedir = typeof os.homedir === 'function';\n\nexport function homedir(): string {\n if (hasHomedir) {\n return os.homedir();\n }\n var home =
|
|
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+)\nvar _require = typeof require === 'undefined' ? _Module.createRequire(import.meta.url) : require;\n\nvar hasHomedir = typeof os.homedir === 'function';\n\nexport function homedir(): string {\n if (hasHomedir) {\n return os.homedir();\n }\n var 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 */\nvar 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 var 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 var 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 var 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 var names = fs.readdirSync(dir);\n return names.map((name) => {\n var fullPath = path.join(dir, name);\n var 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,IAAIC,WAAW,OAAOC,YAAY,cAAcJ,QAAQK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAEzF,IAAIG,aAAa,OAAON,GAAGO,OAAO,KAAK;AAEvC,OAAO,SAASA;IACd,IAAID,YAAY;QACd,OAAON,GAAGO,OAAO;IACnB;IACA,IAAIC,OAAON,SAAS;IACpB,OAAOM;AACT;AAEA;;;;CAIC,GACD,IAAIC,cAAc,OAAOC,OAAOC,SAAS,CAACC,QAAQ,KAAK;AAEvD,OAAO,SAASC,eAAeC,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIP,aAAa;QACf,OAAOK,IAAIF,QAAQ,CAACG,QAAQC;IAC9B;IACA,IAAIC,MAAMD,aAAaE,YAAYJ,IAAIK,MAAM,GAAGH;IAChD,OAAOF,IAAIM,WAAW,CAACL,YAAYE,MAAMF,OAAOI,MAAM;AACxD;AAEA;;CAEC,GACD,OAAO,SAASE,WAAWC,GAAW;IACpC,IAAIC,SAASrB,SAAS;IACtBqB,OAAOC,IAAI,CAACF;AACd;AAEA;;CAEC,GACD,OAAO,SAASG,OAAOH,GAAW;IAChC,IAAII,aAAaxB,SAAS,oBAAoBwB,UAAU;IACxDA,WAAWJ;AACb;AAWA,OAAO,SAASK,iBAAiBL,GAAW;IAC1C,IAAIM,QAAQ9B,GAAG+B,WAAW,CAACP;IAC3B,OAAOM,MAAME,GAAG,CAAC,CAACC;QAChB,IAAIC,WAAW/B,KAAKgC,IAAI,CAACX,KAAKS;QAC9B,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"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/constants.ts"],"sourcesContent":["import path from 'path';\nimport { homedir } from './compat.ts';\n\nexport const storagePath = path.join(homedir(), '.nvu') as string;\n"],"names":["path","homedir","storagePath","join"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,SAASC,OAAO,QAAQ,cAAc;AAEtC,OAAO,MAAMC,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/constants.ts"],"sourcesContent":["import path from 'path';\nimport { homedir } from './compat.ts';\n\n// Allow NVU_HOME override for testing\nexport const storagePath = (process.env.NVU_HOME || path.join(homedir(), '.nvu')) as string;\n"],"names":["path","homedir","storagePath","process","env","NVU_HOME","join"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,SAASC,OAAO,QAAQ,cAAc;AAEtC,sCAAsC;AACtC,OAAO,MAAMC,cAAeC,QAAQC,GAAG,CAACC,QAAQ,IAAIL,KAAKM,IAAI,CAACL,WAAW,QAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-version-use",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -32,11 +32,15 @@
|
|
|
32
32
|
"nvu": "bin/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"
|
|
35
|
+
"bin",
|
|
36
|
+
"dist",
|
|
37
|
+
"scripts",
|
|
38
|
+
"shim"
|
|
36
39
|
],
|
|
37
40
|
"scripts": {
|
|
38
41
|
"build": "tsds build",
|
|
39
42
|
"format": "tsds format",
|
|
43
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
40
44
|
"prepublishOnly": "tsds validate",
|
|
41
45
|
"test": "tsds test:node --no-timeouts",
|
|
42
46
|
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
@@ -45,9 +49,12 @@
|
|
|
45
49
|
"dependencies": {
|
|
46
50
|
"cross-spawn-cb": "^2.4.10",
|
|
47
51
|
"exit": "^0.1.2",
|
|
52
|
+
"fs-remove-compat": "^0.2.1",
|
|
53
|
+
"get-remote": "^2.2.8",
|
|
48
54
|
"getopts-compat": "^2.2.6",
|
|
49
55
|
"homedir-polyfill": "^1.0.3",
|
|
50
56
|
"install-module-linked": "^1.3.10",
|
|
57
|
+
"mkdirp-classic": "^0.5.3",
|
|
51
58
|
"node-resolve-versions": "^1.3.11",
|
|
52
59
|
"node-version-utils": "^1.3.15",
|
|
53
60
|
"queue-cb": "^1.6.1",
|
|
@@ -56,14 +63,14 @@
|
|
|
56
63
|
},
|
|
57
64
|
"devDependencies": {
|
|
58
65
|
"@types/mocha": "^10.0.10",
|
|
59
|
-
"@types/node": "^24.10.
|
|
66
|
+
"@types/node": "^24.10.2",
|
|
60
67
|
"cr": "^0.1.0",
|
|
61
68
|
"fs-copy-compat": "^0.1.3",
|
|
62
69
|
"fs-remove-compat": "^0.2.1",
|
|
63
70
|
"is-version": "^1.0.7",
|
|
64
71
|
"mkdirp-classic": "^0.5.3",
|
|
65
72
|
"node-version-install": "^1.4.18",
|
|
66
|
-
"node-version-use": "^1.9.
|
|
73
|
+
"node-version-use": "^1.9.9",
|
|
67
74
|
"pinkie-promise": "^2.0.1",
|
|
68
75
|
"ts-dev-stack": "^1.21.2",
|
|
69
76
|
"tsds-config": "^0.2.0"
|