123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #!/usr/bin/env sh
- #
- ###############################################################
- #
- # This is Gridfinity makeweb (Release 202101030B) [GFODLv1]
- #
- ###############################################################
- #
- # The Gridfinity Open Documentation License v1.0 (GFODLv1)
- #
- # Copyright © 2021 Jeffrey H. Johnson. <trnsz@pobox.com>
- # Copyright © 2021 Gridfinity, LLC. <admin@gridfinity.com>
- #
- # All Rights Reserved.
- #
- # Redistribution and use, in source and compiled forms,
- # with or without modification, are permitted, provided
- # that the following conditions are met:
- #
- # 1. Redistributions of source code must retain the
- # above copyright notice, this list of conditions,
- # and the following disclaimer, within the first
- # ten lines of this file, completely unmodified.
- #
- # 2. Redistributions in compiled form must reproduce
- # the above copyright notice, this list of conditions,
- # and the following disclaimer in the documentation,
- # and/or other materials provided with the distribution.
- #
- # THIS DOCUMENTATION IS PROVIDED BY THE AUTHORS "AS IS",
- # AND ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT
- # NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- # AND FITNESS FOR ANY PARTICULAR PURPOSE ARE DISCLAIMED.
- # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- # DAMAGES, INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- # SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS,
- # OR BUSINESS INTERRUPTION, HOWEVER CAUSED, AND ON ANY
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- # OR TORT, INCLUDING NEGLIGENCE OR OTHERWISE, ARISING IN
- # ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- #
- ###############################################################
- # makeweb 202101030B requires: POSIX sh, semver-tool >=3.2.0,
- # fixjson >=1.1.0, vangen >=20201119, sponge >=20060219,
- # Tidy-HTML5 >=5.7.28, GNU find, GNU xargs, GNU sed, recent Git
- ###############################################################
- #
- set -u ||
- true
- :
- set -e ||
- true
- :
- if [ ! -f "./modules.json" ]; then
- printf '%s\n' \
- "Error: modules.json not found" \
- >&2
- exit 1
- fi
- printf '%s ' \
- "Cleaning JSON..."
- fixjson -w -i 1 modules.json \
- >/dev/null \
- 2>&1 ||
- {
- printf '%s\n' \
- "Error: fixjson failed" \
- >&2
- exit 1
- }
- printf '%s\n' \
- "ok" ||
- true
- :
- printf '%s ' \
- "Running vangen..."
- "${GOBIN:?}/vangen" \
- -config "./modules.json" \
- -out "./public" \
- >/dev/null \
- 2>&1 ||
- {
- printf '%s\n' \
- "Error: vangen failed" \
- >&2
- exit 1
- }
- printf '%s\n' \
- "ok" ||
- true
- :
- printf '%s ' \
- "Debranding index..." ||
- true
- :
- grep -iav \
- '^Generated by .*vangen.*.$' \
- public/index.html \
- 2>/dev/null |
- sed -e 's/ Go Modules//' |
- grep -iav 'Tools:' |
- grep -iav 'Libraries:' |
- sponge public/index.html \
- 2>/dev/null \
- 1>&2 ||
- {
- printf '%s\n' \
- "Error: debranding failed" \
- >&2
- exit 1
- }
- printf '%s\n' \
- "ok" ||
- true
- :
- printf '%s ' \
- "Cleaning HTML..." ||
- true
- :
- find "./public" -name '*.html' -exec \
- tidy --add-meta-charset true -utf8 -w 0 -qiubnm \
- "{}" \; \
- 2>/dev/null \
- >/dev/null \
- 2>&1 ||
- {
- printf '%s\n' \
- "Error: cleaning failed" \
- >&2
- exit 1
- }
- printf '%s\n' \
- "ok" ||
- true
- :
- printf '%s ' \
- "Transforming HTML..." ||
- true
- :
- find ./public -name '*.html' -print0 \
- 2>/dev/null |
- xargs -0 -L1 -I{} \
- sh -c \
- 'grep -iav ".*generator.*HTML.*Tidy.*>$" "{}" 2>/dev/null |
- sed -e "s/<HR>//" |
- sed -e "s/\"\//\"/" |
- sed -e "s/display: inline-block;/text-align: center; display: inline-block;/" |
- sed -e "s/<STYLE>/<STYLE>\n .center-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 100vh; }/" |
- sed -e "s/<DIV class=\"content\">/<DIV class=\"center-screen\">/" |
- sed -e "s/Home: /<SMALL>Docs: /" |
- sed -e "s/Source: /Repo: /" |
- sed -e "s/<UL>//" -e "s/<LI>//" -e "s/<\/UL>//" -e "s/<\/LI>/<\/SMALL>/" |
- grep -v "^ \+$" |
- tidy --add-meta-charset true -utf8 -w 0 -qiubnm 2>/dev/null |
- grep -iav ".*generator.*HTML.*Tidy.*>$" 2>/dev/null |
- sponge "{}"
- >/dev/null
- 2>&1' \
- printf '%s\n' \
- "Done" ||
- true
- :
- printf '%s\n' \
- "$(date)" \
- >./.timestamp &&
- git add ./.timestamp
- :
- printf '%s\n' \
- "Preparing commit..." ||
- true
- :
- git gc --aggressive --prune=now ||
- true
- :
- SEMVER="$(eval printf '%s' "$(printf "%s" "$(semver-tool bump patch "$(printf '%d.%d.%d' "1" "$(grep '"_cXX": "' ./modules.json | \
- tr -d ',_"cX ' | cut -d ':' -f 2)" "$(cut -d '.' -f 3 ./.patch | \
- cut -d '.' -f 1)")") | sponge ./.patch")"; cat ./.patch)"
- git add -A && \
- git tag -s "${SEMVER:?}" -m "v${SEMVER:?} - $(date)" &&
- printf '%s\n' \
- "Set new semver tag: ${SEMVER}" &&\
- git commit -q -aS -m "Pushing Pages: $(date)" &&
- git pushall master &&
- printf '%s\n' "Complete."
- :
|