#!/bin/bash -x
echo "## Updating openvidu-tutorials"
find -type f -name 'package-lock.json' -exec rm {} \;
find -type d -name 'node_modules' -exec rm -rf {} \;
# Updating openvidu-browser dependencies in package.json files [openvidu-insecure-angular, openvidu-insecure-react, openvidu-ionic]
find . -type f -name 'package.json' -not \( -path '*/node_modules/*' -o -path '*/package-lock.json' \) -exec sed -i "s/\"openvidu-browser\": \"$FROM_VERSION\"/\"openvidu-browser\": \"$TO_VERSION\"/" {} \;
# Updating openvidu-react dependencies in package.json files [openvidu-library-react]
find . -type f -name 'package.json' -not \( -path '*/node_modules/*' -o -path '*/package-lock.json' \) -exec sed -i "s/\"openvidu-react\": \"$FROM_VERSION\"/\"openvidu-react\": \"$TO_VERSION\"/" {} \;
# Updating openvidu-angular dependencies in package.json files [openvidu-library-angular]
find . -type f -name 'package.json' -not \( -path '*/node_modules/*' -o -path '*/package-lock.json' \) -exec sed -i "s/\"openvidu-angular\": \"$FROM_VERSION\"/\"openvidu-angular\": \"$TO_VERSION\"/" {} \;
# Run "npm install" in every npm project [openvidu-insecure-angular, openvidu-insecure-react, openvidu-library-angular, openvidu-library-react, openvidu-ionic, openvidu-js-node, openvidu-mvc-node, openvidu-recording-node]
for tutorial in openvidu-insecure-angular openvidu-insecure-react openvidu-library-angular openvidu-library-react openvidu-ionic openvidu-js-node openvidu-mvc-node openvidu-recording-node; do
cd $tutorial && npm install && cd ..
done
# Update every import in every *.html or *.ejs file (10 files changed)
for file in *.html *.ejs; do
find . -type f -name $file -not \( -path '*/node_modules/*' -o -path '*/package-lock.json' \) -exec sed -i "s/