Skip to content

Migrate Node.js installation to bash with fnm support#24

Merged
ooloth merged 7 commits intomainfrom
feature/node-installation
Jul 11, 2025
Merged

Migrate Node.js installation to bash with fnm support#24
ooloth merged 7 commits intomainfrom
feature/node-installation

Conversation

@ooloth
Copy link
Owner

@ooloth ooloth commented Jul 11, 2025

💪 What

  • Files Created:
    • lib/node-utils.bash - Node.js/fnm utility functions (5 functions, 5 tests)
    • bin/install/node.bash - Bash replacement for node.zsh
    • test/install/test-node-utils.bats - 5 utility function tests
    • test/install/test-node-installation.bats - 3 integration tests
  • Test Coverage: 8 comprehensive tests covering all functionality
  • Quality: 8/8 tests passing, zero shellcheck warnings

🤔 Why

  • Bash Migration: Part of migration from custom zsh to industry-standard bash + shellcheck + bats
  • Professional Tooling: Enables shellcheck linting and bats testing for Node.js installation
  • Shared Utilities: Extracts reusable Node.js/fnm logic for future use
  • Better Testing: Comprehensive test coverage with proper mocking

👀 Usage

Run Node.js installation:

./bin/install/node.bash

Features:

  • Detects if fnm is installed (prerequisite)
  • Gets latest Node.js version from fnm
  • Checks if latest version already installed (skips if present)
  • Installs with corepack enabled
  • Sets as default and uses immediately

👩‍🔬 How to validate

Run utility tests:

bats test/install/test-node-utils.bats

Run integration tests:

bats test/install/test-node-installation.bats

Expected output (8 tests total):

# Utility tests
1..5
ok 1 fnm_installed returns false when fnm not found
ok 2 fnm_installed returns true when fnm is found
ok 3 get_latest_node_version returns latest version from fnm ls-remote
ok 4 check_node_version_installed detects installed version
ok 5 install_node_version installs and sets default

# Integration tests
1..3
ok 1 node.bash exists and is executable
ok 2 node.bash skips installation when latest version already installed
ok 3 node.bash installs latest version when not present

Verify shellcheck compliance:

shellcheck lib/node-utils.bash bin/install/node.bash

Architecture

Functions Provided:

  • fnm_installed() - Detects fnm command availability
  • get_latest_node_version() - Gets latest version from fnm ls-remote
  • check_node_version_installed() - Checks if specific version is installed
  • install_node_version() - Installs version with corepack, sets default

Key Features:

  • fnm Integration: Uses fnm for Node.js version management
  • Latest Version: Always installs the latest available version
  • Corepack Support: Enables corepack for package manager support
  • Idempotent: Skips installation if latest already present

🔗 Related links

Implementation Details

TDD Approach:

  • 8 test cases following strict TDD methodology
  • Each commit represents one test case with implementation
  • Comprehensive mocking for isolated testing
  • Behavioral testing focus

Migration Benefits:

  • Professional tooling (shellcheck + bats)
  • Shared utilities for code reuse
  • Better error handling with strict mode
  • Comprehensive test coverage

@ooloth ooloth marked this pull request as ready for review July 11, 2025 23:57
@ooloth ooloth merged commit e4b16ff into main Jul 11, 2025
1 check passed
@ooloth ooloth deleted the feature/node-installation branch July 11, 2025 23:59
ooloth added a commit that referenced this pull request Jul 12, 2025
Updates the bash migration plan to clearly explain the parallel
development approach:

- Building setup.bash system alongside existing setup.zsh (not replacing)
- Both systems can coexist indefinitely until cutover decision
- Zero disruption to existing workflows during development
- Clear boundaries between bash infrastructure and zsh user experience

Also updated status to reflect recent merged PRs:
- PR #22: setup.bash entry point
- PR #23: Rust installation migration
- PR #24: Node.js installation migration
- PR #25: Neovim installation migration (in review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant