node-version-bridge 0.5.0 → 0.6.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 +25 -15
- package/bin/nvb +94 -4
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -31,7 +31,24 @@ Aliases like `lts/*`, `lts/iron`, `node`, `stable`, and `latest` are automatical
|
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
34
|
-
###
|
|
34
|
+
### npm (recommended)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g node-version-bridge
|
|
38
|
+
nvb setup
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This installs the `nvb` command globally and configures the shell hook automatically.
|
|
42
|
+
|
|
43
|
+
### GitHub Releases
|
|
44
|
+
|
|
45
|
+
Download the latest release from [GitHub Releases](https://github.com/Marcosreuquen/node-version-bridge/releases), extract it, and run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bash install.sh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### From source
|
|
35
52
|
|
|
36
53
|
```bash
|
|
37
54
|
git clone https://github.com/marcosreuquen/node-version-bridge.git
|
|
@@ -58,13 +75,13 @@ Then add the hook to your shell config:
|
|
|
58
75
|
**Zsh** — add to `~/.zshrc`:
|
|
59
76
|
|
|
60
77
|
```bash
|
|
61
|
-
|
|
78
|
+
eval "$(nvb init zsh)"
|
|
62
79
|
```
|
|
63
80
|
|
|
64
81
|
**Bash** — add to `~/.bashrc`:
|
|
65
82
|
|
|
66
83
|
```bash
|
|
67
|
-
|
|
84
|
+
eval "$(nvb init bash)"
|
|
68
85
|
```
|
|
69
86
|
|
|
70
87
|
### Verify installation
|
|
@@ -87,13 +104,16 @@ This removes installed files, the shell hook from your config, and the cache.
|
|
|
87
104
|
|
|
88
105
|
### Manual
|
|
89
106
|
|
|
90
|
-
1. Remove the `
|
|
107
|
+
1. Remove the nvb lines from your `.zshrc`/`.bashrc` (`eval "$(nvb init ...)"` or `source ...nvb.zsh`/`nvb.bash`)
|
|
91
108
|
2. Delete the install directory: `rm -rf ~/.local/share/nvb`
|
|
92
109
|
3. Optional — delete the cache: `rm -rf ~/.cache/node-version-bridge`
|
|
93
110
|
|
|
94
111
|
## Usage
|
|
95
112
|
|
|
96
113
|
```bash
|
|
114
|
+
# Configure shell hook (run once after install)
|
|
115
|
+
nvb setup
|
|
116
|
+
|
|
97
117
|
# Show resolved version vs active version
|
|
98
118
|
nvb current
|
|
99
119
|
|
|
@@ -156,18 +176,8 @@ bash test/run.sh
|
|
|
156
176
|
- No need to commit manager-specific files when `.nvmrc`/`.node-version` already exists.
|
|
157
177
|
- Works with any popular Node version manager.
|
|
158
178
|
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Documentation
|
|
162
|
-
|
|
163
|
-
- [Product concept](./docs/concept.md)
|
|
164
|
-
- [Technical design](./docs/technical-design.md)
|
|
165
|
-
- [Roadmap](./docs/roadmap.md)
|
|
166
|
-
- [Implementation plan](./docs/implementation-plan.md)
|
|
167
|
-
- [Changelog](./CHANGELOG.md)
|
|
168
|
-
|
|
169
179
|
## Status
|
|
170
180
|
|
|
171
|
-
v0.
|
|
181
|
+
v0.6.0 — automatic shell hook setup, `nvb setup` and `nvb init` commands. See [Changelog](./CHANGELOG.md).
|
|
172
182
|
|
|
173
183
|
**[Full Documentation](https://marcosreuquen.github.io/node-version-bridge/)**
|
package/bin/nvb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
8
|
-
NVB_VERSION="0.
|
|
8
|
+
NVB_VERSION="0.6.0"
|
|
9
9
|
|
|
10
10
|
# Resolve script location (handles symlinks on macOS/Linux)
|
|
11
11
|
_nvb_resolve_root() {
|
|
@@ -230,6 +230,91 @@ nvb_cmd_config() {
|
|
|
230
230
|
esac
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
nvb_cmd_init() {
|
|
234
|
+
local shell_name="${1:-}"
|
|
235
|
+
|
|
236
|
+
if [[ -z "$shell_name" ]]; then
|
|
237
|
+
# Auto-detect from parent shell
|
|
238
|
+
shell_name="$(basename "${SHELL:-}")"
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
case "$shell_name" in
|
|
242
|
+
zsh)
|
|
243
|
+
cat <<'HOOK'
|
|
244
|
+
_nvb_hook() {
|
|
245
|
+
[[ "${_NVB_LAST_DIR:-}" == "$PWD" ]] && return
|
|
246
|
+
_NVB_LAST_DIR="$PWD"
|
|
247
|
+
eval "$(nvb refresh 2>/dev/null)"
|
|
248
|
+
}
|
|
249
|
+
autoload -U add-zsh-hook
|
|
250
|
+
add-zsh-hook chpwd _nvb_hook
|
|
251
|
+
_nvb_hook
|
|
252
|
+
HOOK
|
|
253
|
+
;;
|
|
254
|
+
bash)
|
|
255
|
+
cat <<'HOOK'
|
|
256
|
+
_nvb_hook() {
|
|
257
|
+
[[ "${_NVB_LAST_DIR:-}" == "$PWD" ]] && return
|
|
258
|
+
_NVB_LAST_DIR="$PWD"
|
|
259
|
+
eval "$(nvb refresh 2>/dev/null)"
|
|
260
|
+
}
|
|
261
|
+
if [[ ";${PROMPT_COMMAND:-};" != *";_nvb_hook;"* ]]; then
|
|
262
|
+
PROMPT_COMMAND="_nvb_hook;${PROMPT_COMMAND:-}"
|
|
263
|
+
fi
|
|
264
|
+
HOOK
|
|
265
|
+
;;
|
|
266
|
+
*)
|
|
267
|
+
echo "Unknown shell: ${shell_name}. Supported: zsh, bash" >&2
|
|
268
|
+
return 1
|
|
269
|
+
;;
|
|
270
|
+
esac
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
nvb_cmd_setup() {
|
|
274
|
+
local shell_name
|
|
275
|
+
shell_name="$(basename "${SHELL:-}")"
|
|
276
|
+
|
|
277
|
+
if [[ "$shell_name" != "zsh" && "$shell_name" != "bash" ]]; then
|
|
278
|
+
echo "[nvb] Could not detect shell (got: ${shell_name}). Supported: zsh, bash" >&2
|
|
279
|
+
echo "[nvb] Add manually to your shell config:" >&2
|
|
280
|
+
# shellcheck disable=SC2016
|
|
281
|
+
echo ' eval "$(nvb init zsh)" # for zsh' >&2
|
|
282
|
+
# shellcheck disable=SC2016
|
|
283
|
+
echo ' eval "$(nvb init bash)" # for bash' >&2
|
|
284
|
+
return 1
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
local rc_file
|
|
288
|
+
case "$shell_name" in
|
|
289
|
+
zsh) rc_file="${ZDOTDIR:-$HOME}/.zshrc" ;;
|
|
290
|
+
bash) rc_file="$HOME/.bashrc" ;;
|
|
291
|
+
esac
|
|
292
|
+
|
|
293
|
+
# shellcheck disable=SC2016
|
|
294
|
+
local hook_line='eval "$(nvb init '"${shell_name}"')"'
|
|
295
|
+
local marker="# node-version-bridge:hook"
|
|
296
|
+
|
|
297
|
+
# Check if already configured (new or legacy format)
|
|
298
|
+
if [[ -f "$rc_file" ]]; then
|
|
299
|
+
if grep -qF "nvb init" "$rc_file" || grep -qF "$marker" "$rc_file"; then
|
|
300
|
+
echo "[nvb] Shell hook already configured in ${rc_file}"
|
|
301
|
+
return 0
|
|
302
|
+
fi
|
|
303
|
+
fi
|
|
304
|
+
|
|
305
|
+
echo "[nvb] Adding shell hook to ${rc_file}..."
|
|
306
|
+
{
|
|
307
|
+
echo ""
|
|
308
|
+
echo "$marker"
|
|
309
|
+
echo "$hook_line"
|
|
310
|
+
} >> "$rc_file"
|
|
311
|
+
|
|
312
|
+
echo "[nvb] Done! Restart your shell or run:"
|
|
313
|
+
echo ""
|
|
314
|
+
echo " source ${rc_file}"
|
|
315
|
+
echo ""
|
|
316
|
+
}
|
|
317
|
+
|
|
233
318
|
nvb_cmd_help() {
|
|
234
319
|
cat <<EOF
|
|
235
320
|
node-version-bridge v${NVB_VERSION}
|
|
@@ -240,6 +325,8 @@ using your preferred version manager.
|
|
|
240
325
|
Usage: nvb <command> [options]
|
|
241
326
|
|
|
242
327
|
Commands:
|
|
328
|
+
setup Auto-configure shell hook (run once after install)
|
|
329
|
+
init Output shell hook code for eval (used in shell config)
|
|
243
330
|
refresh Detect version and output shell commands to apply it (for eval)
|
|
244
331
|
current Show resolved version, source, and active Node version
|
|
245
332
|
doctor Check available managers and configuration
|
|
@@ -257,9 +344,10 @@ Config examples:
|
|
|
257
344
|
Supported version files: .nvmrc, .node-version, .tool-versions, package.json (engines.node)
|
|
258
345
|
Supported managers: nvm, fnm, mise, asdf, n
|
|
259
346
|
|
|
260
|
-
Shell integration
|
|
261
|
-
|
|
262
|
-
|
|
347
|
+
Shell integration:
|
|
348
|
+
nvb setup Auto-configure (recommended, run once)
|
|
349
|
+
eval "$(nvb init zsh)" Manual — add to ~/.zshrc
|
|
350
|
+
eval "$(nvb init bash)" Manual — add to ~/.bashrc
|
|
263
351
|
|
|
264
352
|
Environment variables:
|
|
265
353
|
NVB_MANAGER Force a specific version manager (nvm, fnm, mise, asdf, n)
|
|
@@ -276,6 +364,8 @@ EOF
|
|
|
276
364
|
# --- Main dispatch ---
|
|
277
365
|
|
|
278
366
|
case "${1:-help}" in
|
|
367
|
+
setup) nvb_cmd_setup ;;
|
|
368
|
+
init) shift; nvb_cmd_init "$@" ;;
|
|
279
369
|
refresh) nvb_cmd_refresh ;;
|
|
280
370
|
current) nvb_cmd_current ;;
|
|
281
371
|
doctor) nvb_cmd_doctor ;;
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-version-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Detect Node.js version from project files and apply it via any version manager",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nvb": "bin/nvb"
|
|
7
7
|
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "echo '\\n Run \"nvb setup\" to configure your shell hook.\\n'"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
12
|
"bin/",
|
|
10
13
|
"lib/",
|