<commit_before>#! /usr/bin/env bash

# ------------------------------- Functions ------------------------------

main_loop() {
    say_hello

    if [[ -z "$PROJ" ]] || [[ -z "$TRGT" ]]; then
        echo "${red:-}You must specify a directory containing a *.csproj file AND a target location.${normal:-}"
        echo
        exit 1
    fi

    check_for_dotnet

    if [[ $? -eq 0 ]]; then compile_net_project; else exit 1; fi
    if [[ $? -eq 0 ]]; then transfer_files; else exit 1; fi
    if [[ $? -eq 0 ]]; then say_pass; create_pkg; else say_fail; exit 1; fi
    if [[ $? -eq 0 ]]; then
        echo -n "AppImageKit compression:"
        say_pass

        if [[ -z $NO_DEL ]]; then
            delete_temp_files
        fi
    else
        echo -n "AppImageKit compression:"
        say_fail
        exit 1
    fi
    echo -n "Packaging complete:"
    say_pass
    echo "${green:-}New NET_Pkg created at $TRGT/$CSPROJ$EXTN${normal:-}"
    say_bye
    echo
}

check_for_dotnet() {
    check_for_sdk
    if [[ $? != 0 ]]; then
        install_prompt
    else
        return 0
    fi
}

check_for_sdk() {
    echo -n "Checking if .NET sdk is installed..."

    if [[ -d /tmp/.net-sdk-test ]]; then rm -rf /tmp/.net-sdk-test; fi

    mkdir /tmp/.net-sdk-test && cd /tmp/.net-sdk-test
    dotnet new sln &> /dev/null

    if [[ $? -eq 0 ]]; then
        say_pass
        cd $PKG_DIR
        rm -rf /tmp/.net-sdk-test
        return 0;
    else
        say_warning
        cd $PKG_DIR
        rm -rf /tmp/.net-sdk-test
        return 1;
    fi;
}


install_prompt() {
    echo -n "Checking if necessary libraries are present"
    source $PKG_DIR/NET_Pkg.Template/usr/bin/lib-check.sh

    if [[ $libs_needed == "true" ]]; then
        say_warning
        echo "The following libraries are missing and will also need to be installed:"
        if [[ $need_unwind == "true" ]]; then echo " - libunwind"; fi
        if [[ $need_icu == "true" ]]; then echo " - libunicu"; fi
        if [[ $need_gettext == "true" ]]; then echo " - gettext"; fi
        echo "${yellow:-}It is recommended that you acquire these from your package manager, but can be locally installed.${normal:-}"
        read -p "Would you like to download & install the .NET sdk and needed libraries? (y/n): " yn
        export yn=$yn
    else
        say_pass
        read -p "Would you like to download & install the .NET sdk? (y/n): " yn
        export yn=$yn
    fi

    while true; do
        case $yn in
            [Yy]* )
                if [[ $libs_needed == "true" ]]; then 
                start_installer
                if [[ $? -eq 0 ]]; then
                    check_path
                else
                    exit 1
                fi
                ;;
            [Nn]* ) echo "${red:-}User aborted the application.${normal:-}"; echo; exit 1;;
            * ) echo "Please answer yes or no.";;
        esac
    done
}

start_installer() {
    if [[ libs_needed == "true" ]]; then
        $PKG_DIR/NET_Pkg.Template/usr/bin/install-libs.sh
    fi

    $PKG_DIR/NET_Pkg.Template/usr/bin/dotnet-installer.sh -sdk
    if [[ $? -eq 0 ]]; then
        return 0
    else
        exit 1
    fi
}

