From fbca634f884afa1d0d189d8fd15ca4c6f25b95c7 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 4 May 2020 14:11:24 -0400 Subject: [PATCH] Change build-lite.sh to POSIX sh syntax This should solve incompatibilities with non-GNU systems. --- build-lite.sh | 40 +++++++++++++++++++----------------- public/js/buttonFunctions.js | 4 ++-- public/js/home.js | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/build-lite.sh b/build-lite.sh index 62110fac..f15396e0 100644 --- a/build-lite.sh +++ b/build-lite.sh @@ -1,39 +1,41 @@ -#!/bin/bash +#!/bin/sh # Build script for a "lite" (purely client-side) version of Aspine -# Note: This script has only been tested with Bash in a GNU environment -# (on Linux); your mileage may vary on BSD, macOS, Cygwin/MSYS (Windows), etc. +# This script has been written in POSIX sh but has only been tested +# in Bash in a GNU environment. + +# Dependencies: grep with support for context, sed, perl rm -rf dist-lite/ mkdir -p dist-lite/ cp -r public/* dist-lite/ -mappings="$( +( \ grep -A100 'new Map' serve.js \ | grep -A3 '^ \[' \ | grep -Ev '\[|\]' \ | sed 's/ '\''//' \ -| sed 's/'\'',*//' -)" +| sed 's/'\'',*//' \ +) \ +| { + while read -r endpoint + do + read -r path + + mkdir -p "$(dirname "dist-lite/$endpoint")" + # Create the parent directory + cp "./$path" "dist-lite/$endpoint" + # Copy the node module to dist-lite + done +} +# grep and sed commands explanation: # Find the line in serve.js containing 'new Map' and get the next 100 lines # Limit the search to lines that contain ' [' and the next three lines # Remove lines with brackets # Remove leading whitespace and single quote character # Remove trailing single quote character and comma (if any) -echo $mappings | \ -while read -d ' ' endpoint -do - read -d ' ' path - - mkdir -p "$(dirname dist-lite$endpoint)" - # Create the parent directory - cp ".$path" "dist-lite$endpoint" - # Copy the node module to dist-lite -done -# https://stackoverflow.com/a/21256704 - cp -r ./node_modules/@fortawesome/fontawesome-free/webfonts/ \ dist-lite/fonts/fontawesome/webfonts # Copy Font Awesome files @@ -63,5 +65,5 @@ dist-lite/js/clock.js # https://unix.stackexchange.com/a/32912 version="$(git describe | sed 's/^v\?\(.*\)/\1/')" -sed -i 's/\/\/#include $version/"'$version'"/g' dist-lite/js/* +sed -i 's/\/\/#include version/"'"$version"'"/g' dist-lite/js/* # Hard-code version number (use sed to trim 'v') diff --git a/public/js/buttonFunctions.js b/public/js/buttonFunctions.js index 74d67123..5315d8bd 100755 --- a/public/js/buttonFunctions.js +++ b/public/js/buttonFunctions.js @@ -294,7 +294,7 @@ let exportTableData = async function(prefs) { //#ifdef lite /* obj.version = ( -//#include $version +//#include version ); */ //#endif @@ -375,7 +375,7 @@ let importTableData = async function(obj) { //#ifdef lite /* let version = ( -//#include $version +//#include version ); */ //#endif diff --git a/public/js/home.js b/public/js/home.js index 3dfee8a1..3f660c1c 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -1059,7 +1059,7 @@ $.ajax("/version").then(ver => $("#version").text(ver)); //#ifdef lite /* $("#version").text( -//#include $version +//#include version ); */ //#endif