108 lines
2.9 KiB
Plaintext
108 lines
2.9 KiB
Plaintext
![]() |
#!/usr/bin/env nu
|
||
|
|
||
|
# Build All Plugins Script
|
||
|
# Builds all nu_plugin_* directories in release mode
|
||
|
|
||
|
# Version check - mandatory for all plugin operations
|
||
|
def version_check [] {
|
||
|
try {
|
||
|
nu scripts/check_version.nu --quiet | ignore
|
||
|
} catch {
|
||
|
print "❌ Nushell version mismatch detected!"
|
||
|
print "🔧 Run: nu scripts/check_version.nu --fix"
|
||
|
exit 1
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Get all plugin directories
|
||
|
def get_plugin_directories [] {
|
||
|
glob "nu_plugin_*" | where ($it | path type) == "dir"
|
||
|
}
|
||
|
|
||
|
# Build a single plugin
|
||
|
def build_plugin [plugin_dir: string] {
|
||
|
print $"🔨 Building ($plugin_dir)..."
|
||
|
|
||
|
try {
|
||
|
cd $plugin_dir
|
||
|
let result = cargo build --release
|
||
|
cd ..
|
||
|
print $"✅ Created ($plugin_dir)"
|
||
|
{plugin: $plugin_dir, status: "success", error: null}
|
||
|
} catch {|err|
|
||
|
cd ..
|
||
|
print $"❌ Error in ($plugin_dir): ($err.msg)"
|
||
|
{plugin: $plugin_dir, status: "error", error: $err.msg}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Main function
|
||
|
def main [
|
||
|
--verbose (-v) # Verbose output
|
||
|
--parallel (-p) # Build plugins in parallel (experimental)
|
||
|
] {
|
||
|
# Mandatory version check before any plugin operations
|
||
|
version_check
|
||
|
|
||
|
# Ensure we're in the repository root directory
|
||
|
if not ("nu_plugin_clipboard" | path exists) {
|
||
|
error make {msg: "Please run this script from the nushell-plugins repository root directory"}
|
||
|
}
|
||
|
|
||
|
print "🚀 Building all nushell plugins..."
|
||
|
|
||
|
let plugin_dirs = get_plugin_directories
|
||
|
|
||
|
if ($plugin_dirs | length) == 0 {
|
||
|
print "❓ No nu_plugin_* directories found"
|
||
|
return
|
||
|
}
|
||
|
|
||
|
print $"📦 Found ($plugin_dirs | length) plugins to build:"
|
||
|
for dir in $plugin_dirs {
|
||
|
print $" - ($dir)"
|
||
|
}
|
||
|
print ""
|
||
|
|
||
|
let start_time = date now
|
||
|
mut results = []
|
||
|
|
||
|
if $parallel {
|
||
|
# Experimental parallel building (may have issues with cargo lock)
|
||
|
print "⚡ Building in parallel mode (experimental)..."
|
||
|
$results = ($plugin_dirs | par-each {|dir| build_plugin $dir})
|
||
|
} else {
|
||
|
# Sequential building (safer)
|
||
|
for dir in $plugin_dirs {
|
||
|
let result = build_plugin $dir
|
||
|
$results = ($results | append $result)
|
||
|
print "---"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let end_time = date now
|
||
|
let duration = $end_time - $start_time
|
||
|
|
||
|
# Summary
|
||
|
print "\n📊 Build Summary:"
|
||
|
let successful = $results | where status == "success"
|
||
|
let failed = $results | where status == "error"
|
||
|
|
||
|
print $"✅ Successful: ($successful | length)"
|
||
|
print $"❌ Failed: ($failed | length)"
|
||
|
print $"⏱️ Total time: ($duration)"
|
||
|
|
||
|
if ($failed | length) > 0 {
|
||
|
print "\n❌ Failed builds:"
|
||
|
for failure in $failed {
|
||
|
print $" - ($failure.plugin): ($failure.error)"
|
||
|
}
|
||
|
exit 1
|
||
|
} else {
|
||
|
print "\n🎉 All plugins built successfully!"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($env.NUSHELL_EXECUTION_CONTEXT? | default "" | str contains "run") {
|
||
|
main
|
||
|
}
|