Procházet zdrojové kódy

Merge pull request #1112 from dalf/manange_sh

[mod] simplify manage.sh
Adam Tauber před 7 roky
rodič
revize
88f2c6dc96
No account linked to committer's email
2 změnil soubory, kde provedl 67 přidání a 33 odebrání
  1. 1
    3
      .travis.yml
  2. 66
    30
      manage.sh

+ 1
- 3
.travis.yml Zobrazit soubor

@@ -13,11 +13,9 @@ python:
13 13
 before_install:
14 14
   - "export DISPLAY=:99.0"
15 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 17
   - ./manage.sh install_geckodriver ~/drivers
19 18
   - export PATH=~/drivers:$PATH
20
-install:
21 19
   - ./manage.sh npm_packages
22 20
   - ./manage.sh update_dev_packages
23 21
   - pip install codecov

+ 66
- 30
manage.sh Zobrazit soubor

@@ -1,11 +1,27 @@
1 1
 #!/bin/sh
2 2
 
3 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 15
 PYTHONPATH="$BASE_DIR"
5 16
 SEARX_DIR="$BASE_DIR/searx"
6 17
 ACTION="$1"
7 18
 
8 19
 cd -- "$BASE_DIR"
20
+set -e
21
+
22
+#
23
+# Python
24
+#
9 25
 
10 26
 update_packages() {
11 27
     pip install --upgrade pip
@@ -27,7 +43,7 @@ install_geckodriver() {
27 43
     if [ -z "$NOTFOUND" ]; then
28 44
         return
29 45
     fi
30
-    GECKODRIVER_VERSION="v0.18.0"
46
+    GECKODRIVER_VERSION="v0.19.1"
31 47
     PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
32 48
     case "$PLATFORM" in
33 49
         "linux 32bit" | "linux2 32bit") ARCH="linux32";;
@@ -58,6 +74,10 @@ install_geckodriver() {
58 74
     chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
59 75
 }
60 76
 
77
+locales() {
78
+    pybabel compile -d "$SEARX_DIR/translations"
79
+}
80
+
61 81
 pep8_check() {
62 82
     echo '[!] Running pep8 check'
63 83
     # ignored rules:
@@ -92,26 +112,16 @@ tests() {
92 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 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 125
     echo '[!] install NPM packages for oscar theme'
116 126
     cd -- "$BASE_DIR/searx/static/themes/oscar"
117 127
     npm install
@@ -121,6 +131,23 @@ npm_packages() {
121 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 151
 grunt_build() {
125 152
     echo '[!] Grunt build : oscar theme'
126 153
     grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
@@ -128,9 +155,9 @@ grunt_build() {
128 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 162
 help() {
136 163
     [ -z "$1" ] || printf 'Error: %s\n' "$1"
@@ -138,19 +165,28 @@ help() {
138 165
 
139 166
 Commands
140 167
 ========
141
-    npm_packages         - Download & install dependencies
142
-    grunt_build          - Build js files
143 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 179
     locales              - Compile locales
145
-    pep8_check           - Pep8 validation
146
-    py_test_coverage     - Unit test coverage
147
-    robot_tests          - Run selenium tests
148 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 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