Skip to main content

There are steps that must be followed in order to setup skuid-grunt.  Sometimes, a little automation helps.  This script is for Mac OS or Linux, and surely has much room for improvement.  Feel free to use, change, suggest, or user for light reading 🙂.

skgruntmenu.sh

----------------------------

###########################  AUTOMATION #############################

#    set -e

# Get configuration parameters.

######################################################################

#export setx=“set -x”

export setx=“set +x”

if x -e .menusrc ]

then

  . .menusrc

fi


prereqs() 

{  

   NODEINSTALLED=1

   GITINSTALLED=1

   command -v node status >/dev/null 2>&1 || { echo >&2 “Node is not installed.”; NODEINSTALLED=0; }

   command -v git status >/dev/null 2>&1 || { echo >&2 “Git is not installed.”; GITINSTALLED=0; }

   if NODEINSTALLED == 0 || GITINSTALLED == 0 ]; then

      echo “Node.js and Git need to be installed before proceeding”

      echo “Do you want to download them? (y n) c”

      read prerequest

      case $prerequest in

      y) echo “Install PreReqs”

       if < ‘uname -a | grep -c Darwin’ -eq 1 ]; then

         echo “OSX detected”

         open https://git-scm.com/download/mac

      sleep 5  

      open https://nodejs.org/dist/v6.1.0/node-v6.1.0.pkg

       else

         echo “OSX not detected”

      open https://nodejs.org/en/

      open https://git-scm.com/download

       fi 

       echo “Press Enter to continue… “

         read confirmation

         ;;

      n) echo “OK”;;

      ) echo “Invalid choice”;;

      esac

   fi

}

instructions1()

{

clear

echo “#####################################################################”

echo “#                          Instructions “

echo “#####################################################################”

echo “Create a NEW Connected App. (This is required to continue)”

echo “Open the Org for Salesforce and go to Setup”

echo "   * Create Connected app”

echo "   * Connected App Name: NBCSandbox1 (No spaces, just like Salesforce)”

echo "   * API Name: NBCSandbox1 (same as Connected App Name)“

echo "   * Contact email: whatever you want”

echo "   * Click   Enable OAuth Settings   box"

echo "   * Callback URL:  http://localhost:3000";

echo "   * Selected OAuth Scopes: choose   Access and manage your data (api), add it to the right box"

echo "   * Save"

echo "   * Click on the saved app to show the Consumer Key and Consumer Secret"

echo "   * Get your security Token: (My Settings, Personal, Reset my security token)“

echo "   *    Note: My Settings must be enabled for your profile.”

echo "   * Password + Security Token"

echo " "

echo “Are you ready to enter the Authentication Settings now? (y n)”

read read2

case $read2 in

y) authentication

   ;;

n) echo “OK”;;

) echo “Invalid choice”;;

esac

}


check_env() 

{

   clear

   echo “Checking currently installed items”

   echo “------------------------------------------------------- “

   echo “Checking Node Package Manager Installation”

   npm --version

   echo “-------------------------------------”

   echo “Checking Node Package Manager Installation”

   if - -d skuid-grunt-starter ]; then

       echo clone of skuid-grunt-starter.git not run yet

   else

    echo skuid-grunt-starter.git exists

   fi

   echo “-------------------------------------”

   echo “Checking GIT Installation”

   git --version

   echo “-------------------------------------”

   echo “Checking GRUNT-CLI Installation”

   grunt --version

   echo “-------------------------------------”

   echo “Checking for Authentication values set”  

   echo Consumer Key: $CON_APP_CLIENT_ID

   echo Client Secret: $CON_APP_CLIENT_SECRET

   echo Username: $SKUID_GRUNT_USERNAME

   echo Security Token: $stoken

   echo Password with appended Security Token: $SKUID_GRUNT_PASSWORD

   echo GruntfilesDir: $GruntfilesDir 

   echo “-------------------------------------”

   echo Git Config File:

   cat ~/.gitconfig

   echo “-------------------------------------”

   echo Commit edit message File:

   cat skuid-grunt-starter/.git/COMMIT_EDITMSG

   echo “-------------------------------------”

   echo “Press Enter to continue… “

   read confirmation

}


