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
+ 25
23
Compare changes
  • Side-by-side
  • Inline
cli 0 → 100755
+ 87
0
#!/bin/bash
usage() {
echo -e "Usage $0 <command> [args]\n"
echo -e "COMMANDS\n"
echo -e "build-mirador : build Mirador viewer. Needed when changing branch on Mirador "
echo -e "build-mirador-plugin : build Mirador plugin. Needed when changing branch on plugin "
echo -e "clean-mirador : Clean node node_modules and package-lock of Mirador. "
echo -e "clean-mirador-plugin : Clean node node_modules and package-lock of Mirador on plugin. Useful when encoutering error 'Not a git repository' on building "
echo -e "clean-integration : Clean node node_modules and package-lock of POC. It's not recursive. "
echo -e "up : Start building and running of all the solution. Can be used with --build flag"
echo -e "init-submodule : Need to be run after installation"
echo -e "update-submodule : Need to be run after installation or when updating Mirador or the plugin"
}
cmdup="docker-compose up"
cmddown="docker-compose down"
cmdinitsubmodule="git submodule init"
cmdupdatetsubmodule="git submodule update"
cmdbuildmirador="'"
cmdbuildmiradorplugin=""
MIRADOR_FOLDER=mirador-video-annotation
MIRADOR_ANNOTATION_FOLDER=annotations-plugin
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 && 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 "** Start install ..."
FILE='.env'
if [ ! -f "$FILE" ]; then
echo "** $FILE does not exist. Please copy .env template. [cp .env.template .env] and set COMPOSE_FILE to suit your needs"
exit 0
fi
echo "** Submodule initialisation ..."
$cmdinitsubmodule
$cmdupdatesubmodule
echo "** Submodule initialized"
echo "** Building Mirador ..."
cd $MIRADOR_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c 'cd /opt && npm install && npm run build:es'
echo "** Mirador build."
echo "** Building Mirador plugin ..."
cd $MIRADOR_ANNOTATION_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c 'cd /opt && npm install && npm run build'
echo "** Mirador plugin build."
;;
"up")
$cmdup $@
;;
"init-submodules")
$cmdinitsubmodule
;;
"update-submodules")
$cmdupdatesubmodule
;;
*)
echo "ERROR: No command given"
usage
exit 1
;;
esac
Loading