compile_net_project() {
    cd $PROJ

    find_csproj
    if [[ -z $VERB ]]; then echo -n "Restoring .NET project dependencies..."; fi
    if ! [[ -z $VERB ]]; then dotnet restore; else dotnet restore >/dev/null; fi
<commit_msg>Forgot to push fix<commit_after>#! /usr/bin/env bash

# ------------------------------- Functions ------------------------------

main_loop() {
    say_hello

    if [[ -z "$PROJ" ]] || [[ -z "$TRGT" ]]; then
        echo "${red:-}You must specify a directory containing a *.csproj file AND a target location.${normal:-}"
        echo
        exit 1
    fi

    check_for_dotnet

    if [[ $? -eq 0 ]]; then compile_net_project; else exit 1; fi
    if [[ $? -eq 0 ]]; then transfer_files; else exit 1; fi
    if [[ $? -eq 0 ]]; then say_pass; create_pkg; else say_fail; exit 1; fi
    if [[ $? -eq 0 ]]; then
        echo -n "AppImageKit compression:"
        say_pass

        if [[ -z $NO_DEL ]]; then
            delete_temp_files
        fi
    else
        echo -n "AppImageKit compression:"
        say_fail
        exit 1
    fi
    echo -n "Packaging complete:"
    say_pass
    echo "${green:-}New NET_Pkg created at $TRGT/$CSPROJ$EXTN${normal:-}"
    say_bye
    echo
}

check_for_dotnet() {
    check_for_sdk
    if [[ $? != 0 ]]; then
        install_prompt
    else
        return 0
    fi
}

check_for_sdk() {
    echo -n "Checking if .NET sdk is installed..."

    if [[ -d /tmp/.net-sdk-test ]]; then rm -rf /tmp/.net-sdk-test; fi

    mkdir /tmp/.net-sdk-test && cd /tmp/.net-sdk-test
    dotnet new sln &> /dev/null

    if [[ $? -eq 0 ]]; then
        say_pass
        cd $PKG_DIR
        rm -rf /tmp/.net-sdk-test
        return 0;
    else
        say_warning
        cd $PKG_DIR
        rm -rf /tmp/.net-sdk-test
        return 1;
    fi;
}


install_prompt() {
    echo -n "Checking if necessary libraries are present"
    source $PKG_DIR/NET_Pkg.Template/usr/bin/lib-check.sh

    if [[ $libs_needed == "true" ]]; then
        say_warning
        echo "The following libraries are missing and will also need to be installed:"
        if [[ $need_unwind == "true" ]]; then echo " - libunwind"; fi
        if [[ $need_icu == "true" ]]; then echo " - libunicu"; fi
        if [[ $need_gettext == "true" ]]; then echo " - gettext"; fi
        echo "${yellow:-}It is recommended that you acquire these from your package manager, but can be locally installed.${normal:-}"
        read -p "Would you like to download & install the .NET sdk and needed libraries? (y/n): " yn
        export yn=$yn
    else
        say_pass
        read -p "Would you like to download & install the .NET sdk? (y/n): " yn
        export yn=$yn
    fi

    while true; do
        case $yn in
            [Yy]* )
                start_installer
                if [[ $? -eq 0 ]]; then
                    check_path
                else
                    exit 1
                fi
                ;;
            [Nn]* ) echo "${red:-}User aborted the application.${normal:-}"; echo; exit 1;;
            * ) echo "Please answer yes or no.";;
        esac
    done
}

start_installer() {
    if [[ $libs_needed == "true" ]]; then
        $PKG_DIR/NET_Pkg.Template/usr/bin/install-libs.sh
    fi

    $PKG_DIR/NET_Pkg.Template/usr/bin/dotnet-installer.sh -sdk
    if [[ $? -eq 0 ]]; then
        return 0
    else
        exit 1
    fi
}

compile_net_project() {
    cd $PROJ

    find_csproj
    if [[ -z $VERB ]]; then echo -n "Restoring .NET project dependencies..."; fi
    if ! [[ -z $VERB ]]; then dotnet restore; else dotnet restore >/dev/null; fi

{'fraction_non_alphanumeric': 0.14624388798340496, 'fraction_numerical': 0.00592680397095866, 'mean_word_length': 1.6892430278884463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1306888', 'n_tokens_mistral': 2284, 'n_tokens_neox': 2169, 'n_words': 679}