#!/bin/bash # Deployment script for Salesforce Composite Envelope Builder echo "๐Ÿš€ Salesforce Composite Envelope Builder Deployment" echo "==================================================" echo "" # Check if sf CLI is installed if ! command -v sf &> /dev/null; then echo "โŒ Salesforce CLI not found. Please install it first:" echo " npm install -g @salesforce/cli" exit 1 fi echo "โœ… Salesforce CLI found: $(sf --version)" echo "" # Ask for org type echo "Which org do you want to deploy to?" echo "1) Sandbox" echo "2) Production" read -p "Enter choice (1 or 2): " ORG_CHOICE if [ "$ORG_CHOICE" == "1" ]; then ORG_TYPE="sandbox" INSTANCE_URL="https://test.salesforce.com" ORG_ALIAS="composite-envelope-sandbox" elif [ "$ORG_CHOICE" == "2" ]; then ORG_TYPE="production" INSTANCE_URL="https://login.salesforce.com" ORG_ALIAS="composite-envelope-production" else echo "โŒ Invalid choice. Exiting." exit 1 fi echo "" echo "๐Ÿ“ Deploying to: $ORG_TYPE" echo "๐Ÿ”— Instance URL: $INSTANCE_URL" echo "๐Ÿท๏ธ Org Alias: $ORG_ALIAS" echo "" # Authorize org echo "๐Ÿ” Authorizing org..." sf org login web --alias "$ORG_ALIAS" --instance-url "$INSTANCE_URL" if [ $? -ne 0 ]; then echo "โŒ Authorization failed. Exiting." exit 1 fi echo "โœ… Authorization successful" echo "" # Set default org echo "โš™๏ธ Setting default org..." sf config set target-org "$ORG_ALIAS" echo "" echo "๐Ÿ“ฆ Deploying metadata..." sf project deploy start --target-org "$ORG_ALIAS" if [ $? -ne 0 ]; then echo "โŒ Deployment failed. Check errors above." exit 1 fi echo "" echo "โœ… Deployment successful!" echo "" # Run tests echo "๐Ÿงช Running unit tests..." sf apex run test --wait 10 --result-format human --code-coverage --target-org "$ORG_ALIAS" if [ $? -ne 0 ]; then echo "โš ๏ธ Some tests failed. Please review." else echo "โœ… All tests passed!" fi echo "" echo "==================================================" echo "โœ… Deployment Complete!" echo "" echo "Next steps:" echo "1. Configure Docusign credentials in Salesforce" echo "2. Update your Screen Flow to call the Apex Action" echo "3. Test with real Docusign templates" echo "" echo "See docs/deployment-guide.md for detailed instructions."