Skip to content

Commit 901e9a0

Browse files
committed
chore: Add sdk install script in test-app
1 parent e5c9eba commit 901e9a0

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

test-app/install_sdk.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# Script to build, pack, and install the ImageKit Angular SDK in test-app
4+
# Usage: ./install_sdk.sh
5+
6+
set -e # Exit on error
7+
8+
# Colors for output
9+
GREEN='\033[0;32m'
10+
BLUE='\033[0;34m'
11+
RED='\033[0;31m'
12+
NC='\033[0m' # No Color
13+
14+
echo -e "${BLUE}=====================================${NC}"
15+
echo -e "${BLUE}ImageKit Angular SDK - Build & Install${NC}"
16+
echo -e "${BLUE}=====================================${NC}"
17+
18+
# Get the directory where this script is located
19+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
20+
SDK_DIR="$SCRIPT_DIR/../sdk"
21+
DIST_DIR="$SDK_DIR/dist/imagekit-angular"
22+
23+
# Navigate to SDK directory
24+
echo -e "\n${BLUE}Step 1: Building SDK...${NC}"
25+
cd "$SDK_DIR"
26+
27+
# Install dependencies if node_modules doesn't exist
28+
if [ ! -d "node_modules" ]; then
29+
echo -e "${BLUE}Installing SDK dependencies...${NC}"
30+
npm install
31+
fi
32+
33+
# Build the SDK
34+
echo -e "${BLUE}Running build...${NC}"
35+
npm run build
36+
37+
# Check if build was successful
38+
if [ ! -d "$DIST_DIR" ]; then
39+
echo -e "${RED}Error: Build failed. Distribution directory not found.${NC}"
40+
exit 1
41+
fi
42+
43+
echo -e "${GREEN}✓ Build complete${NC}"
44+
45+
# Navigate to dist directory and pack
46+
echo -e "\n${BLUE}Step 2: Packing SDK...${NC}"
47+
cd "$DIST_DIR"
48+
49+
# Remove any existing tarballs
50+
rm -f *.tgz
51+
52+
# Pack the SDK
53+
npm pack
54+
55+
# Find the latest tarball
56+
TARBALL=$(ls -t *.tgz | head -1)
57+
58+
if [ -z "$TARBALL" ]; then
59+
echo -e "${RED}Error: No tarball found after packing.${NC}"
60+
exit 1
61+
fi
62+
63+
echo -e "${GREEN}✓ Created tarball: $TARBALL${NC}"
64+
65+
# Get the full path to the tarball
66+
TARBALL_PATH="$DIST_DIR/$TARBALL"
67+
68+
# Navigate to test-app directory
69+
echo -e "\n${BLUE}Step 3: Installing SDK in test-app...${NC}"
70+
cd "$SCRIPT_DIR"
71+
72+
# Install dependencies if node_modules doesn't exist
73+
if [ ! -d "node_modules" ]; then
74+
echo -e "${BLUE}Installing test-app dependencies...${NC}"
75+
npm install
76+
fi
77+
78+
# Uninstall any existing version of the SDK
79+
echo -e "${BLUE}Removing existing SDK installation...${NC}"
80+
npm uninstall @imagekit/angular 2>/dev/null || true
81+
82+
# Install the new tarball
83+
echo -e "${BLUE}Installing SDK from: $TARBALL${NC}"
84+
npm install "$TARBALL_PATH"
85+
86+
echo -e "\n${GREEN}=====================================${NC}"
87+
echo -e "${GREEN}✓ SDK successfully installed!${NC}"
88+
echo -e "${GREEN}=====================================${NC}"
89+
echo -e "\nYou can now run the test-app with: ${BLUE}npm start${NC}"

0 commit comments

Comments
 (0)