<commit_before>#!/bin/bash
###################
# Task Runner     #
# CLABE Validator #
###################

# To make this file runnable:
#     $ chmod +x *.sh.command

banner="CLABE Validator"
projectHome=$(cd $(dirname $0); pwd)

setupTools() {
   # Check for Node.js installation and download project dependencies
   cd $projectHome
   echo
   echo $banner
   echo $(echo $banner | sed -e "s/./=/g")
   pwd
   echo
   echo "Node.js:"
   which node || { echo "Need to install Node.js: https://nodejs.org"; exit; }
   node --version
   npm install
   npm update
   npm outdated
   echo
   }

buildProject() {
   cd $projectHome
   echo "Build:"
   npm test
   echo
   }

releaseInstructions() {
   cd $projectHome
   repository=$(grep repository package.json | awk -F'"' '{print $4}' | sed s/github://)
   package="https://raw.githubusercontent.com/$repository/master/package.json"
   version=$(grep '"version"' package.json | awk -F'"' '{print $4}')
   pushed=$(curl --silent $package | grep '"version":' | awk -F'"' '{print $4}')
   released=$(git tag | tail -1)
   echo "Local changes:"
   git status --short
   echo
   echo "Recent releases:"
   git tag | tail -5
   echo
   echo "Release progress:"
   echo "   $version (local) --> $pushed (pushed) --> $released (released)"
   echo
   echo "Next release action:"
   nextActionUpdate() {
      echo "   === Increment version ==="
      echo "   Edit pacakge.json to bump version $version to next version number"
      echo "   $projectHome/package.json"
      }
   nextActionCommit() {
      echo "   === Commit and push ==="
      echo "   Check in changed source files for v$version with the message:"
      echo "   Set version for next release"
      }
   nextActionTag() {
      echo "   === Release checkin ==="
      echo "   Check in remaining changed files with the message:"
      echo "   Release v$version"
      echo "   === Tag and publish ==="
      echo "   cd $projectHome"
      echo "   git tag --annotate --message 'Release' $version"
      echo "   git remote --verbose"
      echo "   git push origin --tags"
      echo "   npm publish"
      }
   checkStatus() {
      test $version \> $pushed && nextActionCommit || nextActionUpdate
      }
   test $pushed \> $released && nextActionTag || checkStatus
   echo
   }

publishWebFiles() {
   cd $projectHome
   publishWebRoot=$(grep ^DocumentRoot /private/etc/apache2/httpd.conf | awk -F\" '{ print $2 }')
   publishSite=$publishWebRoot/centerkey.com
   publishFolder=$publishSite/clabe
   publish() {
      echo "Publishing:"
      mkdir -p $publishFolder
      cp -v clabe.js   $publishFolder
      cp -v clabe.html $publishFolder/index.html
      echo
      }
   test -w $publishSite && publish
   }

setupTools
buildProject
releaseInstructions
publishWebFiles
sleep 2
open clabe.html
<commit_msg>Display test output last for higher visibility<commit_after>#!/bin/bash
###################
# Task Runner     #
# CLABE Validator #
###################

# To make this file runnable:
#     $ chmod +x *.sh.command

banner="CLABE Validator"
projectHome=$(cd $(dirname $0); pwd)

setupTools() {
   # Check for Node.js installation and download project dependencies
   cd $projectHome
   echo
   echo $banner
   echo $(echo $banner | sed -e "s/./=/g")
   pwd
   echo
   echo "Node.js:"
   which node || { echo "Need to install Node.js: https://nodejs.org"; exit; }
   node --version
   npm install
   npm update
   npm outdated
   echo
   }

releaseInstructions() {
   cd $projectHome
   repository=$(grep repository package.json | awk -F'"' '{print $4}' | sed s/github://)
   package="https://raw.githubusercontent.com/$repository/master/package.json"
   version=$(grep '"version"' package.json | awk -F'"' '{print $4}')
   pushed=$(curl --silent $package | grep '"version":' | awk -F'"' '{print $4}')
   released=$(git tag | tail -1)
   echo "Local changes:"
   git status --short
   echo
   echo "Recent releases:"
   git tag | tail -5
   echo
   echo "Release progress:"
   echo "   $version (local) --> $pushed (pushed) --> $released (released)"
   echo
   echo "Next release action:"
   nextActionUpdate() {
      echo "   === Increment version ==="
      echo "   Edit pacakge.json to bump version $version to next version number"
      echo "   $projectHome/package.json"
      }
   nextActionCommit() {
      echo "   === Commit and push ==="
      echo "   Check in changed source files for v$version with the message:"
      echo "   Set version for next release"
      }
   nextActionTag() {
      echo "   === Release checkin ==="
      echo "   Check in remaining changed files with the message:"
      echo "   Release v$version"
      echo "   === Tag and publish ==="
      echo "   cd $projectHome"
      echo "   git tag --annotate --message 'Release' $version"
      echo "   git remote --verbose"
      echo "   git push origin --tags"
      echo "   npm publish"
      }
   checkStatus() {
      test $version \> $pushed && nextActionCommit || nextActionUpdate
      }
   test $pushed \> $released && nextActionTag || checkStatus
   echo
   }

buildProject() {
   cd $projectHome
   echo "Build:"
   npm test
   echo
   }

publishWebFiles() {
   cd $projectHome
   publishWebRoot=$(grep ^DocumentRoot /private/etc/apache2/httpd.conf | awk -F\" '{ print $2 }')
   publishSite=$publishWebRoot/centerkey.com
   publishFolder=$publishSite/clabe
   publish() {
      echo "Publishing:"
      mkdir -p $publishFolder
      cp -v clabe.js   $publishFolder
      cp -v clabe.html $publishFolder/index.html
      echo
      }
   test -w $publishSite && publish
   }

setupTools
releaseInstructions
buildProject
publishWebFiles
sleep 2
open clabe.html

{'fraction_non_alphanumeric': 0.13961666959732724, 'fraction_numerical': 0.0031651134165640933, 'mean_word_length': 2.681553398058252, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1643971', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1724, 'n_words': 534}