on master help sign in
[mod] simplify manage.sh

- npm install less@2.7 less-plugin-clean-css grunt-cli is moved inside manage.sh - if it is possible to source manage.sh to update the PATH (to start grunt) - tidy the help documentation - update the geckodriver version to 0.19.1

commit5dc8b271f03763c1f9f2614701a176b72ddce108 authorAlexandre Flament <alex@al-f.net> dateSun 10 Dec 2017, 10:30 (9 years ago) parent7752b0a
2 files changed+67−33
.travis.yml+1−3 manage.sh+66−30
.travis.yml+1−3
@@ -13,11 +13,9 @@ python:
1313before_install:
1414 - "export DISPLAY=:99.0"
1515 - "sh -e /etc/init.d/xvfb start"
16− - npm install less@2.7 less-plugin-clean-css grunt-cli
17− - export PATH=`pwd`/node_modules/.bin:$PATH
16+install:
1817 - ./manage.sh install_geckodriver ~/drivers
1918 - export PATH=~/drivers:$PATH
20−install:
2119 - ./manage.sh npm_packages
2220 - ./manage.sh update_dev_packages
2321 - pip install codecov
manage.sh+66−30
@@ -1,11 +1,27 @@
11#!/bin/sh
22
33BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")"
4+export PATH="$BASE_DIR/node_modules/.bin":$PATH
5+
6+# the script can be sourced to update the PATH
7+# see https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
8+if [ $_ != $0 ]; then
9+ unset BASE_DIR
10+ # sourced : exit now
11+ return
12+fi
13+
14+# subshell
415PYTHONPATH="$BASE_DIR"
516SEARX_DIR="$BASE_DIR/searx"
617ACTION="$1"
718
819cd -- "$BASE_DIR"
20+set -e
21+
22+#
23+# Python
24+#
925
1026update_packages() {
1127 pip install --upgrade pip
@@ -27,7 +43,7 @@ install_geckodriver() {
2743 if [ -z "$NOTFOUND" ]; then
2844 return
2945 fi
30− GECKODRIVER_VERSION="v0.18.0"
46+ GECKODRIVER_VERSION="v0.19.1"
3147 PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
3248 case "$PLATFORM" in
3349 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
@@ -58,6 +74,10 @@ install_geckodriver() {
5874 chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
5975}
6076
77+locales() {
78+ pybabel compile -d "$SEARX_DIR/translations"
79+}
80+
6181pep8_check() {
6282 echo '[!] Running pep8 check'
6383 # ignored rules:
@@ -92,26 +112,16 @@ tests() {
92112 set +e
93113}
94114
95−build_style() {
96− lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
97−}
98115
99−styles() {
100− echo '[!] Building styles'
101− build_style themes/legacy/less/style.less themes/legacy/css/style.css
102− build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
103− build_style themes/courgette/less/style.less themes/courgette/css/style.css
104− build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
105− build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
106− build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
107− # built using grunt
108− #build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
109− #build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
110− #build_style themes/simple/less/style.less themes/simple/css/searx.min.css
111− #build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
112−}
116+#
117+# Web
118+#
113119
114120npm_packages() {
121+ echo '[!] install NPM packages'
122+ cd -- "$BASE_DIR"
123+ npm install less@2.7 less-plugin-clean-css grunt-cli
124+
115125 echo '[!] install NPM packages for oscar theme'
116126 cd -- "$BASE_DIR/searx/static/themes/oscar"
117127 npm install
@@ -121,6 +131,23 @@ npm_packages() {
121131 npm install
122132}
123133
134+build_style() {
135+ lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
136+}
137+
138+styles() {
139+ echo '[!] Building legacy style'
140+ build_style themes/legacy/less/style.less themes/legacy/css/style.css
141+ build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
142+ echo '[!] Building courgette style'
143+ build_style themes/courgette/less/style.less themes/courgette/css/style.css
144+ build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
145+ echo '[!] Building pix-art style'
146+ build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
147+ echo '[!] Building bootstrap style'
148+ build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
149+}
150+
124151grunt_build() {
125152 echo '[!] Grunt build : oscar theme'
126153 grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
@@ -128,9 +155,9 @@ grunt_build() {
128155 grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
129156}
130157
131−locales() {
132− pybabel compile -d "$SEARX_DIR/translations"
133−}
158+#
159+# Help
160+#
134161
135162help() {
136163 [ -z "$1" ] || printf 'Error: %s\n' "$1"
@@ -138,19 +165,28 @@ help() {
138165
139166Commands
140167========
141− npm_packages - Download & install dependencies
142− grunt_build - Build js files
143168 help - This text
169+
170+ Build requirements
171+ ------------------
172+ update_packages - Check & update production dependency changes
173+ update_dev_packages - Check & update development and production dependency changes
174+ install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests)
175+ npm_packages - Download & install npm dependencies (source manage.sh to update the PATH)
176+
177+ Build
178+ -----
144179 locales - Compile locales
145− pep8_check - Pep8 validation
146− py_test_coverage - Unit test coverage
147− robot_tests - Run selenium tests
148180 styles - Build less files
149− tests - Run all python tests (pep8, unit, robot)
181+ grunt_build - Build files for themes
182+
183+ Tests
184+ -----
150185 unit_tests - Run unit tests
151− update_dev_packages - Check & update development and production dependency changes
152− update_packages - Check & update dependency changes
153− install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests)
186+ pep8_check - Pep8 validation
187+ robot_tests - Run selenium tests
188+ tests - Run all python tests (pep8, unit, robot_tests)
189+ py_test_coverage - Unit test coverage
154190"
155191}
156192