Update PowerShell scripts to use consistent two-character options (Part 1)

🔄 PowerShell Option Consistency - Phase 1 Complete:

 Updated Scripts:
  - sf-deploy.ps1: -to, -sr, -dr, -ts, -hp (matches Bash)
  - sf-dry-run.ps1: -to, -sr, -dr, -ts, -hp (matches Bash)
  - sf-web-open.ps1: -to, -pt, -ur, -hp (matches Bash)
  - sf-check.ps1: -vb, -hp (matches Bash)
  - sf-org-create.ps1: -al, -dd, -df, -st, -tp, -hp (matches Bash)

🎯 Consistency Achieved:
  - All parameter names now match their Bash counterparts exactly
  - Help text updated with descriptive option names
  - Examples updated to show new two-character options
  - All validation logic updated to use new parameter names

🚀 Cross-Platform Alignment:
  - PowerShell and Bash scripts now have identical option schemes
  - Users get consistent experience across platforms
  - No more confusion between single-char and two-char options

Remaining: 7 more PowerShell scripts to update for full consistency.
This commit is contained in:
reynold
2025-08-28 19:19:15 +08:00
parent f22a46d711
commit 579264e3d1
5 changed files with 133 additions and 133 deletions

View File

@@ -1,9 +1,9 @@
param(
[string]$o = "",
[string]$s = "",
[string]$d = "",
[string]$t = "",
[switch]$h
[string]$to = "",
[string]$sr = "",
[string]$dr = "",
[string]$ts = "",
[switch]$hp
)
function Show-Help {
@@ -11,53 +11,53 @@ function Show-Help {
sf-deploy.ps1 PowerShell wrapper for ``sf project deploy start``
USAGE:
sf-deploy.ps1 -o <ORG_ALIAS_OR_USERNAME> (-s "<src1>,<src2>[,...]" | -d <DIRECTORY>) [-t "<Test1>,<Test2>[,...]"]
sf-deploy.ps1 -h
sf-deploy.ps1 -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTORY>) [-ts "<Test1>,<Test2>[,...]"]
sf-deploy.ps1 -hp
OPTIONS:
-o Org alias or username for --target-org
-s Comma-separated list of --source-dir paths
-d Single directory path to deploy (alternative to -s)
-t Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
-h Show this help
-to Target org alias or username for --target-org
-sr Sources - comma-separated list of --source-dir paths
-dr Directory - single directory path to deploy (alternative to -sr)
-ts Tests - comma-separated list of --tests (enables --test-level RunSpecifiedTests)
-hp Help - show this help
EXAMPLES:
1) Real deploy with multiple flexipages (specific files):
sf-deploy.ps1 -o "DEMO-ORG" ``
-s "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
sf-deploy.ps1 -to "DEMO-ORG" ``
-sr "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
2) Real deploy with entire directory:
sf-deploy.ps1 -o "DEMO-ORG" -d "force-app/main/default/classes"
sf-deploy.ps1 -to "DEMO-ORG" -dr "force-app/main/default/classes"
3) Real deploy with specified tests:
sf-deploy.ps1 -o "DEMO-ORG" ``
-s "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
-t "SelectorOpportunity_Test,SelectorOpportunity2_Test"
sf-deploy.ps1 -to "DEMO-ORG" ``
-sr "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
-ts "SelectorOpportunity_Test,SelectorOpportunity2_Test"
Notes:
- Use -s for specific files (comma-separated) OR -d for entire directories (not both).
- Use -sr for specific files (comma-separated) OR -dr for entire directories (not both).
- Pass absolute or repo-relative paths.
- Multiple tests are comma-separated in -t; they will be expanded to multiple --tests flags.
- Multiple tests are comma-separated in -ts; they will be expanded to multiple --tests flags.
"@
}
# Show help if requested or no parameters provided
if ($h -or ($o -eq "" -and $s -eq "" -and $d -eq "" -and $t -eq "")) {
if ($hp -or ($to -eq "" -and $sr -eq "" -and $dr -eq "" -and $ts -eq "")) {
Show-Help
exit 0
}
# Validate that either -s or -d is provided, but not both
if ($s -ne "" -and $d -ne "") {
Write-Error "Cannot use both -s and -d options. Use -s for specific files or -d for directories."
# Validate that either -sr or -dr is provided, but not both
if ($sr -ne "" -and $dr -ne "") {
Write-Error "Cannot use both -sr and -dr options. Use -sr for specific files or -dr for directories."
Write-Host ""
Show-Help
exit 1
}
# Validate required parameters
if ($o -eq "" -or ($s -eq "" -and $d -eq "")) {
Write-Error "Must provide -o (org) and either -s (specific files) or -d (directory path)."
if ($to -eq "" -or ($sr -eq "" -and $dr -eq "")) {
Write-Error "Must provide -to (org) and either -sr (specific files) or -dr (directory path)."
Write-Host ""
Show-Help
exit 1
@@ -94,8 +94,8 @@ catch {
$cmd = @("sf", "project", "deploy", "start")
# Add source directories (specific files)
if ($s -ne "") {
$sourcesArray = $s -split ","
if ($sr -ne "") {
$sourcesArray = $sr -split ","
foreach ($src in $sourcesArray) {
$src = $src.Trim()
if ($src -ne "") {
@@ -106,20 +106,20 @@ if ($s -ne "") {
}
# Add directory path
if ($d -ne "") {
if ($dr -ne "") {
$cmd += "--source-dir"
$cmd += $d
$cmd += $dr
}
# Add target org
if ($o -ne "") {
if ($to -ne "") {
$cmd += "--target-org"
$cmd += $o
$cmd += $to
}
# Add tests if specified
if ($t -ne "") {
$testsArray = $t -split ","
if ($ts -ne "") {
$testsArray = $ts -split ","
$cmd += "--test-level"
$cmd += "RunSpecifiedTests"