121 lines
4.6 KiB
Bash
121 lines
4.6 KiB
Bash
#!/bin/bash
|
|
|
|
echo "🚀 LWC Production Deployment to Salesforce Sandbox"
|
|
echo "=================================================="
|
|
echo ""
|
|
|
|
# Configuration
|
|
SANDBOX_URL="https://tso3--r1.sandbox.lightning.force.com"
|
|
USERNAME="contact+tso3@propertycrm.ae.r1"
|
|
PASSWORD="Demo@123"
|
|
|
|
# Check if Salesforce CLI is installed
|
|
if ! command -v sf &> /dev/null; then
|
|
echo "❌ Salesforce CLI (sf) is not installed!"
|
|
echo ""
|
|
echo "📋 Please install Salesforce CLI first:"
|
|
echo " 1. Visit: https://developer.salesforce.com/tools/sfdxcli"
|
|
echo " 2. Install the CLI for your operating system"
|
|
echo " 3. Run this script again"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Salesforce CLI found"
|
|
echo ""
|
|
|
|
# Check if already authenticated
|
|
echo "🔐 Checking authentication status..."
|
|
if sf org list --json | grep -q "tso3--r1"; then
|
|
echo "✅ Already authenticated to sandbox: tso3--r1"
|
|
ORG_ALIAS="tso3--r1"
|
|
else
|
|
echo "⚠️ Not authenticated to sandbox"
|
|
echo ""
|
|
echo "🔑 Authenticating to sandbox..."
|
|
|
|
# Authenticate to sandbox
|
|
sf org login web --instance-url "$SANDBOX_URL" --alias "tso3--r1" --set-default-dev-hub
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Authentication successful!"
|
|
ORG_ALIAS="tso3--r1"
|
|
else
|
|
echo "❌ Authentication failed!"
|
|
echo "Please check your credentials and try again."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "🏗️ Deploying LWC components to sandbox..."
|
|
|
|
# Deploy the source code
|
|
echo "📦 Deploying source code..."
|
|
sf project deploy start --source-dir force-app --target-org "$ORG_ALIAS"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ LWC deployment successful!"
|
|
else
|
|
echo "❌ LWC deployment failed!"
|
|
echo "Please check the error messages above."
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "🔧 Setting up custom objects and fields..."
|
|
|
|
# Deploy custom objects
|
|
echo "📊 Deploying Property Template object..."
|
|
sf project deploy start --source-dir force-app/main/default/objects --target-org "$ORG_ALIAS"
|
|
|
|
echo "📋 Deploying Property object fields..."
|
|
sf project deploy start --source-dir force-app/main/default/objects/Property__c --target-org "$ORG_ALIAS"
|
|
|
|
echo "📋 Deploying Property Template object fields..."
|
|
sf project deploy start --source-dir force-app/main/default/objects/Property_Template__c --target-org "$ORG_ALIAS"
|
|
|
|
echo ""
|
|
echo "🎯 Setting up permission sets..."
|
|
|
|
# Create permission set for the LWC
|
|
echo "🔐 Creating permission set..."
|
|
sf data upsert --sobjecttype PermissionSet --sobjectid Id --external-id Name --values "Name='Property_Brochure_Generator_Access' Label='Property Brochure Generator Access' Description='Access to Property Brochure Generator LWC'" --target-org "$ORG_ALIAS"
|
|
|
|
# Assign permissions to the permission set
|
|
echo "🔑 Assigning permissions..."
|
|
sf data upsert --sobjecttype PermissionSet --sobjectid Id --external-id Name --values "Name='Property_Brochure_Generator_Access' pcrm__Property__c=true pcrm__Property_Template__c=true" --target-org "$ORG_ALIAS"
|
|
|
|
echo ""
|
|
echo "📱 Setting up Lightning App Page..."
|
|
|
|
# Create a Lightning App Page
|
|
echo "📄 Creating Lightning App Page..."
|
|
sf data upsert --sobjecttype LightningPage --sobjectid Id --external-id DeveloperName --values "DeveloperName='Property_Brochure_Generator' MasterLabel='Property Brochure Generator' LightningComponent__c='propertyTemplateSelector' IsAvailableInTouch=true IsAvailableInLightning=true IsAvailableInClassic=true" --target-org "$ORG_ALIAS"
|
|
|
|
echo ""
|
|
echo "🎉 Deployment completed successfully!"
|
|
echo "===================================="
|
|
echo ""
|
|
echo "📋 What was deployed:"
|
|
echo " ✅ LWC Component: propertyTemplateSelector"
|
|
echo " ✅ Apex Controller: PropertyTemplateController"
|
|
echo " ✅ Custom Objects: Property__c, Property_Template__c"
|
|
echo " ✅ Permission Set: Property_Brochure_Generator_Access"
|
|
echo " ✅ Lightning App Page: Property Brochure Generator"
|
|
echo ""
|
|
echo "🚀 Next Steps:"
|
|
echo " 1. Open your sandbox: $SANDBOX_URL"
|
|
echo " 2. Login with: $USERNAME / $PASSWORD"
|
|
echo " 3. Go to Setup → App Manager → Property Brochure Generator"
|
|
echo " 4. Or search for 'Property Brochure Generator' in the app launcher"
|
|
echo ""
|
|
echo "🔧 Important Configuration:"
|
|
echo " ⚠️ Update the PDF API URL in the LWC JavaScript file:"
|
|
echo " - Open: force-app/main/default/lwc/propertyTemplateSelector/propertyTemplateSelector.js"
|
|
echo " - Change: pdfApiBaseUrl = 'https://your-ip-address:8000/api'"
|
|
echo " - Replace 'your-ip-address' with your actual server IP"
|
|
echo ""
|
|
echo "📖 For PDF generation API setup, see: README.md"
|
|
echo ""
|
|
echo "🎯 Your LWC is now ready for production use!" |