chbase: Use same strategy for relative paths as qa
This commit is contained in:
parent
472e3a8cba
commit
acf909ab1e
@ -17,13 +17,12 @@ run() {
|
|||||||
case "${f}" in
|
case "${f}" in
|
||||||
"${FILE}/"*.html|"${FILE}/"*.js|"${FILE}/"*.css)
|
"${FILE}/"*.html|"${FILE}/"*.js|"${FILE}/"*.css)
|
||||||
run "${NEWBASE}" "${f}";;
|
run "${NEWBASE}" "${f}";;
|
||||||
*)
|
|
||||||
[ -d "${f}" ] && run "${NEWBASE}" "${f}";;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
elif [ -f "${FILE}" ]
|
elif [ -f "${FILE}" ]
|
||||||
then
|
then
|
||||||
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@base: \"${CURRENT_BASE%/}\"@base: \"${NEWBASE%/}\"@;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g;s@\"${CURRENT_BASE}_app/immutable/@\"${NEWBASE}_app/immutable/@g;s@^(\s+)paths: \{\"base\":\s*\"[^\"]*\",\"assets\":\s*\"[^\"]*\"\},\$@\1paths: {\"base\":\"${NEWBASE%/}\",\"assets\":\"${NEWBASE%/}\"},@;s@url\(${CURRENT_BASE}_app/immutable/@url(${NEWBASE}_app/immutable/@g;s@\"${CURRENT_BASE#/}_app/@\"${NEWBASE#/}_app/@g" ${FILE}
|
echo "Updating base path for $FILE..."
|
||||||
|
sed -ri "s@<base href=\"${CURRENT_BASE}\">@<base href=\"${NEWBASE}\">@;s@\"${CURRENT_BASE}_app/@\"${NEWBASE}_app/@;s@base: \"${CURRENT_BASE%/}\"@base: \"${NEWBASE%/}\"@" ${FILE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,12 @@ run() {
|
|||||||
case "${f}" in
|
case "${f}" in
|
||||||
"${FILE}/"*.html|"${FILE}/"*.js)
|
"${FILE}/"*.html|"${FILE}/"*.js)
|
||||||
run "${NEWBASE}" "${f}";;
|
run "${NEWBASE}" "${f}";;
|
||||||
*)
|
|
||||||
[ -d "${f}" ] && run "${NEWBASE}" "${f}";;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
elif [ -f "${FILE}" ]
|
elif [ -f "${FILE}" ]
|
||||||
then
|
then
|
||||||
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g;s@\"${CURRENT_BASE}_app/immutable/@\"${NEWBASE}_app/immutable/@g;s@\"${CURRENT_BASE}_app/\"@\"${NEWBASE}_app/\"@g" ${FILE}
|
echo "Updating base path for $FILE..."
|
||||||
|
sed -ri "s@<base href=\"${CURRENT_BASE}\">@<base href=\"${NEWBASE}\">@;s@\"${CURRENT_BASE}_app/@\"${NEWBASE}_app/@;s@base: \"${CURRENT_BASE%/}\"@base: \"${NEWBASE%/}\"@" ${FILE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@ const config = {
|
|||||||
adapter: adapt({
|
adapter: adapt({
|
||||||
fallback: 'index.html'
|
fallback: 'index.html'
|
||||||
}),
|
}),
|
||||||
paths: {
|
|
||||||
// base: '/2022',
|
|
||||||
relative: false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# You can define the current base URL in your environment
|
|
||||||
[ -n "${CURRENT_BASE}" ] || CURRENT_BASE="/"
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "$0 NEWBASE STATICDIR"
|
|
||||||
echo
|
|
||||||
echo " This script can be used to change the base URL of the frontend."
|
|
||||||
echo " Gives as PATH, the path to the static directory."
|
|
||||||
echo " You should use this script only one time (ie. from a fresh git repository),"
|
|
||||||
echo " as it doesn't erase previously defined base: it assumes the current base is /."
|
|
||||||
echo
|
|
||||||
echo " For example:"
|
|
||||||
echo
|
|
||||||
echo " $0 /$(date -d 'next year' +%Y)/" static/
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
run() {
|
|
||||||
local NEWBASE=$1
|
|
||||||
local FILE=$2
|
|
||||||
|
|
||||||
if [ -d "${FILE}" ]
|
|
||||||
then
|
|
||||||
for f in "${FILE}/"*.html "${FILE}/"*.js
|
|
||||||
do
|
|
||||||
run "${NEWBASE}" "${f}"
|
|
||||||
done
|
|
||||||
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
|
|
||||||
[ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views"
|
|
||||||
elif [ -f "${FILE}" ]
|
|
||||||
then
|
|
||||||
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g" ${FILE}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ $# -gt 1 ]
|
|
||||||
then
|
|
||||||
run $1 $2
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user