added sf cli wrappers
This commit is contained in:
72
sf-deploy
Executable file
72
sf-deploy
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
show_help() {
|
||||
cat <<'EOF'
|
||||
sf-deploy — wrapper for `sf project deploy start`
|
||||
|
||||
USAGE:
|
||||
sf-deploy -o <ORG_ALIAS_OR_USERNAME> -s "<src1>,<src2>[,...]" [-t "<Test1>,<Test2>[,...]"]
|
||||
|
||||
OPTIONS:
|
||||
-o Org alias or username for --target-org
|
||||
-s Comma-separated list of --source-dir paths
|
||||
-t Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-h Show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Real deploy with multiple flexipages:
|
||||
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:
|
||||
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.
|
||||
- Multiple tests are comma-separated in -t; they will be expanded to multiple --tests flags.
|
||||
EOF
|
||||
}
|
||||
|
||||
ORG=""
|
||||
declare -a SOURCES_ARR=()
|
||||
declare -a TESTS_ARR=()
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
show_help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while getopts ":o:s:t:h" opt; do
|
||||
case "$opt" in
|
||||
o) ORG="$OPTARG" ;;
|
||||
s) IFS=',' read -r -a SOURCES_ARR <<< "$OPTARG" ;;
|
||||
t) IFS=',' read -r -a TESTS_ARR <<< "$OPTARG" ;;
|
||||
h) show_help; exit 0 ;;
|
||||
\?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2; echo; show_help; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
CMD=(sf project deploy start)
|
||||
|
||||
# sources
|
||||
for SRC in "${SOURCES_ARR[@]:-}"; do
|
||||
[[ -n "$SRC" ]] && CMD+=(--source-dir "$SRC")
|
||||
done
|
||||
|
||||
# org
|
||||
[[ -n "$ORG" ]] && CMD+=(--target-org "$ORG")
|
||||
|
||||
# tests
|
||||
if [[ ${#TESTS_ARR[@]:-0} -gt 0 ]]; then
|
||||
CMD+=(--test-level RunSpecifiedTests)
|
||||
for T in "${TESTS_ARR[@]}"; do
|
||||
[[ -n "$T" ]] && CMD+=(--tests "$T")
|
||||
done
|
||||
fi
|
||||
|
||||
echo ">>> Running: ${CMD[*]}"
|
||||
exec "${CMD[@]}"
|
||||
Reference in New Issue
Block a user