#!/bin/bash

REPO_NAME=p101xp-release
REPO_URL="https://artifactory101xp.jfrog.io/artifactory101xp/api/pods/$REPO_NAME"

echo "Install cocoapods..."
if [[ -z `gem list | grep cocoapods` ]]; then
	sudo gem install cocoapods
else
	echo "Skip: cocoapods already installed!"
fi

echo "Install cocoapods-art..."
if [[ -z `gem list | grep cocoapods-art` ]]; then
	sudo gem install cocoapods-art
else
	echo "Skip: cocoapods-art already installed!"
fi

echo "Create netrc..."
if [ ! -f ~/.netrc ]; then
	echo "machine artifactory101xp.jfrog.io
	login sdk-user
	password Dt!k(5JR&6" > ~/.netrc
	echo "netrc is created"
else
	echo "Skip: netrc already exists!"
fi

echo "Add repo $REPO_NAME..."
if [ ! -d ~/.cocoapods/repos-art/$REPO_NAME ]; then
	pod repo-art add $REPO_NAME $REPO_URL
else
	echo "Skip: repo already exists!"
fi

echo "Try to update repo $REPO_NAME..."
pod repo-art update $REPO_NAME
if [ -f Podfile ]; then
	pod update
fi
