summaryrefslogtreecommitdiff
path: root/manage
diff options
context:
space:
mode:
Diffstat (limited to 'manage')
-rwxr-xr-xmanage65
1 files changed, 56 insertions, 9 deletions
diff --git a/manage b/manage
index daa7171da..ec8e13c0a 100755
--- a/manage
+++ b/manage
@@ -1,19 +1,28 @@
#!/usr/bin/env bash
# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
-# shellcheck disable=SC2031
+
+# shellcheck disable=SC2034
+main_cmd="$(basename "$0")"
# shellcheck source=utils/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")/utils/lib.sh"
+# shellcheck source=utils/lib.sh
+source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_nvm.sh"
+
# shellcheck source=utils/lib_static.sh
source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_static.sh"
+# shellcheck source=utils/lib_go.sh
+source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_go.sh"
+
# config
PYOBJECTS="searx"
PY_SETUP_EXTRAS='[test]'
GECKODRIVER_VERSION="v0.28.0"
+export NODE_MINIMUM_VERSION="16.13.0"
# SPHINXOPTS=
pylint.FILES() {
@@ -41,6 +50,7 @@ PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES="supported_languages,language_aliases,log
PYLINT_OPTIONS="-m pylint -j 0 --rcfile .pylintrc"
help() {
+ nvm.help
cat <<EOF
buildenv:
rebuild ./utils/brand.env
@@ -63,9 +73,12 @@ docker.:
gecko.driver:
download & install geckodriver if not already installed (required for
robot_tests)
+EOF
+ nvm.help
+ cat <<EOF
node.:
env : download & install npm dependencies locally
- clean : drop npm installations
+ clean : drop locally npm installations
py.:
build : Build python packages at ./${PYDIST}
clean : delete virtualenv and intermediate py files
@@ -77,6 +90,7 @@ pyenv.:
pypi.upload:
Upload python packages to PyPi (to test use pypi.upload.test)
test.:
+ yamllint : lint YAML files (YAMLLINT_FILES)
pylint : lint PYLINT_FILES, searx/engines, searx & tests
pep8 : pycodestyle (pep8) for all files except PYLINT_FILES
unit : run unit tests
@@ -90,6 +104,7 @@ themes.:
pygments.:
less : build LESS files for pygments
EOF
+ go.help
static_help
}
@@ -498,10 +513,9 @@ gecko.driver() {
}
node.env() {
- if ! required_commands npm; then
- info_msg "to install build tools use::"
- info_msg " sudo -H ./utils/searx.sh install buildhost"
- die 1 "install needed build tools first"
+ if ! nvm.min_node "${NODE_MINIMUM_VERSION}"; then
+ info_msg "install Node.js by NVM"
+ nvm.nodejs
fi
( set -e
@@ -520,7 +534,7 @@ node.clean() {
build_msg CLEAN "npm is not installed / ignore npm dependencies"
return 0
fi
- build_msg CLEAN "locally installed npm dependencies"
+ build_msg CLEAN "themes -- locally installed npm dependencies"
( set -e
npm --prefix searx/static/themes/oscar run clean
npm --prefix searx/static/themes/simple run clean
@@ -692,11 +706,44 @@ themes.oscar() {
}
themes.simple() {
- build_msg GRUNT "theme: simple"
- npm --prefix searx/static/themes/simple run build
+ local static="searx/static/themes/simple"
+ ( set -e
+ convert_if_newer "src/brand/searxng-wordmark.svg" "$static/img/favicon.png" \
+ -transparent white -resize 64x64
+ build_msg GRUNT "theme: simple"
+ npm --prefix searx/static/themes/simple run build
+ )
dump_return $?
}
+convert_if_newer() {
+
+ # usage: convert_if_newer <origfile> <outfile> [<options>, ...]
+ #
+ # convert_if_newer "path/to/origin.svg" "path/to/converted.png" -resize 100x100
+ #
+ # Run's ImageMagik' convert comand to generate <outfile> from <origfile>, if
+ # <origfile> is newer than <outfile>. The command line is to convert is::
+ #
+ # convert <origfile> [<options>, ...] <outfile>
+
+ local src_file="$1" && shift
+ local dst_file="$1" && shift
+
+ if [[ "${src_file}" -nt "${dst_file}" ]]; then
+ if ! required_commands convert; then
+ info_msg "to install build tools use::"
+ info_msg " sudo -H ./utils/searx.sh install buildhost"
+ die 1 "install needed build tools first"
+ fi
+ build_msg CONVERT "${src_file}" "$@" "${dst_file}"
+ convert "${src_file}" "$@" "${dst_file}"
+ else
+ build_msg CONVERT "${dst_file} (up-to-date)"
+ fi
+}
+
+
PYLINT_FILES=()
while IFS= read -r line; do
PYLINT_FILES+=("$line")