updated scripts
This commit is contained in:
58
sf-deploy
58
sf-deploy
@@ -6,31 +6,37 @@ show_help() {
|
||||
sf-deploy — wrapper for `sf project deploy start`
|
||||
|
||||
USAGE:
|
||||
sf-deploy -o <ORG_ALIAS_OR_USERNAME> -s "<src1>,<src2>[,...]" [-t "<Test1>,<Test2>[,...]"]
|
||||
sf-deploy -o <ORG_ALIAS_OR_USERNAME> (-s "<src1>,<src2>[,...]" | -d <DIRECTORY>) [-t "<Test1>,<Test2>[,...]"]
|
||||
|
||||
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
|
||||
|
||||
EXAMPLES:
|
||||
1) Real deploy with multiple flexipages:
|
||||
1) Real deploy with multiple flexipages (specific files):
|
||||
sf-deploy -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"
|
||||
|
||||
2) Real deploy with specified tests:
|
||||
2) Real deploy with entire directory:
|
||||
sf-deploy -o DEMO-ORG -d "force-app/main/default/classes"
|
||||
|
||||
3) Real deploy with specified tests:
|
||||
sf-deploy -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"
|
||||
|
||||
Notes:
|
||||
- Pass absolute or repo-relative paths in -s, separated by commas.
|
||||
- Use -s for specific files (comma-separated) OR -d 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.
|
||||
EOF
|
||||
}
|
||||
|
||||
ORG=""
|
||||
DIR_PATH=""
|
||||
declare -a SOURCES_ARR=()
|
||||
declare -a TESTS_ARR=()
|
||||
|
||||
@@ -39,10 +45,11 @@ if [[ $# -eq 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while getopts ":o:s:t:h" opt; do
|
||||
while getopts ":o:s:d:t:h" opt; do
|
||||
case "$opt" in
|
||||
o) ORG="$OPTARG" ;;
|
||||
s) IFS=',' read -r -a SOURCES_ARR <<< "$OPTARG" ;;
|
||||
d) DIR_PATH="$OPTARG" ;;
|
||||
t) IFS=',' read -r -a TESTS_ARR <<< "$OPTARG" ;;
|
||||
h) show_help; exit 0 ;;
|
||||
\?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;;
|
||||
@@ -50,13 +57,52 @@ while getopts ":o:s:t:h" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate that either -s or -d is provided, but not both
|
||||
if [[ -n "$DIR_PATH" && ${#SOURCES_ARR[@]} -gt 0 ]]; then
|
||||
echo "Error: Cannot use both -s and -d options. Use -s for specific files or -d for directories." >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate that at least one source option is provided
|
||||
if [[ -z "$DIR_PATH" && ${#SOURCES_ARR[@]} -eq 0 ]]; then
|
||||
echo "Error: Must provide either -s (specific files) or -d (directory path)." >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Silent environment check - verify SF CLI is available
|
||||
if ! command -v sf >/dev/null 2>&1; then
|
||||
echo "❌ Salesforce CLI (sf) not found!"
|
||||
echo
|
||||
echo "Running environment check to help you get started..."
|
||||
echo
|
||||
|
||||
# Try to find and run sf-check in the same directory as this script
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
if [[ -x "$SCRIPT_DIR/sf-check" ]]; then
|
||||
"$SCRIPT_DIR/sf-check"
|
||||
elif command -v sf-check >/dev/null 2>&1; then
|
||||
sf-check
|
||||
else
|
||||
echo "sf-check not found. Please install the Salesforce CLI from:"
|
||||
echo "https://developer.salesforce.com/tools/sfdxcli"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CMD=(sf project deploy start)
|
||||
|
||||
# sources
|
||||
# sources (specific files)
|
||||
for SRC in "${SOURCES_ARR[@]:-}"; do
|
||||
[[ -n "$SRC" ]] && CMD+=(--source-dir "$SRC")
|
||||
done
|
||||
|
||||
# directory path
|
||||
[[ -n "$DIR_PATH" ]] && CMD+=(--source-dir "$DIR_PATH")
|
||||
|
||||
# org
|
||||
[[ -n "$ORG" ]] && CMD+=(--target-org "$ORG")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user