authentication()

{

   echo “Access ClientID and Client Secret in the Saleforce Org”

   echo “------------------------------------------------------”

   echo “Go to Build, Create then apps”

   echo “Go to the bottom of the page and click New button”

   echo “Copy the Consumer Key”

   echo $“Paste the Consumer Key Here:  c”

   read CON_APP_CLIENT_ID

   echo $“Paste the Client Secret Here:  c”

   read CON_APP_CLIENT_SECRET

   echo $“Paste your username Here:  c”

   read SKUID_GRUNT_USERNAME

   echo $“Paste the password Here:  c”

   read SKUID_GRUNT_PASSWORD

   echo $“Paste your Security Token Here:  c”

   read stoken

   SKUID_GRUNT_PASSWORD=$SKUID_GRUNT_PASSWORD$stoken

   clear

   export CON_APP_CLIENT_ID

   export CON_APP_CLIENT_SECRET

   export SKUID_GRUNT_USERNAME

   export SKUID_GRUNT_PASSWORD


   

   echo export CON_APP_CLIENT_ID=$CON_APP_CLIENT_ID > .menusrc

   echo export CON_APP_CLIENT_SECRET=$CON_APP_CLIENT_SECRET >> .menusrc

   echo export SKUID_GRUNT_USERNAME=$SKUID_GRUNT_USERNAME >> .menusrc

   echo export SKUID_GRUNT_PASSWORD=$SKUID_GRUNT_PASSWORD >> .menusrc

   sleep 1

#   . .menusrc

    if ‘uname -a | grep -c Darwin’ -eq 1 ]; then

       echo “OSX detected”

       echo “#############################” >> ~/.bash_profile

       date “+SkuidGruntInstall_%Y%m%d_%H%M%S config” >> ~/.bash_profile

       cat .menusrc >> ~/.bash_profile

        . ~/.bash_profile

     else

       echo “OSX not detected. Configure for Linux”

       echo “#############################” >> ~/.bashrc

       date “+SkuidGruntInstall_%Y%m%d_%H%M%S config” >> ~/.bashrc

       cat .menusrc >> ~/.bashrc

        . ~/.bashrc

     fi 

     echo “Press Enter to continue… “

     read confirmation

   echo $”

   echo $“A directory to store the Skuid files will need to be defined in Grunfile.js”

   echo “Press Enter to continue… “

   read confirmation

   echo $”

   echo $”

   echo “Installation still needs to be done. Want to do that now? (y n)”

   read choice2

   case $choice2 in

   y) installation

      ;;

   n) echo “OK”;;

   *) echo “Invalid choice”;;

   esac


}


installation()

{

   clear

   echo “This script will install the necessary components for Skuid-Grunt integration”

   echo $“Press Enter to continue… c”

   read confirmation

   install_log=$PWD”/”‘date “+SkuidGruntInstall_%Y%m%d_%H%M%S.log”’

   #echo Log file - $install_log

   echo $”

   echo $”

   echo ########### npm install -g grunt-cli ##################

   echo “Executing: “” npm install -g grunt-cli “”  (note: will not finish without network connection)”

   echo $”

   echo “This will use the Node Package Manager to install the Grunt Command Line Interpreter”

   echo $”

   echo “Press Enter to execute…wait till finished.  If the time is too long,  Ctrl c”

   echo npm install -g grunt-cli | tee -a $install_log

   read confirmation

   npm install -g grunt-cli 

   echo $”

   echo $”

   grep -n error npm-debug.log | tee -a $install_log

   clear

   ############### git clone of skuid-grunt-starter.git ##############

   echo  “Executing: git clone of skuid-grunt-starter.git”

   echo “This will bring a skeleton of a basic project to your local drive”

   echo “and remove any pre-existing skuid-grunt-starter directories”

   echo “Press Enter to continue…”

   read confirmation

   if t -d skuid-grunt-starter ]; then

       rm -rf skuid-grunt-starter

   fi

   echo “git clone https://bitbucket.org/skuid/skuid-grunt-starter.git”; | tee -a $install_log

   git clone https://bitbucket.org/skuid/skuid-grunt-starter.git

   cd skuid-grunt-starter

   pwd

   echo Removing leftover .gir directory| tee -a $install_log

   rm -rf .git

   echo  Initializing GIT | tee -a $install_log

   git init

   echo Adding git element | tee -a $install_log

   git add .

   echo Commiting new file with label: Project scaffolding | tee -a $install_log

   git commit -m “Project scaffolding”

   echo Installing Node Package Manager | tee -a $install_log

   npm install

   grunt --version | tee -a $install_log

   echo $“Press Enter to continue… c”

      read confirmation

}


