<commit_before>#!/usr/bin/env sh
set -eu

TARGET_FRAMEWORK="netcoreapp3.1"

MAIN_PROJECT="ArchiSteamFarm"
TESTS_PROJECT="${MAIN_PROJECT}.Tests"
SOLUTION="${MAIN_PROJECT}.sln"
CONFIGURATION="Release"
OUT="out"

ASF_UI=1
CLEAN=0
PULL=1
SHARED_COMPILATION=1
TEST=1

PRINT_USAGE() {
	echo "Usage: $0 [--clean] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]"
}

cd "$(dirname "$(readlink -f "$0")")"

for ARG in "$@"; do
	case "$ARG" in
		debug|Debug) CONFIGURATION="Debug" ;;
		release|Release) CONFIGURATION="Release" ;;
		--asf-ui) ASF_UI=1 ;;
		--no-asf-ui) ASF_UI=0 ;;
		--clean) CLEAN=1 ;;
		--no-clean) CLEAN=0 ;;
		--pull) PULL=1 ;;
		--no-pull) PULL=0 ;;
		--shared-compilation) SHARED_COMPILATION=1 ;;
		--no-shared-compilation) SHARED_COMPILATION=0 ;;
		--test) TEST=1 ;;
		--no-test) TEST=0 ;;
		--help) PRINT_USAGE; exit 0 ;;
		*) PRINT_USAGE; exit 1
	esac
done

trap "trap - TERM && kill -- -$$" INT TERM

if ! command -v dotnet >/dev/null; then
	echo "ERROR: dotnet CLI tools are not installed!"
	exit 1
fi

dotnet --info

if [ "$PULL" -eq 1 ] && [ -d ".git" ] && command -v git >/dev/null; then
	git pull --recurse-submodules=on-demand || true
fi

if [ ! -f "$SOLUTION" ]; then
	echo "ERROR: $SOLUTION could not be found!"
	exit 1
fi

if [ "$ASF_UI" -eq 1 ]; then
	if [ -f "ASF-ui/package.json" ] && command -v npm >/dev/null; then
		echo "Building ASF-ui..."

		# ASF-ui doesn't clean itself after old build
		rm -rf "ASF-ui/dist"

		(
			cd ASF-ui
			npm ci
			npm run-script deploy
		)

		# ASF's output www folder needs cleaning as well
		rm -rf "${OUT}/www"
	else
		echo "WARNING: ASF-ui dependencies are missing, skipping build of ASF-ui..."
	fi
fi

DOTNET_FLAGS="-c $CONFIGURATION -f $TARGET_FRAMEWORK --nologo"

if [ "$SHARED_COMPILATION" -eq 0 ]; then
	DOTNET_FLAGS="$DOTNET_FLAGS /p:UseSharedCompilation=false"
fi<commit_msg>Update cc.sh<commit_after>#!/usr/bin/env sh
set -eu

TARGET_FRAMEWORK="netcoreapp3.1"

MAIN_PROJECT="ArchiSteamFarm"
TESTS_PROJECT="${MAIN_PROJECT}.Tests"
SOLUTION="${MAIN_PROJECT}.sln"
CONFIGURATION="Release"
OUT="out"

ASF_UI=1
CLEAN=0
PULL=1
SHARED_COMPILATION=1
TEST=1

PRINT_USAGE() {
	echo "Usage: $0 [--clean] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]"
}

cd "$(dirname "$(readlink -f "$0")")"

for ARG in "$@"; do
	case "$ARG" in
		debug|Debug) CONFIGURATION="Debug" ;;
		release|Release) CONFIGURATION="Release" ;;
		--asf-ui) ASF_UI=1 ;;
		--no-asf-ui) ASF_UI=0 ;;
		--clean) CLEAN=1 ;;
		--no-clean) CLEAN=0 ;;
		--pull) PULL=1 ;;
		--no-pull) PULL=0 ;;
		--shared-compilation) SHARED_COMPILATION=1 ;;
		--no-shared-compilation) SHARED_COMPILATION=0 ;;
		--test) TEST=1 ;;
		--no-test) TEST=0 ;;
		--help) PRINT_USAGE; exit 0 ;;
		*) PRINT_USAGE; exit 1
	esac
done

trap "trap - TERM && kill -- -$$" INT TERM

if ! command -v dotnet >/dev/null; then
	echo "ERROR: dotnet CLI tools are not installed!"
	exit 1
fi

dotnet --info

if [ "$PULL" -eq 1 ] && [ -d ".git" ] && command -v git >/dev/null; then
	git pull --recurse-submodules=on-demand || true
fi

if [ ! -f "$SOLUTION" ]; then
	echo "ERROR: $SOLUTION could not be found!"
	exit 1
fi

os_type="$(uname -s)"

case "$os_type" in
	"Darwin") os_type="osx" ;;
	"Linux") os_type="linux" ;;
	*) echo "ERROR: Unknown OS type: ${os_type}. If you believe that our script should work on your machine, please let us know."; exit 1
esac

cpu_architecture="$(uname -m)"

case "$cpu_architecture" in
	"aarch64") cpu_architecture="arm64" ;;
	"armv7l") cpu_architecture="arm" ;;
	"x86_64") cpu_architecture="x64" ;;
	*) echo "ERROR: Unknown CPU architecture: ${cpu_architecture}. If you believe that our script should work on your machine, please let us know."; exit 1
esac

echo "INFO: Detected ${os_type}-${cpu_architecture} machine."

if [ "$ASF_UI" -eq 1 ]; then
	if [ -f "ASF-ui/package.json" ] && command -v npm >/dev/null; then
		echo "INFO: Building ASF-ui..."

		# ASF-ui doesn't clean itself after old build
		rm -rf "ASF-ui/dist"

		npm ci --no-progress --prefix ASF-ui
		npm run-script deploy --no-progress --prefix ASF-ui

		# ASF's output www folder needs cleaning as well
		rm -rf "${OUT}/www"
	else
		echo "WARNING: ASF-ui dependencies are missing, skipping build of ASF-ui..."
	fi
fi

DOTNET_FLAGS="-c $CONFIGURATION -f $TARGET_FRAMEWORK -p:UseAppHost=false -r ${os_type}-${cpu_architecture} --nologo --self-contained false"

if [ "$SHARED_COMPILATION" -eq 0 ]; then
	DOTNET_FLAGS="$DOTNET_FLAGS -p:UseSharedCompilation=false"
fi
{'fraction_non_alphanumeric': 0.175936184356304, 'fraction_numerical': 0.014402836250830933, 'mean_word_length': 3.6488156539649848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3409868', 'n_tokens_mistral': 1950, 'n_tokens_neox': 1791, 'n_words': 473}