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

50 lines
1.5 KiB
Bash
Raw Normal View History

2022-06-04 18:04:25 +00:00
#!/bin/bash
###############
## D.HENRY (https://www.mytindydc.com)
# Patchs are apply to be API nodejs compliant
# UserReport because i don't want third party in the running app
################################
echo "[INFO]Starting applying patchs..."
## Usefull for nodejs-server
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"
## Usefull for nodejs-server
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"
## Usefull for nodejs-server
## 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"
## 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"