Skip to content

Commit

Permalink
modified develop_academy.sh to compile dev only once when changed
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishnavimulik25 committed Mar 29, 2024
1 parent 992c6dc commit 4a847a9
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions scripts/develop_academy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,55 @@ if ! command -v nvm &> /dev/null; then
source $NVM_DIR/nvm.sh;
fi

# Prepare yarn
if ! command -v yarn --version &> /dev/null; then
npm install --global yarn
fi

# Prepare the frontend
nvm install 16
nvm use 16

# Checking if the frontend needs compilation
cd react_frontend/
yarn install
yarn build
DIRECTORY_TO_MONITOR="."

new_checksum=$(find "$DIRECTORY_TO_MONITOR" \( -path "*/node_modules" -o \
-path "*/__pycache__" -o \
-path "*/migrations" -o \
-name "yarn.lock" -o \
-name "checksum.txt" \) -prune \
-o -type f -exec md5sum {} + | \
sort | \
md5sum | \
awk '{print $1}')

echo $new_checksum

existing_checksum_file="$DIRECTORY_TO_MONITOR/checksum.txt"
echo $existing_checksum_file

if [ -f "$existing_checksum_file" ]; then
existing_checksum=$(cat "$existing_checksum_file")
echo $existing_checksum
if [ "$existing_checksum" != "$new_checksum" ]; then
echo "$new_checksum" > "$existing_checksum_file"
if command -v npm &> /dev/null; then
npm install --force
npm run dev &
sleep 10

else
yarn install
yarn dev run &
sleep 10
fi
else
echo "No Compilation needed"
fi
else
echo "$new_checksum" > "$existing_checksum_file"
npm install --force
npm run dev &
sleep 10
fi


cd ..

# Prepare the compose file
Expand All @@ -59,7 +97,8 @@ if [ $radi_version != "humble" ]; then
fi
cp compose_cfg/$compose_file docker-compose.yaml


# Proceed with docker-compose commands
docker compose up;
docker compose down;
docker-compose up
docker-compose down
rm docker-compose.yaml

0 comments on commit 4a847a9

Please sign in to comment.