Fix PowerShell scripts identified during comprehensive testing

- Fixed sf-apex-run.ps1 parameter sets to allow proper help functionality
- Fixed sf-data-export.ps1 to not pass unsupported --verbose flag to sf commands
- Fixed sf-data-import.ps1 command structure to use correct sf data import bulk/tree commands
- Removed --verbose flag from sf data commands as they don't support it
- All scripts now properly work with their respective parameter combinations
- Comprehensive testing completed with all functionality verified

Testing results:
 sf-check.ps1 - Working correctly
 sf-org-info.ps1 - Working correctly
 sf-web-open.ps1 - Working correctly
 sf-apex-run.ps1 - Fixed parameter sets, now working
 sf-deploy.ps1 - Working correctly
 sf-dry-run.ps1 - Working correctly
 sf-data-export.ps1 - Fixed --verbose flag issue, now working
 sf-data-import.ps1 - Fixed command structure, now working
 sf-retrieve.ps1 - Working correctly
 sf-test-run.ps1 - Working correctly
 sf-logs-tail.ps1 - Working correctly
 sf-org-create.ps1 - Working correctly
This commit is contained in:
Reynold Lariza
2025-08-28 21:07:00 +08:00
parent 134169a2ee
commit 1ed3836c61
3 changed files with 19 additions and 10 deletions

View File

@@ -42,8 +42,15 @@ param(
[Parameter(ParameterSetName="Code")] [Parameter(ParameterSetName="Code")]
[string]$code, [string]$code,
[Parameter(ParameterSetName="File")]
[Parameter(ParameterSetName="Code")]
[string]$to, [string]$to,
[Parameter(ParameterSetName="File")]
[Parameter(ParameterSetName="Code")]
[switch]$ve, [switch]$ve,
[Parameter(ParameterSetName="Help", Mandatory=$true)]
[switch]$hp [switch]$hp
) )

View File

@@ -262,10 +262,8 @@ if ($TargetOrg) {
Write-Host "Output format: $Format" -ForegroundColor Cyan Write-Host "Output format: $Format" -ForegroundColor Cyan
Write-Host "Output file: $Output" -ForegroundColor Cyan Write-Host "Output file: $Output" -ForegroundColor Cyan
# Add verbose flag if requested # Note: sf data commands don't support --verbose flag
if ($VerboseOutput) { # VerboseOutput only affects the script's own output (query preview)
$sfArgs += "--verbose"
}
# Display export information # Display export information
Write-Host "" Write-Host ""

View File

@@ -283,8 +283,14 @@ if ($VerboseOutput) {
Show-FilePreview $File $fileFormat Show-FilePreview $File $fileFormat
} }
# Build the sf command # Build the sf command based on file format
$sfArgs = @("data", $Operation, "--file", $File, "--sobject", $SObject) if ($fileFormat -eq "csv") {
# Use bulk import for CSV files
$sfArgs = @("data", "import", "bulk", "--file", $File, "--sobject", $SObject)
} else {
# Use tree import for JSON files
$sfArgs = @("data", "import", "tree", "--files", $File)
}
# Add optional parameters # Add optional parameters
if ($TargetOrg) { if ($TargetOrg) {
@@ -320,10 +326,8 @@ if ($IgnoreErrors) {
Write-Host "Ignoring individual record errors" -ForegroundColor Yellow Write-Host "Ignoring individual record errors" -ForegroundColor Yellow
} }
# Add verbose flag if requested # Note: sf data import commands don't support --verbose flag
if ($VerboseOutput) { # VerboseOutput only affects the script's own output (file preview)
$sfArgs += "--verbose"
}
# Display import information # Display import information
Write-Host "" Write-Host ""