-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest-local.sh
More file actions
executable file
·114 lines (93 loc) · 2.26 KB
/
test-local.sh
File metadata and controls
executable file
·114 lines (93 loc) · 2.26 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
113
114
#!/bin/bash
set -e
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
# Check for expect
command -v expect >/dev/null 2>&1 || {
echo "Installing expect..."
brew install expect
}
# Cleanup function
cleanup() {
echo -e "${BLUE}🧹 Cleaning up...${NC}"
rm -rf react-native-test-module
rm -f test-module.exp
}
# Error handler
handle_error() {
echo -e "${RED}❌ Error on line $1${NC}"
cleanup
exit 1
}
trap 'handle_error $LINENO' ERR
if [ -d "react-native-test-module" ]; then
echo -e "${RED}❌ react-native-test-module already exists. removing folder${NC}"
cleanup
fi
# Create expect script
cat << 'EOF' > test-module.exp
#!/usr/bin/expect -f
set timeout 30
spawn bun create nitro-module --skip-install
# Module name
expect "📝 What is the name of your module?" {send "test-module\r"}
# Platform selection
expect "🎯 Select target platforms:"
sleep 1
send \x20
sleep 1
send \x1B\[B
sleep 1
send \x20
send \r
# Language selection
expect "💻 Select programming languages:"
sleep 1
send \x20
sleep 1
send \x1B\[B\x1B\[B
sleep 1
send \x20
send \r
# Package manager
expect "📦 Select package manager:" {send \r}
# Module type (Default to Nitro Module)
expect "📦 Select module type:" {send \r}
# Confirm package name
expect "✨ Your package name will be called:" {send "y\r"}
expect eof
EOF
chmod +x test-module.exp
# Install, build and link bun
bun install
bun run build
bun link
# Generate module
echo -e "${BLUE}🎯 Generating module...${NC}"
./test-module.exp
# Build iOS/Android
if [ -d "react-native-test-module" ]; then
if [ -d "react-native-test-module/example" ] && [ -d "react-native-test-module/node_modules" ]; then
cd react-native-test-module/example
bun pod
cd ios
xcodebuild -workspace TestModuleExample.xcworkspace \
-scheme TestModuleExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 16' build
cd ../android
./gradlew assembleDebug --no-daemon
./gradlew --stop
cd ../../..
fi
else
echo -e "${RED}❌ Module generation failed${NC}"
cleanup
exit 1
fi
cleanup
echo -e "${GREEN}✅ Test completed${NC}"