Skip to content
Snippets Groups Projects

Draft : Resolve "Add a CLI tool"

Open Anthony requested to merge 44-add-a-cli-tool into main
1 file
+ 72
0
Compare changes
  • Side-by-side
  • Inline
cli 0 → 100755
+ 72
0
 
#!/bin/bash
 
 
is_docker() {
 
if [ ! -z "$(which docker-compose 2>/dev/null)" ];
 
then
 
echo "1"
 
else
 
echo "0"
 
fi
 
}
 
 
usage() {
 
echo -e "Usage $0 <command> [args]\n"
 
echo -e "COMMANDS\n"
 
}
 
 
 
cmdup="docker-compose up"
 
cmddown="docker-compose down"
 
 
MIRADOR_FOLDER=mirador-video-annotation
 
MIRADOR_ANNOTATION_FOLDER=annotations-plugin
 
 
user=$(awk -F '=' '/DB_USERNAME/{print $2}' .env)
 
db=$(awk -F '=' '/DB_DATABASE/{print $2}' .env)
 
pass=$(awk -F '=' '/DB_PASSWORD/{print $2}' .env)
 
mysql="mysql -u $user $db -p$pass"
 
 
DIR="$(dirname $0)"
 
SCRIPTS_DIR="$DIR/public/scripts"
 
 
action=$1
 
shift
 
# Keep actions sorted
 
case $action in
 
"build-mirador")
 
cd $MIRADOR_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c "cd /opt && npm install && npm run build:es"
 
;;
 
"build-mirador-plugin")
 
cd $MIRADOR_ANNOTATION_FOLDER/$MIRADOR_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c "cd /opt && npm install && npm run build:es"
 
cd .. && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c "cd /opt && npm install && npm run build"
 
;;
 
"clean-mirador")
 
cd $MIRADOR_FOLDER && rm -R -f node_modules package-lock.json
 
;;
 
"clean-mirador-plugin")
 
cd $MIRADOR_ANNOTATION_FOLDER && rm -R -f node_modules package-lock.json
 
;;
 
"clean-integration")
 
rm -R -f node_modules package-lock.json
 
;;
 
"clean-all")
 
echo "TODO"
 
;;
 
"down")
 
$cmddown
 
;;
 
"help")
 
usage
 
;;
 
"install")
 
echo "TODO"
 
;;
 
"up")
 
$cmdup $@
 
;;
 
*)
 
echo "ERROR: No command given"
 
usage
 
exit 1
 
;;
 
esac
Loading