This repository has been archived on 2022-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
mydraftcc-nodejs-server/patch.sh

57 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2022-06-04 18:04:25 +00:00
#!/bin/bash
##############################################################
2022-06-04 18:04:25 +00:00
## D.HENRY (https://www.mytindydc.com)
# (required) API nodejs compliant
# (Optional) : UserReport because i don't want third party in the running app
# So default is keeping, to remove from source, execute :
# ./patch.sh "optional"
##############################################################
2022-06-05 12:30:40 +00:00
echo "Option $1"
echo "[INFO]Starting applying patches..."
2022-06-04 18:04:25 +00:00
## required for nodejs-server
2022-06-04 18:04:25 +00:00
match="(const API_URL.*)(https:\/\/api.mydraft.cc)(.*)$"
file="ui/src/wireframes/model/actions/loading.ts"
echo "[Patching]$match-$file"
# i replace https://api.mydraft.cc with ''
sed -i -E "s,$match,\1\3," "$file"
echo " [INFO]done"
## required for nodejs-server
2022-06-04 18:04:25 +00:00
echo "[Patching]Replacing load route / with /get"
sed -i 's,${API_URL}/${args.tokenToRead},${API_URL}/get/${args.tokenToRead},' "$file"
if [ "$?" != "0" ];then exit 1;fi
echo " [INFO]done"
## required for nodejs-server
2022-06-04 18:04:25 +00:00
## ContentType ERR Content-Type and application/json (needed for express body-parser)
echo "[Patching]ContentType-application/json"
sed -i -E "s,ContentType.*text\/json(.*)$,'Content-Type': 'application\/json\1," "$file"
if [ "$?" != "0" ];then exit 1;fi
echo " [INFO]done"
##########Optional - execute with parameter "optional"
if [ "$1" == "optional" ];then
## Usefull for ... me :)
echo "[Patching]Removing UserReport from application"
## Remove UserReport support
if [ -f "ui/src/core/react/UserReport.tsx" ];then
rm -r ui/src/core/react/UserReport.tsx
if [ "$?" != "0" ];then exit 1;fi
fi
## Patch tsx
files=$(grep -r "UserReport" ui/src | awk -F ":" '{print $1}' |uniq |xargs)
for f in $files
do
echo " [INFO]Patching UserReport in $f"
sed -i -E 's/.*UserReport.*//' "$f"
if [ "$?" != "0" ];then exit 1;fi
done
echo " [INFO]done"
else
echo "[Patching]UserReport was kept, to remove it, restart : ./patch.sh \"optional\""
fi
##############################