forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate-env.sh
More file actions
executable file
·212 lines (186 loc) · 6.02 KB
/
Copy pathvalidate-env.sh
File metadata and controls
executable file
·212 lines (186 loc) · 6.02 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
#!/bin/bash
# Environment Validation Script
# Checks if all prerequisites are installed and configured correctly
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_header() {
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"
}
print_check() {
if [ $1 -eq 0 ]; then
echo -e "${GREEN}✓${NC} $2"
return 0
else
echo -e "${RED}✗${NC} $2"
return 1
fi
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
# Track overall status
ALL_CHECKS_PASSED=0
print_header "🔍 Validating Copilot SDK Development Environment"
# Check GitHub CLI
print_header "GitHub CLI"
if command -v gh &> /dev/null; then
VERSION=$(gh --version | head -n1)
print_check 0 "GitHub CLI installed: $VERSION"
# Check authentication
if gh auth status &> /dev/null; then
print_check 0 "GitHub CLI is authenticated"
else
print_check 1 "GitHub CLI is not authenticated"
print_info "Run: gh auth login"
ALL_CHECKS_PASSED=1
fi
else
print_check 1 "GitHub CLI not found"
print_info "Install from: https://cli.github.com/"
ALL_CHECKS_PASSED=1
fi
# Check Copilot CLI
print_header "Copilot CLI"
if command -v copilot &> /dev/null; then
print_check 0 "Copilot CLI is installed"
# Try to get version
if copilot --version &> /dev/null; then
VERSION=$(copilot --version 2>&1 | head -n1 || echo "version check failed")
print_info "Version: $VERSION"
fi
else
print_check 1 "Copilot CLI not found"
print_info "Install: gh extension install github/gh-copilot"
ALL_CHECKS_PASSED=1
fi
# Check Node.js
print_header "Node.js / TypeScript SDK"
if command -v node &> /dev/null; then
NODE_VERSION=$(node -v)
print_check 0 "Node.js installed: $NODE_VERSION"
# Check version is 18+
NODE_MAJOR=$(echo $NODE_VERSION | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_MAJOR" -ge 18 ]; then
print_check 0 "Node.js version is 18+"
else
print_warning "Node.js version should be 18 or higher"
fi
if command -v npm &> /dev/null; then
NPM_VERSION=$(npm -v)
print_check 0 "npm installed: $NPM_VERSION"
else
print_check 1 "npm not found"
fi
else
print_warning "Node.js not installed (optional)"
print_info "Install from: https://nodejs.org/"
fi
# Check Python
print_header "Python SDK"
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version)
print_check 0 "Python installed: $PYTHON_VERSION"
if command -v pip3 &> /dev/null; then
PIP_VERSION=$(pip3 --version)
print_check 0 "pip installed: $PIP_VERSION"
else
print_check 1 "pip not found"
fi
# Check for uv (recommended)
if command -v uv &> /dev/null; then
UV_VERSION=$(uv --version)
print_check 0 "uv installed: $UV_VERSION (recommended)"
else
print_warning "uv not installed (recommended for faster package management)"
print_info "Install: curl -LsSf https://astral.sh/uv/install.sh | sh"
fi
else
print_warning "Python not installed (optional)"
print_info "Install from: https://www.python.org/"
fi
# Check Go
print_header "Go SDK"
if command -v go &> /dev/null; then
GO_VERSION=$(go version)
print_check 0 "Go installed: $GO_VERSION"
else
print_warning "Go not installed (optional)"
print_info "Install from: https://go.dev/doc/install"
fi
# Check .NET
print_header ".NET SDK"
if command -v dotnet &> /dev/null; then
DOTNET_VERSION=$(dotnet --version)
print_check 0 ".NET installed: $DOTNET_VERSION"
else
print_warning ".NET not installed (optional)"
print_info "Install from: https://dotnet.microsoft.com/download"
fi
# Check additional tools
print_header "Additional Tools"
if command -v git &> /dev/null; then
GIT_VERSION=$(git --version)
print_check 0 "Git installed: $GIT_VERSION"
else
print_check 1 "Git not found (required)"
ALL_CHECKS_PASSED=1
fi
if command -v code &> /dev/null; then
print_check 0 "VS Code installed"
else
print_warning "VS Code not installed (recommended)"
print_info "Install from: https://code.visualstudio.com/"
fi
if command -v just &> /dev/null; then
JUST_VERSION=$(just --version)
print_check 0 "just command runner installed: $JUST_VERSION"
else
print_warning "just not installed (optional, useful for running tasks)"
print_info "Install from: https://github.com/casey/just"
fi
# Summary
print_header "Summary"
if [ $ALL_CHECKS_PASSED -eq 0 ]; then
echo -e "${GREEN}✓ All required checks passed!${NC}"
echo ""
echo "Your environment is ready for Copilot SDK development!"
echo ""
echo "Next steps:"
echo "1. Choose a template from: templates/"
echo "2. Copy the template to start your project"
echo "3. Follow the template's README for setup"
echo ""
echo "Quick start:"
echo " cd templates/typescript-quickstart # or python-quickstart"
echo " npm install # or pip install -r requirements.txt"
echo " cp ../../.env.example .env"
echo " npm start # or python src/main.py"
exit 0
else
echo -e "${YELLOW}⚠ Some checks failed${NC}"
echo ""
echo "Please install the missing required components before continuing."
echo "See the messages above for installation instructions."
echo ""
echo "Required:"
echo " - GitHub CLI (gh)"
echo " - Copilot CLI extension"
echo " - Git"
echo ""
echo "Optional (at least one SDK):"
echo " - Node.js (for TypeScript SDK)"
echo " - Python (for Python SDK)"
echo " - Go (for Go SDK)"
echo " - .NET (for .NET SDK)"
exit 1
fi