-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-testing.sh
More file actions
executable file
Β·133 lines (110 loc) Β· 4.01 KB
/
start-testing.sh
File metadata and controls
executable file
Β·133 lines (110 loc) Β· 4.01 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Directus Usage Analytics - Testing Environment Setup Script
# This script builds the extension and starts a local Directus instance for testing
set -e # Exit on error
echo "π Directus Usage Analytics - Testing Environment Setup"
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
# Step 1: Check prerequisites
echo -e "${BLUE}π Checking prerequisites...${NC}"
if ! command -v docker &> /dev/null; then
echo -e "${RED}β Docker is not installed. Please install Docker first.${NC}"
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo -e "${RED}β Docker Compose is not installed. Please install Docker Compose first.${NC}"
exit 1
fi
if ! command -v node &> /dev/null; then
echo -e "${RED}β Node.js is not installed. Please install Node.js 18.x or higher.${NC}"
exit 1
fi
if ! command -v npm &> /dev/null; then
echo -e "${RED}β npm is not installed. Please install npm.${NC}"
exit 1
fi
echo -e "${GREEN}β
All prerequisites met${NC}"
echo ""
# Step 2: Install dependencies (if needed)
if [ ! -d "node_modules" ]; then
echo -e "${BLUE}π¦ Installing dependencies...${NC}"
npm install
echo -e "${GREEN}β
Dependencies installed${NC}"
echo ""
else
echo -e "${GREEN}β
Dependencies already installed${NC}"
echo ""
fi
# Step 3: Build extension
echo -e "${BLUE}π¨ Building extension...${NC}"
npm run build
if [ ! -f "dist/api.js" ] || [ ! -f "dist/app.js" ]; then
echo -e "${RED}β Build failed - dist files not created${NC}"
exit 1
fi
echo -e "${GREEN}β
Extension built successfully${NC}"
echo -e " - dist/api.js ($(du -h dist/api.js | cut -f1))"
echo -e " - dist/app.js ($(du -h dist/app.js | cut -f1))"
echo ""
# Step 4: Stop any existing containers
echo -e "${BLUE}π Stopping existing containers (if any)...${NC}"
docker-compose down 2>/dev/null || true
echo ""
# Step 5: Start Docker containers
echo -e "${BLUE}π³ Starting Docker containers...${NC}"
docker-compose up -d
echo -e "${GREEN}β
Containers started${NC}"
echo ""
# Step 6: Wait for Directus to be ready
echo -e "${BLUE}β³ Waiting for Directus to be ready...${NC}"
echo -e "${YELLOW} This may take 30-60 seconds for first-time setup...${NC}"
MAX_ATTEMPTS=60
ATTEMPT=0
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
if curl -s http://localhost:8055/server/health > /dev/null 2>&1; then
echo -e "${GREEN}β
Directus is ready!${NC}"
break
fi
ATTEMPT=$((ATTEMPT + 1))
echo -ne " Attempt $ATTEMPT/$MAX_ATTEMPTS...\r"
sleep 2
done
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo -e "${RED}β Directus failed to start within timeout${NC}"
echo -e "${YELLOW}π Check logs with: docker-compose logs directus${NC}"
exit 1
fi
echo ""
echo ""
echo -e "${GREEN}π Setup Complete!${NC}"
echo "======================================================="
echo ""
echo -e "${BLUE}π Access Points:${NC}"
echo -e " Directus Admin: ${YELLOW}http://localhost:8055${NC}"
echo -e " Database: ${YELLOW}localhost:5432${NC}"
echo ""
echo -e "${BLUE}π Login Credentials:${NC}"
echo -e " Email: ${YELLOW}admin@example.com${NC}"
echo -e " Password: ${YELLOW}admin123${NC}"
echo ""
echo -e "${BLUE}π Find the Extension:${NC}"
echo " 1. Open http://localhost:8055 in your browser"
echo " 2. Login with credentials above"
echo " 3. Go to Settings (gear icon) β Usage Analytics"
echo ""
echo -e "${BLUE}π Testing Guide:${NC}"
echo -e " Read ${YELLOW}TESTING.md${NC} for comprehensive testing checklist"
echo ""
echo -e "${BLUE}π οΈ Useful Commands:${NC}"
echo -e " View logs: ${YELLOW}docker-compose logs -f directus${NC}"
echo -e " Restart: ${YELLOW}docker-compose restart directus${NC}"
echo -e " Stop: ${YELLOW}docker-compose down${NC}"
echo -e " Rebuild: ${YELLOW}npm run build && docker-compose restart directus${NC}"
echo ""
echo -e "${GREEN}Happy Testing! π${NC}"