Repository navigation
Expand file tree
/
Copy pathsetup-dev.sh
More file actions
executable file
·356 lines (306 loc) · 9.9 KB
/
Copy pathsetup-dev.sh
File metadata and controls
executable file
·356 lines (306 loc) · 9.9 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#!/bin/bash
# Development setup script using uv for fast Python dependency management
# This script sets up the complete development environment for fplaunchwrapper
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if uv is installed
check_uv() {
if ! command -v uv &> /dev/null; then
log_info "Installing uv (fast Python package installer)..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.cargo/bin:$PATH"
fi
if command -v uv &> /dev/null; then
log_success "uv is available: $(uv --version)"
return 0
else
log_error "Failed to install uv"
return 1
fi
}
# Install Python dependencies using uv
install_dependencies() {
local mode="${1:-dev}"
log_info "Installing Python dependencies with uv (mode: $mode)..."
case "$mode" in
"minimal")
uv pip install -e .
;;
"robustness")
uv pip install -e ".[robustness]"
;;
"advanced")
uv pip install -e ".[robustness,advanced]"
;;
"dev")
uv pip install -e ".[robustness,advanced,dev]"
;;
"full")
uv pip install -e ".[all]"
;;
*)
log_error "Unknown installation mode: $mode"
echo "Available modes: minimal, robustness, advanced, dev, full"
return 1
;;
esac
log_success "Python dependencies installed successfully"
}
# Install system dependencies
install_system_deps() {
log_info "Checking for system dependencies..."
local missing_deps=()
# Check for Flatpak
if ! command -v flatpak &> /dev/null; then
missing_deps+=("flatpak")
fi
# Check for dialog (for interactive prompts)
if ! command -v dialog &> /dev/null; then
missing_deps+=("dialog")
fi
# Python testing is built-in, no additional dependencies needed
# Check for shell script linting
if ! command -v shellcheck &> /dev/null; then
missing_deps+=("shellcheck")
fi
if [ ${#missing_deps[@]} -ne 0 ]; then
log_warn "Missing system dependencies: ${missing_deps[*]}"
log_info "Installing system dependencies..."
# Detect package manager and install dependencies
if command -v apt-get &> /dev/null; then
# Debian/Ubuntu
sudo apt-get update
sudo apt-get install -y flatpak dialog
elif command -v dnf &> /dev/null; then
# Fedora/RHEL
sudo dnf install -y flatpak dialog
elif command -v pacman &> /dev/null; then
# Arch Linux
sudo pacman -S --noconfirm flatpak dialog
elif command -v zypper &> /dev/null; then
# openSUSE
sudo zypper install -y flatpak dialog
else
log_error "Unsupported package manager. Please install manually:"
echo " - flatpak"
echo " - dialog"
return 1
fi
# Initialize Flatpak if not already done
if ! flatpak remotes | grep -q flathub; then
log_info "Adding Flathub remote..."
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
log_success "System dependencies installed"
else
log_success "All system dependencies are available"
fi
}
# Set up development environment
setup_dev_environment() {
log_info "Setting up development environment..."
# Create virtual environment if it doesn't exist
if [ ! -d ".venv" ]; then
log_info "Creating virtual environment..."
uv venv .venv
fi
# Activate virtual environment
# shellcheck disable=SC1091
source .venv/bin/activate
# Install development dependencies
install_dependencies "dev"
# Create symlinks for development scripts
log_info "Creating development script symlinks..."
# Make scripts executable
chmod +x fplaunch-generate fplaunch-manage fplaunch-cleanup fplaunch-setup-systemd
# Create symlinks in ~/.local/bin if it exists
local local_bin="$HOME/.local/bin"
if [ -d "$local_bin" ]; then
ln -sf "$(pwd)/fplaunch-generate" "$local_bin/" 2>/dev/null || true
ln -sf "$(pwd)/fplaunch-manage" "$local_bin/" 2>/dev/null || true
ln -sf "$(pwd)/fplaunch-cleanup" "$local_bin/" 2>/dev/null || true
ln -sf "$(pwd)/fplaunch-setup-systemd" "$local_bin/" 2>/dev/null || true
log_info "Created symlinks in $local_bin"
fi
log_success "Development environment setup complete"
}
# Run tests
run_tests() {
log_info "Running comprehensive test suite..."
# Check for Python
if ! command -v python3 &> /dev/null; then
log_error "Python 3 not found"
return 1
fi
# Run performance tests
log_info "Running performance benchmarks..."
if python3 test_performance_simple.py; then
log_success "Performance tests passed"
else
log_error "Performance tests failed"
fi
# Run safety validation tests
log_info "Running safety validation tests..."
if python3 test_integration_safety.py; then
log_success "Safety tests passed"
else
log_error "Safety tests failed"
fi
# Run Python unit tests
if command -v pytest &> /dev/null; then
log_info "Running Python unit tests..."
if python3 -c "
import sys
sys.path.insert(0, '.')
# Run key test suites
from tests.python.test_safe_constructor import TestSafeConstructorValidation
from tests.python.test_edge_cases_focused import TestInputValidationEdgeCases
# Test constructor validation
test_constructor = TestSafeConstructorValidation()
test_constructor.test_wrapper_generator_constructor()
test_constructor.test_wrapper_manager_constructor()
test_constructor.test_wrapper_cleanup_constructor()
test_constructor.test_app_launcher_constructor()
test_constructor.test_systemd_setup_constructor()
# Test edge cases
test_edges = TestInputValidationEdgeCases()
test_edges.test_empty_and_none_inputs()
test_edges.test_extremely_long_inputs()
print('All Python tests passed!')
"; then
log_success "Python unit tests passed"
else
log_error "Python unit tests failed"
fi
else
log_warn "pytest not available, running basic validation..."
if python3 -c "
from lib.generate import WrapperGenerator
from lib.manage import WrapperManager
from lib.cleanup import WrapperCleanup
from lib.launch import AppLauncher
print('✅ Python modules imported successfully')
"; then
log_success "Basic Python validation passed"
else
log_error "Basic Python validation failed"
fi
fi
}
# Show usage information
show_usage() {
cat << EOF
fplaunchwrapper Development Setup Script
USAGE:
$0 [COMMAND] [OPTIONS]
COMMANDS:
setup Set up complete development environment (default)
deps Install only Python dependencies
system Install only system dependencies
test Run test suite
clean Clean up development environment
OPTIONS:
--mode MODE Dependency installation mode:
minimal - Core dependencies only
robustness - + pydantic, tomli, psutil
advanced - + click, rich, validators
dev - + testing and development tools (default)
full - All dependencies
EXAMPLES:
$0 # Full development setup
$0 deps --mode minimal # Install minimal dependencies
$0 system # Install system dependencies only
$0 test # Run tests
DEPENDENCY MODES:
minimal - Core functionality only
robustness - Type-safe config, process monitoring
advanced - Modern CLI, rich output, validation
dev - Testing, linting, formatting tools
full - Everything including security and integration tools
EOF
}
# Main function
main() {
local command="${1:-setup}"
local mode="dev"
# Parse arguments
shift
while [ $# -gt 0 ]; do
case "$1" in
--mode)
mode="$2"
shift 2
;;
-h|--help)
show_usage
exit 0
;;
*)
log_error "Unknown option: $1"
show_usage
exit 1
;;
esac
done
case "$command" in
setup)
log_info "Starting complete development environment setup..."
check_uv
install_system_deps
setup_dev_environment
run_tests
log_success "Development environment setup complete!"
echo ""
echo "Next steps:"
echo " 1. Activate virtual environment: source .venv/bin/activate"
echo " 2. Run tests: uv run pytest"
echo " 3. Start developing!"
;;
deps)
check_uv
install_dependencies "$mode"
;;
system)
install_system_deps
;;
test)
run_tests
;;
clean)
log_info "Cleaning up development environment..."
rm -rf .venv
rm -rf .pytest_cache
rm -rf .coverage
rm -rf htmlcov
rm -rf __pycache__
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete
log_success "Development environment cleaned"
;;
*)
log_error "Unknown command: $command"
show_usage
exit 1
;;
esac
}
# Run main function
main "$@"