skuidgrunterrors() 

{

       echo “Here are some possible errors:”

       echo "   Warning: Task “skuid-pull:dev” not found. Use --force to continue.”

       echo "   --You are not in the skuid-grunt-starter directory created during installation”

       echo "   Fatal error: invalid_grant - authentication failure”

       echo "   --Reset Security Token. Run env from terminal and ensure your variables are correct”

       echo "   Fatal error: Could not find a match for URL /skuid/api/v1/pages”

       echo "   --This can happen if Skuid is below version 7.31. Upgrade Skuid”

       echo "   --Goto Installed Packages to view version. Goto AppExchange to Upgrade”

       echo “”

       echo $“Press Enter to continue… c”

       read confirmation

}

#”~/.gitconfig" 

#skuid-grunt-starter/.git/COMMIT_EDITMSG

clear

prereqs

########################  MENU  ################################

while true

do

  clear

  echo “###########################################################################” 

  echo “#                           Skuid Grunt                                   #”

  echo “###########################################################################” 

  echo “# A toolkit that enables Skuid developers to extend their development     #”

  echo “#  processes to their Skuid pages                                         #” 

  echo “#                                                                         #”

  echo “# Features:                                                               #”

  echo “# * Pull Skuid pages from any Salesforce org into your local filesystem.  #”

  echo “# * Push Skuid pages from a local filesystem to any Salesforce org.       #”

  echo “# * Generate a Skuid Page Pack that can be shared across orgs.            #”

  echo “#-------------------------------------------------------------------------#” 

  echo “# - Skuid: Tom Scalzo    May 2016                                         #” 

  echo “#-------------------------------------------------------------------------#” 

  echo “1  - Instruction (Beginner)” 

  echo “2  - Check Current Environment”

  echo “3  - Set Authentication Values”

  echo “4  - Installation”

  echo “5  - Test pull pages for Dev”

  echo “q  - Quit”

  echo 

  if $NODEINSTALLED == 0  ]; then

  echo “Warning: NPM is not installed. This is required. Choose option 3 to download”

  fi

  if $GITINSTALLED == 0 ]; then

  echo “Warning: GIT is not installed. This is required. Choose option 3 to download”

  fi

  echo $“Enter your menu choice: c”


  read read1

  clear

  case $read1 in 

    q) echo exiting

       exit;;

    1) echo “1 - Instructions1”;

        $setx;

   instructions1

   set +x;;

    2) echo “Check ENV”;

       $setx;

       check_env

       set +x;;

    3) echo “Authentication”;

       $setx;

       authentication

       set +x;;

    4) echo “Installation”;

       $setx;

       installation       

       set +x;;

    5) echo "skuid-pull:dev “;

       $setx;

       cd skuid-grunt-starter

       clear

       skuidgrunterrors

       echo $”

"

       grunt skuid-pull:dev

       echo $“Press Enter to continue… c”

       read confirmation

       set +x;;       

    😉 echo “Invalid option”;;

  esac

# exit

done