r3 updates

master
Theunis J. Botha 2021-10-01 09:42:40 +02:00
parent 11a4ecb03a
commit 779069a810
3 changed files with 29 additions and 6 deletions

View File

@ -21,7 +21,7 @@ r3_completions() {
fi
if [ "${#COMP_WORDS[@]}" == "4" ]; then
COMPREPLY=($(compgen -W "base extends component_base component_extends entity_base entity_extends r3_base runtime_base runtime_extends system_base system_extends static" "${COMP_WORDS[3]}"))
COMPREPLY=($(compgen -W "base extends object_base object_extends component_base component_extends entity_base entity_extends r3_base runtime_base runtime_extends system_base system_extends static" "${COMP_WORDS[3]}"))
fi
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "component_extends" ] ; then
@ -29,6 +29,11 @@ r3_completions() {
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
fi
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "object_extends" ] ; then
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-r3-object.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
fi
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "entity_extends" ] ; then
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-entity/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
@ -54,7 +59,7 @@ r3_completions() {
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
fi
if [[ "${#COMP_WORDS[@]}" == "5" && ( "${COMP_WORDS[3]}" =~ ^.*base$ || "${COMP_WORDS[3]}" == "static") ]]; then
if [[ "${#COMP_WORDS[@]}" == "5" && ( "${COMP_WORDS[3]}" =~ ^.*base$ || "${COMP_WORDS[3]}" == "static") ]]; then
COMPREPLY=($(compgen -W "$(find "${R3_SRC_FOLDER}" -ls | grep drw | sed "s/.*src\/r3/./" | sed "s/$/\//" | sed "s/\/\//\//g" | perl -pe 's/\n/ /g')" "${COMP_WORDS[4]}"))
fi

@ -1 +1 @@
Subproject commit 1c6f6a3755366afc81687856c41902756847902f
Subproject commit 40e85bf6d4c9e8872de9a0445e43d8b0bb646e30

24
r3.sh
View File

@ -58,6 +58,12 @@ cleanup() {
cd "${CWD}" 2>&1 || exit
}
echo ' _____ __ ';
echo ' _____|__ / _____/ /_ ';
echo ' / ___/ /_ < / ___/ __ \';
echo ' / / ___/ /_ (__ ) / / /';
echo '/_/ /____/(_)____/_/ /_/ ';
echo ''
R3_INSTALL_PATH=/usr/share/cybafelo/r3/r3-cloud
R3_V2_LIB_PATH=${R3_INSTALL_PATH}/r3-libs/r3-v2
@ -66,6 +72,7 @@ R3_FOLDER="${R3_V2_SRC_PATH}/r3/"
R3_SYSTEM_FOLDER="${R3_V2_SRC_PATH}/r3/r3-system/"
R3_COMPONENT_FOLDER="${R3_V2_SRC_PATH}/r3/r3-component/"
R3_RUNTIME_FOLDER="${R3_V2_SRC_PATH}/r3/r3-runtime/"
R3_OBJECT_FOLDER="${R3_V2_SRC_PATH}/r3/r3-object/"
R3_ENTITY_FOLDER="${R3_V2_SRC_PATH}/r3/r3-entity/"
TEMPLATE_FOLDER="${R3_V2_SRC_PATH}/templates/"
@ -82,6 +89,12 @@ trap cleanup EXIT
cd "${R3_INSTALL_PATH}" 2>&1 || exit 2
#ENV_FILE='.env'
#
#export $(egrep -v '^#' "${ENV_FILE}" | xargs)
#
#echo "${API_URL}";
if [ "${TASK}" = 'update-token-db' ];
then
echo "updating token.db"
@ -96,7 +109,8 @@ then
CLASS_NAME=$ARG1
TEMPLATE="${ARG2}.template"
FILE_NAME="r3$(echo "${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
FILE_NAME="$(echo "r3${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}' | sed 's/r3\-r3\-/r3-/' | sed 's/r3\-r3/r3/').js"
SUBFOLDER='./'
if [ -n "${ARG4}" ];
@ -117,7 +131,7 @@ then
if [[ "${ARG2}" =~ ^.*extends$ ]];
then
EXTEND_CLASS="${ARG3}"
EXTEND_CLASS_FILE_NAME="r3$(echo "${EXTEND_CLASS}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
EXTEND_CLASS_FILE_NAME="$(echo "r3${EXTEND_CLASS}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}' | sed 's/r3\-r3\-/r3-/' | sed 's/r3\-r3/r3/').js"
fi
if [[ "${ARG2}" =~ ^.*base$ ]] ||
@ -222,6 +236,10 @@ check_file_found() {
FILE="${R3_ENTITY_FOLDER}${ORIG_FILE}"
fi
if [ ! -f "${FILE}" ]; then
FILE="${R3_OBJECT_FOLDER}${ORIG_FILE}"
fi
if [ ! -f "${FILE}" ]; then
exit 4
fi
@ -260,7 +278,7 @@ then
sed -i -E 's/([0-9]+\.[0-9]+\.)([0-9]+)/echo "\1$((\2+1))"/e' version
COMMANDS=$(grep "r3 create" .r3_history | sed "s/^.*r3 /r3 /" | sed "s/\s+/ /g" | sort --unique | perl -pe "s/\n/,/" | perl -pe "s/\s+,/,/g" | perl -pe "s/,$//")
FILES=$(grep "r3 create" .r3_history | sed "s/^.*r3 /r3 /" | sed "s/\s+/ /g" | sort --unique | cut -d' ' -f3 | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}' | sed "s/^/r3/" | sed "s/$/.js/")
FILES=$(grep "r3 create" .r3_history | sed "s/^.*r3 /r3 /" | sed "s/\s+/ /g" | sort --unique | cut -d' ' -f3 | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}' | sed "s/^/r3/" | sed 's/r3\-r3\-/r3-/' | sed "s/$/.js/" | sed 's/r3\-r3\.js/r3.js/')
IFS=',' read -a commands <<< $COMMANDS