forked from lblod/domain-files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.sh
executable file
·105 lines (93 loc) · 2.98 KB
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash -i
repositories=([email protected]:lblod/app-gelinkt-notuleren.git
[email protected]:lblod/app-mandatendatabank.git
[email protected]:lblod/app-digitaal-loket.git
[email protected]:lblod/json-api-documentation.git
[email protected]:lblod/app-toezicht-abb.git
[email protected]:lblod/app-leidinggevenden-databank.git)
confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
cloneOrPullRepository() {
repo=$1
dirname=`echo $repo | sed -r 's/(https:\/\/|git@)github.com(:|\/)[a-z]+\/([a-z-]+)(.git)?/\3/'`
if [ -d $dirname ];then
pushd $dirname > /dev/null
git checkout development > /dev/null
git pull > /dev/null
popd > /dev/null
else
git clone $repo > /dev/null
fi
echo $dirname
}
generateEmber() {
repo=$1
domainSource=$2
dirname=`cloneOrPullRepository $repo`
echo "==== $dirname ===="
pushd $dirname > /dev/null
edi "npm install" < /dev/tty
commands=`docker run --rm -v $work_dir/$domainSource/config/resources/:/config -i command-generator | grep ember | sed -e 's/ember/edi ember/'`
while read line;do
$line < /dev/tty
done <<< "$commands"
git add .
git diff --cached
git status
confirm "Commit files? [y/N]" && git commit -m "syncing shared domain configuration"
popd > /dev/null
}
if [ ! -d $1 ];then
echo "Error : $1 is not a directory"
echo
echo "Usage: "
echo " $0 /your/work/directory"
exit -1
fi
domain_dir=`pwd`
work_dir="$( cd "$1" ; pwd -P )"
echo "will attempt to sync domain files to repositories cloned in $work_dir"
pushd $work_dir > /dev/null
for repository in ${repositories[*]}; do
dirname=`cloneOrPullRepository $repository`
echo "==== $dirname ==="
pushd $dirname > /dev/null
git checkout development
for domain in $domain_dir/master-*-domain.lisp; do
basename=`basename $domain`
filename=`echo $basename | sed -e 's/master-/slave-/'`
cp $domain config/resources/$filename
git add config/resources/$filename
done
git diff --cached
git status
confirm "Commit files? [y/N]" && git commit -m "syncing shared domain configuration" &&
confirm "Push commit? [y/N]" && git push
popd > /dev/null
done
confirm "update admin applications? [y/N]" || exit 0
echo "setting up command generator"
dirname=`cloneOrPullRepository "https://github.com/tenforce/ember-mu-application-generator-generator"`
echo "==== $dirname ==="
pushd $dirname > /dev/null
# fix generator
lastline=`tail -n 1 startup.lisp`
if [[ $lastline != "(exit)" ]];then
echo "(exit)" >> startup.lisp
fi
docker build -t command-generator . > /dev/null
popd > /dev/null
# demo editor
#generateEmber "[email protected]:lblod/frontend-editor-admin" "app-demo-editor"
# loket
#generateEmber "[email protected]:lblod/frontend-loket-admin" "app-digitaal-loket"