From cac1ea44c22aee614ab9a6c4cf1bfbf9c6b6e2ee Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 20 Jun 2020 17:30:03 +0200 Subject: [PATCH] fix make-standalone, add html doc to it --- dev/make-distribution.sh | 16 ++++++++++------ dev/make-html.sh | 13 +++++++++++++ dev/make-standalone.sh | 15 ++++++++++----- 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100755 dev/make-html.sh diff --git a/dev/make-distribution.sh b/dev/make-distribution.sh index cb87687..3dc9f72 100755 --- a/dev/make-distribution.sh +++ b/dev/make-distribution.sh @@ -2,7 +2,7 @@ # file: make-distribution.sh # creates files and arcchives to dirtribute bashbot # -#### $$VERSION$$ v0.96-0-g3871ca9 +#### $$VERSION$$ v0.98-dev-63-g0b8c047 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -33,10 +33,13 @@ done # create dir for distribution and copy files mkdir -p "${DISTDIR}" 2>/dev/null # shellcheck disable=SC2086 +echo "Copy files" +# shellcheck disable=SC2086 cp -r ${DISTFILES} "${DISTDIR}" cd "${DISTDIR}" || exit 1 # do not overwrite on update +echo "Create .dist files" for file in mycommands.sh bashbot.rc addons/*.sh do [ "${file}" = "addons/*.sh" ] && continue @@ -44,6 +47,7 @@ do done # dwonload JSON.sh +echo "Inject JSON.sh" JSONSHFILE="JSON.sh/JSON.sh" if [ ! -f "${JSONSHFILE}" ]; then mkdir "JSON.sh" 2>/dev/null @@ -52,17 +56,17 @@ if [ ! -f "${JSONSHFILE}" ]; then fi # make html doc -mkdir html 2>/dev/null -cp README.html html/index.html -find doc -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "./html/$(basename ${0%.md}.html)"' {} \; -find examples -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "${0%.md}.html"' {} \; -find README.html html examples -iname "*.html" -type f -exec sh -c 'sed -i -E "s/href=\"(\.\.\/)*doc\//href=\"\1html\//g;s/href=\"(.*).md(#.*)*\"/href=\"\1.html\"/g" ${0}' {} \; +echo "Create html doc" +#shellcheck disable=SC1090 +source "$GIT_DIR/../dev/make-html.sh" # create archive cd .. || exit 1 +echo "Create dist archives" zip -rq "${DISTNAME}-${VERSION}.zip" "${DISTNAME}" tar -czf "${DISTNAME}-${VERSION}.tar.gz" "${DISTNAME}" +echo "Done!" # shellcheck disable=SC2086 ls -ld ${DISTNAME}-${VERSION}.* diff --git a/dev/make-html.sh b/dev/make-html.sh new file mode 100755 index 0000000..795a1fd --- /dev/null +++ b/dev/make-html.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# magic to ensure that we're always inside the root of our application, +# no matter from which directory we'll run script +if [ ! -f README.html ]; then + echo "This script must run where README.html is!" && exit 1 +fi + +# make html doc +mkdir html 2>/dev/null +cp README.html html/index.html +find doc -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "./html/$(basename ${0%.md}.html)"' {} \; +find examples -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "${0%.md}.html"' {} \; +find README.html html examples -iname "*.html" -type f -exec sh -c 'sed -i -E "s/href=\"(\.\.\/)*doc\//href=\"\1html\//g;s/href=\"(.*).md(#.*)*\"/href=\"\1.html\"/g" ${0}' {} \; diff --git a/dev/make-standalone.sh b/dev/make-standalone.sh index d979cf3..b1b29c3 100755 --- a/dev/make-standalone.sh +++ b/dev/make-standalone.sh @@ -5,7 +5,7 @@ # If you your bot is finished you can use make-standalone.sh to create the # the old all-in-one bashbot: bashbot.sh and commands.sh only! # -#### $$VERSION$$ v0.96-0-g3871ca9 +#### $$VERSION$$ v0.98-dev-63-g0b8c047 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -18,7 +18,7 @@ fi #DISTNAME="telegram-bot-bash" DISTDIR="./STANDALONE/${DISTNAME}" -DISTFILES="bashbot.sh bashbot.rc commands.sh mycommands.sh dev/obfuscate.sh modules LICENSE README.txt token count botacl botadmin" +DISTFILES="bashbot.sh bashbot.rc commands.sh mycommands.sh dev/obfuscate.sh modules LICENSE README.* doc botacl botconfig.jssh" # run pre_commit on files dev/hooks/pre-commit.sh @@ -38,7 +38,7 @@ echo " ... create unified commands.sh" { # first head of commands.sh - sed -n '0,/^if / p' commands.sh | head -n -2 | grep -v 'mycommands.sh' + sed -n '0,/^if / p' commands.sh | head -n -2 # then mycommands from first non comment line on printf '\n##############################\n# my commands starts here ...\n' @@ -46,7 +46,7 @@ echo " ... create unified commands.sh" # last tail of commands.sh printf '\n##############################\n# default commands starts here ...\n' - sed -n '/\/mycommands.sh"/,$ p' commands.sh | tail -n +2 + sed -n '/source .*\/mycommands.sh"/,$ p' commands.sh | tail -n +2 } >>$$commands.sh @@ -79,10 +79,15 @@ sed -E -e '/(shellcheck)|(#!\/bin\/bash)/! s/^[[:space:]]*#.*//' -e 's/^[[:space sed -E -e '/(shellcheck)|(#!\/bin\/bash)/! s/^[[:space:]]*#.*//' -e 's/^[[:space:]]*//' -e '/^$/d' commands.sh > commands.sh.min chmod +x bashbot.sh.min +# make html doc +echo "Create html doc" +#shellcheck disable=SC1090 +source "$GIT_DIR/../dev/make-html.sh" + echo "Done!" cd .. || exit 1 echo -e "\\nStandalone bashbot files are now availible in \"${DISTDIR}\":\\n" -ls -l "${DISTDIR}"* +ls -l "${DISTDIR}"