Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·171 lines (148 loc) · 4.48 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·171 lines (148 loc) · 4.48 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
#!/bin/bash
# OpenCode Config Setup Script
# This script sets up opencode-config with uv and .venv
set -e
# Parse command line arguments
DRY_RUN=false
TEST_MODE=false
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
DRY_RUN=true
shift
;;
--test)
TEST_MODE=true
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# 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 uv is installed
check_uv() {
if ! command -v uv &> /dev/null; then
print_error "uv is not installed. Please install uv first:"
echo "curl -LsSf https://astral.sh/uv/install.sh | sh"
exit 1
fi
print_success "uv is installed"
}
# Create virtual environment with uv
create_venv() {
print_status "Creating virtual environment with uv..."
if [ ! -d ".venv" ]; then
uv venv
print_success "Virtual environment created at .venv"
else
print_warning "Virtual environment already exists at .venv"
fi
}
# Install dependencies with uv
install_deps() {
print_status "Installing dependencies with uv..."
uv sync
print_success "Dependencies installed"
}
# Setup global configuration
setup_global_config() {
print_status "Setting up global configuration..."
# Create ~/.opencode directory if it doesn't exist
mkdir -p ~/.opencode
# Copy global configurations
if [ -d "config/global" ]; then
cp -r config/global/* ~/.opencode/
print_success "Global configuration copied to ~/.opencode/"
else
print_warning "No global configuration found in config/global/"
fi
}
# Setup project configuration (optional)
setup_project_config() {
if [ "$1" = "--project" ]; then
print_status "Setting up project configuration..."
if [ -d "config/project/.opencode" ]; then
cp -r config/project/.opencode ./
print_success "Project configuration copied to ./.opencode/"
else
print_warning "No project configuration found in config/project/.opencode/"
fi
fi
}
# Validate installation
validate_installation() {
print_status "Validating installation..."
# Run compatibility test
if uv run python scripts/test-compatibility.py; then
print_success "Installation validation passed"
else
print_error "Installation validation failed"
exit 1
fi
}
# Main setup function
main() {
if [ "$DRY_RUN" = true ]; then
print_status "DRY-RUN: Starting OpenCode Config setup simulation..."
else
print_status "Starting OpenCode Config setup..."
fi
if [ "$DRY_RUN" = false ]; then
# Setup bd (beads) issue tracker
if [ -f "scripts/setup-bd.sh" ]; then
print_status "Setting up bd (beads) issue tracker..."
./scripts/setup-bd.sh
else
print_warning "bd setup script not found. Skipping bd setup."
fi
check_uv
create_venv
install_deps
setup_global_config
setup_project_config "$@"
validate_installation
else
print_status "DRY-RUN: Would check uv installation"
print_status "DRY-RUN: Would create virtual environment"
print_status "DRY-RUN: Would install dependencies"
print_status "DRY-RUN: Would setup global configuration"
print_status "DRY-RUN: Would setup project configuration"
print_status "DRY-RUN: Would validate installation"
fi
if [ "$DRY_RUN" = false ]; then
print_success "OpenCode Config setup complete!"
echo
print_status "Next steps:"
echo "1. Activate the virtual environment: source .venv/bin/activate"
echo "2. Check ready work: ./scripts/bd-wrapper.sh ready"
echo "3. Run tests: uv run python scripts/test-compatibility.py"
echo "4. Customize configurations in ~/.opencode/ or ./.opencode/"
echo
else
print_success "DRY-RUN: OpenCode Config setup simulation complete!"
fi
print_status "For project-specific setup, run: ./setup.sh --project"
}
# Run main function with all arguments
main "$@"