Forked from Mischi/setup-project-dependencies.sh
Last active
August 29, 2015 14:22
-
-
Save WISHPRO/a49192957ecbbf916e7a to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# | |
# Copyright (c) 2015 Fabian Raetz <fabian.raetz@gmail.com> | |
# | |
# Permission to use, copy, modify, and distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
set -e | |
#set -x | |
scriptdir=$(dirname $0) | |
projectdir=$scriptdir/.. | |
projectname=$(basename -- "$(dirname -- "$scriptdir")") | |
setup_bedrock_ansible_deps() { | |
ansibledir=$projectdir/ansible | |
if [ -d "$ansibledir" ]; then | |
cd $ansibledir | |
ansible-galaxy install -r requirements.yml -p vendor/roles | |
cd - | |
fi | |
} | |
setup_theme_deps() { | |
themedir=$projectdir/site/web/app/themes/$projectname | |
if [ -d "$themedir" ]; then | |
cd $themedir | |
npm install | |
bower install | |
gulp | |
gulp --production | |
cd - | |
fi | |
} | |
setup_bedrock_ansible_deps | |
setup_theme_deps |
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
#!/bin/sh | |
# | |
# Copyright (c) 2015 Fabian Raetz <fabian.raetz@gmail.com> | |
# | |
# Permission to use, copy, modify, and distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
set -e | |
#set -x | |
#TODO | |
#npm -g install npm@latest gulp bower |
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
#!/bin/sh | |
# | |
# Copyright (c) 2015 Fabian Raetz <fabian.raetz@gmail.com> | |
# | |
# Permission to use, copy, modify, and distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
set -e | |
#set -x | |
# folder where this script is located | |
scriptroot=$(dirname $0) | |
usage() { | |
echo "usage: ${0##*/} [-aAcghls] projectname" | |
cat <<EOF | |
options: | |
-A setup sage, bedrock_ansible, bedrock_capistrano and initialize git. | |
-a setup roots/bedrock_ansible. | |
-c setup roots/bedrock_capistrano. | |
-g initialize git repostitory. | |
-h show help / usage. | |
-l use latest version of sage/bedrock_*, instead of latest release. | |
-s setup roots/sage theme and roots/soil plugin. | |
EOF | |
exit 0 | |
} | |
fAnsible=false | |
fCapistrano=false | |
fGit=false | |
fLatest=false | |
fSage=false | |
while getopts "aAcgl" OPT; do | |
case $OPT in | |
a) | |
fAnsible=true | |
;; | |
A) | |
fAnsible=true | |
fCapistrano=true | |
fGit=true | |
fSage=true | |
;; | |
c) | |
fCapistrano=true | |
;; | |
g) | |
fGit=true | |
;; | |
h) | |
usage | |
;; | |
l) | |
fLatest=true | |
;; | |
s) | |
fSage=true | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
# ensure that a projectname is provided | |
[ $# -ne 1 ] && usage | |
projectdir=$1 | |
projectname=$(basename $1) | |
setup() { | |
mkdir -p $projectdir | |
} | |
# clone repo and remove .git folder | |
# save latest commitid in $projectdir | |
clone_git_repo() { | |
local verfile=$projectdir/ROOTSVERSIONS.md | |
local lastrelease=master | |
local src=$1 | |
local dest=$2 | |
git clone $src $dest | |
# checkout last release | |
if ! $fLatest; then | |
lastrelease=$(git -C $dest tag | tail -1) | |
git -C $dest checkout -b $lastrelease | |
fi | |
echo "=== $src ($lastrelease)" >> $verfile | |
git -C $dest log --abbrev-commit --pretty=oneline | head -1 >> $verfile | |
echo >> $verfile | |
rm -rf $dest/.git | |
} | |
setup_bedrock() { | |
echo "setting up bedrock:" | |
clone_git_repo https://github.com/roots/bedrock.git \ | |
$projectdir/site | |
} | |
setup_bedrock_ansible() { | |
echo "setting up bedrock-ansible:" | |
local devconf=$projectdir/ansible/group_vars/development | |
clone_git_repo https://github.com/roots/bedrock-ansible.git \ | |
$projectdir/ansible | |
# TODO: merge with below | |
local name=$(echo $projectname | sed -r 's/(.*)\..*/\1/') | |
sed -e "s/example\.com/$projectname/g" -e "s/example/$name/g" \ | |
$devconf > $devconf-new | |
mv $devconf-new $devconf | |
} | |
setup_bedrock_capistrano() { | |
echo "setting up bedrock-capistrano:" | |
} | |
setup_theme() { | |
echo "setting up theme \"$projectname\" (based on sage):" | |
local themedir=$projectdir/site/web/app/themes/$projectname | |
local assetmanifest=$themedir/assets/manifest.json | |
clone_git_repo https://github.com/roots/sage.git $themedir | |
# TODO: merge with above | |
local name=$(echo $projectname | sed -r 's/(.*)\..*/\1/') | |
sed -e "s/example/$name/g" $assetmanifest> $assetmanifest-new | |
mv $assetmanifest-new $assetmanifest | |
setup_soil | |
} | |
setup_soil() { | |
# TODO: remmove hardcoded version | |
cd $projectdir/site | |
composer require roots/soil 3.4.0 | |
#wp plugin active | |
cd - | |
} | |
setup_git() { | |
echo "setting up git:" | |
git -C $projectdir init | |
git -C $projectdir add . | |
git -C $projectdir commit -m "Initial commmit of \"$projectname\"" | |
} | |
copy_setup_scripts() { | |
echo "copying setup scripts:" | |
local setupdir=$projectdir/setup | |
mkdir $setupdir | |
cp $scriptroot/setup-project-dependencies.sh $setupdir/ | |
} | |
setup | |
setup_bedrock | |
$fAnsible && setup_bedrock_ansible | |
#$fCapistrano && setup_bedrock_capistrano | |
$fSage && setup_theme | |
copy_setup_scripts | |
$fGit && setup_git | |
$projectdir/setup/setup-project-dependencies.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment