2025-09-24 18:52:07 +01:00
|
|
|
#!/usr/bin/env nu
|
|
|
|
|
|
|
|
|
|
# Collect Full Binaries Script
|
|
|
|
|
# Collects nushell binary, workspace plugins, and custom plugins for full distribution
|
|
|
|
|
|
|
|
|
|
use lib/common_lib.nu [log_info, log_error, log_success, log_warn, validate_nushell_version]
|
|
|
|
|
|
|
|
|
|
def main [
|
|
|
|
|
--platform (-p): string = "" # Target platform (e.g., linux-x86_64, darwin-arm64)
|
|
|
|
|
--output (-o): string = "distribution" # Output directory
|
2025-09-24 21:28:50 +01:00
|
|
|
--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)
|
2025-09-24 18:52:07 +01:00
|
|
|
--profile: string = "" # Build profile to use
|
|
|
|
|
] {
|
2025-09-24 21:28:50 +01:00
|
|
|
# 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)
|
# Summary
fix: help system integration, build process optimization, and plugin rebuild efficiency
## Detailed Description
This commit addresses critical issues in the help system discoverability, build process robustness, and plugin rebuild efficiency.
### 1. Help System Integration (New Feature)
**Issue**: Version-update module recipes were not discoverable
- Not shown in `just help modules`
- Not referenced in `just help`
- Not included in help navigation system
- Users had to manually run `just --list` to find update commands
**Solution**:
- Added version-update module to all help outputs
- Updated `justfiles/help.just` to document all 30+ version-update recipes
- Created new `just commands` recipe as discoverable alias for `just --list`
- Integrated version-update into help-all workflow
**Impact**:
- Version-update commands now fully discoverable via help system
- Users can find update commands with: `just help modules`, `just help`, `just commands`
- Improved overall help system navigation
**Files Modified**:
- `justfiles/help.just` (+23 lines)
- Added version-update module to help sections
- Added to modules list
- Added to help-all workflow
- New `commands` recipe showing all recipes by group
### 2. Build Process Fixes (Phase 3: Bin Archives)
#### 2a. Plugin Archive Collection Bug
**Issue**: "No plugins found to package" warning in Phase 3
- Collected 26 plugin binaries but reported 0
- Archive creation skipped because count was wrong
**Root Cause**: `each` command returns null, so `| length` returned 0
```nushell
# ❌ OLD - each returns null
let plugin_count = (ls nu_plugin_*/target/release/nu_plugin_* | each {|p|
cp $p.name $"($temp_dir)/"
} | length) # Returns 0!
```
**Solution**: Separated counting from copying with proper filtering
```nushell
# ✅ NEW - count before operations
let plugins_to_copy = (ls nu_plugin_*/target/release/nu_plugin_* | where type == "file")
let plugin_count = ($plugins_to_copy | length)
```
**Impact**:
- Now correctly collects and reports 26 plugins
- Filters out .d dependency files automatically
- Warning eliminated
#### 2b. Tar Archive Path Handling
**Issue**: Tar command failing silently with relative paths in subshell
- `cd $temp_dir` changes context unpredictably
- Relative path `../$archive_name` fails in subshell
- Archive file not created despite exit code 0
**Root Cause**: Shell context and relative path issues in Nushell `do` block
**Solution**: Used `tar -C` with absolute paths instead of `cd`
```nushell
# ❌ OLD - unreliable context switching
do {
cd $temp_dir
tar -czf ../$archive_name .
}
# ✅ NEW - absolute paths, no context switching
tar -C $temp_dir -czf $archive_path .
```
**Additional Improvements**:
- Absolute path construction using `pwd | path join`
- Better error diagnostics with exit code and stderr output
- File verification after creation
**Impact**:
- Tar archives now created successfully
- Robust path handling across platforms
- Clear error messages for debugging
#### 2c. File Size Calculation Type Error
**Issue**: Runtime error when calculating archive size
```
Error: The '/' operator does not work on values of type 'list<filesize>'
```
**Root Cause**: `ls` returns list of records, so `.size` was a list
```nushell
# ❌ OLD - returns list<filesize>
(ls $archive_path).size / 1024 / 1024
# ✅ NEW - returns filesize
(ls $archive_path | get 0.size) / 1024 / 1024
```
**Impact**:
- Proper file size calculation in MB
- No more type errors
**Files Modified**:
- `scripts/create_full_distribution.nu` (+58 lines, refactored plugin collection)
- Fixed plugin counting logic
- Improved path handling with absolute paths
- Enhanced error diagnostics
### 3. Plugin Rebuild Optimization
**Issue**: All plugins marked for rebuild even when dependencies unchanged
- Step 4 (`update_all_plugins.nu`) touched all Cargo.toml files at 01:00:32
- Step 5 saw all files as "newer" than binaries
- Marked ALL plugins for rebuild, though cargo only rebuilt changed ones
**Root Cause**: Script always saved files, even when no changes made
```nushell
# ❌ OLD - always saves, touching file timestamp
$updated_content | to toml | save -f $cargo_toml
```
**Solution**: Only save if content actually changed
```nushell
# ✅ NEW - compare before writing
let original_toml = $content | to toml
let new_toml = $updated_content | to toml
if $original_toml != $new_toml {
$updated_content | to toml | save -f $cargo_toml
}
```
**Impact**:
- Unchanged files preserve original timestamps
- Only plugins with actual dependency changes are rebuilt
- Efficient rebuild process with accurate file modification detection
**Files Modified**:
- `scripts/update_all_plugins.nu` (+12 lines, added content comparison)
- Only touches files with real changes
- Preserves timestamps for efficiency
- Clearer logic and comments
### 4. Documentation
**Files Modified**:
- `CHANGELOG.md` (+56 lines)
- Added comprehensive 2025-10-19 entry
- Documented all fixes with root causes
- Listed files modified and impact summary
## Technical Details
### Nushell Patterns Used
1. **Proper List Handling**:
- `ls` returns list of records, access with `| get 0.size`
- Filter with `where type == "file"` to exclude metadata
2. **Absolute Path Construction**:
- `pwd | append "path" | path join` for cross-platform paths
- Safer than string concatenation with `/`
3. **Content Comparison**:
- Compare TOML string representation before saving
- Preserves file timestamps for efficiency
4. **Error Diagnostics**:
- Capture `stderr` from commands
- Report exit codes and error messages separately
## Testing
- [x] Help system shows version-update module
- [x] `just commands` displays all recipes by group
- [x] Phase 3 bin archive creation works
- [x] Plugin collection reports correct count (26)
- [x] Tar archives created successfully
- [x] File size calculated correctly
- [x] Plugin rebuild only touches changed files
- [x] CHANGELOG updated with all changes
## Files Changed
```
38 files changed, 2721 insertions(+), 2548 deletions(-)
Core Changes:
- justfiles/help.just (+23) Help system integration
- scripts/create_full_distribution.nu (+58) Build process fixes
- scripts/update_all_plugins.nu (+12) Rebuild optimization
- CHANGELOG.md (+56) Documentation
Dependency Updates:
- All plugin Cargo.toml and Cargo.lock files (version consistency)
```
## Breaking Changes
None. These are bug fixes and optimizations that maintain backward compatibility.
## Migration Notes
No migration needed. Improvements are transparent to users.
## Related Issues
- Help system discoverability
- Build process Phase 3 failures
- Unnecessary plugin rebuilds
- Build process reliability
## Checklist
- [x] Changes follow Rust/Nushell idioms
- [x] Code is well-commented
- [x] Error handling is comprehensive
- [x] Documentation is updated
- [x] All changes tested
- [x] No breaking changes introduced
2025-10-19 01:17:13 +01:00
|
|
|
|
|
|
|
|
# Skip validate_nushell_version when in automation (system nu may be broken)
|
|
|
|
|
# Validation already done in previous steps of complete-update workflow
|
2025-09-24 18:52:07 +01:00
|
|
|
|
2025-09-24 21:28:50 +01:00
|
|
|
if $list_platforms_flag {
|
2025-09-24 18:52:07 +01:00
|
|
|
list_available_platforms
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-24 21:28:50 +01:00
|
|
|
if $list_flag {
|
|
|
|
|
list_available_binaries $platform $release_flag $profile
|
2025-09-24 18:52:07 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-24 21:28:50 +01:00
|
|
|
if $all_platforms_flag {
|
|
|
|
|
collect_all_platforms $output $force_flag $include_nushell_flag $release_flag $profile
|
2025-09-24 18:52:07 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Collect binaries for specific or current platform
|
2025-09-24 21:28:50 +01:00
|
|
|
collect_binaries $platform $output $force_flag $include_nushell_flag $release_flag $profile
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# List available platforms for collection
|
|
|
|
|
def list_available_platforms [] {
|
|
|
|
|
log_info "🌍 Available platforms for collection:"
|
|
|
|
|
log_info "===================================="
|
|
|
|
|
|
|
|
|
|
let platforms = detect_available_platforms
|
|
|
|
|
|
|
|
|
|
if ($platforms | is-empty) {
|
|
|
|
|
log_warn "⚠️ No built binaries found. Build plugins first with 'just build' or 'just build-cross-all'"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for platform in $platforms {
|
|
|
|
|
log_info $" ✅ ($platform.name)"
|
|
|
|
|
log_info $" Target: ($platform.target)"
|
|
|
|
|
log_info $" Nushell: ($platform.has_nushell)"
|
|
|
|
|
log_info $" Plugins: ($platform.plugin_count)"
|
|
|
|
|
log_info ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# List available binaries for a platform
|
|
|
|
|
def list_available_binaries [
|
|
|
|
|
platform: string
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
] {
|
|
|
|
|
log_info "📋 Available binaries:"
|
|
|
|
|
log_info "====================="
|
|
|
|
|
|
|
|
|
|
let current_platform = if ($platform | is-empty) {
|
|
|
|
|
detect_current_platform
|
|
|
|
|
} else {
|
|
|
|
|
$platform
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_info $"Platform: ($current_platform)"
|
|
|
|
|
log_info ""
|
|
|
|
|
|
|
|
|
|
# Check nushell binary
|
|
|
|
|
let nushell_info = get_nushell_binary_info $current_platform $use_release $profile
|
|
|
|
|
if ($nushell_info | is-not-empty) {
|
|
|
|
|
log_info "🚀 Nushell Binary:"
|
|
|
|
|
log_info $" Path: ($nushell_info.path)"
|
|
|
|
|
log_info $" Size: ($nushell_info.size)"
|
|
|
|
|
log_info $" Modified: ($nushell_info.modified)"
|
|
|
|
|
log_info ""
|
|
|
|
|
} else {
|
|
|
|
|
log_warn "⚠️ Nushell binary not found for this platform"
|
|
|
|
|
log_info ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check workspace plugins
|
|
|
|
|
let workspace_plugins = get_workspace_plugins_info $current_platform $use_release $profile
|
|
|
|
|
if not ($workspace_plugins | is-empty) {
|
|
|
|
|
log_info "🧩 Workspace Plugins:"
|
|
|
|
|
for plugin in $workspace_plugins {
|
|
|
|
|
log_info $" ✅ ($plugin.name) - ($plugin.size)"
|
|
|
|
|
}
|
|
|
|
|
log_info ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check custom plugins
|
|
|
|
|
let custom_plugins = get_custom_plugins_info $current_platform $use_release $profile
|
|
|
|
|
if not ($custom_plugins | is-empty) {
|
|
|
|
|
log_info "🔧 Custom Plugins:"
|
|
|
|
|
for plugin in $custom_plugins {
|
|
|
|
|
log_info $" ✅ ($plugin.name) - ($plugin.size)"
|
|
|
|
|
}
|
|
|
|
|
log_info ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let total_count = (
|
|
|
|
|
($workspace_plugins | length) +
|
|
|
|
|
($custom_plugins | length) +
|
|
|
|
|
(if ($nushell_info | is-not-empty) { 1 } else { 0 })
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
log_info $"📊 Total binaries: ($total_count)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Collect binaries for all platforms
|
|
|
|
|
def collect_all_platforms [
|
|
|
|
|
output: string
|
|
|
|
|
force: bool
|
|
|
|
|
include_nushell: bool
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
] {
|
|
|
|
|
log_info "🌍 Collecting binaries for all platforms..."
|
|
|
|
|
|
|
|
|
|
let platforms = detect_available_platforms
|
|
|
|
|
|
|
|
|
|
if ($platforms | is-empty) {
|
|
|
|
|
log_error "❌ No built binaries found. Build first with 'just build-cross-all'"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for platform in $platforms {
|
|
|
|
|
log_info $"📦 Collecting for ($platform.name)..."
|
|
|
|
|
try {
|
|
|
|
|
collect_binaries $platform.target $output $force $include_nushell $use_release $profile
|
|
|
|
|
} catch { |err|
|
2025-09-24 21:28:50 +01:00
|
|
|
log_error $"❌ Failed to collect ($platform.name): (($err | get msg | default 'Unknown error'))"
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_success "✅ Collection complete for all platforms"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Main collection function
|
|
|
|
|
def collect_binaries [
|
|
|
|
|
platform: string
|
|
|
|
|
output: string
|
|
|
|
|
force: bool
|
|
|
|
|
include_nushell: bool
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
] {
|
|
|
|
|
let target_platform = if ($platform | is-empty) {
|
|
|
|
|
detect_current_platform
|
|
|
|
|
} else {
|
|
|
|
|
$platform
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_info $"📦 Collecting binaries for platform: ($target_platform)"
|
|
|
|
|
|
|
|
|
|
# Create output structure
|
|
|
|
|
let platform_dir = $"($output)/($target_platform)"
|
|
|
|
|
create_target_structure $platform_dir $force
|
|
|
|
|
|
|
|
|
|
mut collected_files = []
|
|
|
|
|
|
|
|
|
|
# Collect nushell binary if requested
|
|
|
|
|
if $include_nushell {
|
# Summary
fix: help system integration, build process optimization, and plugin rebuild efficiency
## Detailed Description
This commit addresses critical issues in the help system discoverability, build process robustness, and plugin rebuild efficiency.
### 1. Help System Integration (New Feature)
**Issue**: Version-update module recipes were not discoverable
- Not shown in `just help modules`
- Not referenced in `just help`
- Not included in help navigation system
- Users had to manually run `just --list` to find update commands
**Solution**:
- Added version-update module to all help outputs
- Updated `justfiles/help.just` to document all 30+ version-update recipes
- Created new `just commands` recipe as discoverable alias for `just --list`
- Integrated version-update into help-all workflow
**Impact**:
- Version-update commands now fully discoverable via help system
- Users can find update commands with: `just help modules`, `just help`, `just commands`
- Improved overall help system navigation
**Files Modified**:
- `justfiles/help.just` (+23 lines)
- Added version-update module to help sections
- Added to modules list
- Added to help-all workflow
- New `commands` recipe showing all recipes by group
### 2. Build Process Fixes (Phase 3: Bin Archives)
#### 2a. Plugin Archive Collection Bug
**Issue**: "No plugins found to package" warning in Phase 3
- Collected 26 plugin binaries but reported 0
- Archive creation skipped because count was wrong
**Root Cause**: `each` command returns null, so `| length` returned 0
```nushell
# ❌ OLD - each returns null
let plugin_count = (ls nu_plugin_*/target/release/nu_plugin_* | each {|p|
cp $p.name $"($temp_dir)/"
} | length) # Returns 0!
```
**Solution**: Separated counting from copying with proper filtering
```nushell
# ✅ NEW - count before operations
let plugins_to_copy = (ls nu_plugin_*/target/release/nu_plugin_* | where type == "file")
let plugin_count = ($plugins_to_copy | length)
```
**Impact**:
- Now correctly collects and reports 26 plugins
- Filters out .d dependency files automatically
- Warning eliminated
#### 2b. Tar Archive Path Handling
**Issue**: Tar command failing silently with relative paths in subshell
- `cd $temp_dir` changes context unpredictably
- Relative path `../$archive_name` fails in subshell
- Archive file not created despite exit code 0
**Root Cause**: Shell context and relative path issues in Nushell `do` block
**Solution**: Used `tar -C` with absolute paths instead of `cd`
```nushell
# ❌ OLD - unreliable context switching
do {
cd $temp_dir
tar -czf ../$archive_name .
}
# ✅ NEW - absolute paths, no context switching
tar -C $temp_dir -czf $archive_path .
```
**Additional Improvements**:
- Absolute path construction using `pwd | path join`
- Better error diagnostics with exit code and stderr output
- File verification after creation
**Impact**:
- Tar archives now created successfully
- Robust path handling across platforms
- Clear error messages for debugging
#### 2c. File Size Calculation Type Error
**Issue**: Runtime error when calculating archive size
```
Error: The '/' operator does not work on values of type 'list<filesize>'
```
**Root Cause**: `ls` returns list of records, so `.size` was a list
```nushell
# ❌ OLD - returns list<filesize>
(ls $archive_path).size / 1024 / 1024
# ✅ NEW - returns filesize
(ls $archive_path | get 0.size) / 1024 / 1024
```
**Impact**:
- Proper file size calculation in MB
- No more type errors
**Files Modified**:
- `scripts/create_full_distribution.nu` (+58 lines, refactored plugin collection)
- Fixed plugin counting logic
- Improved path handling with absolute paths
- Enhanced error diagnostics
### 3. Plugin Rebuild Optimization
**Issue**: All plugins marked for rebuild even when dependencies unchanged
- Step 4 (`update_all_plugins.nu`) touched all Cargo.toml files at 01:00:32
- Step 5 saw all files as "newer" than binaries
- Marked ALL plugins for rebuild, though cargo only rebuilt changed ones
**Root Cause**: Script always saved files, even when no changes made
```nushell
# ❌ OLD - always saves, touching file timestamp
$updated_content | to toml | save -f $cargo_toml
```
**Solution**: Only save if content actually changed
```nushell
# ✅ NEW - compare before writing
let original_toml = $content | to toml
let new_toml = $updated_content | to toml
if $original_toml != $new_toml {
$updated_content | to toml | save -f $cargo_toml
}
```
**Impact**:
- Unchanged files preserve original timestamps
- Only plugins with actual dependency changes are rebuilt
- Efficient rebuild process with accurate file modification detection
**Files Modified**:
- `scripts/update_all_plugins.nu` (+12 lines, added content comparison)
- Only touches files with real changes
- Preserves timestamps for efficiency
- Clearer logic and comments
### 4. Documentation
**Files Modified**:
- `CHANGELOG.md` (+56 lines)
- Added comprehensive 2025-10-19 entry
- Documented all fixes with root causes
- Listed files modified and impact summary
## Technical Details
### Nushell Patterns Used
1. **Proper List Handling**:
- `ls` returns list of records, access with `| get 0.size`
- Filter with `where type == "file"` to exclude metadata
2. **Absolute Path Construction**:
- `pwd | append "path" | path join` for cross-platform paths
- Safer than string concatenation with `/`
3. **Content Comparison**:
- Compare TOML string representation before saving
- Preserves file timestamps for efficiency
4. **Error Diagnostics**:
- Capture `stderr` from commands
- Report exit codes and error messages separately
## Testing
- [x] Help system shows version-update module
- [x] `just commands` displays all recipes by group
- [x] Phase 3 bin archive creation works
- [x] Plugin collection reports correct count (26)
- [x] Tar archives created successfully
- [x] File size calculated correctly
- [x] Plugin rebuild only touches changed files
- [x] CHANGELOG updated with all changes
## Files Changed
```
38 files changed, 2721 insertions(+), 2548 deletions(-)
Core Changes:
- justfiles/help.just (+23) Help system integration
- scripts/create_full_distribution.nu (+58) Build process fixes
- scripts/update_all_plugins.nu (+12) Rebuild optimization
- CHANGELOG.md (+56) Documentation
Dependency Updates:
- All plugin Cargo.toml and Cargo.lock files (version consistency)
```
## Breaking Changes
None. These are bug fixes and optimizations that maintain backward compatibility.
## Migration Notes
No migration needed. Improvements are transparent to users.
## Related Issues
- Help system discoverability
- Build process Phase 3 failures
- Unnecessary plugin rebuilds
- Build process reliability
## Checklist
- [x] Changes follow Rust/Nushell idioms
- [x] Code is well-commented
- [x] Error handling is comprehensive
- [x] Documentation is updated
- [x] All changes tested
- [x] No breaking changes introduced
2025-10-19 01:17:13 +01:00
|
|
|
# Try direct path first (for automation workflow)
|
|
|
|
|
let direct_path = "./nushell/target/release/nu"
|
|
|
|
|
let nushell_source = if ($direct_path | path exists) {
|
|
|
|
|
$direct_path
|
|
|
|
|
} else {
|
|
|
|
|
# Fall back to cross-compilation aware lookup
|
|
|
|
|
let info = get_nushell_binary_info $target_platform $use_release $profile
|
|
|
|
|
if ($info | is-not-empty) { $info.path } else { "" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($nushell_source | is-not-empty) and ($nushell_source | path exists) {
|
2025-09-24 18:52:07 +01:00
|
|
|
let dest_path = $"($platform_dir)/nu"
|
|
|
|
|
let dest_path = if $nu.os-info.name == "windows" { $"($dest_path).exe" } else { $dest_path }
|
|
|
|
|
|
# Summary
fix: help system integration, build process optimization, and plugin rebuild efficiency
## Detailed Description
This commit addresses critical issues in the help system discoverability, build process robustness, and plugin rebuild efficiency.
### 1. Help System Integration (New Feature)
**Issue**: Version-update module recipes were not discoverable
- Not shown in `just help modules`
- Not referenced in `just help`
- Not included in help navigation system
- Users had to manually run `just --list` to find update commands
**Solution**:
- Added version-update module to all help outputs
- Updated `justfiles/help.just` to document all 30+ version-update recipes
- Created new `just commands` recipe as discoverable alias for `just --list`
- Integrated version-update into help-all workflow
**Impact**:
- Version-update commands now fully discoverable via help system
- Users can find update commands with: `just help modules`, `just help`, `just commands`
- Improved overall help system navigation
**Files Modified**:
- `justfiles/help.just` (+23 lines)
- Added version-update module to help sections
- Added to modules list
- Added to help-all workflow
- New `commands` recipe showing all recipes by group
### 2. Build Process Fixes (Phase 3: Bin Archives)
#### 2a. Plugin Archive Collection Bug
**Issue**: "No plugins found to package" warning in Phase 3
- Collected 26 plugin binaries but reported 0
- Archive creation skipped because count was wrong
**Root Cause**: `each` command returns null, so `| length` returned 0
```nushell
# ❌ OLD - each returns null
let plugin_count = (ls nu_plugin_*/target/release/nu_plugin_* | each {|p|
cp $p.name $"($temp_dir)/"
} | length) # Returns 0!
```
**Solution**: Separated counting from copying with proper filtering
```nushell
# ✅ NEW - count before operations
let plugins_to_copy = (ls nu_plugin_*/target/release/nu_plugin_* | where type == "file")
let plugin_count = ($plugins_to_copy | length)
```
**Impact**:
- Now correctly collects and reports 26 plugins
- Filters out .d dependency files automatically
- Warning eliminated
#### 2b. Tar Archive Path Handling
**Issue**: Tar command failing silently with relative paths in subshell
- `cd $temp_dir` changes context unpredictably
- Relative path `../$archive_name` fails in subshell
- Archive file not created despite exit code 0
**Root Cause**: Shell context and relative path issues in Nushell `do` block
**Solution**: Used `tar -C` with absolute paths instead of `cd`
```nushell
# ❌ OLD - unreliable context switching
do {
cd $temp_dir
tar -czf ../$archive_name .
}
# ✅ NEW - absolute paths, no context switching
tar -C $temp_dir -czf $archive_path .
```
**Additional Improvements**:
- Absolute path construction using `pwd | path join`
- Better error diagnostics with exit code and stderr output
- File verification after creation
**Impact**:
- Tar archives now created successfully
- Robust path handling across platforms
- Clear error messages for debugging
#### 2c. File Size Calculation Type Error
**Issue**: Runtime error when calculating archive size
```
Error: The '/' operator does not work on values of type 'list<filesize>'
```
**Root Cause**: `ls` returns list of records, so `.size` was a list
```nushell
# ❌ OLD - returns list<filesize>
(ls $archive_path).size / 1024 / 1024
# ✅ NEW - returns filesize
(ls $archive_path | get 0.size) / 1024 / 1024
```
**Impact**:
- Proper file size calculation in MB
- No more type errors
**Files Modified**:
- `scripts/create_full_distribution.nu` (+58 lines, refactored plugin collection)
- Fixed plugin counting logic
- Improved path handling with absolute paths
- Enhanced error diagnostics
### 3. Plugin Rebuild Optimization
**Issue**: All plugins marked for rebuild even when dependencies unchanged
- Step 4 (`update_all_plugins.nu`) touched all Cargo.toml files at 01:00:32
- Step 5 saw all files as "newer" than binaries
- Marked ALL plugins for rebuild, though cargo only rebuilt changed ones
**Root Cause**: Script always saved files, even when no changes made
```nushell
# ❌ OLD - always saves, touching file timestamp
$updated_content | to toml | save -f $cargo_toml
```
**Solution**: Only save if content actually changed
```nushell
# ✅ NEW - compare before writing
let original_toml = $content | to toml
let new_toml = $updated_content | to toml
if $original_toml != $new_toml {
$updated_content | to toml | save -f $cargo_toml
}
```
**Impact**:
- Unchanged files preserve original timestamps
- Only plugins with actual dependency changes are rebuilt
- Efficient rebuild process with accurate file modification detection
**Files Modified**:
- `scripts/update_all_plugins.nu` (+12 lines, added content comparison)
- Only touches files with real changes
- Preserves timestamps for efficiency
- Clearer logic and comments
### 4. Documentation
**Files Modified**:
- `CHANGELOG.md` (+56 lines)
- Added comprehensive 2025-10-19 entry
- Documented all fixes with root causes
- Listed files modified and impact summary
## Technical Details
### Nushell Patterns Used
1. **Proper List Handling**:
- `ls` returns list of records, access with `| get 0.size`
- Filter with `where type == "file"` to exclude metadata
2. **Absolute Path Construction**:
- `pwd | append "path" | path join` for cross-platform paths
- Safer than string concatenation with `/`
3. **Content Comparison**:
- Compare TOML string representation before saving
- Preserves file timestamps for efficiency
4. **Error Diagnostics**:
- Capture `stderr` from commands
- Report exit codes and error messages separately
## Testing
- [x] Help system shows version-update module
- [x] `just commands` displays all recipes by group
- [x] Phase 3 bin archive creation works
- [x] Plugin collection reports correct count (26)
- [x] Tar archives created successfully
- [x] File size calculated correctly
- [x] Plugin rebuild only touches changed files
- [x] CHANGELOG updated with all changes
## Files Changed
```
38 files changed, 2721 insertions(+), 2548 deletions(-)
Core Changes:
- justfiles/help.just (+23) Help system integration
- scripts/create_full_distribution.nu (+58) Build process fixes
- scripts/update_all_plugins.nu (+12) Rebuild optimization
- CHANGELOG.md (+56) Documentation
Dependency Updates:
- All plugin Cargo.toml and Cargo.lock files (version consistency)
```
## Breaking Changes
None. These are bug fixes and optimizations that maintain backward compatibility.
## Migration Notes
No migration needed. Improvements are transparent to users.
## Related Issues
- Help system discoverability
- Build process Phase 3 failures
- Unnecessary plugin rebuilds
- Build process reliability
## Checklist
- [x] Changes follow Rust/Nushell idioms
- [x] Code is well-commented
- [x] Error handling is comprehensive
- [x] Documentation is updated
- [x] All changes tested
- [x] No breaking changes introduced
2025-10-19 01:17:13 +01:00
|
|
|
copy_binary $nushell_source $dest_path $force
|
2025-09-24 18:52:07 +01:00
|
|
|
$collected_files = ($collected_files | append {
|
|
|
|
|
name: "nu"
|
|
|
|
|
type: "nushell"
|
|
|
|
|
path: $dest_path
|
|
|
|
|
size: (get_file_size $dest_path)
|
|
|
|
|
})
|
|
|
|
|
log_success $"✅ Collected nushell binary"
|
|
|
|
|
} else {
|
# Summary
fix: help system integration, build process optimization, and plugin rebuild efficiency
## Detailed Description
This commit addresses critical issues in the help system discoverability, build process robustness, and plugin rebuild efficiency.
### 1. Help System Integration (New Feature)
**Issue**: Version-update module recipes were not discoverable
- Not shown in `just help modules`
- Not referenced in `just help`
- Not included in help navigation system
- Users had to manually run `just --list` to find update commands
**Solution**:
- Added version-update module to all help outputs
- Updated `justfiles/help.just` to document all 30+ version-update recipes
- Created new `just commands` recipe as discoverable alias for `just --list`
- Integrated version-update into help-all workflow
**Impact**:
- Version-update commands now fully discoverable via help system
- Users can find update commands with: `just help modules`, `just help`, `just commands`
- Improved overall help system navigation
**Files Modified**:
- `justfiles/help.just` (+23 lines)
- Added version-update module to help sections
- Added to modules list
- Added to help-all workflow
- New `commands` recipe showing all recipes by group
### 2. Build Process Fixes (Phase 3: Bin Archives)
#### 2a. Plugin Archive Collection Bug
**Issue**: "No plugins found to package" warning in Phase 3
- Collected 26 plugin binaries but reported 0
- Archive creation skipped because count was wrong
**Root Cause**: `each` command returns null, so `| length` returned 0
```nushell
# ❌ OLD - each returns null
let plugin_count = (ls nu_plugin_*/target/release/nu_plugin_* | each {|p|
cp $p.name $"($temp_dir)/"
} | length) # Returns 0!
```
**Solution**: Separated counting from copying with proper filtering
```nushell
# ✅ NEW - count before operations
let plugins_to_copy = (ls nu_plugin_*/target/release/nu_plugin_* | where type == "file")
let plugin_count = ($plugins_to_copy | length)
```
**Impact**:
- Now correctly collects and reports 26 plugins
- Filters out .d dependency files automatically
- Warning eliminated
#### 2b. Tar Archive Path Handling
**Issue**: Tar command failing silently with relative paths in subshell
- `cd $temp_dir` changes context unpredictably
- Relative path `../$archive_name` fails in subshell
- Archive file not created despite exit code 0
**Root Cause**: Shell context and relative path issues in Nushell `do` block
**Solution**: Used `tar -C` with absolute paths instead of `cd`
```nushell
# ❌ OLD - unreliable context switching
do {
cd $temp_dir
tar -czf ../$archive_name .
}
# ✅ NEW - absolute paths, no context switching
tar -C $temp_dir -czf $archive_path .
```
**Additional Improvements**:
- Absolute path construction using `pwd | path join`
- Better error diagnostics with exit code and stderr output
- File verification after creation
**Impact**:
- Tar archives now created successfully
- Robust path handling across platforms
- Clear error messages for debugging
#### 2c. File Size Calculation Type Error
**Issue**: Runtime error when calculating archive size
```
Error: The '/' operator does not work on values of type 'list<filesize>'
```
**Root Cause**: `ls` returns list of records, so `.size` was a list
```nushell
# ❌ OLD - returns list<filesize>
(ls $archive_path).size / 1024 / 1024
# ✅ NEW - returns filesize
(ls $archive_path | get 0.size) / 1024 / 1024
```
**Impact**:
- Proper file size calculation in MB
- No more type errors
**Files Modified**:
- `scripts/create_full_distribution.nu` (+58 lines, refactored plugin collection)
- Fixed plugin counting logic
- Improved path handling with absolute paths
- Enhanced error diagnostics
### 3. Plugin Rebuild Optimization
**Issue**: All plugins marked for rebuild even when dependencies unchanged
- Step 4 (`update_all_plugins.nu`) touched all Cargo.toml files at 01:00:32
- Step 5 saw all files as "newer" than binaries
- Marked ALL plugins for rebuild, though cargo only rebuilt changed ones
**Root Cause**: Script always saved files, even when no changes made
```nushell
# ❌ OLD - always saves, touching file timestamp
$updated_content | to toml | save -f $cargo_toml
```
**Solution**: Only save if content actually changed
```nushell
# ✅ NEW - compare before writing
let original_toml = $content | to toml
let new_toml = $updated_content | to toml
if $original_toml != $new_toml {
$updated_content | to toml | save -f $cargo_toml
}
```
**Impact**:
- Unchanged files preserve original timestamps
- Only plugins with actual dependency changes are rebuilt
- Efficient rebuild process with accurate file modification detection
**Files Modified**:
- `scripts/update_all_plugins.nu` (+12 lines, added content comparison)
- Only touches files with real changes
- Preserves timestamps for efficiency
- Clearer logic and comments
### 4. Documentation
**Files Modified**:
- `CHANGELOG.md` (+56 lines)
- Added comprehensive 2025-10-19 entry
- Documented all fixes with root causes
- Listed files modified and impact summary
## Technical Details
### Nushell Patterns Used
1. **Proper List Handling**:
- `ls` returns list of records, access with `| get 0.size`
- Filter with `where type == "file"` to exclude metadata
2. **Absolute Path Construction**:
- `pwd | append "path" | path join` for cross-platform paths
- Safer than string concatenation with `/`
3. **Content Comparison**:
- Compare TOML string representation before saving
- Preserves file timestamps for efficiency
4. **Error Diagnostics**:
- Capture `stderr` from commands
- Report exit codes and error messages separately
## Testing
- [x] Help system shows version-update module
- [x] `just commands` displays all recipes by group
- [x] Phase 3 bin archive creation works
- [x] Plugin collection reports correct count (26)
- [x] Tar archives created successfully
- [x] File size calculated correctly
- [x] Plugin rebuild only touches changed files
- [x] CHANGELOG updated with all changes
## Files Changed
```
38 files changed, 2721 insertions(+), 2548 deletions(-)
Core Changes:
- justfiles/help.just (+23) Help system integration
- scripts/create_full_distribution.nu (+58) Build process fixes
- scripts/update_all_plugins.nu (+12) Rebuild optimization
- CHANGELOG.md (+56) Documentation
Dependency Updates:
- All plugin Cargo.toml and Cargo.lock files (version consistency)
```
## Breaking Changes
None. These are bug fixes and optimizations that maintain backward compatibility.
## Migration Notes
No migration needed. Improvements are transparent to users.
## Related Issues
- Help system discoverability
- Build process Phase 3 failures
- Unnecessary plugin rebuilds
- Build process reliability
## Checklist
- [x] Changes follow Rust/Nushell idioms
- [x] Code is well-commented
- [x] Error handling is comprehensive
- [x] Documentation is updated
- [x] All changes tested
- [x] No breaking changes introduced
2025-10-19 01:17:13 +01:00
|
|
|
log_warn $"⚠️ Nushell binary not found - skipping"
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Collect workspace plugins
|
|
|
|
|
let workspace_plugins = get_workspace_plugins_info $target_platform $use_release $profile
|
|
|
|
|
for plugin in $workspace_plugins {
|
|
|
|
|
let dest_path = $"($platform_dir)/($plugin.name)"
|
|
|
|
|
copy_binary $plugin.path $dest_path $force
|
|
|
|
|
$collected_files = ($collected_files | append {
|
|
|
|
|
name: $plugin.name
|
|
|
|
|
type: "workspace_plugin"
|
|
|
|
|
path: $dest_path
|
|
|
|
|
size: (get_file_size $dest_path)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Collect custom plugins
|
|
|
|
|
let custom_plugins = get_custom_plugins_info $target_platform $use_release $profile
|
|
|
|
|
for plugin in $custom_plugins {
|
|
|
|
|
let dest_path = $"($platform_dir)/($plugin.name)"
|
|
|
|
|
copy_binary $plugin.path $dest_path $force
|
|
|
|
|
$collected_files = ($collected_files | append {
|
|
|
|
|
name: $plugin.name
|
|
|
|
|
type: "custom_plugin"
|
|
|
|
|
path: $dest_path
|
|
|
|
|
size: (get_file_size $dest_path)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Copy additional files
|
|
|
|
|
copy_additional_files $platform_dir $force
|
|
|
|
|
|
|
|
|
|
# Create manifest
|
|
|
|
|
create_manifest $platform_dir $target_platform $collected_files $include_nushell
|
|
|
|
|
|
|
|
|
|
# Create installation script
|
|
|
|
|
create_installation_scripts $platform_dir
|
|
|
|
|
|
|
|
|
|
# Summary
|
# Summary
fix: help system integration, build process optimization, and plugin rebuild efficiency
## Detailed Description
This commit addresses critical issues in the help system discoverability, build process robustness, and plugin rebuild efficiency.
### 1. Help System Integration (New Feature)
**Issue**: Version-update module recipes were not discoverable
- Not shown in `just help modules`
- Not referenced in `just help`
- Not included in help navigation system
- Users had to manually run `just --list` to find update commands
**Solution**:
- Added version-update module to all help outputs
- Updated `justfiles/help.just` to document all 30+ version-update recipes
- Created new `just commands` recipe as discoverable alias for `just --list`
- Integrated version-update into help-all workflow
**Impact**:
- Version-update commands now fully discoverable via help system
- Users can find update commands with: `just help modules`, `just help`, `just commands`
- Improved overall help system navigation
**Files Modified**:
- `justfiles/help.just` (+23 lines)
- Added version-update module to help sections
- Added to modules list
- Added to help-all workflow
- New `commands` recipe showing all recipes by group
### 2. Build Process Fixes (Phase 3: Bin Archives)
#### 2a. Plugin Archive Collection Bug
**Issue**: "No plugins found to package" warning in Phase 3
- Collected 26 plugin binaries but reported 0
- Archive creation skipped because count was wrong
**Root Cause**: `each` command returns null, so `| length` returned 0
```nushell
# ❌ OLD - each returns null
let plugin_count = (ls nu_plugin_*/target/release/nu_plugin_* | each {|p|
cp $p.name $"($temp_dir)/"
} | length) # Returns 0!
```
**Solution**: Separated counting from copying with proper filtering
```nushell
# ✅ NEW - count before operations
let plugins_to_copy = (ls nu_plugin_*/target/release/nu_plugin_* | where type == "file")
let plugin_count = ($plugins_to_copy | length)
```
**Impact**:
- Now correctly collects and reports 26 plugins
- Filters out .d dependency files automatically
- Warning eliminated
#### 2b. Tar Archive Path Handling
**Issue**: Tar command failing silently with relative paths in subshell
- `cd $temp_dir` changes context unpredictably
- Relative path `../$archive_name` fails in subshell
- Archive file not created despite exit code 0
**Root Cause**: Shell context and relative path issues in Nushell `do` block
**Solution**: Used `tar -C` with absolute paths instead of `cd`
```nushell
# ❌ OLD - unreliable context switching
do {
cd $temp_dir
tar -czf ../$archive_name .
}
# ✅ NEW - absolute paths, no context switching
tar -C $temp_dir -czf $archive_path .
```
**Additional Improvements**:
- Absolute path construction using `pwd | path join`
- Better error diagnostics with exit code and stderr output
- File verification after creation
**Impact**:
- Tar archives now created successfully
- Robust path handling across platforms
- Clear error messages for debugging
#### 2c. File Size Calculation Type Error
**Issue**: Runtime error when calculating archive size
```
Error: The '/' operator does not work on values of type 'list<filesize>'
```
**Root Cause**: `ls` returns list of records, so `.size` was a list
```nushell
# ❌ OLD - returns list<filesize>
(ls $archive_path).size / 1024 / 1024
# ✅ NEW - returns filesize
(ls $archive_path | get 0.size) / 1024 / 1024
```
**Impact**:
- Proper file size calculation in MB
- No more type errors
**Files Modified**:
- `scripts/create_full_distribution.nu` (+58 lines, refactored plugin collection)
- Fixed plugin counting logic
- Improved path handling with absolute paths
- Enhanced error diagnostics
### 3. Plugin Rebuild Optimization
**Issue**: All plugins marked for rebuild even when dependencies unchanged
- Step 4 (`update_all_plugins.nu`) touched all Cargo.toml files at 01:00:32
- Step 5 saw all files as "newer" than binaries
- Marked ALL plugins for rebuild, though cargo only rebuilt changed ones
**Root Cause**: Script always saved files, even when no changes made
```nushell
# ❌ OLD - always saves, touching file timestamp
$updated_content | to toml | save -f $cargo_toml
```
**Solution**: Only save if content actually changed
```nushell
# ✅ NEW - compare before writing
let original_toml = $content | to toml
let new_toml = $updated_content | to toml
if $original_toml != $new_toml {
$updated_content | to toml | save -f $cargo_toml
}
```
**Impact**:
- Unchanged files preserve original timestamps
- Only plugins with actual dependency changes are rebuilt
- Efficient rebuild process with accurate file modification detection
**Files Modified**:
- `scripts/update_all_plugins.nu` (+12 lines, added content comparison)
- Only touches files with real changes
- Preserves timestamps for efficiency
- Clearer logic and comments
### 4. Documentation
**Files Modified**:
- `CHANGELOG.md` (+56 lines)
- Added comprehensive 2025-10-19 entry
- Documented all fixes with root causes
- Listed files modified and impact summary
## Technical Details
### Nushell Patterns Used
1. **Proper List Handling**:
- `ls` returns list of records, access with `| get 0.size`
- Filter with `where type == "file"` to exclude metadata
2. **Absolute Path Construction**:
- `pwd | append "path" | path join` for cross-platform paths
- Safer than string concatenation with `/`
3. **Content Comparison**:
- Compare TOML string representation before saving
- Preserves file timestamps for efficiency
4. **Error Diagnostics**:
- Capture `stderr` from commands
- Report exit codes and error messages separately
## Testing
- [x] Help system shows version-update module
- [x] `just commands` displays all recipes by group
- [x] Phase 3 bin archive creation works
- [x] Plugin collection reports correct count (26)
- [x] Tar archives created successfully
- [x] File size calculated correctly
- [x] Plugin rebuild only touches changed files
- [x] CHANGELOG updated with all changes
## Files Changed
```
38 files changed, 2721 insertions(+), 2548 deletions(-)
Core Changes:
- justfiles/help.just (+23) Help system integration
- scripts/create_full_distribution.nu (+58) Build process fixes
- scripts/update_all_plugins.nu (+12) Rebuild optimization
- CHANGELOG.md (+56) Documentation
Dependency Updates:
- All plugin Cargo.toml and Cargo.lock files (version consistency)
```
## Breaking Changes
None. These are bug fixes and optimizations that maintain backward compatibility.
## Migration Notes
No migration needed. Improvements are transparent to users.
## Related Issues
- Help system discoverability
- Build process Phase 3 failures
- Unnecessary plugin rebuilds
- Build process reliability
## Checklist
- [x] Changes follow Rust/Nushell idioms
- [x] Code is well-commented
- [x] Error handling is comprehensive
- [x] Documentation is updated
- [x] All changes tested
- [x] No breaking changes introduced
2025-10-19 01:17:13 +01:00
|
|
|
let total_size = if ($collected_files | is-empty) { 0 } else { ($collected_files | get size | math sum) }
|
2025-09-24 18:52:07 +01:00
|
|
|
log_success $"✅ Collection complete for ($target_platform)"
|
|
|
|
|
log_info $"📊 Collected ($collected_files | length) binaries"
|
|
|
|
|
log_info $"📁 Output directory: ($platform_dir)"
|
|
|
|
|
log_info $"💾 Total size: ($total_size)"
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
platform: $target_platform
|
|
|
|
|
output_dir: $platform_dir
|
|
|
|
|
files: $collected_files
|
|
|
|
|
total_size: $total_size
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get nushell binary information
|
|
|
|
|
def get_nushell_binary_info [
|
|
|
|
|
platform: string
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
]: nothing -> record {
|
|
|
|
|
let nushell_dir = $"($env.PWD)/nushell"
|
2025-09-24 21:28:50 +01:00
|
|
|
mut target_dir = $"($nushell_dir)/target"
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Handle cross-compilation targets
|
|
|
|
|
let target_triple = convert_platform_to_target $platform
|
|
|
|
|
if ($target_triple | is-not-empty) and $target_triple != (detect_current_target) {
|
|
|
|
|
$target_dir = $"($target_dir)/($target_triple)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Determine profile directory
|
2025-09-24 21:28:50 +01:00
|
|
|
mut profile_dir = if ($profile | is-not-empty) {
|
2025-09-24 18:52:07 +01:00
|
|
|
$profile
|
|
|
|
|
} else if $use_release {
|
|
|
|
|
"release"
|
|
|
|
|
} else {
|
|
|
|
|
"debug"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binary_name = if ($platform | str contains "windows") or $nu.os-info.name == "windows" {
|
|
|
|
|
"nu.exe"
|
|
|
|
|
} else {
|
|
|
|
|
"nu"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binary_path = $"($target_dir)/($profile_dir)/($binary_name)"
|
|
|
|
|
|
|
|
|
|
if ($binary_path | path exists) {
|
|
|
|
|
let file_info = ls $binary_path | get 0
|
|
|
|
|
return {
|
|
|
|
|
name: "nu"
|
|
|
|
|
path: $binary_path
|
|
|
|
|
size: $file_info.size
|
|
|
|
|
modified: $file_info.modified
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get workspace plugins information
|
|
|
|
|
def get_workspace_plugins_info [
|
|
|
|
|
platform: string
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
]: nothing -> list<record> {
|
|
|
|
|
let nushell_dir = $"($env.PWD)/nushell"
|
2025-09-24 21:28:50 +01:00
|
|
|
mut target_dir = $"($nushell_dir)/target"
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Handle cross-compilation targets
|
|
|
|
|
let target_triple = convert_platform_to_target $platform
|
|
|
|
|
if ($target_triple | is-not-empty) and $target_triple != (detect_current_target) {
|
|
|
|
|
$target_dir = $"($target_dir)/($target_triple)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Determine profile directory
|
2025-09-24 21:28:50 +01:00
|
|
|
mut profile_dir = if ($profile | is-not-empty) {
|
2025-09-24 18:52:07 +01:00
|
|
|
$profile
|
|
|
|
|
} else if $use_release {
|
|
|
|
|
"release"
|
|
|
|
|
} else {
|
|
|
|
|
"debug"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let workspace_plugins = [
|
|
|
|
|
"nu_plugin_custom_values"
|
|
|
|
|
"nu_plugin_example"
|
|
|
|
|
"nu_plugin_formats"
|
|
|
|
|
"nu_plugin_gstat"
|
|
|
|
|
"nu_plugin_inc"
|
|
|
|
|
"nu_plugin_polars"
|
|
|
|
|
"nu_plugin_query"
|
|
|
|
|
"nu_plugin_stress_internals"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
mut found_plugins = []
|
|
|
|
|
|
|
|
|
|
for plugin in $workspace_plugins {
|
|
|
|
|
let binary_name = if ($platform | str contains "windows") or $nu.os-info.name == "windows" {
|
|
|
|
|
$"($plugin).exe"
|
|
|
|
|
} else {
|
|
|
|
|
$plugin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binary_path = $"($target_dir)/($profile_dir)/($binary_name)"
|
|
|
|
|
|
|
|
|
|
if ($binary_path | path exists) {
|
|
|
|
|
let file_info = ls $binary_path | get 0
|
|
|
|
|
$found_plugins = ($found_plugins | append {
|
|
|
|
|
name: $plugin
|
|
|
|
|
path: $binary_path
|
|
|
|
|
size: $file_info.size
|
|
|
|
|
modified: $file_info.modified
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $found_plugins
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get custom plugins information
|
|
|
|
|
def get_custom_plugins_info [
|
|
|
|
|
platform: string
|
|
|
|
|
use_release: bool
|
|
|
|
|
profile: string
|
|
|
|
|
]: nothing -> list<record> {
|
|
|
|
|
# Get list of plugin directories (nu_plugin_*)
|
|
|
|
|
let plugin_dirs = ls nu_plugin_*
|
2025-09-24 21:28:50 +01:00
|
|
|
| where type == "dir"
|
2025-09-24 18:52:07 +01:00
|
|
|
| where name != "nushell" # Exclude nushell submodule
|
|
|
|
|
| get name
|
|
|
|
|
|
|
|
|
|
mut found_plugins = []
|
|
|
|
|
let target_triple = convert_platform_to_target $platform
|
|
|
|
|
|
|
|
|
|
for plugin_dir in $plugin_dirs {
|
2025-09-24 21:28:50 +01:00
|
|
|
mut target_dir = $"($plugin_dir)/target"
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Handle cross-compilation targets
|
|
|
|
|
if ($target_triple | is-not-empty) and $target_triple != (detect_current_target) {
|
|
|
|
|
$target_dir = $"($target_dir)/($target_triple)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Determine profile directory
|
2025-09-24 21:28:50 +01:00
|
|
|
mut profile_dir = if ($profile | is-not-empty) {
|
2025-09-24 18:52:07 +01:00
|
|
|
$profile
|
|
|
|
|
} else if $use_release {
|
|
|
|
|
"release"
|
|
|
|
|
} else {
|
|
|
|
|
"debug"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binary_name = if ($platform | str contains "windows") or $nu.os-info.name == "windows" {
|
|
|
|
|
$"($plugin_dir).exe"
|
|
|
|
|
} else {
|
|
|
|
|
$plugin_dir
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let binary_path = $"($target_dir)/($profile_dir)/($binary_name)"
|
|
|
|
|
|
|
|
|
|
if ($binary_path | path exists) {
|
|
|
|
|
let file_info = ls $binary_path | get 0
|
|
|
|
|
$found_plugins = ($found_plugins | append {
|
|
|
|
|
name: $plugin_dir
|
|
|
|
|
path: $binary_path
|
|
|
|
|
size: $file_info.size
|
|
|
|
|
modified: $file_info.modified
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $found_plugins
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Utility functions
|
|
|
|
|
def detect_current_platform []: nothing -> string {
|
|
|
|
|
let os = $nu.os-info.name
|
|
|
|
|
let arch = $nu.os-info.arch
|
|
|
|
|
|
|
|
|
|
match [$os, $arch] {
|
|
|
|
|
["linux", "x86_64"] => "linux-x86_64"
|
|
|
|
|
["linux", "aarch64"] => "linux-aarch64"
|
|
|
|
|
["macos", "x86_64"] => "darwin-x86_64"
|
|
|
|
|
["macos", "aarch64"] => "darwin-arm64"
|
|
|
|
|
["windows", "x86_64"] => "windows-x86_64"
|
|
|
|
|
["windows", "aarch64"] => "windows-aarch64"
|
|
|
|
|
_ => $"($os)-($arch)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def detect_current_target []: nothing -> string {
|
|
|
|
|
let os = $nu.os-info.name
|
|
|
|
|
let arch = $nu.os-info.arch
|
|
|
|
|
|
|
|
|
|
match [$os, $arch] {
|
|
|
|
|
["linux", "x86_64"] => "x86_64-unknown-linux-gnu"
|
|
|
|
|
["linux", "aarch64"] => "aarch64-unknown-linux-gnu"
|
|
|
|
|
["macos", "x86_64"] => "x86_64-apple-darwin"
|
|
|
|
|
["macos", "aarch64"] => "aarch64-apple-darwin"
|
|
|
|
|
["windows", "x86_64"] => "x86_64-pc-windows-msvc"
|
|
|
|
|
["windows", "aarch64"] => "aarch64-pc-windows-msvc"
|
|
|
|
|
_ => $"($arch)-unknown-($os)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def convert_platform_to_target [platform: string]: nothing -> string {
|
|
|
|
|
match $platform {
|
|
|
|
|
"linux-x86_64" => "x86_64-unknown-linux-gnu"
|
|
|
|
|
"linux-aarch64" => "aarch64-unknown-linux-gnu"
|
|
|
|
|
"darwin-x86_64" => "x86_64-apple-darwin"
|
|
|
|
|
"darwin-arm64" => "aarch64-apple-darwin"
|
|
|
|
|
"windows-x86_64" => "x86_64-pc-windows-msvc"
|
|
|
|
|
"windows-aarch64" => "aarch64-pc-windows-msvc"
|
|
|
|
|
_ => $platform
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def detect_available_platforms []: nothing -> list<record> {
|
|
|
|
|
mut platforms = []
|
|
|
|
|
|
|
|
|
|
# Check nushell target directory for built platforms
|
|
|
|
|
let nushell_target = $"($env.PWD)/nushell/target"
|
|
|
|
|
if ($nushell_target | path exists) {
|
2025-09-24 21:28:50 +01:00
|
|
|
let target_dirs = try { ls $nushell_target | where type == "dir" | get name } catch { [] }
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
for target_dir in $target_dirs {
|
|
|
|
|
if ($target_dir | str ends-with "target") { continue } # Skip base target dir
|
|
|
|
|
|
|
|
|
|
let target_name = ($target_dir | path basename)
|
|
|
|
|
let platform_name = convert_target_to_platform $target_name
|
|
|
|
|
|
|
|
|
|
# Check if this target has binaries
|
|
|
|
|
let release_dir = $"($target_dir)/release"
|
|
|
|
|
let debug_dir = $"($target_dir)/debug"
|
|
|
|
|
|
|
|
|
|
let has_release = ($release_dir | path exists) and (try { ls $release_dir | where name =~ "nu" | length } catch { 0 }) > 0
|
|
|
|
|
let has_debug = ($debug_dir | path exists) and (try { ls $debug_dir | where name =~ "nu" | length } catch { 0 }) > 0
|
|
|
|
|
|
|
|
|
|
if $has_release or $has_debug {
|
|
|
|
|
$platforms = ($platforms | append {
|
|
|
|
|
name: $platform_name
|
|
|
|
|
target: $target_name
|
|
|
|
|
has_nushell: true
|
|
|
|
|
plugin_count: 0 # Will be calculated
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If no cross-compiled targets found, add current platform
|
|
|
|
|
if ($platforms | is-empty) {
|
|
|
|
|
let current_platform = detect_current_platform
|
|
|
|
|
let current_target = detect_current_target
|
|
|
|
|
|
|
|
|
|
$platforms = ($platforms | append {
|
|
|
|
|
name: $current_platform
|
|
|
|
|
target: $current_target
|
|
|
|
|
has_nushell: true
|
|
|
|
|
plugin_count: 0
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $platforms
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def convert_target_to_platform [target: string]: nothing -> string {
|
|
|
|
|
match $target {
|
|
|
|
|
"x86_64-unknown-linux-gnu" => "linux-x86_64"
|
|
|
|
|
"aarch64-unknown-linux-gnu" => "linux-aarch64"
|
|
|
|
|
"x86_64-apple-darwin" => "darwin-x86_64"
|
|
|
|
|
"aarch64-apple-darwin" => "darwin-arm64"
|
|
|
|
|
"x86_64-pc-windows-msvc" => "windows-x86_64"
|
|
|
|
|
"aarch64-pc-windows-msvc" => "windows-aarch64"
|
|
|
|
|
_ => $target
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_target_structure [target_path: string, force: bool] {
|
|
|
|
|
if ($target_path | path exists) and not $force {
|
|
|
|
|
log_error $"Target directory exists: ($target_path). Use --force to overwrite."
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($target_path | path exists) and $force {
|
|
|
|
|
rm -rf $target_path
|
|
|
|
|
log_warn $"🗑️ Removed existing directory: ($target_path)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mkdir $target_path
|
|
|
|
|
log_info $"📁 Created target directory: ($target_path)"
|
|
|
|
|
|
|
|
|
|
# Create subdirectories
|
|
|
|
|
let subdirs = ["scripts", "config", "docs"]
|
|
|
|
|
for subdir in $subdirs {
|
|
|
|
|
mkdir $"($target_path)/($subdir)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def copy_binary [src: string, dest: string, force: bool] {
|
|
|
|
|
if ($dest | path exists) and not $force {
|
|
|
|
|
log_warn $"⚠️ File exists, skipping: ($dest)"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cp $src $dest
|
|
|
|
|
chmod +x $dest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def copy_additional_files [target_path: string, force: bool] {
|
|
|
|
|
let files_to_copy = [
|
|
|
|
|
{src: "LICENSE", dest: "LICENSE", required: false}
|
|
|
|
|
{src: "README.md", dest: "README.md", required: false}
|
|
|
|
|
{src: "CHANGELOG.md", dest: "CHANGELOG.md", required: false}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for file in $files_to_copy {
|
|
|
|
|
if ($file.src | path exists) {
|
|
|
|
|
let dest_path = $"($target_path)/($file.dest)"
|
|
|
|
|
if not ($dest_path | path exists) or $force {
|
|
|
|
|
cp $file.src $dest_path
|
|
|
|
|
log_info $" 📄 Copied ($file.src) → ($file.dest)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_manifest [
|
|
|
|
|
target_path: string
|
|
|
|
|
platform: string
|
|
|
|
|
files: list<record>
|
|
|
|
|
includes_nushell: bool
|
|
|
|
|
] {
|
|
|
|
|
let manifest = {
|
|
|
|
|
platform: $platform
|
|
|
|
|
created: (date now | format date %Y-%m-%d_%H-%M-%S)
|
|
|
|
|
includes_nushell: $includes_nushell
|
|
|
|
|
total_files: ($files | length)
|
|
|
|
|
files: $files
|
|
|
|
|
nushell_version: (try {
|
|
|
|
|
if $includes_nushell {
|
|
|
|
|
let nu_binary = ($files | where type == "nushell" | get 0)
|
|
|
|
|
if ($nu_binary | is-not-empty) {
|
2025-09-24 21:28:50 +01:00
|
|
|
(run-external $nu_binary.path "--version" | complete | get stdout | str trim)
|
2025-09-24 18:52:07 +01:00
|
|
|
} else {
|
|
|
|
|
"unknown"
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
"not_included"
|
|
|
|
|
}
|
|
|
|
|
} catch { "unknown" })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$manifest | to json | save --force $"($target_path)/manifest.json"
|
|
|
|
|
log_info $"📋 Created manifest: ($target_path)/manifest.json"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_installation_scripts [target_path: string] {
|
|
|
|
|
# Create a basic installation script that registers plugins
|
2025-09-24 21:28:50 +01:00
|
|
|
let install_script = '#!/usr/bin/env nu
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Installation script for nushell and plugins
|
|
|
|
|
# This script registers all plugins with the nushell binary
|
|
|
|
|
|
|
|
|
|
def main [
|
2025-09-24 21:28:50 +01:00
|
|
|
--verify # Verify installation after completion
|
2025-09-24 18:52:07 +01:00
|
|
|
] {
|
2025-09-24 21:28:50 +01:00
|
|
|
print "🚀 Installing Nushell and plugins..."
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Get current directory (should be the distribution directory)
|
|
|
|
|
let dist_dir = $env.PWD
|
|
|
|
|
|
|
|
|
|
# Find nushell binary
|
2025-09-24 21:28:50 +01:00
|
|
|
let nu_binary = if ("nu" | path exists) {
|
|
|
|
|
"./nu"
|
|
|
|
|
} else if ("nu.exe" | path exists) {
|
|
|
|
|
"./nu.exe"
|
2025-09-24 18:52:07 +01:00
|
|
|
} else {
|
2025-09-24 21:28:50 +01:00
|
|
|
print "❌ Nushell binary not found in distribution"
|
2025-09-24 18:52:07 +01:00
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Find plugin binaries
|
2025-09-24 21:28:50 +01:00
|
|
|
let plugins = ls . | where type == "file" | where name =~ "nu_plugin_" | get name
|
2025-09-24 18:52:07 +01:00
|
|
|
|
2025-09-24 21:28:50 +01:00
|
|
|
print $"📦 Found ($plugins | length) plugins to register"
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
# Register each plugin
|
|
|
|
|
for plugin in $plugins {
|
2025-09-24 21:28:50 +01:00
|
|
|
print $" Registering ($plugin)..."
|
2025-09-24 18:52:07 +01:00
|
|
|
try {
|
2025-10-19 00:05:16 +01:00
|
|
|
run-external $nu_binary "-c" $"plugin add ./($plugin)"
|
2025-09-24 18:52:07 +01:00
|
|
|
} catch { |err|
|
2025-09-24 21:28:50 +01:00
|
|
|
print $" ⚠️ Failed to register ($plugin): ($err.msg)"
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if $verify {
|
2025-09-24 21:28:50 +01:00
|
|
|
print "🔍 Verifying installation..."
|
2025-09-24 18:52:07 +01:00
|
|
|
try {
|
2025-09-24 21:28:50 +01:00
|
|
|
let plugin_list = run-external $nu_binary "-c" "plugin list" | complete
|
2025-09-24 18:52:07 +01:00
|
|
|
if $plugin_list.exit_code == 0 {
|
2025-09-24 21:28:50 +01:00
|
|
|
print "✅ Plugin verification successful"
|
2025-09-24 18:52:07 +01:00
|
|
|
print $plugin_list.stdout
|
|
|
|
|
} else {
|
2025-09-24 21:28:50 +01:00
|
|
|
print "❌ Plugin verification failed"
|
2025-09-24 18:52:07 +01:00
|
|
|
print $plugin_list.stderr
|
|
|
|
|
}
|
|
|
|
|
} catch { |err|
|
2025-09-24 21:28:50 +01:00
|
|
|
print $"❌ Verification failed: ($err.msg)"
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-24 21:28:50 +01:00
|
|
|
print "✅ Installation complete!"
|
2025-09-24 18:52:07 +01:00
|
|
|
}
|
2025-09-24 21:28:50 +01:00
|
|
|
'
|
2025-09-24 18:52:07 +01:00
|
|
|
|
|
|
|
|
$install_script | save --force $"($target_path)/install.nu"
|
|
|
|
|
chmod +x $"($target_path)/install.nu"
|
|
|
|
|
log_info $"📜 Created installation script: ($target_path)/install.nu"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def get_file_size [path: string]: nothing -> int {
|
|
|
|
|
try {
|
2025-09-24 21:28:50 +01:00
|
|
|
let file_info = ls $path | get 0
|
|
|
|
|
$file_info.size
|
2025-09-24 18:52:07 +01:00
|
|
|
} catch {
|
|
|
|
|
0
|
|
|
|
|
}
|
|
|
|
|
}
|