Last active
February 24, 2017 13:29
-
-
Save engelfrost/1d3e50019fa2b31acd7d to your computer and use it in GitHub Desktop.
Clone and set up Diversity components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Guess what group the project belongs to | |
function _smart-clone() { | |
local result_name=$1 | |
local repo=$2 | |
local dest=$3 | |
local group | |
if [[ `curl --silent --head --output /dev/null -w "%{http_code}" "https://git.diversity.io/textalk-webshop-native-components/$repo"` == "200" ]] | |
then | |
group="textalk-webshop-native-components" | |
elif [[ `curl --silent --head --output /dev/null -w "%{http_code}" "https://git.diversity.io/textalk-custom-components/$repo"` == "200" ]] | |
then | |
group="textalk-custom-components" | |
elif [[ `curl --silent --head --output /dev/null -w "%{http_code}" "https://git.diversity.io/themes/$repo"` == "200" ]] | |
then | |
group="themes" | |
elif [[ `curl --silent --head --output /dev/null -w "%{http_code}" "https://git.diversity.io/tooling/$repo"` == "200" ]] | |
then | |
group="tooling" | |
elif [[ `curl --silent --head --output /dev/null -w "%{http_code}" "https://git.diversity.io/textalk-custom-themes/$repo"` == "200" ]] | |
then | |
group="custom-themes" | |
fi | |
if [[ -z "$group" ]] | |
then | |
echo "Repo not found" | |
((${result_name}=1)) | |
else | |
git clone [email protected]:$group/$repo.git $dest | |
cd "$dest" | |
((${result_name}=0)) | |
fi | |
} | |
// Clone and set up a Diversity repo | |
function _diversity-clone() { | |
local res | |
local repo=$1 | |
local dest=$2 | |
local feature_branch=$3 | |
_smart-clone res $repo $dest | |
if [[ $res -eq 0 ]] | |
then | |
git checkout master | |
git flow init -df | |
if [[ -n "$feature_branch" ]] | |
then | |
git flow feature start $feature_branch | |
fi | |
atom . | |
yarn | |
if [[ -d "test" ]] | |
then | |
gulp test-dependencies | |
fi | |
if [[ -a ".jscsrc" ]] | |
then | |
json -I -f .jscsrc -e 'this.preset="airbnb"' | |
json -I -f .jscsrc -e 'delete this.esnext=true' | |
json -I -f .jscsrc -e 'delete this.maximumLineLength' | |
fi | |
if [[ -a ".jshintrc" ]] | |
then | |
json -I -f .jshintrc -e 'this.esnext=true' | |
fi | |
fi | |
} | |
# rsync local repo to stage for testing | |
alias stage-rsync='function _stage-rsync() { | |
local repo | |
local local_path="/home/simon/Code/diversity/components" | |
local stage_username="simon" | |
if [[ -z "$1" ]] | |
then | |
repo=${PWD##*/} | |
else | |
repo=$1 | |
fi | |
# Create directory on stage if it does not exist | |
ssh "[email protected]" "cd /home/$stage_username/diversity; test -d \"$repo\" || mkdir \"$repo\"" | |
# Rsync local git repo to stage | |
rsync --exclude-from "$local_path/$repo/.gitignore" -az -e ssh "$local_path/$repo/" "[email protected]:/home/$stage_username/diversity/$repo" | |
};_stage-rsync' | |
# Remove repo from stage | |
alias stage-rm='function _stage-rm() { | |
local stage_username="simon" | |
if [[ -z "$1" ]] | |
then | |
repo=${PWD##*/} | |
else | |
repo=$1 | |
fi | |
ssh "[email protected]" "cd /home/$stage_username/diversity/; rm -rf \"$repo\"" | |
};_stage-rm' | |
# List repos on stage | |
alias stage-ls='function _stage-ls() { | |
local stage_username="josef" | |
ssh "[email protected]" "ls /home/$stage_username/diversity/" | |
};_stage-ls' | |
alias local-clone='function _local-clone() { | |
local repo=$1 | |
local feature_branch=$2 | |
_diversity-clone $repo "/home/josef/Code/$repo" "$feature_branch" | |
};_local-clone' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment