Nushell Scripts for webatui
Comprehensive automation scripts for building, testing, serving, and deploying the webatui project.
Prerequisites
- Nushell installed
- Rust and Cargo
- (Optional) wasm-pack for WASM builds
- (Optional) cargo-tarpaulin for coverage
- (Optional) Netlify/Vercel CLI for deployment
Scripts Overview
build.nu - Build Automation
Comprehensive build automation with support for multiple targets and WASM.
# Build in debug mode
nu scripts/build.nu
# Build in release mode
nu scripts/build.nu --release
# Build WASM with wasm-pack
nu scripts/build.nu --wasm --pack --release
# Build WASM and optimize
nu scripts/build.nu --wasm --release --optimize
# Build for specific target
nu scripts/build.nu --target x86_64-pc-windows-gnu --release
# Show help
nu scripts/build.nu --helpserve.nu - HTTP Server
Serve WASM builds locally with automatic server detection.
# Serve default directory (pkg) on port 8080
nu scripts/serve.nu
# Serve on custom port
nu scripts/serve.nu --port 3000
# Serve specific directory
nu scripts/serve.nu --dir www
# Open browser automatically
nu scripts/serve.nu --open
# Enable CORS for cross-origin requests
nu scripts/serve.nu --cors
# Enable SPA mode
nu scripts/serve.nu --spa --open
# Show help
nu scripts/serve.nu --helpSupported servers (auto-detected):
- Python 3 (built-in http.server)
- Python 2 (SimpleHTTPServer)
- basic-http-server (cargo install basic-http-server)
- http-server (npm install -g http-server)
deploy.nu - Deployment Automation
Deploy WASM builds to various hosting platforms.
# Deploy to GitHub Pages
nu scripts/deploy.nu
# Deploy to Netlify
nu scripts/deploy.nu --target netlify
# Deploy to Vercel
nu scripts/deploy.nu --target vercel
# Dry run to see what would be deployed
nu scripts/deploy.nu --dry-run
# Deploy with custom branch and message
nu scripts/deploy.nu --branch main --message "Update site"
# Show help
nu scripts/deploy.nu --helpDeployment targets:
- github-pages: Deploy to GitHub Pages (free, automatic HTTPS)
- netlify: Deploy to Netlify (requires Netlify CLI)
- vercel: Deploy to Vercel (requires Vercel CLI)
test.nu - Test Runner
Comprehensive test runner with coverage support.
# Run all tests
nu scripts/test.nu
# Run unit tests only
nu scripts/test.nu --unit
# Run tests matching pattern
nu scripts/test.nu --filter my_test_name
# Run tests with output
nu scripts/test.nu --nocapture
# Generate coverage report
nu scripts/test.nu --coverage
# Run WASM tests
nu scripts/test.nu --wasm
# Run benchmarks
nu scripts/test.nu --bench
# Show help
nu scripts/test.nu --helpclean.nu - Cleanup Automation
Clean build artifacts and temporary files.
# Clean everything
nu scripts/clean.nu --all
# Clean only cargo artifacts
nu scripts/clean.nu --cargo
# Clean WASM and cargo
nu scripts/clean.nu --wasm --cargo
# Dry run to see what would be deleted
nu scripts/clean.nu --all --dry-run
# Clean temporary files only
nu scripts/clean.nu --temp
# Show help
nu scripts/clean.nu --helpCleans:
target/- Cargo build artifactspkg/- WASM package outputnode_modules/- Node.js dependenciescoverage/- Coverage reports- Temporary files (*.swp, *~, .DS_Store, etc.)
Integration with justfile
These scripts are integrated with the project’s justfile:
# Using justfile commands (recommended)
just build-wasm
just serve
just deploy
just test
just clean
# Directly using nushell scripts
nu scripts/build.nu --wasm --release
nu scripts/serve.nu --open
nu scripts/deploy.nu
nu scripts/test.nu --coverage
nu scripts/clean.nu --allFeatures
Colorful Output
All scripts provide colorful, informative output:
- Green: Success messages
- Blue: Information messages
- Yellow: Warnings
- Red: Errors
- Cyan: Step headers
- Purple: Commands being executed
Error Handling
- Graceful error handling with informative messages
- Exit codes for CI/CD integration
- Tool availability checks before execution
Dry Run Support
deploy.nuandclean.nusupport--dry-runflag- See what would happen without making changes
Smart Tool Detection
- Automatically detects available tools (Python, Node.js servers, etc.)
- Fallback to alternative tools when primary tools aren’t available
- Helpful installation instructions when tools are missing
Installation of Optional Tools
WASM Tools
# WASM target
rustup target add wasm32-unknown-unknown
# wasm-pack (recommended)
cargo install wasm-pack
# wasm-bindgen-cli
cargo install wasm-bindgen-cli
# wasm-opt (for optimization)
cargo install wasm-optTesting Tools
# Coverage
cargo install cargo-tarpaulin
# Watch mode
cargo install cargo-watchHTTP Servers
# Rust-based server
cargo install basic-http-server
# Node.js-based server
npm install -g http-serverDeployment Tools
# Netlify CLI
npm install -g netlify-cli
netlify login
# Vercel CLI
npm install -g vercel
vercel loginExamples
Full Development Workflow
# 1. Build the project
nu scripts/build.nu --wasm --pack --release --optimize
# 2. Test locally
nu scripts/serve.nu --open --cors
# 3. Run tests
nu scripts/test.nu --all
# 4. Deploy
nu scripts/deploy.nu --target github-pagesCI/CD Pipeline
# Check
cargo check --all-targets
# Build
nu scripts/build.nu --release --wasm --pack
# Test with coverage
nu scripts/test.nu --coverage
# Deploy (only on main branch)
nu scripts/deploy.nu --target netlifyQuick Development Iteration
# Terminal 1: Watch and rebuild
cargo watch -x "build --target wasm32-unknown-unknown"
# Terminal 2: Serve with auto-reload
nu scripts/serve.nu --open --corsTips
-
Use justfile for common tasks: The justfile provides shorter commands and additional workflows.
-
Enable shell completion: Nushell provides excellent tab completion for command arguments.
-
Check help: Every script has a
--helpflag with detailed usage information. -
Dry run first: When using deploy or clean, use
--dry-runto see what will happen. -
Use colorful output: The scripts are designed to be readable with status-based colors.
Troubleshooting
Script doesn’t run
Make sure scripts are executable:
chmod +x scripts/*.nuNushell not found
Install Nushell:
# macOS
brew install nushell
# Linux
cargo install nu
# Windows
winget install nushellWASM build fails
Check WASM toolchain:
rustup target add wasm32-unknown-unknown
cargo install wasm-packServer won’t start
Install a HTTP server:
# Python 3 (usually pre-installed)
python3 --version
# Or install basic-http-server
cargo install basic-http-serverContributing
When adding new scripts:
- Follow the existing pattern for command-line arguments
- Add colorful output with utility functions
- Include comprehensive help message
- Add error checking for required tools
- Update this README
- Add corresponding justfile command
License
Same as parent project.