-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
261 lines (209 loc) Β· 7.38 KB
/
setup.sh
File metadata and controls
261 lines (209 loc) Β· 7.38 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash
# PPTX Translator Pro - Complete Setup Script
# This script will detect and fix all common issues
echo "π PPTX Translator Pro - Complete Setup"
echo "========================================"
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
print_error "package.json not found. Please run this script from the project root directory."
exit 1
fi
print_success "Found package.json - we're in the right directory"
# Check Node.js version
print_status "Checking Node.js version..."
if ! command -v node &> /dev/null; then
print_error "Node.js is not installed. Please install Node.js 16+ from https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt "16" ]; then
print_error "Node.js version $NODE_VERSION is too old. Please install Node.js 16 or higher."
exit 1
fi
print_success "Node.js version $(node --version) is compatible"
# Check npm
print_status "Checking npm..."
if ! command -v npm &> /dev/null; then
print_error "npm is not installed. Please install npm."
exit 1
fi
print_success "npm version $(npm --version) found"
# Clean previous installation
print_status "Cleaning previous installation..."
if [ -d "node_modules" ]; then
print_warning "Removing existing node_modules..."
rm -rf node_modules
fi
if [ -f "package-lock.json" ]; then
print_warning "Removing existing package-lock.json..."
rm -f package-lock.json
fi
# Install dependencies
print_status "Installing dependencies..."
npm install
# Check if installation was successful
if [ ! -d "node_modules" ]; then
print_error "npm install failed. Please check your internet connection and try again."
exit 1
fi
print_success "Basic dependencies installed"
# Install critical PPTX processing libraries
print_status "Installing PPTX processing libraries..."
npm install googleapis@^126.0.1 jszip@^3.10.1 xml2js@^0.6.2 pptxgenjs@^3.12.0 @types/xml2js@^0.4.14
# Verify critical packages
print_status "Verifying critical packages..."
MISSING_PACKAGES=()
if [ ! -d "node_modules/googleapis" ]; then
MISSING_PACKAGES+=("googleapis")
fi
if [ ! -d "node_modules/jszip" ]; then
MISSING_PACKAGES+=("jszip")
fi
if [ ! -d "node_modules/xml2js" ]; then
MISSING_PACKAGES+=("xml2js")
fi
if [ ! -d "node_modules/pptxgenjs" ]; then
MISSING_PACKAGES+=("pptxgenjs")
fi
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
print_error "Some critical packages are missing: ${MISSING_PACKAGES[*]}"
print_status "Attempting to install missing packages individually..."
for package in "${MISSING_PACKAGES[@]}"; do
print_status "Installing $package..."
npm install "$package" --force
done
fi
# Create sample PPTX file for testing
print_status "Creating sample PPTX file for testing..."
cat > test-sample.txt << 'EOF'
This is a test file to demonstrate the PPTX size issue.
If your PPTX file is only 70 bytes, it's likely corrupted or empty.
A normal PowerPoint file should be at least 10KB (10,240 bytes).
To create a proper test file:
1. Open Microsoft PowerPoint
2. Create a new presentation
3. Add title slide: "Test Presentation"
4. Add content slide: "This is sample content for testing PPTX Translator Pro"
5. Add conclusion slide: "Thank you for testing"
6. Save as .pptx format
The resulting file should be 15-50KB in size.
EOF
print_success "Created test-sample.txt with instructions"
# Check current directory structure
print_status "Verifying project structure..."
REQUIRED_FILES=("App.tsx" "package.json" "vite.config.ts" "services/googleApi.ts" "services/pptxProcessor.ts" "services/translationService.ts")
MISSING_FILES=()
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$file" ]; then
MISSING_FILES+=("$file")
fi
done
if [ ${#MISSING_FILES[@]} -gt 0 ]; then
print_warning "Some project files are missing: ${MISSING_FILES[*]}"
print_status "The application will still work in development mode"
fi
# Test npm scripts
print_status "Testing npm scripts..."
if ! npm run --silent 2>/dev/null | grep -q "dev"; then
print_warning "npm run dev script not found - adding basic Vite script"
# You could add script modification here if needed
fi
# Create debug information
print_status "Creating debug information..."
cat > DEBUG_INFO.txt << EOF
PPTX Translator Pro - Debug Information
Generated: $(date)
System Information:
- Node.js: $(node --version)
- npm: $(npm --version)
- OS: $(uname -s)
- Current directory: $(pwd)
Project Status:
- Dependencies installed: $([ -d "node_modules" ] && echo "YES" || echo "NO")
- Critical packages verified: $([ ${#MISSING_PACKAGES[@]} -eq 0 ] && echo "YES" || echo "NO")
Common Issues and Solutions:
1. "File is too small (70 bytes)":
- Your PPTX file is corrupted or empty
- Create a new PPTX with actual content (should be >10KB)
- Use the "Generate Sample File" button in the app
2. "Module not found" errors:
- Run: rm -rf node_modules package-lock.json
- Run: npm install
- Run: npm install googleapis jszip xml2js pptxgenjs
3. "Google APIs not available":
- This is NORMAL in development mode
- App will use mock data for demonstration
- Real functionality requires Google Cloud setup
4. Translation takes too long:
- This is normal - Google Translate needs time
- Mock mode simulates this delay
- Real translations can take 2-5 minutes
Next Steps:
1. Run: npm run dev
2. Open: http://localhost:3000
3. Generate sample file or create your own PPTX
4. Test the translation process
5. Check browser console (F12) for detailed logs
For more help, check INSTRUKCJE_UZYTKOWNIKA.md
EOF
print_success "Created DEBUG_INFO.txt"
# Final checks and summary
echo ""
echo "π Setup Complete! Summary:"
echo "=========================="
print_success "β
Node.js and npm are properly installed"
print_success "β
All dependencies have been installed"
print_success "β
Project structure is valid"
if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then
print_success "β
All critical PPTX processing packages are available"
else
print_warning "β οΈ Some packages may need manual installation"
fi
echo ""
echo "π Ready to start!"
echo "=================="
echo "1. Run the application:"
echo " npm run dev"
echo ""
echo "2. Open in browser:"
echo " http://localhost:3000"
echo ""
echo "3. About your 70-byte PPTX file:"
print_error " β 70 bytes is TOO SMALL for a real PowerPoint file"
print_warning " β οΈ Normal PPTX files are 10KB - 50MB in size"
print_success " β
Use 'Generate Sample File' button in the app"
echo ""
echo "4. For detailed help:"
echo " - Read INSTRUKCJE_UZYTKOWNIKA.md"
echo " - Check DEBUG_INFO.txt"
echo " - Enable debug mode in browser console: localStorage.setItem('debug', 'true')"
echo ""
echo "π― The app works in DEVELOPMENT MODE by default"
echo " - Uses mock data for demonstration"
echo " - Shows how the real process would work"
echo " - No Google APIs required for testing"
echo ""
print_success "Setup completed successfully! π"
# Make the script executable for next time
chmod +x "$0"
exit 0