-
Notifications
You must be signed in to change notification settings - Fork 1
/
builder.sh
196 lines (149 loc) · 4.81 KB
/
builder.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
RED='\033[1;31m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color
DIR=$(cd `dirname $0` && pwd)
DIR_VUE="${DIR}/modules/AdminPanelWebclient/vue"
TASK="list"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-t|--task)
TASK="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
getThemeList ()
{
LIST=$(find ${DIR}/modules/CoreWebclient/styles/themes -maxdepth 1 -mindepth 1 -type d -printf '%f,')
echo ${LIST::-1}
}
if [ "$TASK" = "list" ]; then
printf "The script can be used to intall NPM dependencies and build required static files. See the full list of the supported commands:
- npm
- build
- build-main
- build-admin
- watch-js
- watch-styles
- pack
- upload
- prepare-demo
- upload-demo
- build-documentation
- analyze
"
fi
echo TASK: "$TASK"
if [ "$TASK" = "npm" ]; then
cd ${DIR}
npm install
if [ -d "$DIR_VUE" ]; then
cd ${DIR_VUE}
npm install
npm install -g @quasar/cli
fi
fi
if [ "$TASK" = "build" ]; then
./builder.sh -t build-main
./builder.sh -t build-admin
fi
if [ "$TASK" = "build-main" ]; then
cd ${DIR}
THEME_LIST="$(getThemeList)"
npm run styles:build --themes=${THEME_LIST}
npm run js:build
npm run js:min
fi
if [ "$TASK" = "build-admin" ]; then
if [ -d "$DIR_VUE" ]; then
cd ${DIR_VUE}
npm run build-production
fi
fi
if [ "$TASK" = "watch-js" ]; then
cd ${DIR}
printf "${GREEN}Running watcher for ${RED}JS files\n"$NC
npm run js:watch
fi
if [ "$TASK" = "watch-styles" ]; then
cd ${DIR}
THEME_LIST="$(getThemeList)"
printf "${GREEN}Running watcher for themes: ${RED}${THEME_LIST}\n"$NC
npm run styles:watch --themes ${THEME_LIST}
fi
if [ "$TASK" = "pack" ]; then
echo 'deny from all' > data/.htaccess
PRODUCT_VERSION=`cat VERSION`
if [ -f "$DEMO_MODULES_FILE" ]; then
PRODUCT_VERSION=`cat VERSION`
rm ${PRODUCT_NAME}_${PRODUCT_VERSION}.zip
fi
printf $GREEN"CREATING ZIP FILE: ${RED}${PRODUCT_NAME}_${PRODUCT_VERSION}.zip\n"$NC
zip -rq ${PRODUCT_NAME}_${PRODUCT_VERSION}.zip data/settings/config.json data/settings/modules data/.htaccess modules static system vendor dev adminpanel ".htaccess" dav.php index.php LICENSE VERSION README.md CHANGELOG.txt favicon.ico robots.txt package.json composer.json composer.lock pre-config.json -x **/*.bak *.git* *node_modules/\*
fi
if [ "$TASK" = "upload" ]; then
cd ${DIR}
PRODUCT_VERSION=`cat VERSION`
echo UPLOAD ZIP FILE: "${PRODUCT_NAME}_${PRODUCT_VERSION}.zip"
curl -v --ftp-create-dirs --retry 6 -T ${PRODUCT_NAME}_${PRODUCT_VERSION}.zip -u ${FTP_USER}:${FTP_PASSWORD} ftp://afterlogic.com/
fi
if [ "$TASK" = "prepare-demo" ]; then
cd ${DIR}
printf "Adding extra modules at ${GREEN}${DIR}${NC}...\n"
curl -o ${DIR}/extra_modules.txt -u ${FTP_USER}:${FTP_PASSWORD} ftp://afterlogic.com/demo/${PRODUCT_NAME}/extra_modules.txt
# wget --no-parent --recursive --level=1 --no-directories --user=${FTP_USER} --password=${FTP_PASSWORD} ftp://afterlogic.com/demo/${PRODUCT_NAME}/
DEMO_MODULES_FILE="./extra_modules.txt"
if [ -f "$DEMO_MODULES_FILE" ]; then
printf $GREEN"Installing demo modules.\n"$NC
HAS_DEMO=`cat composer.json | grep -o --max-count=1 demo-mode-plugin`
if [ "${HAS_DEMO}" = "" ]; then
sed -i '/"afterlogic\/aurora-framework".*/r extra_modules.txt' composer.json
fi
# temporarily removing plesk signup module
sed -i '/aurora-module-mail-signup-plesk/d' composer.json
php composer.phar update afterlogic/aurora-module-demo-mode-plugin
else
printf $RED"No extra_modules.txt file is found. Skipping this step.\n"$NC
fi
printf $GREEN"End 'prepare-demo' task\n"$NC
fi
if [ "$TASK" = "upload-demo" ]; then
cd ${DIR}
PRODUCT_VERSION=`cat VERSION`
echo UPLOAD ZIP FILE: "${PRODUCT_NAME}_${PRODUCT_VERSION}.zip"
curl -v --ftp-create-dirs --retry 6 -T ${PRODUCT_NAME}_${PRODUCT_VERSION}.zip -u ${FTP_USER}:${FTP_PASSWORD} ftp://afterlogic.com/demo/
fi
if [ "$TASK" = "build-documentation" ]; then
cd ${DIR}
PRODUCT_VERSION=`cat VERSION`
DOCUMENTATION_FILE=${PRODUCT_NAME}_${PRODUCT_VERSION}_apigen.zip
printf "${GREEN}BUILDING DOCUMENTATION\n"$NC
cd ${DIR}/dev/docs
./build-apigen.sh
# ./build-phpdoc.sh
printf "${GREEN}PACKING DOCUMENTATION: ${RED}${DOCUMENTATION_FILE}\n"$NC
cd ${DIR}/docs/api
echo $(cd `dirname $0` && pwd)
zip -rq ${DOCUMENTATION_FILE} *
curl -v --ftp-create-dirs --retry 6 -T ${DOCUMENTATION_FILE} -u ${FTP_USER}:${FTP_PASSWORD} ftp://afterlogic.com/
fi
if [ "$TASK" = "analyze" ]; then
cd ${DIR}
vendor/bin/phpstan analyse | grep '[ERROR]' -F
# if [ $? != 0 ]
# then
printf "\r\n To get more details on the found errors please run:\r\n "$YELLOW"vendor/bin/phpstan analyze"$NC"\r\n"
exit 1
# fi
fi