lib_sxng_node.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. export NODE_MINIMUM_VERSION="16.13.0"
  4. node.help(){
  5. cat <<EOF
  6. node.:
  7. env : download & install SearXNG's npm dependencies locally
  8. env.dev : download & install developer and CI tools
  9. clean : drop locally npm installations
  10. EOF
  11. }
  12. nodejs.ensure() {
  13. if ! nvm.min_node "${NODE_MINIMUM_VERSION}"; then
  14. info_msg "install Node.js by NVM"
  15. nvm.nodejs
  16. fi
  17. }
  18. node.env() {
  19. nodejs.ensure
  20. ( set -e
  21. build_msg INSTALL "./searx/static/themes/simple/package.json"
  22. npm --prefix searx/static/themes/simple install
  23. )
  24. dump_return $?
  25. }
  26. node.env.dev() {
  27. nodejs.ensure
  28. build_msg INSTALL "./package.json: developer and CI tools"
  29. npm install
  30. }
  31. node.clean() {
  32. if ! required_commands npm 2>/dev/null; then
  33. build_msg CLEAN "npm is not installed / ignore npm dependencies"
  34. return 0
  35. fi
  36. build_msg CLEAN "themes -- locally installed npm dependencies"
  37. ( set -e
  38. npm --prefix searx/static/themes/simple run clean
  39. )
  40. build_msg CLEAN "locally installed developer and CI tools"
  41. ( set -e
  42. npm --prefix . run clean
  43. )
  44. dump_return $?
  45. }