forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-dev-env.sh
More file actions
executable file
·259 lines (218 loc) · 6.91 KB
/
setup-dev-env.sh
File metadata and controls
executable file
·259 lines (218 loc) · 6.91 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
#!/bin/bash
# Setup script for GitHub Copilot SDK Development Environment
# This script automates the installation of prerequisites for agentic app development
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Helper functions
print_header() {
echo -e "\n${BLUE}======================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}======================================${NC}\n"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
check_command() {
if command -v "$1" &> /dev/null; then
return 0
else
return 1
fi
}
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
echo "windows"
else
echo "unknown"
fi
}
# Main setup
print_header "GitHub Copilot SDK - Development Environment Setup"
OS=$(detect_os)
echo "Detected OS: $OS"
# Check for GitHub CLI
print_header "Checking Prerequisites"
if check_command gh; then
print_success "GitHub CLI (gh) is installed"
gh --version
else
print_warning "GitHub CLI (gh) not found"
echo "Installing GitHub CLI..."
if [[ "$OS" == "macos" ]]; then
if check_command brew; then
brew install gh
else
print_error "Homebrew not found. Please install from https://brew.sh"
exit 1
fi
elif [[ "$OS" == "linux" ]]; then
# Install gh on Linux
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install -y gh
else
print_error "Please install GitHub CLI manually: https://cli.github.com/"
exit 1
fi
print_success "GitHub CLI installed"
fi
# Check for Copilot CLI
print_header "Checking Copilot CLI"
if check_command copilot; then
print_success "Copilot CLI is installed"
copilot --version || true
else
print_warning "Copilot CLI not found"
echo "Installing Copilot CLI extension..."
gh extension install github/gh-copilot || gh extension upgrade github/gh-copilot
print_success "Copilot CLI extension installed"
fi
# Check authentication
print_header "Checking GitHub Authentication"
if gh auth status &> /dev/null; then
print_success "GitHub CLI is authenticated"
else
print_warning "GitHub CLI is not authenticated"
echo "Please authenticate now..."
gh auth login
fi
# Ask user which SDKs to set up
print_header "SDK Selection"
echo "Which SDKs would you like to set up? (You can select multiple)"
echo ""
read -p "Set up Node.js/TypeScript SDK? (y/n): " setup_nodejs
read -p "Set up Python SDK? (y/n): " setup_python
read -p "Set up Go SDK? (y/n): " setup_go
read -p "Set up .NET SDK? (y/n): " setup_dotnet
# Node.js Setup
if [[ "$setup_nodejs" =~ ^[Yy]$ ]]; then
print_header "Setting up Node.js/TypeScript SDK"
if check_command node; then
NODE_VERSION=$(node -v)
print_success "Node.js is installed: $NODE_VERSION"
else
print_error "Node.js not found. Please install from https://nodejs.org/"
fi
if check_command npm; then
print_success "npm is installed: $(npm -v)"
else
print_error "npm not found"
fi
fi
# Python Setup
if [[ "$setup_python" =~ ^[Yy]$ ]]; then
print_header "Setting up Python SDK"
if check_command python3; then
PYTHON_VERSION=$(python3 --version)
print_success "Python is installed: $PYTHON_VERSION"
else
print_error "Python3 not found. Please install from https://www.python.org/"
fi
if check_command pip3; then
print_success "pip is installed: $(pip3 --version)"
else
print_error "pip not found"
fi
# Check for uv (recommended)
if check_command uv; then
print_success "uv is installed: $(uv --version)"
else
print_warning "uv not found (recommended for faster Python package management)"
read -p "Install uv? (y/n): " install_uv
if [[ "$install_uv" =~ ^[Yy]$ ]]; then
curl -LsSf https://astral.sh/uv/install.sh | sh
print_success "uv installed"
fi
fi
fi
# Go Setup
if [[ "$setup_go" =~ ^[Yy]$ ]]; then
print_header "Setting up Go SDK"
if check_command go; then
GO_VERSION=$(go version)
print_success "Go is installed: $GO_VERSION"
else
print_error "Go not found. Please install from https://go.dev/doc/install"
fi
fi
# .NET Setup
if [[ "$setup_dotnet" =~ ^[Yy]$ ]]; then
print_header "Setting up .NET SDK"
if check_command dotnet; then
DOTNET_VERSION=$(dotnet --version)
print_success ".NET is installed: $DOTNET_VERSION"
else
print_error ".NET not found. Please install from https://dotnet.microsoft.com/download"
fi
fi
# Additional tools
print_header "Checking Additional Development Tools"
if check_command git; then
print_success "Git is installed: $(git --version)"
else
print_warning "Git not found. Please install Git"
fi
if check_command code; then
print_success "VS Code is installed"
else
print_warning "VS Code not found. Recommended for development: https://code.visualstudio.com/"
fi
# Summary
print_header "Setup Summary"
echo "Your development environment has been checked and configured!"
echo ""
echo "Next steps:"
echo "1. Create a new project directory"
echo "2. Install the SDK for your chosen language"
echo "3. Follow the Getting Started guide: docs/getting-started.md"
echo ""
echo "Quick start examples:"
if [[ "$setup_nodejs" =~ ^[Yy]$ ]]; then
echo ""
echo "Node.js/TypeScript:"
echo " mkdir my-app && cd my-app"
echo " npm init -y"
echo " npm install @github/copilot-sdk tsx"
fi
if [[ "$setup_python" =~ ^[Yy]$ ]]; then
echo ""
echo "Python:"
echo " mkdir my-app && cd my-app"
echo " python3 -m venv venv"
echo " source venv/bin/activate"
echo " pip install github-copilot-sdk"
fi
if [[ "$setup_go" =~ ^[Yy]$ ]]; then
echo ""
echo "Go:"
echo " mkdir my-app && cd my-app"
echo " go mod init my-app"
echo " go get github.com/github/copilot-sdk/go"
fi
if [[ "$setup_dotnet" =~ ^[Yy]$ ]]; then
echo ""
echo ".NET:"
echo " dotnet new console -n MyApp"
echo " cd MyApp"
echo " dotnet add package GitHub.Copilot.SDK"
fi
echo ""
print_success "Setup complete! Happy coding! 🚀"