diff --git a/antora-ui/build.sh b/antora-ui/build.sh index 1eaff1b..bdd6da0 100755 --- a/antora-ui/build.sh +++ b/antora-ui/build.sh @@ -7,7 +7,9 @@ if [ -z "$npm_version" ]; then echo "npm is not installed" exit 1 fi - +# Add node_modules/.bin to path +PATH=$(pwd)/node_modules/.bin:$PATH +export PATH gulp_version=$(gulp --version 2>/dev/null) if [ -z "$gulp_version" ]; then echo "gulp is not installed" diff --git a/sitedoc.sh b/sitedoc.sh index 9e5263a..c70527c 100755 --- a/sitedoc.sh +++ b/sitedoc.sh @@ -20,13 +20,16 @@ if [ -z "$node_version" ]; then echo "Node.js is not installed"play exit 1 fi -major_version=$(echo $node_version | egrep -o "v([0-9]+)\." | cut -c 2- | rev | cut -c 2- | rev) +# major_version=$(echo $node_version | egrep -o "v([0-9]+)\." | cut -c 2- | rev | cut -c 2- | rev) +major_version=$(echo "$node_version" | awk -F. '{print $1}' | cut -c 2-) if [ "$major_version" -lt "16" ]; then echo "Node.js version $node_version is not supported. Please upgrade to version 16 or higher." node_path=$(which node) echo "node_path=${node_path}" fi +# Check if antora is available +PATH=$(pwd)/node_modules/.bin:$PATH antora_version=$(antora --version 2>/dev/null) if [ -n "$antora_version" ]; then ANTORA_CMD='antora' @@ -40,6 +43,7 @@ else fi fi +# Build UI if we have to cwd=$(pwd) script_dir=$(dirname "$(readlink -f "$0")") if ! [ -e "$script_dir/antora-ui/build/ui-bundle.zip" ] || \ @@ -50,6 +54,7 @@ then cd "$cwd" || exit fi +# Identify current commit id for footer if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then commit_id=$(git rev-parse HEAD) commit_id=$(expr substr "$commit_id" 1 7) @@ -57,6 +62,7 @@ else commit_id="" fi +# Install node modules if needed if [ ! -d "node_modules" ] || [ "$(find package.json -prune -printf '%T@\n' | cut -d . -f 1)" -gt "$(find node_modules -prune -printf '%T@\n' | cut -d . -f 1)" ]; then npm ci fi