fix: resolve sf-logs-tail utils.sh dependency by reorganizing directory structure

- Renamed misc/ directory to utils/ for better organization
- Updated sf-logs-tail to source utils/utils.sh correctly
- This fixes the 'No such file or directory' error when running sf-logs-tail
- The utils directory contains cross-platform timeout functions needed for macOS compatibility
This commit is contained in:
reynold
2025-08-28 22:57:07 +08:00
parent b99cdc1959
commit 4020d881f1
12 changed files with 4 additions and 4 deletions

135
utils/quick-test.ps1 Normal file
View File

@@ -0,0 +1,135 @@
# Quick Validation Test for SF CLI Wrapper Scripts (PowerShell Edition)
# Tests essential functionality with PWC-TEAM-DEV org
$ErrorActionPreference = "Stop"
# Test configuration
$TEST_ORG = "PWC-TEAM-DEV"
# Colors for output
function Write-Green { param($Text) Write-Host $Text -ForegroundColor Green }
function Write-Red { param($Text) Write-Host $Text -ForegroundColor Red }
function Write-Yellow { param($Text) Write-Host $Text -ForegroundColor Yellow }
function Write-Blue { param($Text) Write-Host $Text -ForegroundColor Blue }
Write-Blue "SF CLI Wrapper Quick Validation (PowerShell)"
Write-Blue "============================================="
Write-Yellow "Target Org: $TEST_ORG"
Write-Host ""
# Test counters
$Script:TESTS = 0
$Script:PASSED = 0
function Test-Help {
param($ScriptName)
Write-Host "Testing $ScriptName help... " -NoNewline
$Script:TESTS++
try {
$process = Start-Process -FilePath "bash" -ArgumentList "./$ScriptName", "-hp" -NoNewWindow -Wait -PassThru -RedirectStandardOutput "$env:TEMP/null" -RedirectStandardError "$env:TEMP/null"
if ($process.ExitCode -eq 0) {
Write-Green ""
$Script:PASSED++
} else {
Write-Red ""
}
} catch {
Write-Red ""
}
}
function Test-TwoCharOptions {
param($ScriptName, $TestCommand)
Write-Host "Testing $ScriptName two-char options... " -NoNewline
$Script:TESTS++
try {
$process = Start-Process -FilePath "bash" -ArgumentList "-c", $TestCommand -NoNewWindow -Wait -PassThru -RedirectStandardOutput "$env:TEMP/output.txt" -RedirectStandardError "$env:TEMP/error.txt"
# Check if output contains option recognition errors
$output = Get-Content "$env:TEMP/output.txt" -ErrorAction SilentlyContinue
$error = Get-Content "$env:TEMP/error.txt" -ErrorAction SilentlyContinue
$allText = "$output $error"
if ($allText -match "Unknown option" -or $allText -match "Invalid option") {
Write-Red "✗ (Two-character option not recognized)"
} else {
Write-Green ""
$Script:PASSED++
}
# Clean up temp files
Remove-Item "$env:TEMP/output.txt" -ErrorAction SilentlyContinue
Remove-Item "$env:TEMP/error.txt" -ErrorAction SilentlyContinue
} catch {
Write-Red ""
}
}
function Test-BasicCommand {
param($Description, $Command)
Write-Host "Testing $Description... " -NoNewline
$Script:TESTS++
try {
$process = Start-Process -FilePath "bash" -ArgumentList "-c", $Command -NoNewWindow -Wait -PassThru -RedirectStandardOutput "$env:TEMP/null" -RedirectStandardError "$env:TEMP/null"
if ($process.ExitCode -eq 0) {
Write-Green ""
$Script:PASSED++
} else {
Write-Red ""
}
} catch {
Write-Red ""
}
}
Write-Blue "=== Testing Help Functions ==="
Test-Help "sf-check"
Test-Help "sf-deploy"
Test-Help "sf-dry-run"
Test-Help "sf-web-open"
Test-Help "sf-org-create"
Test-Help "sf-org-info"
Test-Help "sf-retrieve"
Test-Help "sf-test-run"
Test-Help "sf-apex-run"
Test-Help "sf-data-export"
Test-Help "sf-data-import"
Test-Help "sf-logs-tail"
Write-Host ""
Write-Blue "=== Testing Two-Character Options ==="
Test-TwoCharOptions "sf-deploy" "./sf-deploy -to $TEST_ORG >/dev/null 2>&1 || true"
Test-TwoCharOptions "sf-dry-run" "./sf-dry-run -to $TEST_ORG >/dev/null 2>&1 || true"
Test-TwoCharOptions "sf-web-open" "./sf-web-open -to $TEST_ORG -ur >/dev/null 2>&1 || true"
Test-TwoCharOptions "sf-org-create" "./sf-org-create -al Test >/dev/null 2>&1 || true"
Test-TwoCharOptions "sf-data-export" "./sf-data-export -qy 'SELECT Id FROM User LIMIT 1' -to $TEST_ORG >/dev/null 2>&1 || true"
Write-Host ""
Write-Blue "=== Testing Basic Functionality ==="
Test-BasicCommand "sf-check basic" "./sf-check >/dev/null 2>&1"
Test-BasicCommand "sf-org-info" "./sf-org-info -ls >/dev/null 2>&1"
Test-BasicCommand "sf-web-open URL-only" "./sf-web-open -to $TEST_ORG -ur >/dev/null 2>&1"
Write-Host ""
Write-Blue "=== Quick Test Summary ==="
Write-Blue "========================"
Write-Host "Tests run: $Script:TESTS"
Write-Green "Passed: $Script:PASSED"
Write-Red "Failed: $($Script:TESTS - $Script:PASSED)"
if ($Script:PASSED -eq $Script:TESTS) {
Write-Host ""
Write-Green "🎉 All quick tests passed!"
Write-Yellow "Run ./test-wrapper-suite.ps1 for comprehensive testing."
exit 0
} else {
Write-Host ""
Write-Red "❌ Some quick tests failed."
Write-Yellow "Run ./test-wrapper-suite.ps1 for detailed testing."
exit 1
}