From 15d0e274b39340f19c3c5dde8cfdec451fa044c0 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 15 Jan 2025 17:26:45 +0100 Subject: [PATCH] [fix] build workflows of the themes Signed-off-by: Markus Heiser --- Makefile | 7 +-- docs/dev/quickstart.rst | 6 ++- searx/static/themes/simple/gruntfile.js | 6 ++- searx/static/themes/simple/package.json | 9 ++-- utils/lib_sxng_static.sh | 3 +- utils/lib_sxng_test.sh | 7 ++- utils/lib_sxng_themes.sh | 59 +++++++++++++++++-------- 7 files changed, 66 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 073b4de27..de4a7e5f0 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ search.checker.%: install $(Q)./manage pyenv.cmd searxng-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))" PHONY += test ci.test test.shell -ci.test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.pybabel +ci.test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.pybabel test.themes test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.shell test.shell: $(Q)shellcheck -x -s dash \ @@ -83,8 +83,9 @@ MANAGE += node.env node.env.dev node.clean MANAGE += py.build py.clean MANAGE += pyenv pyenv.install pyenv.uninstall MANAGE += format.python -MANAGE += test.yamllint test.pylint test.pyright test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean -MANAGE += themes.all themes.simple themes.simple.test pygments.less +MANAGE += test.yamllint test.pylint test.pyright test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean test.themes +MANAGE += themes.all themes.fix themes.test +MANAGE += themes.simple themes.simple.pygments themes.simple.fix MANAGE += static.build.commit static.build.drop static.build.restore MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs diff --git a/docs/dev/quickstart.rst b/docs/dev/quickstart.rst index 917d90c12..1b15a5b4a 100644 --- a/docs/dev/quickstart.rst +++ b/docs/dev/quickstart.rst @@ -6,7 +6,8 @@ Development Quickstart .. _npm: https://www.npmjs.com/ .. _Node.js: https://nodejs.org/ - +.. _eslint: https://eslint.org/ +.. _stylelint: https://stylelint.io/ .. sidebar:: further read @@ -40,7 +41,8 @@ to our ":ref:`how to contribute`" guideline. If you implement themes, you will need to setup a :ref:`Node.js environment `. Before you call *make run* (2.), you need to compile the -modified styles and JavaScript: ``make node.clean themes.all`` +modified styles and JavaScript: ``make node.clean themes.all``. If eslint_ or +stylelint_ report some issues, try ``make themes.fix``. Alternatively you can also compile selective the theme you have modified, e.g. the *simple* theme. diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js index bd04b2468..a40e48120 100644 --- a/searx/static/themes/simple/gruntfile.js +++ b/searx/static/themes/simple/gruntfile.js @@ -21,9 +21,10 @@ module.exports = function (grunt) { pkg: grunt.file.readJSON('package.json'), watch: { scripts: { - files: ['gruntfile.js', 'src/**'], + files: ['gruntfile.js', 'eslint.config.mjs', '.stylelintrc.json', 'src/**'], tasks: [ 'eslint', + 'stylelint', 'copy', 'uglify', 'less', @@ -49,6 +50,7 @@ module.exports = function (grunt) { stylelint: { options: { formatter: 'unix', + fix: grunt.option('fix') }, src: [ 'src/less/**/*.less', @@ -298,7 +300,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-stylelint'); grunt.loadNpmTasks('grunt-eslint'); - grunt.registerTask('test', ['eslint']); + grunt.registerTask('test', ['eslint', 'stylelint']); grunt.registerTask('default', [ 'eslint', diff --git a/searx/static/themes/simple/package.json b/searx/static/themes/simple/package.json index 5ff49057a..e56adbaa7 100644 --- a/searx/static/themes/simple/package.json +++ b/searx/static/themes/simple/package.json @@ -29,12 +29,13 @@ "scripts": { "all": "npm install && grunt", "build": "grunt", - "test": "grunt test", + "clean": "rm -Rf node_modules", "eslint": "grunt eslint", "eslint-fix": "grunt eslint --fix", - "watch": "grunt watch", - "clean": "rm -Rf node_modules", + "fix": "grunt test --fix", "stylelint": "grunt stylelint", - "stylelint-fix": "grunt stylelint --fix" + "stylelint-fix": "grunt stylelint --fix", + "test": "grunt test", + "watch": "grunt watch --fix" } } diff --git a/utils/lib_sxng_static.sh b/utils/lib_sxng_static.sh index 2f074b91e..d991d4b89 100755 --- a/utils/lib_sxng_static.sh +++ b/utils/lib_sxng_static.sh @@ -100,7 +100,8 @@ static.build.commit() { static.build.drop &>/dev/null ( set -e - # build the themes + # fix & build the themes + themes.fix themes.all # add build files diff --git a/utils/lib_sxng_test.sh b/utils/lib_sxng_test.sh index 9ac71aeeb..895a338fa 100755 --- a/utils/lib_sxng_test.sh +++ b/utils/lib_sxng_test.sh @@ -89,7 +89,6 @@ test.robot() { dump_return $? } - test.rst() { build_msg TEST "[reST markup] ${RST_FILES[*]}" @@ -98,6 +97,12 @@ test.rst() { done } +test.themes() { + build_msg TEST 'SearXNG themes' + themes.test + dump_return $? +} + test.pybabel() { TEST_BABEL_FOLDER="build/test/pybabel" build_msg TEST "[extract messages] pybabel" diff --git a/utils/lib_sxng_themes.sh b/utils/lib_sxng_themes.sh index a276dd8c5..95d38ae8d 100755 --- a/utils/lib_sxng_themes.sh +++ b/utils/lib_sxng_themes.sh @@ -7,21 +7,41 @@ declare _creset themes.help(){ cat <&1 \ - | prefix_stdout "${_Blue}THEME ${1} ${_creset} " \ - | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |' + } # 2>&1 \ + # | prefix_stdout "${_Blue}THEME ${1} ${_creset} " \ + # | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |' } themes.simple() { ( set -e - node.env themes.simple.pygments + build_msg SIMPLE "theme: run build" + # "run build" includes tests from eslint and stylelint + npm --prefix searx/static/themes/simple run build ) - build_msg GRUNT "theme: simple" - npm --prefix searx/static/themes/simple run build dump_return $? } @@ -67,11 +87,14 @@ themes.simple.pygments() { return 0 } +themes.simple.fix() { + build_msg SIMPLE "theme: fix" + npm --prefix searx/static/themes/simple run fix + dump_return $? +} themes.simple.test() { - build_msg TEST "theme: simple" - node.env - npm --prefix searx/static/themes/simple install + build_msg SIMPLE "theme: run test" npm --prefix searx/static/themes/simple run test dump_return $? }