diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index c1e488cb..d5f6e4da 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -30,14 +30,11 @@ jobs: - name: Download validatornu # There isn't a package with a `validatornu` command in Ubuntu, so download the validator - # from the GitHub releases and change the validate-static script later to use it. + # from the GitHub releases and change the process-static script later to use it. run: curl -OL https://github.com/validator/validator/releases/download/${{ env.VALIDATOR_VERSION }}/vnu.linux.zip && unzip vnu.linux.zip if: steps.validator-cache.outputs.cache-hit != 'true' - - run: sed -i 's+validatornu+vnu-runtime-image/bin/vnu+g' validate-static - - - name: validate static - run: ./validate-static + - run: sed -i 's+validatornu+vnu-runtime-image/bin/vnu+g' process-static - name: process static run: ./process-static diff --git a/deploy-static b/deploy-static index 60d18fc7..d002acbd 100755 --- a/deploy-static +++ b/deploy-static @@ -2,7 +2,6 @@ set -o errexit -o nounset -o pipefail -./validate-static ./process-static servers=( diff --git a/process-static b/process-static index 8a103e19..9f33578c 100755 --- a/process-static +++ b/process-static @@ -11,10 +11,14 @@ rm -rf static-tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs. mv static-tmp/js/fastboot/dist static-tmp/js/fastboot/v1.0.9 for file in static-tmp/**/*.@(json|webmanifest); do + json_verify < "$file" >/dev/null json_reformat -m < "$file" | sponge "$file" done +stylelint static-tmp/**/*.css find static-tmp -name '*.css' -exec csso {} -o {} \; + +eslint static-tmp/**/!(fastboot.min.m|z-worker-pako.|pako_inflate.min.|)js find static-tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \; replace="" @@ -28,6 +32,8 @@ done cp nginx/nginx.conf nginx.conf.tmp sed -i "$replace" static-tmp/**/*.html nginx.conf.tmp +xmllint --noout static-tmp/**/*.html +validatornu --Werror --also-check-css --also-check-svg static-tmp/**/!(bimi).@(css|html|svg) find static-tmp -name '*.html' -exec html-minifier --collapse-whitespace \ --process-scripts "application/ld+json" --collapse-boolean-attributes \ --remove-attribute-quotes --remove-comments --remove-empty-attributes \ diff --git a/validate-static b/validate-static deleted file mode 100755 index 8776be99..00000000 --- a/validate-static +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -o errexit -o nounset -o pipefail -shopt -s dotglob extglob globstar - -export PATH="$PWD/node_modules/.bin:$PATH" - -rm -rf static-tmp -cp -a static static-tmp -rm -rf static-tmp/js/fastboot/{!(dist),dist/!(fastboot.min.mjs|fastboot.min.mjs.map|vendor)} - -for file in static-tmp/**/*.@(json|webmanifest); do - json_verify < "$file" >/dev/null -done - -xmllint --noout static-tmp/**/*.@(html|svg|xml) -eslint static-tmp/**/!(fastboot.min.m|z-worker-pako.|pako_inflate.min.|)js -stylelint static-tmp/**/*.css -validatornu --Werror --also-check-css --also-check-svg static-tmp/**/!(bimi).@(css|html|svg)