feat: add basic script to build techradar

This commit is contained in:
Mathias Schopmans
2024-02-29 11:46:58 +01:00
committed by Mathias Schopmans
parent 535c9e8a8f
commit 2682ea4e46
6 changed files with 570 additions and 948 deletions

46
bin/techradar.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
CWD=$(pwd)
BUILDER_DIR="$CWD/.techradar"
SOURCE_DIR="$CWD/node_modules/aoe_technology_radar"
PARAMETER=$1 # "build" or "serve"
function info {
echo -e "\033[32m$1\033[0m"
}
function error {
echo "Error: $1"
exit 1
}
# create builder dir by copying source dir if it does not exist
if [ ! -d "$BUILDER_DIR" ]; then
cp -R "$SOURCE_DIR" "$BUILDER_DIR" || error "Could not copy $SOURCE_DIR to $BUILDER_DIR"
cd "$BUILDER_DIR" || error "Could not change to $BUILDER_DIR"
info "Installing npm packages"
npm install || error "Could not install npm packages"
fi
cp -R "$CWD/radar" "$BUILDER_DIR/data/radar" || error "Could not copy $CWD/radar to $BUILDER_DIR/data/radar"
cp -R $CWD/public/* "$BUILDER_DIR/public/" || error "Could not copy $CWD/public to $BUILDER_DIR/public"
cd "$BUILDER_DIR" || error "Could not change to $BUILDER_DIR"
info "Building data"
npm run build:data
if [ "$PARAMETER" == "serve" ]; then
info "Starting techradar"
npm run dev
fi
if [ "$PARAMETER" == "build" ]; then
info "Building techradar"
npm run build
if [ -d "$CWD/build" ]; then
rm -rf "$CWD/build"
fi
info "Copying techradar to $CWD/build"
mv "$BUILDER_DIR/out" "$CWD/build"
fi