From edb2f36b5794ca989a39992f5a8d70a09ca26c0f Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Wed, 25 Jan 2023 18:33:34 -0600 Subject: [PATCH] chore: added script builder and updated scripts --- scripts/build.sh | 12 +++++ scripts/mfgames-project-script-builder.sh | 55 +++++++++++++++++++++++ scripts/release.sh | 13 +++++- scripts/test.sh | 10 +++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100755 scripts/mfgames-project-script-builder.sh diff --git a/scripts/build.sh b/scripts/build.sh index 93c4e62..e4fc5dd 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,3 +1,15 @@ +# !/usr/bin/env bash + +#mfgames-project:setup@v0.0.0 +log() { echo "๐Ÿšง $(basename $0): $@"; } +cd $(dirname $(dirname $0)) +#mfgames-project:setup + +log "cleaning old files" rm -f *.epub *.pdf + +log "installing NPM" npm install --ci + +log "running build" npm run build diff --git a/scripts/mfgames-project-script-builder.sh b/scripts/mfgames-project-script-builder.sh new file mode 100755 index 0000000..4ddfb5d --- /dev/null +++ b/scripts/mfgames-project-script-builder.sh @@ -0,0 +1,55 @@ +# !/usr/bin/env bash + +# Variables +version=0.0.0 + +# Make sure we have the proper parameters. +usage() { + echo "USAGE $0 script.sh [script2.sh]" + exit 1 +} + +if [ "x$1" = "x" ] +then + usage +fi + +# Go through the script and look for each one. +for script in "$@" +do + # Write out the file. + echo '# !/usr/bin/env bash' > .mfgames-project.tmp + + if [ -f $script ] + then + cat $script \ + | sed -n '/usr.bin.env bash/!p' \ + | sed '/^#mfgames-project:setup@/q' \ + | sed -n '/mfgames-project:setup/!p' \ + >> .mfgames-project.tmp + else + echo >> .mfgames-project.tmp + fi + + echo "#mfgames-project:setup@v$version" >> .mfgames-project.tmp + + if [ -f $script ] && grep 'log() { echo' $script > /dev/null + then + grep 'log() { echo' $script >> .mfgames-project.tmp + else + unicode=$(unipicker) + echo "log() { echo \"$unicode \$(basename \$0): \$@\"; }" >> .mfgames-project.tmp + fi + + echo "cd \$(dirname \$(dirname \$0))" >> .mfgames-project.tmp + echo "#mfgames-project:setup" >> .mfgames-project.tmp + + if [ -f $script ] + then + sed '1,/^#mfgames-project:setup$/d' < $script >> .mfgames-project.tmp + fi + + # Finish up and make the script executable. + mv .mfgames-project.tmp $script + chmod a+x $script +done diff --git a/scripts/release.sh b/scripts/release.sh index 7b2cee9..b27086a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,15 @@ -cd $(dirname $0)/.. +# !/usr/bin/env bash + +#mfgames-project:setup@v0.0.0 +log() { echo "๐Ÿšข $(basename $0): $@"; } +cd $(dirname $(dirname $0)) +#mfgames-project:setup + +log "cleaning old old version" rm -f exit-planning* + +log "installing NPM" npm install --ci + +log "running release" npx semantic-release diff --git a/scripts/test.sh b/scripts/test.sh index 8037f12..b10de4c 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,2 +1,12 @@ +# !/usr/bin/env bash + +#mfgames-project:setup@v0.0.0 +log() { echo "๐Ÿงช $(basename $0): $@"; } +cd $(dirname $(dirname $0)) +#mfgames-project:setup + +log "installing NPM" npm install --ci + +log "verifying commits" npx commitlint-gitlab-ci -x @commitlint/config-conventional