From c01325688158fdde886e2ecb347d8d4d9707a84d Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Wed, 16 Jun 2021 15:39:32 +0200 Subject: [PATCH] [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. --- manage | 36 +++++++------------------ searx/static/themes/simple/package.json | 6 ++--- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/manage b/manage index d91904255..024fdf39a 100755 --- a/manage +++ b/manage @@ -13,7 +13,6 @@ source_dot_config PYOBJECTS="searx" PY_SETUP_EXTRAS='[test]' -NPM_PACKAGES="less@2.7 less-plugin-clean-css grunt-cli" GECKODRIVER_VERSION="v0.28.0" # SPHINXOPTS= @@ -296,39 +295,24 @@ gecko.driver() { } node.env() { - local err=0 - pushd "${REPO_ROOT}" &> /dev/null # shellcheck disable=SC2230 which npm &> /dev/null || die 1 'node.env - npm is not found!' ( set -e - # shellcheck disable=SC2030 - PATH="$(npm bin):$PATH" - export PATH - build_msg INSTALL "npm install $NPM_PACKAGES" - # shellcheck disable=SC2086 - npm install $NPM_PACKAGES + build_msg INSTALL "theme: oscar" + npm --prefix searx/static/themes/oscar install - cd "${REPO_ROOT}/searx/static/themes/oscar" - build_msg INSTALL "($(pwd)) npm install" - npm install - - build_msg INSTALL "($(pwd)) npm install" - cd "${REPO_ROOT}/searx/static/themes/simple" - npm install + build_msg INSTALL "theme: simple" + npm --prefix searx/static/themes/simple install ) - err=$? - popd &> /dev/null - dump_return "$err" + dump_return $? } node.clean() { build_msg CLEAN "locally installed npm dependencies" rm -rf \ - ./node_modules \ - ./package-lock.json \ ./searx/static/themes/oscar/package-lock.json \ ./searx/static/themes/oscar/node_modules \ ./searx/static/themes/simple/package-lock.json \ @@ -482,16 +466,14 @@ themes.all() { } themes.oscar() { - local gruntfile=searx/static/themes/oscar/gruntfile.js - build_msg GRUNT "${gruntfile}" - PATH="$(npm bin):$PATH" grunt --gruntfile "${gruntfile}" + build_msg GRUNT "theme: oscar" + npm --prefix searx/static/themes/oscar run build dump_return $? } themes.simple() { - local gruntfile=searx/static/themes/simple/gruntfile.js - build_msg GRUNT "${gruntfile}" - PATH="$(npm bin):$PATH" grunt --gruntfile "${gruntfile}" + build_msg GRUNT "theme: simple" + npm --prefix searx/static/themes/simple run build dump_return $? } diff --git a/searx/static/themes/simple/package.json b/searx/static/themes/simple/package.json index 038520a3d..e23157bf4 100644 --- a/searx/static/themes/simple/package.json +++ b/searx/static/themes/simple/package.json @@ -20,8 +20,8 @@ "leaflet": "^1.7.1" }, "scripts": { - "build": "npm install && grunt", - "start": "grunt watch", - "test": "grunt" + "all": "npm install && grunt", + "build": "grunt", + "watch": "grunt watch" } }