Skip to content

Commit db8838f

Browse files
authored
feat(nodeup): add local managed-alias shim setup (#192)
## Summary - extend `scripts/setup/nodeup-local.sh` to create idempotent `node`/`npm`/`npx` shims after local install - validate installed `nodeup` binary exists/executable before emitting shell exports - document updated local installer and symlink contract in `docs/project-nodeup.md` ## Validation - `./scripts/setup/nodeup-local.sh --help` - `NODEUP_LOCAL_INSTALL_ROOT=/tmp/nodeup-local-test ./scripts/setup/nodeup-local.sh > /tmp/nodeup-local-eval.sh` - verified `/tmp/nodeup-local-test/bin/{nodeup,node,npm,npx}` and symlink targets - `eval "$(cat /tmp/nodeup-local-eval.sh)"` then verified `command -v nodeup node npm npx` - verified deterministic not-found when no default runtime is set - verified delegated execution via linked runtime for `node`, `npm`, and `npx`
1 parent 0189061 commit db8838f

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

docs/project-nodeup.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ Dispatch contract:
249249
Symlink contract:
250250
- Shims point to one nodeup binary.
251251
- Runtime behavior branches by `argv[0]`.
252+
- Local setup script `scripts/setup/nodeup-local.sh` must create or refresh `node`, `npm`, and
253+
`npx` symlinks in the local install `bin/` directory with `ln -sfn` so reruns are idempotent.
252254

253255
## Storage
254256
- Install root: managed Node.js runtimes per version (`data/toolchains/<version>`).
@@ -304,8 +306,13 @@ Local development install and shell-session patch:
304306
- `eval "$(./scripts/setup/nodeup-local.sh)"`
305307
- Script contract:
306308
: Installs from `crates/nodeup` using `cargo install --path .`.
309+
: Verifies installed `nodeup` binary exists at `<install-root>/bin/nodeup` and is executable.
310+
: Creates managed alias shims `node`, `npm`, and `npx` in `<install-root>/bin`, each pointing to
311+
the `nodeup` binary via symlink.
307312
: Uses install root `${NODEUP_LOCAL_INSTALL_ROOT:-<repo>/.local/nodeup}`.
308313
: Prints shell exports for `PATH` and `NODEUP_SELF_BIN_PATH` so the current shell session can apply them immediately.
314+
: Does not auto-select a default runtime; operators bootstrap runtime explicitly after install:
315+
`nodeup default lts`, then verify with `node --version` and `npm --version`.
309316

310317
Planned commands:
311318
- Build: `cargo build -p nodeup`

scripts/setup/nodeup-local.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ set -eu
44

55
if [ "${1:-}" = "--help" ]; then
66
cat >&2 <<'EOF'
7-
Install nodeup from the local workspace and print shell exports for the current session.
7+
Install nodeup from the local workspace, create managed alias shims, and print shell
8+
exports for the current session.
89
910
Usage:
1011
eval "$(./scripts/setup/nodeup-local.sh)"
1112
13+
Post-install bootstrap:
14+
nodeup default lts
15+
node --version
16+
npm --version
17+
1218
Optional environment variables:
1319
NODEUP_LOCAL_INSTALL_ROOT Install root (default: <repo>/.local/nodeup)
1420
EOF
@@ -27,6 +33,19 @@ echo "[nodeup-local] installing with cargo install --path . --root \"$install_ro
2733
cargo install --path . --root "$install_root"
2834
) >&2
2935

36+
nodeup_binary="$install_bin_dir/nodeup"
37+
if [ ! -x "$nodeup_binary" ]; then
38+
echo "[nodeup-local] expected installed binary at \"$nodeup_binary\" but it is missing or not executable" >&2
39+
exit 1
40+
fi
41+
42+
echo "[nodeup-local] ensuring managed alias shims in \"$install_bin_dir\"" >&2
43+
for alias in node npm npx; do
44+
ln -sfn nodeup "$install_bin_dir/$alias"
45+
echo "[nodeup-local] shim ready: $alias -> nodeup" >&2
46+
done
47+
48+
echo "[nodeup-local] installation complete; bootstrap runtime with: nodeup default lts" >&2
3049
echo "[nodeup-local] printing shell exports for current session patch" >&2
3150
printf '_nodeup_local_bin="%s"\n' "$install_bin_dir"
3251
printf 'case ":$PATH:" in *":${_nodeup_local_bin}:"*) ;; *) export PATH="${_nodeup_local_bin}:$PATH" ;; esac\n'

0 commit comments

Comments
 (0)