[mod] remove common grunt install

Before this commit, there are 3 node_modules directory:
* one in .
* two others in ./searx/statics/themes/*

This is no desirable:
* it declares the npm depdenencies in the shell script.
* dependabot can't updates theses dependencies.
* this is a not standard way to build a package (two different locations for the dependencies).

With this commit and the PR  #150 there is one unique node_modules directory per theme.
This commit is contained in:
Alexandre Flament 2021-06-16 15:39:32 +02:00
parent 85033f3d09
commit c013256881
2 changed files with 12 additions and 30 deletions

36
manage
View File

@ -13,7 +13,6 @@ source_dot_config
PYOBJECTS="searx" PYOBJECTS="searx"
PY_SETUP_EXTRAS='[test]' PY_SETUP_EXTRAS='[test]'
NPM_PACKAGES="less@2.7 less-plugin-clean-css grunt-cli"
GECKODRIVER_VERSION="v0.28.0" GECKODRIVER_VERSION="v0.28.0"
# SPHINXOPTS= # SPHINXOPTS=
@ -296,39 +295,24 @@ gecko.driver() {
} }
node.env() { node.env() {
local err=0
pushd "${REPO_ROOT}" &> /dev/null
# shellcheck disable=SC2230 # shellcheck disable=SC2230
which npm &> /dev/null || die 1 'node.env - npm is not found!' which npm &> /dev/null || die 1 'node.env - npm is not found!'
( set -e ( set -e
# shellcheck disable=SC2030
PATH="$(npm bin):$PATH"
export PATH
build_msg INSTALL "npm install $NPM_PACKAGES" build_msg INSTALL "theme: oscar"
# shellcheck disable=SC2086 npm --prefix searx/static/themes/oscar install
npm install $NPM_PACKAGES
cd "${REPO_ROOT}/searx/static/themes/oscar" build_msg INSTALL "theme: simple"
build_msg INSTALL "($(pwd)) npm install" npm --prefix searx/static/themes/simple install
npm install
build_msg INSTALL "($(pwd)) npm install"
cd "${REPO_ROOT}/searx/static/themes/simple"
npm install
) )
err=$? dump_return $?
popd &> /dev/null
dump_return "$err"
} }
node.clean() { node.clean() {
build_msg CLEAN "locally installed npm dependencies" build_msg CLEAN "locally installed npm dependencies"
rm -rf \ rm -rf \
./node_modules \
./package-lock.json \
./searx/static/themes/oscar/package-lock.json \ ./searx/static/themes/oscar/package-lock.json \
./searx/static/themes/oscar/node_modules \ ./searx/static/themes/oscar/node_modules \
./searx/static/themes/simple/package-lock.json \ ./searx/static/themes/simple/package-lock.json \
@ -482,16 +466,14 @@ themes.all() {
} }
themes.oscar() { themes.oscar() {
local gruntfile=searx/static/themes/oscar/gruntfile.js build_msg GRUNT "theme: oscar"
build_msg GRUNT "${gruntfile}" npm --prefix searx/static/themes/oscar run build
PATH="$(npm bin):$PATH" grunt --gruntfile "${gruntfile}"
dump_return $? dump_return $?
} }
themes.simple() { themes.simple() {
local gruntfile=searx/static/themes/simple/gruntfile.js build_msg GRUNT "theme: simple"
build_msg GRUNT "${gruntfile}" npm --prefix searx/static/themes/simple run build
PATH="$(npm bin):$PATH" grunt --gruntfile "${gruntfile}"
dump_return $? dump_return $?
} }

View File

@ -20,8 +20,8 @@
"leaflet": "^1.7.1" "leaflet": "^1.7.1"
}, },
"scripts": { "scripts": {
"build": "npm install && grunt", "all": "npm install && grunt",
"start": "grunt watch", "build": "grunt",
"test": "grunt" "watch": "grunt watch"
} }
} }