Browse Source

Merge pull request #1112 from dalf/manange_sh

[mod] simplify manage.sh
Adam Tauber 7 years ago
parent
commit
88f2c6dc96
No account linked to committer's email
2 changed files with 67 additions and 33 deletions
  1. 1
    3
      .travis.yml
  2. 66
    30
      manage.sh

+ 1
- 3
.travis.yml View File

13
 before_install:
13
 before_install:
14
   - "export DISPLAY=:99.0"
14
   - "export DISPLAY=:99.0"
15
   - "sh -e /etc/init.d/xvfb start"
15
   - "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:
18
   - ./manage.sh install_geckodriver ~/drivers
17
   - ./manage.sh install_geckodriver ~/drivers
19
   - export PATH=~/drivers:$PATH
18
   - export PATH=~/drivers:$PATH
20
-install:
21
   - ./manage.sh npm_packages
19
   - ./manage.sh npm_packages
22
   - ./manage.sh update_dev_packages
20
   - ./manage.sh update_dev_packages
23
   - pip install codecov
21
   - pip install codecov

+ 66
- 30
manage.sh View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 
2
 
3
 BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")"
3
 BASE_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
4
 PYTHONPATH="$BASE_DIR"
15
 PYTHONPATH="$BASE_DIR"
5
 SEARX_DIR="$BASE_DIR/searx"
16
 SEARX_DIR="$BASE_DIR/searx"
6
 ACTION="$1"
17
 ACTION="$1"
7
 
18
 
8
 cd -- "$BASE_DIR"
19
 cd -- "$BASE_DIR"
20
+set -e
21
+
22
+#
23
+# Python
24
+#
9
 
25
 
10
 update_packages() {
26
 update_packages() {
11
     pip install --upgrade pip
27
     pip install --upgrade pip
27
     if [ -z "$NOTFOUND" ]; then
43
     if [ -z "$NOTFOUND" ]; then
28
         return
44
         return
29
     fi
45
     fi
30
-    GECKODRIVER_VERSION="v0.18.0"
46
+    GECKODRIVER_VERSION="v0.19.1"
31
     PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
47
     PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
32
     case "$PLATFORM" in
48
     case "$PLATFORM" in
33
         "linux 32bit" | "linux2 32bit") ARCH="linux32";;
49
         "linux 32bit" | "linux2 32bit") ARCH="linux32";;
58
     chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
74
     chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
59
 }
75
 }
60
 
76
 
77
+locales() {
78
+    pybabel compile -d "$SEARX_DIR/translations"
79
+}
80
+
61
 pep8_check() {
81
 pep8_check() {
62
     echo '[!] Running pep8 check'
82
     echo '[!] Running pep8 check'
63
     # ignored rules:
83
     # ignored rules:
92
     set +e
112
     set +e
93
 }
113
 }
94
 
114
 
95
-build_style() {
96
-    lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
97
-}
98
 
115
 
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
+#
113
 
119
 
114
 npm_packages() {
120
 npm_packages() {
121
+    echo '[!] install NPM packages'
122
+    cd -- "$BASE_DIR"
123
+    npm install less@2.7 less-plugin-clean-css grunt-cli
124
+
115
     echo '[!] install NPM packages for oscar theme'
125
     echo '[!] install NPM packages for oscar theme'
116
     cd -- "$BASE_DIR/searx/static/themes/oscar"
126
     cd -- "$BASE_DIR/searx/static/themes/oscar"
117
     npm install
127
     npm install
121
     npm install
131
     npm install
122
 }
132
 }
123
 
133
 
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
+
124
 grunt_build() {
151
 grunt_build() {
125
     echo '[!] Grunt build : oscar theme'
152
     echo '[!] Grunt build : oscar theme'
126
     grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
153
     grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
128
     grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
155
     grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
129
 }
156
 }
130
 
157
 
131
-locales() {
132
-    pybabel compile -d "$SEARX_DIR/translations"
133
-}
158
+#
159
+# Help
160
+#
134
 
161
 
135
 help() {
162
 help() {
136
     [ -z "$1" ] || printf 'Error: %s\n' "$1"
163
     [ -z "$1" ] || printf 'Error: %s\n' "$1"
138
 
165
 
139
 Commands
166
 Commands
140
 ========
167
 ========
141
-    npm_packages         - Download & install dependencies
142
-    grunt_build          - Build js files
143
     help                 - This text
168
     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
+    -----
144
     locales              - Compile locales
179
     locales              - Compile locales
145
-    pep8_check           - Pep8 validation
146
-    py_test_coverage     - Unit test coverage
147
-    robot_tests          - Run selenium tests
148
     styles               - Build less files
180
     styles               - Build less files
149
-    tests                - Run all python tests (pep8, unit, robot)
181
+    grunt_build          - Build files for themes
182
+
183
+    Tests
184
+    -----
150
     unit_tests           - Run unit tests
185
     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
154
 "
190
 "
155
 }
191
 }
156
 
192