node-version-use 1.9.9 → 2.1.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 +37 -33
- 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 +77 -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 +52 -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/cjs/worker.js +5 -26
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/cli.js +35 -29
- 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 +53 -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 +36 -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/dist/esm/worker.js +3 -16
- package/dist/esm/worker.js.map +1 -1
- package/package.json +17 -7
- package/scripts/ensure-test-binaries.ts +27 -0
- package/scripts/postinstall.cjs +462 -0
- package/dist/cjs/lib/loadSpawnTerm.d.cts +0 -19
- package/dist/cjs/lib/loadSpawnTerm.d.ts +0 -19
- package/dist/cjs/lib/loadSpawnTerm.js +0 -103
- package/dist/cjs/lib/loadSpawnTerm.js.map +0 -1
- package/dist/esm/lib/loadSpawnTerm.d.ts +0 -19
- package/dist/esm/lib/loadSpawnTerm.js +0 -42
- package/dist/esm/lib/loadSpawnTerm.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,42 +1,140 @@
|
|
|
1
1
|
## node-version-use
|
|
2
2
|
|
|
3
|
-
Cross-platform solution for using multiple versions of
|
|
3
|
+
Cross-platform solution for using multiple versions of Node.js. Useful for compatibility testing and transparent version switching.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Installation
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g node-version-use
|
|
7
9
|
```
|
|
8
|
-
# specific version
|
|
9
|
-
$ nvu 14.4.0 npm run test
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
$ nvu 12 npm run test
|
|
11
|
+
On install, nvu automatically downloads platform-specific binaries to `~/.nvu/bin/`. To enable transparent Node version switching, add to your shell profile:
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
```bash
|
|
14
|
+
# For bash (~/.bashrc) or zsh (~/.zshrc):
|
|
15
|
+
export PATH="$HOME/.nvu/bin:$PATH"
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
|
|
17
|
+
# For fish (~/.config/fish/config.fish):
|
|
18
|
+
set -gx PATH $HOME/.nvu/bin $PATH
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Set a global default Node version
|
|
25
|
+
nvu default 20
|
|
26
|
+
|
|
27
|
+
# Or set a project-specific version (creates .nvmrc)
|
|
28
|
+
nvu local 18
|
|
29
|
+
|
|
30
|
+
# Now 'node' and 'npm' use the configured version automatically
|
|
31
|
+
node --version # v20.x.x (or v18.x.x in project directory)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Commands
|
|
35
|
+
|
|
36
|
+
#### Version Management
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Set global default version
|
|
40
|
+
nvu default 20
|
|
19
41
|
|
|
20
|
-
#
|
|
21
|
-
|
|
42
|
+
# Set local version for current directory (creates .nvmrc)
|
|
43
|
+
nvu local 18
|
|
22
44
|
|
|
23
|
-
#
|
|
24
|
-
|
|
45
|
+
# Install a Node version
|
|
46
|
+
nvu install 22
|
|
47
|
+
|
|
48
|
+
# Uninstall a Node version
|
|
49
|
+
nvu uninstall 22
|
|
50
|
+
|
|
51
|
+
# List installed versions
|
|
52
|
+
nvu list
|
|
53
|
+
|
|
54
|
+
# Show which version would be used
|
|
55
|
+
nvu which
|
|
25
56
|
```
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
#### Binary Management
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Install/reinstall binaries
|
|
62
|
+
nvu setup
|
|
63
|
+
|
|
64
|
+
# Remove binaries
|
|
65
|
+
nvu teardown
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Run Commands with Specific Versions
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Run with a specific version
|
|
72
|
+
nvu 14.4.0 npm run test
|
|
73
|
+
|
|
74
|
+
# Run with highest matching major version
|
|
75
|
+
nvu 12 npm run test
|
|
28
76
|
|
|
77
|
+
# Run with LTS version
|
|
78
|
+
nvu lts npm run test
|
|
79
|
+
|
|
80
|
+
# Run with multiple versions (comma-delimited)
|
|
81
|
+
nvu 0.8,4,8,14 npm run test
|
|
82
|
+
|
|
83
|
+
# Run with version expression
|
|
84
|
+
nvu >=0.8 node --version
|
|
85
|
+
|
|
86
|
+
# Use engines.node from package.json
|
|
87
|
+
nvu engines node --version
|
|
29
88
|
```
|
|
30
|
-
var assert = require('assert');
|
|
31
|
-
var nvu = require('node-version-use');
|
|
32
89
|
|
|
33
|
-
|
|
34
|
-
|
|
90
|
+
### How It Works
|
|
91
|
+
|
|
92
|
+
nvu uses lightweight binaries that intercept `node`, `npm`, and `npx` commands. When you run `node`, the binary:
|
|
93
|
+
|
|
94
|
+
1. Checks for `.nvurc` in current/parent directories
|
|
95
|
+
2. Checks for `.nvmrc` in current/parent directories
|
|
96
|
+
3. Falls back to `~/.nvu/default`
|
|
97
|
+
4. Executes the matching installed Node version
|
|
98
|
+
|
|
99
|
+
This works in all contexts: terminals, IDEs, CI, scripts - without shell integration.
|
|
100
|
+
|
|
101
|
+
### Version Resolution
|
|
102
|
+
|
|
103
|
+
The binary resolves partial versions to installed versions:
|
|
104
|
+
- `20` matches `v20.19.6`
|
|
105
|
+
- `18.19` matches `v18.19.0`
|
|
106
|
+
- `v22` matches `v22.0.0`
|
|
107
|
+
|
|
108
|
+
### JavaScript API
|
|
35
109
|
|
|
36
|
-
|
|
37
|
-
nvu
|
|
110
|
+
```javascript
|
|
111
|
+
const nvu = require('node-version-use');
|
|
112
|
+
|
|
113
|
+
// Run with callback
|
|
114
|
+
nvu('>=0.8', 'node', ['--version'], { versions: '12', stdio: 'inherit' }, (err, results) => {
|
|
115
|
+
// results is an array per-version of form {version, error, result}
|
|
38
116
|
});
|
|
39
117
|
|
|
40
|
-
//
|
|
41
|
-
await nvu('engines',
|
|
118
|
+
// Run with async/await
|
|
119
|
+
const results = await nvu('engines', 'node', ['--version'], { stdio: 'inherit' });
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Uninstalling
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Remove binaries
|
|
126
|
+
nvu teardown
|
|
127
|
+
|
|
128
|
+
# Optionally remove all nvu data
|
|
129
|
+
rm -rf ~/.nvu
|
|
42
130
|
```
|
|
131
|
+
|
|
132
|
+
Then remove the PATH line from your shell profile.
|
|
133
|
+
|
|
134
|
+
### Compatibility
|
|
135
|
+
|
|
136
|
+
- macOS (arm64, x64)
|
|
137
|
+
- Linux (arm64, x64)
|
|
138
|
+
- Windows (arm64, x64)
|
|
139
|
+
|
|
140
|
+
Compatible with `.nvmrc` files from nvm, fnm, and other version managers.
|
package/dist/cjs/cli.js
CHANGED
|
@@ -12,9 +12,10 @@ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
|
|
|
12
12
|
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
13
|
var _getoptscompat = /*#__PURE__*/ _interop_require_default(require("getopts-compat"));
|
|
14
14
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
15
|
+
var _spawnterm = require("spawn-term");
|
|
15
16
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
16
|
-
var _indexts =
|
|
17
|
-
var
|
|
17
|
+
var _indexts = require("./commands/index.js");
|
|
18
|
+
var _indexts1 = /*#__PURE__*/ _interop_require_default(require("./index.js"));
|
|
18
19
|
function _interop_require_default(obj) {
|
|
19
20
|
return obj && obj.__esModule ? obj : {
|
|
20
21
|
default: obj
|
|
@@ -32,9 +33,20 @@ function printHelp(name) {
|
|
|
32
33
|
console.log("".concat(name, " v").concat(version));
|
|
33
34
|
console.log('');
|
|
34
35
|
console.log("Usage: ".concat(name, " [options] <version> <command> [args...]"));
|
|
36
|
+
console.log(" ".concat(name, " <subcommand> [args...]"));
|
|
35
37
|
console.log('');
|
|
36
38
|
console.log('Run commands with specific Node.js versions');
|
|
37
39
|
console.log('');
|
|
40
|
+
console.log('Subcommands:');
|
|
41
|
+
console.log(' default [version] Set or display the global default Node version');
|
|
42
|
+
console.log(' local [version] Set or display the local Node version (.nvmrc)');
|
|
43
|
+
console.log(' install <version> Download and install a Node version');
|
|
44
|
+
console.log(' uninstall <version> Remove an installed Node version');
|
|
45
|
+
console.log(' list List installed Node versions');
|
|
46
|
+
console.log(' which Show which Node version would be used');
|
|
47
|
+
console.log(' setup Install/reinstall binaries to ~/.nvu/bin');
|
|
48
|
+
console.log(' teardown Remove binaries from ~/.nvu/bin');
|
|
49
|
+
console.log('');
|
|
38
50
|
console.log('Options:');
|
|
39
51
|
console.log(' -v, --version Print version number');
|
|
40
52
|
console.log(' -h, --help Print this help message');
|
|
@@ -46,9 +58,11 @@ function printHelp(name) {
|
|
|
46
58
|
console.log(' --silent Suppress logging');
|
|
47
59
|
console.log('');
|
|
48
60
|
console.log('Examples:');
|
|
49
|
-
console.log(" ".concat(name, " 22 node --version"));
|
|
50
|
-
console.log(" ".concat(name, " 22,20,18 npm test"));
|
|
51
|
-
console.log(" ".concat(name, " engines node --version"));
|
|
61
|
+
console.log(" ".concat(name, " 22 node --version Run with Node 22"));
|
|
62
|
+
console.log(" ".concat(name, " 22,20,18 npm test Run with multiple versions"));
|
|
63
|
+
console.log(" ".concat(name, " engines node --version Use version from package.json"));
|
|
64
|
+
console.log(" ".concat(name, " default 20 Set global default to Node 20"));
|
|
65
|
+
console.log(" ".concat(name, " local 18 Create .nvmrc with Node 18"));
|
|
52
66
|
}
|
|
53
67
|
var _default = function(argv, name) {
|
|
54
68
|
var options = (0, _getoptscompat.default)(argv, {
|
|
@@ -86,10 +100,15 @@ var _default = function(argv, name) {
|
|
|
86
100
|
(0, _exit.default)(0);
|
|
87
101
|
return;
|
|
88
102
|
}
|
|
103
|
+
// Check if first argument is a subcommand
|
|
104
|
+
var args = options._;
|
|
105
|
+
if (args.length > 0 && (0, _indexts.isCommand)(args[0])) {
|
|
106
|
+
(0, _indexts.runCommand)(args[0], args.slice(1));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
89
109
|
// define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');
|
|
90
110
|
// define.option('-s, --silent', 'suppress logging', false);
|
|
91
111
|
options.sort = options.desc ? -1 : 1;
|
|
92
|
-
var args = options._;
|
|
93
112
|
if (args.length === 0) {
|
|
94
113
|
console.log("Missing version expression. Example usage: ".concat(name, " version command arg1 arg2"));
|
|
95
114
|
(0, _exit.default)(ERROR_CODE);
|
|
@@ -101,7 +120,7 @@ var _default = function(argv, name) {
|
|
|
101
120
|
return;
|
|
102
121
|
}
|
|
103
122
|
options.stdio = 'inherit'; // pass through stdio
|
|
104
|
-
(0,
|
|
123
|
+
(0, _indexts1.default)(args[0], args[1], args.slice(2), options, function(err, results) {
|
|
105
124
|
if (err && !err.results) {
|
|
106
125
|
console.log(err.message);
|
|
107
126
|
(0, _exit.default)(ERROR_CODE);
|
|
@@ -112,33 +131,18 @@ var _default = function(argv, name) {
|
|
|
112
131
|
return !!result.error;
|
|
113
132
|
});
|
|
114
133
|
if (!options.silent) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}, createSession = _ref.createSession, figures = _ref.figures, formatArguments = _ref.formatArguments;
|
|
127
|
-
if (!createSession) {
|
|
128
|
-
console.log('\n======================');
|
|
129
|
-
results.forEach(function(res) {
|
|
130
|
-
console.log("".concat(res.error ? figures.cross : figures.tick, " ").concat(res.version).concat(res.error ? " Error: ".concat(res.error.message) : ''));
|
|
131
|
-
});
|
|
132
|
-
console.log('\n----------------------');
|
|
133
|
-
console.log("".concat(name, " ").concat(formatArguments(args).join(' ')));
|
|
134
|
-
console.log("".concat(figures.tick, " ").concat(results.length - errors.length, " succeeded"));
|
|
135
|
-
if (errors.length) console.log("".concat(figures.cross, " ").concat(errors.length, " failed"));
|
|
136
|
-
}
|
|
137
|
-
(0, _exit.default)(err || errors.length ? ERROR_CODE : 0);
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
(0, _exit.default)(err || errors.length ? ERROR_CODE : 0);
|
|
134
|
+
if (!_spawnterm.createSession) {
|
|
135
|
+
console.log('\n======================');
|
|
136
|
+
results.forEach(function(res) {
|
|
137
|
+
console.log("".concat(res.error ? _spawnterm.figures.cross : _spawnterm.figures.tick, " ").concat(res.version).concat(res.error ? " Error: ".concat(res.error.message) : ''));
|
|
138
|
+
});
|
|
139
|
+
console.log('\n----------------------');
|
|
140
|
+
console.log("".concat(name, " ").concat((0, _spawnterm.formatArguments)(args).join(' ')));
|
|
141
|
+
console.log("".concat(_spawnterm.figures.tick, " ").concat(results.length - errors.length, " succeeded"));
|
|
142
|
+
if (errors.length) console.log("".concat(_spawnterm.figures.cross, " ").concat(errors.length, " failed"));
|
|
143
|
+
}
|
|
141
144
|
}
|
|
145
|
+
(0, _exit.default)(err || errors.length ? ERROR_CODE : 0);
|
|
142
146
|
});
|
|
143
147
|
};
|
|
144
148
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
package/dist/cjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport url from 'url';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport { createSession, figures, formatArguments } from 'spawn-term';\nimport url from 'url';\nimport { isCommand, runCommand } from './commands/index.ts';\nimport run from './index.ts';\nimport type { UseError, UseOptions, UseResult } from './types.ts';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nconst ERROR_CODE = 13;\n\nfunction getVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} [options] <version> <command> [args...]`);\n console.log(` ${name} <subcommand> [args...]`);\n console.log('');\n console.log('Run commands with specific Node.js versions');\n console.log('');\n console.log('Subcommands:');\n console.log(' default [version] Set or display the global default Node version');\n console.log(' local [version] Set or display the local Node version (.nvmrc)');\n console.log(' install <version> Download and install a Node version');\n console.log(' uninstall <version> Remove an installed Node version');\n console.log(' list List installed Node versions');\n console.log(' which Show which Node version would be used');\n console.log(' setup Install/reinstall binaries to ~/.nvu/bin');\n console.log(' teardown Remove binaries from ~/.nvu/bin');\n console.log('');\n console.log('Options:');\n console.log(' -v, --version Print version number');\n console.log(' -h, --help Print this help message');\n console.log(' -r, --range Range type (major, minor, patch) with filters (lts, even, odd)');\n console.log(' Default: major,even');\n console.log(' -d, --desc Sort versions in descending order');\n console.log(' -e, --expanded Use expanded version format');\n console.log(' -s, --streaming Enable streaming output');\n console.log(' --silent Suppress logging');\n console.log('');\n console.log('Examples:');\n console.log(` ${name} 22 node --version Run with Node 22`);\n console.log(` ${name} 22,20,18 npm test Run with multiple versions`);\n console.log(` ${name} engines node --version Use version from package.json`);\n console.log(` ${name} default 20 Set global default to Node 20`);\n console.log(` ${name} local 18 Create .nvmrc with Node 18`);\n}\n\nexport default (argv: string[], name: string): undefined => {\n const options = getopts(argv, {\n alias: { range: 'r', desc: 'd', expanded: 'e', streaming: 's', silent: 'si', version: 'v', help: 'h' },\n default: { range: 'major,even', interactive: true },\n boolean: ['silent', 'desc', 'expanded', 'streaming', 'interactive', 'version', 'help'],\n stopEarly: true,\n });\n\n if (options.version) {\n console.log(getVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(name);\n exit(0);\n return;\n }\n\n // Check if first argument is a subcommand\n const args = options._;\n if (args.length > 0 && isCommand(args[0])) {\n runCommand(args[0], args.slice(1));\n return;\n }\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n if (args.length === 0) {\n console.log(`Missing version expression. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n if (args.length === 1) {\n console.log(`Missing command. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n\n options.stdio = 'inherit'; // pass through stdio\n run(args[0], args[1], args.slice(2), options as unknown as UseOptions, (err: UseError, results: UseResult[]): undefined => {\n if (err && !err.results) {\n console.log(err.message);\n exit(ERROR_CODE);\n return;\n }\n if (err) results = err.results;\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n if (!createSession) {\n console.log('\\n======================');\n results.forEach((res) => {\n console.log(`${res.error ? figures.cross : figures.tick} ${res.version}${res.error ? ` Error: ${res.error.message}` : ''}`);\n });\n console.log('\\n----------------------');\n console.log(`${name} ${formatArguments(args).join(' ')}`);\n console.log(`${figures.tick} ${results.length - errors.length} succeeded`);\n if (errors.length) console.log(`${figures.cross} ${errors.length} failed`);\n }\n }\n exit(err || errors.length ? ERROR_CODE : 0);\n });\n};\n"],"names":["__dirname","path","dirname","__filename","url","fileURLToPath","ERROR_CODE","getVersion","packagePath","join","packageJson","JSON","parse","fs","readFileSync","version","printHelp","name","console","log","argv","options","getopts","alias","range","desc","expanded","streaming","silent","help","default","interactive","boolean","stopEarly","exit","args","_","length","isCommand","runCommand","slice","sort","stdio","run","err","results","message","errors","filter","result","error","createSession","forEach","res","figures","cross","tick","formatArguments"],"mappings":";;;;+BAyDA;;;eAAA;;;2DAzDiB;yDACF;oEACK;2DACH;yBACuC;0DACxC;uBACsB;+DACtB;;;;;;AAGhB,IAAMA,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,IAAMC,aAAa;AAEnB,SAASC;IACP,IAAMC,cAAcP,aAAI,CAACQ,IAAI,CAACT,WAAW,MAAM,MAAM;IACrD,IAAMU,cA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defineProperty(exports, /**
|
|
6
|
+
* nvu default [version]
|
|
7
|
+
*
|
|
8
|
+
* Set or display the global default Node version.
|
|
9
|
+
* This is used when no .nvmrc or .nvurc is found in the project.
|
|
10
|
+
*/ "default", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return defaultCmd;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
|
|
17
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
18
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
|
+
var _compatts = require("../compat.js");
|
|
20
|
+
var _constantsts = require("../constants.js");
|
|
21
|
+
function _interop_require_default(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function defaultCmd(args) {
|
|
27
|
+
var defaultFilePath = _path.default.join(_constantsts.storagePath, 'default');
|
|
28
|
+
// If no version provided, display current default
|
|
29
|
+
if (args.length === 0) {
|
|
30
|
+
if (_fs.default.existsSync(defaultFilePath)) {
|
|
31
|
+
var currentVersion = _fs.default.readFileSync(defaultFilePath, 'utf8').trim();
|
|
32
|
+
console.log("Current default: ".concat(currentVersion));
|
|
33
|
+
} else {
|
|
34
|
+
console.log('No default version set.');
|
|
35
|
+
console.log('Usage: nvu default <version>');
|
|
36
|
+
}
|
|
37
|
+
(0, _exit.default)(0);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var version = args[0].trim();
|
|
41
|
+
// Validate version format (basic check, indexOf for Node 0.8+ compat)
|
|
42
|
+
if (!version || version.indexOf('-') === 0) {
|
|
43
|
+
console.log('Usage: nvu default <version>');
|
|
44
|
+
console.log('Example: nvu default 20');
|
|
45
|
+
(0, _exit.default)(1);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Ensure storage directory exists
|
|
49
|
+
if (!_fs.default.existsSync(_constantsts.storagePath)) {
|
|
50
|
+
(0, _compatts.mkdirpSync)(_constantsts.storagePath);
|
|
51
|
+
}
|
|
52
|
+
// Write the default version
|
|
53
|
+
_fs.default.writeFileSync(defaultFilePath, "".concat(version, "\n"), 'utf8');
|
|
54
|
+
console.log("Default Node version set to: ".concat(version));
|
|
55
|
+
(0, _exit.default)(0);
|
|
56
|
+
}
|
|
57
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/default.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu default [version]\n *\n * Set or display the global default Node version.\n * This is used when no .nvmrc or .nvurc is found in the project.\n */\nexport default function defaultCmd(args: string[]): void {\n var defaultFilePath = path.join(storagePath, 'default');\n\n // If no version provided, display current default\n if (args.length === 0) {\n if (fs.existsSync(defaultFilePath)) {\n var currentVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n console.log(`Current default: ${currentVersion}`);\n } else {\n console.log('No default version set.');\n console.log('Usage: nvu default <version>');\n }\n exit(0);\n return;\n }\n\n var version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu default <version>');\n console.log('Example: nvu default 20');\n exit(1);\n return;\n }\n\n // Ensure storage directory exists\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n\n // Write the default version\n fs.writeFileSync(defaultFilePath, `${version}\\n`, 'utf8');\n console.log(`Default Node version set to: ${version}`);\n exit(0);\n}\n"],"names":["defaultCmd","args","defaultFilePath","path","join","storagePath","length","fs","existsSync","currentVersion","readFileSync","trim","console","log","exit","version","indexOf","mkdirpSync","writeFileSync"],"mappings":";;;;+BAMA;;;;;CAKC,GACD;;;eAAwBA;;;2DAZP;yDACF;2DACE;wBACU;2BACC;;;;;;AAQb,SAASA,WAAWC,IAAc;IAC/C,IAAIC,kBAAkBC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE7C,kDAAkD;IAClD,IAAIJ,KAAKK,MAAM,KAAK,GAAG;QACrB,IAAIC,WAAE,CAACC,UAAU,CAACN,kBAAkB;YAClC,IAAIO,iBAAiBF,WAAE,CAACG,YAAY,CAACR,iBAAiB,QAAQS,IAAI;YAClEC,QAAQC,GAAG,CAAC,AAAC,oBAAkC,OAAfJ;QAClC,OAAO;YACLG,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;QACd;QACAC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUd,IAAI,CAAC,EAAE,CAACU,IAAI;IAE1B,sEAAsE;IACtE,IAAI,CAACI,WAAWA,QAAQC,OAAO,CAAC,SAAS,GAAG;QAC1CJ,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,kCAAkC;IAClC,IAAI,CAACP,WAAE,CAACC,UAAU,CAACH,wBAAW,GAAG;QAC/BY,IAAAA,oBAAU,EAACZ,wBAAW;IACxB;IAEA,4BAA4B;IAC5BE,WAAE,CAACW,aAAa,CAAChB,iBAAiB,AAAC,GAAU,OAARa,SAAQ,OAAK;IAClDH,QAAQC,GAAG,CAAC,AAAC,gCAAuC,OAARE;IAC5CD,IAAAA,aAAI,EAAC;AACP"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get commands () {
|
|
13
|
+
return commands;
|
|
14
|
+
},
|
|
15
|
+
get isCommand () {
|
|
16
|
+
return isCommand;
|
|
17
|
+
},
|
|
18
|
+
get runCommand () {
|
|
19
|
+
return runCommand;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _defaultts = /*#__PURE__*/ _interop_require_default(require("./default.js"));
|
|
23
|
+
var _installts = /*#__PURE__*/ _interop_require_default(require("./install.js"));
|
|
24
|
+
var _listts = /*#__PURE__*/ _interop_require_default(require("./list.js"));
|
|
25
|
+
var _localts = /*#__PURE__*/ _interop_require_default(require("./local.js"));
|
|
26
|
+
var _setupts = /*#__PURE__*/ _interop_require_default(require("./setup.js"));
|
|
27
|
+
var _teardownts = /*#__PURE__*/ _interop_require_default(require("./teardown.js"));
|
|
28
|
+
var _uninstallts = /*#__PURE__*/ _interop_require_default(require("./uninstall.js"));
|
|
29
|
+
var _whichts = /*#__PURE__*/ _interop_require_default(require("./which.js"));
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var commands = {
|
|
36
|
+
default: _defaultts.default,
|
|
37
|
+
local: _localts.default,
|
|
38
|
+
list: _listts.default,
|
|
39
|
+
which: _whichts.default,
|
|
40
|
+
install: _installts.default,
|
|
41
|
+
uninstall: _uninstallts.default,
|
|
42
|
+
setup: _setupts.default,
|
|
43
|
+
teardown: _teardownts.default
|
|
44
|
+
};
|
|
45
|
+
function isCommand(name) {
|
|
46
|
+
return name in commands;
|
|
47
|
+
}
|
|
48
|
+
function runCommand(name, args) {
|
|
49
|
+
var cmd = commands[name];
|
|
50
|
+
if (cmd) {
|
|
51
|
+
cmd(args);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/index.ts"],"sourcesContent":["import defaultCmd from './default.ts';\nimport installCmd from './install.ts';\nimport listCmd from './list.ts';\nimport localCmd from './local.ts';\nimport setupCmd from './setup.ts';\nimport teardownCmd from './teardown.ts';\nimport uninstallCmd from './uninstall.ts';\nimport whichCmd from './which.ts';\n\nexport const commands: Record<string, (args: string[]) => void> = {\n default: defaultCmd,\n local: localCmd,\n list: listCmd,\n which: whichCmd,\n install: installCmd,\n uninstall: uninstallCmd,\n setup: setupCmd,\n teardown: teardownCmd,\n};\n\nexport function isCommand(name: string): boolean {\n return name in commands;\n}\n\nexport function runCommand(name: string, args: string[]): void {\n const cmd = commands[name];\n if (cmd) {\n cmd(args);\n }\n}\n"],"names":["commands","isCommand","runCommand","default","defaultCmd","local","localCmd","list","listCmd","which","whichCmd","install","installCmd","uninstall","uninstallCmd","setup","setupCmd","teardown","teardownCmd","name","args","cmd"],"mappings":";;;;;;;;;;;QASaA;eAAAA;;QAWGC;eAAAA;;QAIAC;eAAAA;;;gEAxBO;gEACA;6DACH;8DACC;8DACA;iEACG;kEACC;8DACJ;;;;;;AAEd,IAAMF,WAAqD;IAChEG,SAASC,kBAAU;IACnBC,OAAOC,gBAAQ;IACfC,MAAMC,eAAO;IACbC,OAAOC,gBAAQ;IACfC,SAASC,kBAAU;IACnBC,WAAWC,oBAAY;IACvBC,OAAOC,gBAAQ;IACfC,UAAUC,mBAAW;AACvB;AAEO,SAASjB,UAAUkB,IAAY;IACpC,OAAOA,QAAQnB;AACjB;AAEO,SAASE,WAAWiB,IAAY,EAAEC,IAAc;IACrD,IAAMC,MAAMrB,QAAQ,CAACmB,KAAK;IAC1B,IAAIE,KAAK;QACPA,IAAID;IACN;AACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, /**
|
|
6
|
+
* nvu install <version>
|
|
7
|
+
*
|
|
8
|
+
* Download and install a specific Node version.
|
|
9
|
+
*/ "default", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return installCmd;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
|
|
16
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
17
|
+
var _constantsts = require("../constants.js");
|
|
18
|
+
var _loadNodeVersionInstallts = /*#__PURE__*/ _interop_require_default(require("../lib/loadNodeVersionInstall.js"));
|
|
19
|
+
function _interop_require_default(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function installCmd(args) {
|
|
25
|
+
if (args.length === 0) {
|
|
26
|
+
console.log('Usage: nvu install <version>');
|
|
27
|
+
console.log('Example: nvu install 20');
|
|
28
|
+
console.log(' nvu install 20.10.0');
|
|
29
|
+
console.log(' nvu install lts');
|
|
30
|
+
(0, _exit.default)(1);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var version = args[0].trim();
|
|
34
|
+
// Validate version format (basic check, indexOf for Node 0.8+ compat)
|
|
35
|
+
if (!version || version.indexOf('-') === 0) {
|
|
36
|
+
console.log('Usage: nvu install <version>');
|
|
37
|
+
(0, _exit.default)(1);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.log("Installing Node ".concat(version, "..."));
|
|
41
|
+
// Load node-version-install dynamically
|
|
42
|
+
(0, _loadNodeVersionInstallts.default)(function(err, nodeVersionInstall) {
|
|
43
|
+
if (err || !nodeVersionInstall) {
|
|
44
|
+
console.error('Failed to load node-version-install:', (err === null || err === void 0 ? void 0 : err.message) || 'Module not available');
|
|
45
|
+
console.error('Make sure node-version-install is installed: npm install node-version-install');
|
|
46
|
+
(0, _exit.default)(1);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var versionsPath = _path.default.join(_constantsts.storagePath, 'installed');
|
|
50
|
+
nodeVersionInstall(version, {
|
|
51
|
+
installPath: versionsPath
|
|
52
|
+
}, function(installErr, results) {
|
|
53
|
+
if (installErr) {
|
|
54
|
+
console.error("Failed to install Node ".concat(version, ":"), installErr.message);
|
|
55
|
+
(0, _exit.default)(1);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (results && results.length > 0) {
|
|
59
|
+
var result = results[0];
|
|
60
|
+
console.log("Successfully installed Node ".concat(result.version));
|
|
61
|
+
console.log("Location: ".concat(result.installPath));
|
|
62
|
+
} else {
|
|
63
|
+
console.log("Node ".concat(version, " installed successfully."));
|
|
64
|
+
}
|
|
65
|
+
(0, _exit.default)(0);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/install.ts"],"sourcesContent":["import exit from 'exit';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport loadNodeVersionInstall from '../lib/loadNodeVersionInstall.ts';\n\n/**\n * nvu install <version>\n *\n * Download and install a specific Node version.\n */\nexport default function installCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu install <version>');\n console.log('Example: nvu install 20');\n console.log(' nvu install 20.10.0');\n console.log(' nvu install lts');\n exit(1);\n return;\n }\n\n const version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu install <version>');\n exit(1);\n return;\n }\n\n console.log(`Installing Node ${version}...`);\n\n // Load node-version-install dynamically\n loadNodeVersionInstall((err, nodeVersionInstall) => {\n if (err || !nodeVersionInstall) {\n console.error('Failed to load node-version-install:', err?.message || 'Module not available');\n console.error('Make sure node-version-install is installed: npm install node-version-install');\n exit(1);\n return;\n }\n\n const versionsPath = path.join(storagePath, 'installed');\n\n nodeVersionInstall(\n version,\n {\n installPath: versionsPath,\n },\n (installErr?: Error, results?: { version: string; installPath: string }[]) => {\n if (installErr) {\n console.error(`Failed to install Node ${version}:`, installErr.message);\n exit(1);\n return;\n }\n\n if (results && results.length > 0) {\n const result = results[0];\n console.log(`Successfully installed Node ${result.version}`);\n console.log(`Location: ${result.installPath}`);\n } else {\n console.log(`Node ${version} installed successfully.`);\n }\n exit(0);\n }\n );\n });\n}\n"],"names":["installCmd","args","length","console","log","exit","version","trim","indexOf","loadNodeVersionInstall","err","nodeVersionInstall","error","message","versionsPath","path","join","storagePath","installPath","installErr","results","result"],"mappings":";;;;+BAKA;;;;CAIC,GACD;;;eAAwBA;;;2DAVP;2DACA;2BACW;+EACO;;;;;;AAOpB,SAASA,WAAWC,IAAc;IAC/C,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAMC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAE5B,sEAAsE;IACtE,IAAI,CAACD,WAAWA,QAAQE,OAAO,CAAC,SAAS,GAAG;QAC1CL,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEAF,QAAQC,GAAG,CAAC,AAAC,mBAA0B,OAARE,SAA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