diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2025-08-30 23:44:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-30 23:44:07 +0200 |
commit | 5a79a4edce0f39541d2e9b363dcbe0cc79c32a1e (patch) | |
tree | f0bb15f28881a000f17a8f6d1a74d72e93c6b84b /apps/installer/includes/functions.sh | |
parent | 5c31e3b411ba8dfec9ecdfacca494accf7f59119 (diff) |
Feat/refactoring-module-menu (#22733)
Diffstat (limited to 'apps/installer/includes/functions.sh')
-rw-r--r-- | apps/installer/includes/functions.sh | 154 |
1 files changed, 20 insertions, 134 deletions
diff --git a/apps/installer/includes/functions.sh b/apps/installer/includes/functions.sh index b4bd14caf5..eb9fe1a24e 100644 --- a/apps/installer/includes/functions.sh +++ b/apps/installer/includes/functions.sh @@ -118,142 +118,28 @@ function inst_allInOne() { inst_download_client_data } -function inst_getVersionBranch() { - local res="master" - local v="not-defined" - local MODULE_MAJOR=0 - local MODULE_MINOR=0 - local MODULE_PATCH=0 - local MODULE_SPECIAL=0; - local ACV_MAJOR=0 - local ACV_MINOR=0 - local ACV_PATCH=0 - local ACV_SPECIAL=0; - local curldata=$(curl -f --silent -H 'Cache-Control: no-cache' "$1" || echo "{}") - local parsed=$(echo "$curldata" | "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.compatibility.*.[version,branch]') - - semverParseInto "$ACORE_VERSION" ACV_MAJOR ACV_MINOR ACV_PATCH ACV_SPECIAL - - if [[ ! -z "$parsed" ]]; then - readarray -t vers < <(echo "$parsed") - local idx - res="none" - # since we've the pair version,branch alternated in not associative and one-dimensional - # array, we've to simulate the association with length/2 trick - for idx in `seq 0 $((${#vers[*]}/2-1))`; do - semverParseInto "${vers[idx*2]}" MODULE_MAJOR MODULE_MINOR MODULE_PATCH MODULE_SPECIAL - if [[ $MODULE_MAJOR -eq $ACV_MAJOR && $MODULE_MINOR -le $ACV_MINOR ]]; then - res="${vers[idx*2+1]}" - v="${vers[idx*2]}" - fi - done +############################################################ +# Module helpers and dispatcher # +############################################################ + +# Returns the default branch name of a GitHub repo in the azerothcore org. +# If the API call fails, defaults to "master". +function inst_get_default_branch() { + local repo="$1" + local def + def=$(curl --silent "https://api.github.com/repos/azerothcore/${repo}" \ + | "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.default_branch') + if [ -z "$def" ]; then + def="master" fi - - echo "$v" "$res" -} - -function inst_module_search { - - local res="$1" - local idx=0; - - if [ -z "$1" ]; then - echo "Type what to search or leave blank for full list" - read -p "Insert name: " res - fi - - local search="+$res" - - echo "Searching $res..." - echo ""; - - readarray -t MODS < <(curl --silent "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" \ - | "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.items.*.name') - while (( ${#MODS[@]} > idx )); do - mod="${MODS[idx++]}" - read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$mod/master/acore-module.json") - - if [[ "$b" != "none" ]]; then - echo "-> $mod (tested with AC version: $v)" - else - echo "-> $mod (no revision available for AC v$AC_VERSION, it could not work!)" - fi - done - - echo ""; - echo ""; -} - -function inst_module_install { - local res - if [ -z "$1" ]; then - echo "Type the name of the module to install" - read -p "Insert name: " res - else - res="$1" - fi - - read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json") - - if [[ "$b" != "none" ]]; then - Joiner:add_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information" - else - echo "Cannot install $res module: it doesn't exists or no version compatible with AC v$ACORE_VERSION are available" - fi - - echo ""; - echo ""; -} - -function inst_module_update { - local res; - local _tmp; - local branch; - local p; - - if [ -z "$1" ]; then - echo "Type the name of the module to update" - read -p "Insert name: " res - else - res="$1" - fi - - _tmp=$PWD - - if [ -d "$J_PATH_MODULES/$res/" ]; then - read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json") - - cd "$J_PATH_MODULES/$res/" - - # use current branch if something wrong with json - if [[ "$v" == "none" || "$v" == "not-defined" ]]; then - b=`git rev-parse --abbrev-ref HEAD` - fi - - Joiner:upd_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly" || echo "Cannot update" - cd $_tmp - else - echo "Cannot update! Path doesn't exist" - fi; - - echo ""; - echo ""; -} - -function inst_module_remove { - if [ -z "$1" ]; then - echo "Type the name of the module to remove" - read -p "Insert name: " res - else - res="$1" - fi - - Joiner:remove "$res" && echo "Done, please re-run compiling" || echo "Cannot remove" - - echo ""; - echo ""; + echo "$def" } +# ============================================================================= +# Module Management System +# ============================================================================= +# Load the module manager functions from the dedicated modules-manager directory +source "$AC_PATH_INSTALLER/includes/modules-manager/modules.sh" function inst_simple_restarter { echo "Running $1 ..." @@ -292,4 +178,4 @@ function inst_download_client_data { && echo "unzip downloaded file in $path..." && unzip -q -o "$zipPath" -d "$path/" \ && echo "Remove downloaded file" && rm "$zipPath" \ && echo "INSTALLED_VERSION=$VERSION" > "$dataVersionFile" -} +}
\ No newline at end of file |