diff --git a/README.md b/README.md index e18fe54..de68480 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,47 @@ # 🚀 Nushell Plugins Repository -A comprehensive collection of nushell plugins with automated upstream tracking, dependency management, and development workflows. +A comprehensive collection of nushell plugins with automated upstream tracking, dependency management, development workflows, and **complete Nushell distribution system**. + +## 🆕 NEW: Full Nushell Distribution System + +**Transform from development complexity to one-liner installation!** + +This repository now provides **complete Nushell distributions** that include Nushell itself plus all plugins, offering zero-prerequisite installation for end users: + +### 🎯 End User Installation (Zero Prerequisites) +```bash +# One-liner installation (Linux/macOS) +curl -sSf https://your-url/install.sh | sh + +# Windows PowerShell +iwr https://your-url/install.ps1 | iex + +# Manual installation +wget https://releases/nushell-full-linux-x86_64.tar.gz +tar -xzf nushell-full-*.tar.gz && cd nushell-full-* && ./install.sh +``` + +### 🚀 Developer Distribution Commands +```bash +just build-full # Build nushell + all plugins +just pack-full # Create distribution package +just pack-full-all # All platforms +just verify-full # Verify installation +just release-full-cross # Complete release workflow +``` + +### ✨ Key Features +- **Zero Prerequisites**: No Rust, Cargo, or Nu installation required +- **Cross-Platform**: Linux, macOS, Windows support +- **Complete Environment**: Nushell + all plugins + configuration +- **Professional Installation**: Clean install/uninstall experience +- **Bootstrap Installers**: Production-ready installation scripts ## 📋 Table of Contents - [Quick Start](#-quick-start) +- [End User Installation](#-end-user-installation-zero-prerequisites) +- [Full Distribution System](#-full-distribution-system) - [Why This Repository?](#-why-this-repository) - [Plugin Collection](#-plugin-collection) - [Building and Cross-Compilation](#-building-and-cross-compilation) @@ -18,8 +55,20 @@ A comprehensive collection of nushell plugins with automated upstream tracking, ## 🚀 Quick Start -### Prerequisites +### For End Users (Zero Prerequisites) +```bash +# One-liner installation +curl -sSf https://your-url/install.sh | sh + +# Or download and install manually +wget https://releases/nushell-full-linux-x86_64.tar.gz +tar -xzf nushell-full-*.tar.gz && cd nushell-full-* && ./install.sh +``` + +### For Developers + +#### Prerequisites ```bash # Install required tools curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Rust @@ -27,8 +76,7 @@ cargo install just # Just (optional # Note: Nushell will be auto-installed if missing ``` -### Basic Usage - +#### Development Workflow ```bash # Clone the repository git clone @@ -37,17 +85,19 @@ cd nushell-plugins # Validate nushell version consistency (recommended first step) just validate-nushell -# Using Just (recommended) +# Plugin development just status # Show plugin status just status-mark-locals-ok # Mark local plugins as OK (recommended) just upstream-check # Check for upstream updates just build # Build all plugins just dev-flow # Complete development workflow -# Using scripts directly (with automatic version checking) -./scripts/run.sh plugin_status.nu -./scripts/run.sh check_upstream_changes.nu -./scripts/run.sh build_all.nu +# Distribution creation +just build-nushell # Build nushell + system plugins (uses --workspace flag) +just build-full # Build nushell + system plugins + custom plugins +just collect # Collect nushell + all plugins for distribution +just pack-full # Create distribution package +just release-full-cross # Complete cross-platform release ``` ### ⚠️ Critical: Version Consistency @@ -57,6 +107,151 @@ just dev-flow # Complete development workflow - **Auto-fix**: `just fix-nushell` or `./scripts/run.sh --fix --check-only` - **Manual check**: `just validate-nushell` +## 🎯 Full Distribution System + +### What is it? + +The Full Distribution System transforms this repository from a **development-focused plugin collection** into a **complete Nushell distribution platform**. Instead of requiring users to install Rust, clone repositories, and build plugins, they can now install a complete Nushell environment with a single command. + +### End User Experience + +**Before**: Complex development setup required +```bash +# Users needed to: +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Install Rust +git clone repository && cd nushell-plugins # Clone repo +just validate-nushell && just build # Build everything +# ... multiple complex steps +``` + +**After**: Zero-prerequisite installation +```bash +# Users now only need: +curl -sSf https://your-url/install.sh | sh # Done! +``` + +### Distribution Commands + +#### Building Complete Distributions + +**Step 1: Build Nushell + System Plugins** +```bash +# Build Nushell with built-in system plugins (uses cargo build --workspace) +just build-nushell # Builds: nu + nu_plugin_formats, nu_plugin_inc, nu_plugin_gstat, + # nu_plugin_query, nu_plugin_polars, nu_plugin_custom_values, etc. + +# Build for specific targets +just build-nushell-target linux-arm64 # Cross-compile system plugins +``` + +**Step 2: Build Everything (System + Custom Plugins)** +```bash +# Build nushell + system plugins + custom plugins from this repo +just build-full # Native build (calls build-nushell + build custom plugins) +just build-full-cross # Cross-platform build +just build-full-all # All platforms +``` + +**Step 3: Collect Built Binaries** +```bash +# Collect nushell binary + all plugins for distribution +just collect # Current platform (darwin-arm64) +just collect-all # All available platforms +just collect-platform PLATFORM # Specific platform +``` + +**Step 4: Create Distribution Packages** +```bash +# Create distribution packages +just pack-full # Current platform +just pack-full-all # All platforms +just pack-full-with-installer # Include bootstrap installer + +# Verification and testing +just verify-full # Verify distribution integrity +just test-install-full # Test complete installation process +``` + +#### Cross-Platform Release +```bash +# Complete release workflow +just release-full-cross # Build → Pack → Verify for all platforms + +# Individual platform releases +just release-full-linux # Linux distributions +just release-full-macos # macOS distributions +just release-full-windows # Windows distributions +``` + +#### Installation Modes + +**System Installation** (recommended for end users): +```bash +# Install to system paths with proper integration +./install.sh + +# Windows +./install.ps1 + +# Custom installation path +./install.sh --prefix /opt/nushell +``` + +**Local Installation** (development/testing): +```bash +# Install to user directory without system integration +./install.sh --local + +# Portable installation +./install.sh --portable --path ./nushell-portable +``` + +### Distribution Architecture + +#### Components Included +- **Nushell Binary**: Complete nushell installation +- **All Plugins**: Every plugin in the repository +- **Configuration**: Optimized default configuration +- **Documentation**: Usage guides and help +- **Bootstrap Scripts**: Cross-platform installers +- **Verification**: Installation integrity checks + +#### Platform Support +| Platform | Architecture | Status | Installation Method | +|----------|-------------|--------|-------------------| +| **Linux** | x86_64 | ✅ Full | `curl` installer + manual | +| **Linux** | ARM64 | ✅ Full | `curl` installer + manual | +| **macOS** | Intel | ✅ Full | `curl` installer + manual | +| **macOS** | Apple Silicon | ✅ Full | `curl` installer + manual | +| **Windows** | x86_64 | ✅ Full | PowerShell installer + manual | + +#### Bootstrap Installers +- **Smart Detection**: Automatically detects platform and architecture +- **Conflict Resolution**: Handles existing Nushell installations +- **Path Management**: Configures PATH and shell integration +- **Verification**: Confirms successful installation +- **Clean Uninstall**: Complete removal capability + +### Use Cases + +#### For End Users +- **Simple Installation**: Get Nushell + all plugins with one command +- **No Prerequisites**: No need for Rust, Git, or development tools +- **Professional Experience**: Clean installation/uninstallation +- **Immediate Productivity**: Pre-configured environment with all plugins + +#### For System Administrators +- **Bulk Deployment**: Deploy to multiple systems easily +- **Consistent Environment**: Identical setup across all machines +- **Offline Installation**: Manual packages work without internet +- **Integration Ready**: System-wide installation with proper paths + +#### for Distributors/Packagers +- **Ready Binaries**: All binaries built and tested +- **Cross-Platform**: Support for all major platforms +- **Checksums Included**: Integrity verification built-in +- **Professional Packaging**: Following platform conventions + ## 🎯 Why This Repository? ### The Challenge @@ -75,7 +270,8 @@ This repository provides: - **🔄 Automated Upstream Tracking**: Monitors upstream changes and auto-approves nu_* dependency updates - **📦 Unified Build System**: Builds all plugins with consistent nushell versions - **🛡️ Safe Merge Process**: Preserves local changes while integrating upstream updates -- **🚀 Distribution Pipeline**: Automated packaging and installation scripts +- **🚀 Complete Distribution System**: Full Nushell distributions with zero-prerequisite installation +- **📋 Professional Packaging**: Cross-platform installers and distribution packages - **⚡ Developer Experience**: Just recipes and scripts for common tasks ## 📦 Plugin Collection @@ -460,51 +656,91 @@ nushell-plugins/ ## 📥 Installation Methods -### Method 1: Repository Clone (Recommended for Development) +### Method 1: Full Distribution (Recommended for End Users) + +**Zero-prerequisite installation of complete Nushell environment:** + +```bash +# One-liner installation (Linux/macOS) +curl -sSf https://your-url/install.sh | sh + +# Windows PowerShell +iwr https://your-url/install.ps1 | iex + +# Manual installation from release +wget https://releases/nushell-full-linux-x86_64.tar.gz +tar -xzf nushell-full-*.tar.gz && cd nushell-full-* && ./install.sh + +# Verify installation +nu --version && nu -c "plugin list" +``` + +**What you get:** +- Complete Nushell installation +- All plugins from this repository +- Optimized configuration +- Professional installation experience +- Clean uninstall capability + +### Method 2: Plugin-Only Distribution + +**For users who already have Nushell installed:** + +```bash +# Download plugin-only archive +wget https://releases/nushell-plugins-linux-x86_64.tar.gz +tar -xzf nushell-plugins-*.tar.gz && cd nushell-plugins + +# Install all plugins +./install_plugins.sh + +# Or install specific plugins +./install_plugins.sh --plugins "nu_plugin_clipboard,nu_plugin_highlight" +``` + +### Method 3: Repository Clone (Recommended for Development) + +**For plugin developers and contributors:** ```bash git clone cd nushell-plugins -just build # Build all plugins -just collect # Prepare for installation -# Install specific plugins -cd distribution -nu install_nu_plugins.nu --plugins [nu_plugin_clipboard, nu_plugin_highlight] +# Validate environment +just validate-nushell + +# Build and install plugins only +just build && just collect +cd distribution && nu install_nu_plugins.nu + +# Build complete distributions +just build-full && just pack-full ``` -### Method 2: Pre-built Archive +### Method 4: Individual Plugin Installation + +**For specific plugin installation:** ```bash -# Download and extract archive -wget https://releases.../linux-amd64-nushell-plugins.tar.gz -tar -xzf linux-amd64-nushell-plugins.tar.gz -cd nushell-plugins - -# Install all plugins -nu install_nu_plugins.nu - -# Or install specific plugins -nu install_nu_plugins.nu --plugins [nu_plugin_clipboard] -``` - -### Method 3: Individual Plugin Installation - -```bash -# Build and install single plugin +# From source (development) cd nu_plugin_clipboard cargo build --release plugin add target/release/nu_plugin_clipboard -``` -### Method 4: Using Cargo - -```bash -# For plugins published to crates.io +# From crates.io (if published) cargo install nu_plugin_clipboard plugin add ~/.cargo/bin/nu_plugin_clipboard ``` +### Installation Comparison + +| Method | Prerequisites | What's Included | Best For | +|--------|---------------|-----------------|----------| +| **Full Distribution** | None | Nushell + All Plugins | End users, system admins | +| **Plugin Distribution** | Nushell | All Plugins | Nushell users | +| **Repository Clone** | Rust, Git | Development environment | Contributors, developers | +| **Individual Plugin** | Rust, Nu | Single plugin | Selective installation | + ## 🎮 Using Just Recipes Just provides convenient shortcuts for all common tasks with **automatic version validation**: @@ -522,10 +758,30 @@ just fix-nushell # Auto-fix version mismatches just # Show all available recipes just status # Plugin status dashboard just build # Build all plugins +just build-full # Build nushell + all plugins just test # Test all plugins just clean # Clean build artifacts ``` +### Full Distribution Commands + +```bash +# Building complete distributions +just build-full # Build nushell with all plugins +just build-full-cross # Cross-platform build +just build-full-all # All platforms + +# Creating distribution packages +just pack-full # Create distribution package +just pack-full-all # All platforms +just pack-full-with-installer # Include bootstrap installer + +# Release workflows +just release-full-cross # Complete cross-platform release +just verify-full # Verify distribution integrity +just test-full # Test installation process +``` + ### Upstream Management ```bash diff --git a/justfiles/distro.just b/justfiles/distro.just index bd53a9e..8ed7d5d 100644 --- a/justfiles/distro.just +++ b/justfiles/distro.just @@ -3,11 +3,11 @@ # 📦 COLLECTION COMMANDS -# Collect built plugins for distribution +# Collect built plugins for distribution (UPDATED: now includes nushell + system plugins) [no-cd] collect: - @echo "📦 Collecting plugins for distribution..." - @{{justfile_directory()}}/scripts/run.sh collect_install.nu --force + @echo "📦 Collecting plugins for distribution (nushell + all plugins)..." + @{{justfile_directory()}}/scripts/run.sh collect_full_binaries.nu --release --force # List available built plugins [no-cd] @@ -21,22 +21,28 @@ collect-platforms: @echo "📊 Available platforms for collection:" @{{justfile_directory()}}/scripts/run.sh collect_install.nu --list-platforms -# Collect specific platform +# Collect specific platform (UPDATED: now includes nushell + system plugins) [no-cd] collect-platform PLATFORM: - @echo "📦 Collecting {{PLATFORM}} plugins..." - @{{justfile_directory()}}/scripts/run.sh collect_install.nu --platform {{PLATFORM}} + @echo "📦 Collecting {{PLATFORM}} plugins (nushell + all plugins)..." + @{{justfile_directory()}}/scripts/run.sh collect_full_binaries.nu --platform {{PLATFORM}} --release --force -# Collect all available platforms +# Collect all available platforms (UPDATED: now includes nushell + system plugins) [no-cd] collect-all: - @echo "🌍 Collecting all platforms..." - @{{justfile_directory()}}/scripts/run.sh collect_install.nu --all-platforms + @echo "🌍 Collecting all platforms (nushell + all plugins)..." + @{{justfile_directory()}}/scripts/run.sh collect_full_binaries.nu --all-platforms --release --force # Force collection (overwrite existing) [no-cd] collect-force: - @echo "📦 Force collecting plugins..." + @echo "📦 Force collecting plugins (nushell + all plugins)..." + @{{justfile_directory()}}/scripts/run.sh collect_full_binaries.nu --release --force + +# Legacy: Collect only custom plugins (without nushell/system plugins) +[no-cd] +collect-plugins-only-legacy: + @echo "📦 Collecting custom plugins only (legacy mode)..." @{{justfile_directory()}}/scripts/run.sh collect_install.nu --force # 📋 PACKAGING COMMANDS @@ -209,13 +215,14 @@ distro-help: @echo "📦 Distribution Module Help" @echo "==========================" @echo "" - @echo "COLLECTION:" - @echo " collect - Collect plugins for distribution" + @echo "COLLECTION (UPDATED: now includes nushell + system plugins):" + @echo " collect - Collect nushell + all plugins for distribution" @echo " collect-list - List available built plugins" @echo " collect-platforms - List available platforms" - @echo " collect-platform PLATFORM - Collect specific platform" - @echo " collect-all - Collect all platforms" + @echo " collect-platform PLATFORM - Collect nushell + plugins for specific platform" + @echo " collect-all - Collect nushell + plugins for all platforms" @echo " collect-force - Force collection (overwrite)" + @echo " collect-plugins-only-legacy - Legacy: collect only custom plugins" @echo "" @echo "PACKAGING:" @echo " pack - Create distribution package" diff --git a/justfiles/full_distro.just b/justfiles/full_distro.just index 6ec9584..ec7dd5d 100644 --- a/justfiles/full_distro.just +++ b/justfiles/full_distro.just @@ -271,14 +271,18 @@ full-help: @echo "🚀 Full Distribution Module Help" @echo "===============================" @echo "" - @echo "NUSHELL BUILD:" - @echo " build-nushell - Build nushell with workspace plugins" - @echo " build-nushell-debug - Build nushell (debug mode)" - @echo " build-nushell-target TARGET - Build nushell for specific target" - @echo " build-nushell-features FEAT - Build nushell with custom features" + @echo "NUSHELL + SYSTEM PLUGINS BUILD:" + @echo " build-nushell - Build nushell + ALL system plugins (nu_plugin_*)" + @echo " build-nushell-debug - Build nushell + system plugins (debug mode)" + @echo " build-nushell-target TARGET - Build nushell + system plugins for specific target" + @echo " build-nushell-features FEAT - Build nushell + system plugins with custom features" @echo " build-nushell-deps - Check nushell build dependencies" @echo " build-nushell-info - Show nushell build information" @echo "" + @echo " 💡 NOTE: All 'build-nushell*' commands build the system plugins:" + @echo " nu_plugin_formats, nu_plugin_inc, nu_plugin_gstat, nu_plugin_query," + @echo " nu_plugin_polars, nu_plugin_custom_values, nu_plugin_example, etc." + @echo "" @echo "FULL BUILD WORKFLOWS:" @echo " build-full - Build nushell + all plugins" @echo " build-full-release - Build full release distribution" diff --git a/justfiles/help.just b/justfiles/help.just index 7d38406..3f7faf8 100644 --- a/justfiles/help.just +++ b/justfiles/help.just @@ -23,9 +23,9 @@ help AREA="": echo "===============" echo " just h - Short alias for help" echo " just b - Build all plugins (alias for build)" - echo " just c - Collect all plugins targets (alias for collect)" + echo " just c - Collect nushell + all plugins (alias for collect)" echo " just il - Install plugin in nu from local distro (alias for install-local)" - echo " just is - Install plugin to system and install in nu (alias for install-system)" + echo " just is - Install to ~/.local/bin (alias for install-system)" echo " just s - Show plugin status (alias for status)" echo " just v - Verify plugins (alias for verify-plugins)" echo " just validate-nushell - Check version consistency (START HERE)" @@ -34,9 +34,14 @@ help AREA="": echo "🔧 Most Common Commands:" echo "=======================" echo " just build - Build all plugins" + echo " just build-nushell - Build nushell + system plugins" + echo " just build-full - Build nushell + all plugins" + echo " just collect - Collect nushell + all plugins" + echo " just collect-all - Collect nushell + all plugins (all platforms)" echo " just test - Run all tests" echo " just upstream-check - Check for upstream changes" - echo " just release-cross - Cross-platform release" + echo " just pack-full - Create complete distribution" + echo " just release-full-cross - Full cross-platform release" ;; "modules") echo "📋 AVAILABLE MODULES" @@ -48,9 +53,14 @@ help AREA="": echo " Purpose: Native and cross-platform compilation" echo "" echo "📦 DISTRIBUTION MODULE" - echo " Commands: collect, pack, release-*" + echo " Commands: collect, collect-all, pack, release-*" echo " Help: just distro-help" - echo " Purpose: Collection and packaging of built plugins" + echo " Purpose: Collection and packaging (UPDATED: now includes nushell + system plugins)" + echo "" + echo "🚀 FULL DISTRIBUTION MODULE" + echo " Commands: build-full*, pack-full*, release-full*" + echo " Help: just full-help" + echo " Purpose: Complete Nushell distributions with zero prerequisites" echo "" echo "🔄 UPSTREAM MODULE" echo " Commands: upstream-*, status-*" @@ -114,12 +124,16 @@ help AREA="": echo " just b # Build all plugins (short alias)" echo " just test # Run tests" echo "" - echo "🌍 CROSS-PLATFORM BUILD:" - echo "1. See available platforms:" - echo " just build-targets # List supported platforms" + echo "🚀 FULL DISTRIBUTION WORKFLOW:" + echo "1. Build complete distributions:" + echo " just build-full # Build nushell + all plugins" + echo " just pack-full # Create distribution package" echo "" - echo "2. Build for all platforms:" - echo " just release-cross # Full cross-platform release" + echo "2. Cross-platform release:" + echo " just release-full-cross # Build for all platforms" + echo "" + echo "3. End-user installation:" + echo " curl -sSf https://your-url/install.sh | sh" echo "" echo "🆘 NEED HELP?" echo " just help modules # See all available modules" @@ -179,10 +193,15 @@ modules: @echo " Help: just build-help" @echo "" @echo "📦 DISTRIBUTION MODULE (justfiles/distro.just)" - @echo " Collection and packaging" + @echo " Collection and packaging of plugins" @echo " Commands: collect, pack, release-*" @echo " Help: just distro-help" @echo "" + @echo "🚀 FULL DISTRIBUTION MODULE (justfiles/full_distro.just)" + @echo " Complete Nushell distributions with zero prerequisites" + @echo " Commands: build-full*, pack-full*, release-full*" + @echo " Help: just full-help" + @echo "" @echo "🔄 UPSTREAM MODULE (justfiles/upstream.just)" @echo " Repository tracking and synchronization" @echo " Commands: upstream-*, status-*" @@ -216,6 +235,8 @@ help-all: @echo "" @just distro-help @echo "" + @just full-help + @echo "" @just upstream-help @echo "" @just qa-help @@ -235,7 +256,8 @@ list-all: @echo "" @echo "Module-specific help:" @echo " just build-help - Build module commands" - @echo " just distro-help - Distribution module commands" + @echo " just distro-help - Plugin distribution commands" + @echo " just full-help - Full distribution commands" @echo " just upstream-help - Upstream module commands" @echo " just qa-help - QA module commands" @echo " just tools-help - Tools module commands" diff --git a/justfiles/tools.just b/justfiles/tools.just index a3610d0..eb984a1 100644 --- a/justfiles/tools.just +++ b/justfiles/tools.just @@ -71,7 +71,19 @@ install-local: exit 1 fi - if [ ! -f "distribution/install_nu_plugins.nu" ]; then + + # Detect current platform distribution + PLATFORM_DIR="" + if [ -d "distribution/darwin-arm64" ]; then + PLATFORM_DIR="distribution/darwin-arm64" + elif [ -d "distribution/aarch64-apple-darwin" ]; then + PLATFORM_DIR="distribution/aarch64-apple-darwin" + else + # Find any platform directory + PLATFORM_DIR=$(find distribution -maxdepth 1 -type d -name "*-*" | head -n1) + fi + + if [ -z "$PLATFORM_DIR" ] || [ ! -f "$PLATFORM_DIR/install.nu" ]; then echo "❌ Installation script not found in distribution" echo "💡 Run 'just collect' to regenerate distribution" exit 1 @@ -79,14 +91,15 @@ install-local: echo "📦 Installing plugins locally from distribution..." echo "💡 Using register-only mode (no sudo required)" - cd distribution && nu install_nu_plugins.nu --register-only --verify + echo "💡 Using distribution: $PLATFORM_DIR" + cd "$PLATFORM_DIR" && nu install.nu --verify echo "" echo "✅ Local installation completed!" echo "💡 Plugins are now registered with nushell from current location" echo " Run 'plugin list' in nushell to see installed plugins" -# Install plugins to system from distribution (requires sudo) +# Install plugins to ~/.local/bin from distribution (no sudo required) [no-cd] install-system: #!/usr/bin/env bash @@ -96,19 +109,75 @@ install-system: exit 1 fi - if [ ! -f "distribution/install_nu_plugins.nu" ]; then + # Detect current platform distribution + PLATFORM_DIR="" + if [ -d "distribution/darwin-arm64" ]; then + PLATFORM_DIR="distribution/darwin-arm64" + elif [ -d "distribution/aarch64-apple-darwin" ]; then + PLATFORM_DIR="distribution/aarch64-apple-darwin" + else + # Find any platform directory + PLATFORM_DIR=$(find distribution -maxdepth 1 -type d -name "*-*" | head -n1) + fi + + if [ -z "$PLATFORM_DIR" ] || [ ! -f "$PLATFORM_DIR/install.nu" ]; then echo "❌ Installation script not found in distribution" echo "💡 Run 'just collect' to regenerate distribution" exit 1 fi echo "📦 Installing plugins to system from distribution..." - echo "💡 This will copy binaries to /usr/local/bin (requires sudo)" - cd distribution && nu install_nu_plugins.nu --verify + echo "💡 Using distribution: $PLATFORM_DIR" + echo "⚠️ Note: Due to macOS security restrictions, using alternative approach" + echo "💡 This will install to ~/.local/bin and update PATH" + # Create user bin directory + mkdir -p ~/.local/bin + + # Copy nushell binary to user location (safer than system) + echo " Installing nushell binary to ~/.local/bin..." + cp "$PLATFORM_DIR/nu" ~/.local/bin/nu + chmod +x ~/.local/bin/nu + + # Copy all plugin binaries to user location + echo " Installing plugin binaries to ~/.local/bin..." + cp "$PLATFORM_DIR"/nu_plugin_* ~/.local/bin/ + chmod +x ~/.local/bin/nu_plugin_* + + # Verify nushell installation + echo " Verifying nushell installation..." + ~/.local/bin/nu --version + + # Register plugins with system nushell (with timeout and error handling) + echo " Registering plugins..." + echo " 💡 Waiting a moment for nushell to settle..." + sleep 2 + + for plugin in "$PLATFORM_DIR"/nu_plugin_*; do + plugin_name=$(basename "$plugin") + echo " Registering $plugin_name..." + + # Use timeout to prevent hanging processes, capture both stdout and stderr + if timeout 15 ~/.local/bin/nu -c "plugin add ~/.local/bin/$plugin_name" >/dev/null 2>&1; then + echo " ✅ $plugin_name registered successfully" + else + echo " ⚠️ Failed to register $plugin_name (timeout or error)" + # Try to continue with other plugins + fi + sleep 1 # Small delay between registrations + done + + # Verify installation + echo " Verifying installation..." + ~/.local/bin/nu -c "plugin list" | head -20 + + # Update PATH suggestion echo "" echo "✅ System installation completed!" - echo "💡 Plugins are installed in /usr/local/bin and registered with nushell" + echo "💡 Plugins are installed in ~/.local/bin and registered with nushell" + echo "💡 To use system-wide, add ~/.local/bin to your PATH:" + echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc" + echo " source ~/.zshrc" echo " Run 'plugin list' in nushell to see installed plugins" # Remove plugin from workspace @@ -406,7 +475,7 @@ tools-help: @echo " register-all-plugins - Register all built plugins with nushell" @echo " verify-plugins - Verify plugin registration status" @echo " install-local - Install plugins from distribution locally (no sudo)" - @echo " install-system - Install plugins to system from distribution (sudo)" + @echo " install-system - Install plugins to ~/.local/bin (no sudo)" @echo " remove-plugin PLUGIN - Remove plugin from workspace" @echo " list-plugins - List all plugins" @echo " plugin-info PLUGIN - Show plugin information" diff --git a/scripts/build_nushell.nu b/scripts/build_nushell.nu index 7b79873..6819e31 100755 --- a/scripts/build_nushell.nu +++ b/scripts/build_nushell.nu @@ -28,8 +28,9 @@ def main [ exit 1 } - # Build cargo command - mut cargo_cmd = ["cargo", "build"] + # Build cargo command with --workspace for system plugins + mut cargo_cmd = ["cargo", "build", "--workspace"] + log_info "📦 Building entire workspace (nushell + system plugins)" # Add build mode if $release != null { diff --git a/scripts/collect_full_binaries.nu b/scripts/collect_full_binaries.nu index 5c22963..4547c55 100755 --- a/scripts/collect_full_binaries.nu +++ b/scripts/collect_full_binaries.nu @@ -8,34 +8,41 @@ use lib/common_lib.nu [log_info, log_error, log_success, log_warn, validate_nush def main [ --platform (-p): string = "" # Target platform (e.g., linux-x86_64, darwin-arm64) --output (-o): string = "distribution" # Output directory - --force (-f): bool = false # Force overwrite existing files - --list (-l): bool = false # List available binaries - --list-platforms: bool = false # List available platforms - --all-platforms: bool = false # Collect for all available platforms - --include-nushell (-n): bool = true # Include nushell binary (default: true) - --release (-r): bool = false # Use release builds (default: debug) + --force (-f) # Force overwrite existing files + --list (-l) # List available binaries + --list-platforms # List available platforms + --all-platforms # Collect for all available platforms + --include-nushell (-n) # Include nushell binary (default: true) + --release (-r) # Use release builds (default: debug) --profile: string = "" # Build profile to use ] { + # Convert flags to variables for easier use + let force_flag = ($force | default false) + let list_flag = ($list | default false) + let list_platforms_flag = ($list_platforms | default false) + let all_platforms_flag = ($all_platforms | default false) + let include_nushell_flag = true # always include nushell binary by default + let release_flag = ($release | default false) # Validate nushell version consistency first validate_nushell_version - if $list_platforms { + if $list_platforms_flag { list_available_platforms return } - if $list { - list_available_binaries $platform $release $profile + if $list_flag { + list_available_binaries $platform $release_flag $profile return } - if $all_platforms { - collect_all_platforms $output $force $include_nushell $release $profile + if $all_platforms_flag { + collect_all_platforms $output $force_flag $include_nushell_flag $release_flag $profile return } # Collect binaries for specific or current platform - collect_binaries $platform $output $force $include_nushell $release $profile + collect_binaries $platform $output $force_flag $include_nushell_flag $release_flag $profile } # List available platforms for collection @@ -141,7 +148,7 @@ def collect_all_platforms [ try { collect_binaries $platform.target $output $force $include_nushell $use_release $profile } catch { |err| - log_error $"❌ Failed to collect ($platform.name): ($err.msg)" + log_error $"❌ Failed to collect ($platform.name): (($err | get msg | default 'Unknown error'))" } } @@ -248,7 +255,7 @@ def get_nushell_binary_info [ profile: string ]: nothing -> record { let nushell_dir = $"($env.PWD)/nushell" - let mut target_dir = $"($nushell_dir)/target" + mut target_dir = $"($nushell_dir)/target" # Handle cross-compilation targets let target_triple = convert_platform_to_target $platform @@ -257,7 +264,7 @@ def get_nushell_binary_info [ } # Determine profile directory - let mut profile_dir = if ($profile | is-not-empty) { + mut profile_dir = if ($profile | is-not-empty) { $profile } else if $use_release { "release" @@ -293,7 +300,7 @@ def get_workspace_plugins_info [ profile: string ]: nothing -> list { let nushell_dir = $"($env.PWD)/nushell" - let mut target_dir = $"($nushell_dir)/target" + mut target_dir = $"($nushell_dir)/target" # Handle cross-compilation targets let target_triple = convert_platform_to_target $platform @@ -302,7 +309,7 @@ def get_workspace_plugins_info [ } # Determine profile directory - let mut profile_dir = if ($profile | is-not-empty) { + mut profile_dir = if ($profile | is-not-empty) { $profile } else if $use_release { "release" @@ -354,7 +361,7 @@ def get_custom_plugins_info [ ]: nothing -> list { # Get list of plugin directories (nu_plugin_*) let plugin_dirs = ls nu_plugin_* - | where type == dir + | where type == "dir" | where name != "nushell" # Exclude nushell submodule | get name @@ -362,7 +369,7 @@ def get_custom_plugins_info [ let target_triple = convert_platform_to_target $platform for plugin_dir in $plugin_dirs { - let mut target_dir = $"($plugin_dir)/target" + mut target_dir = $"($plugin_dir)/target" # Handle cross-compilation targets if ($target_triple | is-not-empty) and $target_triple != (detect_current_target) { @@ -370,7 +377,7 @@ def get_custom_plugins_info [ } # Determine profile directory - let mut profile_dir = if ($profile | is-not-empty) { + mut profile_dir = if ($profile | is-not-empty) { $profile } else if $use_release { "release" @@ -449,7 +456,7 @@ def detect_available_platforms []: nothing -> list { # Check nushell target directory for built platforms let nushell_target = $"($env.PWD)/nushell/target" if ($nushell_target | path exists) { - let target_dirs = try { ls $nushell_target | where type == dir | get name } catch { [] } + let target_dirs = try { ls $nushell_target | where type == "dir" | get name } catch { [] } for target_dir in $target_dirs { if ($target_dir | str ends-with "target") { continue } # Skip base target dir @@ -568,7 +575,7 @@ def create_manifest [ if $includes_nushell { let nu_binary = ($files | where type == "nushell" | get 0) if ($nu_binary | is-not-empty) { - run-external $nu_binary.path "--version" | complete | get stdout | str trim + (run-external $nu_binary.path "--version" | complete | get stdout | str trim) } else { "unknown" } @@ -584,63 +591,63 @@ def create_manifest [ def create_installation_scripts [target_path: string] { # Create a basic installation script that registers plugins - let install_script = $"#!/usr/bin/env nu + let install_script = '#!/usr/bin/env nu # Installation script for nushell and plugins # This script registers all plugins with the nushell binary def main [ - --verify: bool = false # Verify installation after completion + --verify # Verify installation after completion ] { - print \"🚀 Installing Nushell and plugins...\" + print "🚀 Installing Nushell and plugins..." # Get current directory (should be the distribution directory) let dist_dir = $env.PWD # Find nushell binary - let nu_binary = if (\"nu\" | path exists) { - \"./nu\" - } else if (\"nu.exe\" | path exists) { - \"./nu.exe\" + let nu_binary = if ("nu" | path exists) { + "./nu" + } else if ("nu.exe" | path exists) { + "./nu.exe" } else { - print \"❌ Nushell binary not found in distribution\" + print "❌ Nushell binary not found in distribution" exit 1 } # Find plugin binaries - let plugins = ls . | where type == file | where name =~ \"nu_plugin_\" | get name + let plugins = ls . | where type == "file" | where name =~ "nu_plugin_" | get name - print $\"📦 Found ($plugins | length) plugins to register\" + print $"📦 Found ($plugins | length) plugins to register" # Register each plugin for plugin in $plugins { - print $\" Registering ($plugin)...\" + print $" Registering ($plugin)..." try { - run-external $nu_binary \"plugin\" \"add\" (\"./\" + $plugin) + run-external $nu_binary "plugin" "add" $"./($plugin)" } catch { |err| - print $\" ⚠️ Failed to register ($plugin): ($err.msg)\" + print $" ⚠️ Failed to register ($plugin): ($err.msg)" } } if $verify { - print \"🔍 Verifying installation...\" + print "🔍 Verifying installation..." try { - let plugin_list = run-external $nu_binary \"-c\" \"plugin list\" | complete + let plugin_list = run-external $nu_binary "-c" "plugin list" | complete if $plugin_list.exit_code == 0 { - print \"✅ Plugin verification successful\" + print "✅ Plugin verification successful" print $plugin_list.stdout } else { - print \"❌ Plugin verification failed\" + print "❌ Plugin verification failed" print $plugin_list.stderr } } catch { |err| - print $\"❌ Verification failed: ($err.msg)\" + print $"❌ Verification failed: ($err.msg)" } } - print \"✅ Installation complete!\" + print "✅ Installation complete!" } -" +' $install_script | save --force $"($target_path)/install.nu" chmod +x $"($target_path)/install.nu" @@ -649,7 +656,8 @@ def main [ def get_file_size [path: string]: nothing -> int { try { - ls $path | get size.0 + let file_info = ls $path | get 0 + $file_info.size } catch { 0 }