forked from mahsanet/proxy_core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre_run_clean.sh
More file actions
executable file
·112 lines (89 loc) · 2.91 KB
/
Copy pathpre_run_clean.sh
File metadata and controls
executable file
·112 lines (89 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
VERBOSE=false
SKIP_ADB=false
PACKAGE_NAME="com.mahsanet.proxy_core_example"
while [[ "$#" -gt 0 ]]; do
case $1 in
-v|--verbose) VERBOSE=true ;;
--skip-adb) SKIP_ADB=true ;;
-p|--package) PACKAGE_NAME="$2"; shift ;;
-h|--help)
echo "Usage: ./presetup.sh [options]"
echo "Options:"
echo " -v, --verbose Enable verbose mode"
echo " --skip-adb Skip ADB uninstall step"
echo " -p, --package Specify package name for ADB uninstall"
echo " -h, --help Show this help message"
exit 0
;;
*) echo "Unknown parameter: $1"; exit 1 ;;
esac
shift
done
function print_verbose() {
if [ "$VERBOSE" = true ]; then
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
fi
}
function handle_error() {
echo "Error: $1"
exit 1
}
function check_command() {
if ! command -v $1 &> /dev/null; then
handle_error "$1 command not found. Please install it first."
fi
}
function remove_lock_files() {
print_verbose "Removing .lock files..."
find . -type f -name "*.lock" -delete || handle_error "Failed to remove lock files"
print_verbose "✓ Lock files removed"
}
function flutter_clean() {
check_command flutter
if [ -d "example" ]; then
print_verbose "Running 'flutter clean' in example folder..."
(cd example && flutter clean) || handle_error "Flutter clean failed in example directory"
print_verbose "✓ Flutter clean completed in example directory"
fi
}
function remove_build_dirs() {
print_verbose "Removing build directories..."
rm -rf android/build/ android/.cxx android/CMakeFiles android/CMakeCache.txt android/cmake_install.cmake android/Makefile
print_verbose "✓ Removed cxx and CMake related files"
rm -rf android/src/main/jniLibs/*
print_verbose "✓ Removed jniLibs content"
rm -rf ios/Frameworks/libproxy_core.xcframework macos/Frameworks/libproxy_core.xcframework
print_verbose "✓ Removed Frameworks content"
}
function remove_app_with_adb() {
if [ "$SKIP_ADB" = true ]; then
print_verbose "Skipping ADB uninstall step"
return
fi
check_command adb
print_verbose "Checking ADB devices..."
local devices=$(adb devices | grep -v "List" | grep "device$")
if [ -z "$devices" ]; then
handle_error "No ADB devices found. Please connect a device first."
fi
print_verbose "Uninstalling package: $PACKAGE_NAME"
if adb uninstall "$PACKAGE_NAME" &> /dev/null; then
print_verbose "✓ App uninstalled successfully"
else
print_verbose "! App was not installed or failed to uninstall"
fi
}
function run_all_tasks() {
print_verbose "Starting presetup tasks..."
mkdir -p android/src/main/jniLibs ios/Frameworks macos/Frameworks
remove_lock_files
flutter_clean
remove_build_dirs
remove_app_with_adb
print_verbose "✓ All presetup tasks completed successfully"
if [ "$VERBOSE" = false ]; then
echo "Setup completed successfully"
fi
}
run_all_tasks