-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbuild-and-bundle.sh
More file actions
executable file
·100 lines (85 loc) · 2.7 KB
/
build-and-bundle.sh
File metadata and controls
executable file
·100 lines (85 loc) · 2.7 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
echo "ImagePickerKMP - Automated Build & Bundle"
echo "========================================="
echo
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
print_step() {
echo -e "${BLUE}Step: $1${NC}"
}
print_success() {
echo -e "${GREEN}Success: $1${NC}"
}
print_warning() {
echo -e "${YELLOW}Warning: $1${NC}"
}
print_error() {
echo -e "${RED}Error: $1${NC}"
}
# Function to verify if command was successful
check_success() {
if [ $? -eq 0 ]; then
print_success "$1"
else
print_error "$1 failed"
exit 1
fi
}
# Step 1: Clean previous build
print_step "Cleaning previous build..."
./gradlew clean
check_success "Clean completed"
# Step 2: Complete build (includes automatic NPM bundle)
print_step "Building project + automatic NPM bundle..."
./gradlew build
check_success "Build + NPM Bundle completed"
# Step 3: Verify that packages were created
JS_PACKAGE_DIR="build/js/packages/ImagePickerKMP-library"
WASM_PACKAGE_DIR="build/js/packages/ImagePickerKMP-library-wasm-js"
echo
echo "Verifying generated packages..."
if [ -d "$JS_PACKAGE_DIR" ]; then
print_success "JavaScript package found: $JS_PACKAGE_DIR"
# Verify package.json
if [ -f "$JS_PACKAGE_DIR/package.json" ]; then
VERSION=$(grep '"version":' "$JS_PACKAGE_DIR/package.json" | sed 's/.*"version": "\(.*\)".*/\1/')
print_success "NPM package version: $VERSION (automatic from Gradle)"
fi
# Verify main bundle
if [ -f "$JS_PACKAGE_DIR/kotlin/ImagePickerKMP-library.js" ]; then
SIZE=$(du -h "$JS_PACKAGE_DIR/kotlin/ImagePickerKMP-library.js" | cut -f1)
print_success "JavaScript bundle: $SIZE"
fi
else
print_error "JavaScript package NOT found"
fi
if [ -d "$WASM_PACKAGE_DIR" ]; then
print_success "WebAssembly package found: $WASM_PACKAGE_DIR"
else
print_warning "WebAssembly package not found (optional)"
fi
# Step 4: Show installation instructions
echo
echo "BUILD COMPLETED!"
echo "================"
echo
echo "Install in your project:"
echo -e "${YELLOW}cd your-web-project${NC}"
echo -e "${YELLOW}npm install $(pwd)/$JS_PACKAGE_DIR${NC}"
echo
echo "Or use npm link:"
echo -e "${YELLOW}cd $JS_PACKAGE_DIR && npm link${NC}"
echo -e "${YELLOW}cd your-web-project && npm link imagepickerkmp${NC}"
echo
echo "Usage example:"
echo -e "${BLUE}import ImagePickerKMP from 'imagepickerkmp';${NC}"
echo -e "${BLUE}ImagePickerKMP.ImagePickerLauncher(onSuccess, onError, onCancel);${NC}"
echo
echo "Available test files:"
echo " - debug-permisos-imagepicker.html (complete diagnostics)"
echo " - $JS_PACKAGE_DIR/test-zero-config.html (basic test)"
echo
echo "Your ImagePickerKMP is ready to use!"