-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
163 lines (135 loc) · 3.44 KB
/
build.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh
get_help()
{
echo "Usage: build -n -d"
echo "-n : skip initialization <optional>"
echo "-d : skip database configuration <optional>"
}
exists()
{
command -v "$1" >/dev/null 2>&1
}
sub_init()
{
if exists dotnet
then
echo "dotnet core is installed on your machine"
else
echo "The .Net Core SDK 1.0.3 is not installed on your machine."
echo "Please get it from here: https://go.microsoft.com/fwlink/?linkid=843448 "
exit
fi
if exists jq
then
echo "jq is installed"
else
echo "The jq JSON parser is not installed. Installing jq..."
sudo apt-get install jq
fi
if exists nodejs
then
echo "NodeJS is installed"
else
echo "NodeJS is not installed. Installing NodeJs..."
sudo apt-get install nodejs
current_location=`pwd`
cd /usr/bin
sudo ln -s nodejs node
cd $current_location
fi
if exists npm
then
echo "npm is installed"
else
echo "npm is not installed. Installing npm..."
sudo apt-get install npm
fi
if exists gulp
then
echo "gulp is installed"
else
echo "gulp is not installed. Installing gulp..."
sudo npm install --global gulp
fi
}
sub_db_config()
{
conn_str=$2;
echo "switching dir to $1"
old_folder=`pwd`
cd $1
encoding=`file --mime-encoding -b appsettings.json`
case $encoding in
"utf-16le")
encoding="utf-16"
;;
"utf-16be")
encoding="utf-16"
;;
esac
contents=`cat appsettings.json | iconv -f $encoding -t ascii`
echo $contents | jq ".ConnectionStrings.Default=\"$2\"" | iconv -f ascii -t $encoding > appsettings.json
cd $old_folder
echo "switching back to parent dir"
}
build_project()
{
folder=$1
current_location=`pwd`
cd $folder
echo "Restoring nuget packages"
dotnet restore
echo "Building project $2"
dotnet build
xterm -e dotnet run &
cd $current_location
}
init=true;
db_config=true;
while getopts "ndh" OPTION
do
case $OPTION in
n)
init=false;
;;
d)
db_config=false;
;;
h)
get_help
exit
;;
esac
done
if $init
then
sub_init
fi
if $db_config
then
IFS= read -r -p "Please set a connection string to an empty or existing database: " connection_string
echo "The connection string is: $connection_string "
sub_db_config "src/RestServices/" "$connection_string"
sub_db_config "src/UI/" "$connection_string"
fi
build_project "src/RestServices" "RestServices"
current=`pwd`
cd "src/UI"
npm install
gulp -b "`pwd`" --color --gulpfile gulpfile.js copy-all
gulp -b "`pwd`" --color --gulpfile gulpfile.js sass
cd $current
build_project "src/UI" "Developer Marketplace"
echo "All Done!"
cat << "EOF"
__________________________________________________
| _____________________________ |
| [1] [2] _____________________________ [_][_][_] |
| [3] [4] [_][_][_] [_][_][_][_] [_][_] [_][_][_] |
| [5] [6] [][][][][][][][][][][][][][_] [1][2][3] |
| [7] [8] [_][][][][][][][][][][][][][] [4][5][6] |
| [9][10] [__][][][][][][][][][][][][_] [7][8][9] |
| [11][12] [___][][][][][][][][][][][__] [__][0][] |
| [_][______________][_] |
|__________________________________________________|
EOF