
|   npm install -g @zohocrm/zdk-cli | 
| #!/bin/bash touch stdout.txt #This script is used to automate ZDK CLI conflict resolve flow conflict_flag=false # Clear stdout.txt at the start > stdout.txt #Step 1: Initial Push Command echo "====Start of the script ====" >> stdout.txt echo "**Executing the initial zdk org:push -j" >> stdout.txt json_content=$(zdk org:push -j) echo "Output  $json_content" >> stdout.txt next_command=$(echo "$json_content" | jq -r '.next_command_sequence // empty') echo "next_command after initial push  is $next_command">> stdout.txt # Check if the JSON is valid if echo "$json_content" | jq empty 2>/dev/null; then #Step 2: Conflict Detection     message=$(echo "$json_content" | jq -r '.message')     echo "message: $message" >>stdout.txt     if [[ "$message" == *"Merge Conflicts!"* ]]; then         #Step 3: Resolving Conflicts         conflict_flag=true         # Pull changes to the local repository and store the output in a variable         echo "**Executing zdk org:pull -j" >> stdout.txt         json_content=$(zdk org:pull -j)         echo "Output  $json_content" >> stdout.txt         if echo "$json_content" | jq empty 2>/dev/null; then             message=$(echo "$json_content" | jq -r '.result')             echo "message $message" >>stdout.txt             IFS=$'\n' read -r -d '' -a filenames <<< "$message"             # Iterate over each filename and execute the resolve command             for filename in "${filenames[@]}"; do                 echo "**Executing zdk org:pull:resolve for $filename" >> stdout.txt                 # Executing zdk org:pull:resolve                  json_content=$(zdk org:pull:resolve -f "$filename" -j)                 echo "Output  $json_content" >> stdout.txt             done             echo "***Executing zdk org:pull:update" >> stdout.txt             json_content=$(zdk org:pull:update -j)             echo "Output  $json_content" >> stdout.txt         fi     fi fi #Step 4: Second Push Attempt after conflict if [ "$conflict_flag" = true ]; then # Push changes to the org and store the output in a variable again echo "***Executing: zdk org:push -j after conflict resolution" >> stdout.txt json_content=$(zdk org:push -j) echo "Output  $json_content" >> stdout.txt # Extract the line containing "next_command_sequence" from the push output next_command=$(echo "$json_content" | jq -r '.next_command_sequence') echo "Next command $next_command " >> stdout.txt fi #Step 5: Push result command # Execute the next command if it exists counter=0  # Initialize a counter if [ -n "$next_command" ]; then     while true; do     # Execute the command stored in next_command and capture the output     echo "***Executing: $next_command -j"  >> stdout.txt     output=$(eval "$next_command -j")     echo "Output $output" >>stdout.txt     # Check if the output contains "Process in progress"     if echo "$output" | grep -q "Process in progress"; then         echo "Push process in progress. Waiting for 5 seconds..."  >> stdout.txt         sleep 5  # Wait for 5 seconds     else         # If not found, break the loop and handle the output         echo "Command executed successfully or completed."  >> stdout.txt         break     fi      # Increment the counter     counter=$((counter + 1))     # Break the loop after 10 iterations     if [ "$counter" -ge 10 ]; then         echo "Maximum number of attempts(10) reached. Exiting the loop." >> stdout.txt         echo "Try executing $next_command after some time" >> stdout.txt         break     fi done fi | 
| chmod +x zdk_automation.sh | 
| ./zdk_automation.sh & tail -f stdout.txt | 


Writer is a powerful online word processor, designed for collaborative work.