feat: windows-devshell
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#!/bin/dash
|
||||
set -eu
|
||||
|
||||
log info "Checking windows-devshell standalone script structure..."
|
||||
|
||||
# Check file exists
|
||||
if ! [ -f "${windowsDevShellStandalone}" ]; then
|
||||
log error "windows-devshell standalone script not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check it's a PowerShell script (should NOT have hardcoded #Requires -RunAsAdministrator)
|
||||
if head -1 "${windowsDevShellStandalone}" | grep -q "#Requires -RunAsAdministrator"; then
|
||||
log error "Script should not hardcode #Requires -RunAsAdministrator"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check it contains base64 placeholder replacement (should be actual base64 now)
|
||||
if grep -q "@LINUX_DEVSHELL_BASE64@" "${windowsDevShellStandalone}"; then
|
||||
log error "Base64 placeholder was not replaced"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check it contains the base64 decode logic
|
||||
if ! grep -q "FromBase64String" "${windowsDevShellStandalone}"; then
|
||||
log error "Script missing base64 decode logic"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check it contains WSL installation logic
|
||||
if ! grep -q "wsl --status" "${windowsDevShellStandalone}"; then
|
||||
log error "Script missing WSL status check"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "wsl --install" "${windowsDevShellStandalone}"; then
|
||||
log error "Script missing WSL install command"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check it contains admin check
|
||||
if ! grep -q "Administrator" "${windowsDevShellStandalone}"; then
|
||||
log error "Script missing admin privilege check"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log success "Standalone script has correct structure"
|
||||
|
||||
# Verify the embedded base64 is valid by checking it's non-empty and only contains base64 chars
|
||||
base64_content=$(grep '^\$linuxDevShellBase64 = ' "${windowsDevShellStandalone}" | sed 's/.*= "//;s/"$//')
|
||||
if [ -z "$base64_content" ]; then
|
||||
log error "Embedded base64 content is empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check base64 content length is reasonable (should be at least a few hundred chars for the linux script)
|
||||
content_len=${#base64_content}
|
||||
if [ "$content_len" -lt 100 ]; then
|
||||
log error "Embedded base64 content too short ($content_len chars)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log success "Embedded base64 content looks valid ($content_len chars)"
|
||||
log success "Standalone structure test passed"
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/dash
|
||||
set -eu
|
||||
|
||||
log info "Checking PowerShell script syntax (basic validation)..."
|
||||
|
||||
# Since we can't run PowerShell in Nix, we do basic structural validation
|
||||
|
||||
# Check for balanced braces
|
||||
open_braces=$(grep -o '{' "${windowsDevShellStandalone}" | wc -l)
|
||||
close_braces=$(grep -o '}' "${windowsDevShellStandalone}" | wc -l)
|
||||
if [ "$open_braces" -ne "$close_braces" ]; then
|
||||
log error "Unbalanced braces: $open_braces open, $close_braces close"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for balanced parentheses
|
||||
open_parens=$(grep -o '(' "${windowsDevShellStandalone}" | wc -l)
|
||||
close_parens=$(grep -o ')' "${windowsDevShellStandalone}" | wc -l)
|
||||
if [ "$open_parens" -ne "$close_parens" ]; then
|
||||
log error "Unbalanced parentheses: $open_parens open, $close_parens close"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check no obvious syntax errors (unclosed strings)
|
||||
# Count quotes - should be even
|
||||
quotes=$(grep -o '"' "${windowsDevShellStandalone}" | wc -l)
|
||||
if [ $((quotes % 2)) -ne 0 ]; then
|
||||
log error "Unbalanced quotes: $quotes total (should be even)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check script has reasonable length
|
||||
lines=$(wc -l < "${windowsDevShellStandalone}")
|
||||
if [ "$lines" -lt 50 ]; then
|
||||
log error "Script too short ($lines lines)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log success "PowerShell script passes basic structural validation"
|
||||
log success "Script is $lines lines, braces/parentheses/quotes balanced"
|
||||
Reference in New Issue
Block a user