forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-dev-env.ps1
More file actions
256 lines (219 loc) · 6.86 KB
/
setup-dev-env.ps1
File metadata and controls
256 lines (219 loc) · 6.86 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
# Setup script for GitHub Copilot SDK Development Environment (Windows)
# Run this script in PowerShell with administrator privileges
$ErrorActionPreference = "Stop"
# Colors for output
function Write-Header {
param([string]$Message)
Write-Host "`n======================================" -ForegroundColor Blue
Write-Host $Message -ForegroundColor Blue
Write-Host "======================================`n" -ForegroundColor Blue
}
function Write-Success {
param([string]$Message)
Write-Host "✓ $Message" -ForegroundColor Green
}
function Write-Warning {
param([string]$Message)
Write-Host "⚠ $Message" -ForegroundColor Yellow
}
function Write-Error {
param([string]$Message)
Write-Host "✗ $Message" -ForegroundColor Red
}
function Test-Command {
param([string]$Command)
try {
Get-Command $Command -ErrorAction Stop | Out-Null
return $true
}
catch {
return $false
}
}
# Main setup
Write-Header "GitHub Copilot SDK - Development Environment Setup"
Write-Host "Detected OS: Windows"
# Check for winget
Write-Header "Checking Prerequisites"
if (-not (Test-Command "winget")) {
Write-Error "winget not found. Please ensure you're running Windows 10 1809+ or Windows 11"
Write-Host "Manual installation required from: https://github.com/microsoft/winget-cli"
exit 1
}
# Check for GitHub CLI
if (Test-Command "gh") {
Write-Success "GitHub CLI (gh) is installed"
gh --version
}
else {
Write-Warning "GitHub CLI (gh) not found"
Write-Host "Installing GitHub CLI..."
winget install --id GitHub.cli
Write-Success "GitHub CLI installed"
}
# Check for Copilot CLI
Write-Header "Checking Copilot CLI"
if (Test-Command "copilot") {
Write-Success "Copilot CLI is installed"
try { copilot --version } catch {}
}
else {
Write-Warning "Copilot CLI not found"
Write-Host "Installing Copilot CLI extension..."
try {
gh extension install github/gh-copilot
}
catch {
gh extension upgrade github/gh-copilot
}
Write-Success "Copilot CLI extension installed"
}
# Check authentication
Write-Header "Checking GitHub Authentication"
try {
gh auth status 2>&1 | Out-Null
Write-Success "GitHub CLI is authenticated"
}
catch {
Write-Warning "GitHub CLI is not authenticated"
Write-Host "Please authenticate now..."
gh auth login
}
# Ask user which SDKs to set up
Write-Header "SDK Selection"
Write-Host "Which SDKs would you like to set up? (You can select multiple)"
Write-Host ""
$setup_nodejs = Read-Host "Set up Node.js/TypeScript SDK? (y/n)"
$setup_python = Read-Host "Set up Python SDK? (y/n)"
$setup_go = Read-Host "Set up Go SDK? (y/n)"
$setup_dotnet = Read-Host "Set up .NET SDK? (y/n)"
# Node.js Setup
if ($setup_nodejs -match "^[Yy]$") {
Write-Header "Setting up Node.js/TypeScript SDK"
if (Test-Command "node") {
$nodeVersion = node -v
Write-Success "Node.js is installed: $nodeVersion"
}
else {
Write-Warning "Node.js not found. Installing..."
winget install --id OpenJS.NodeJS
Write-Success "Node.js installed. You may need to restart your terminal."
}
if (Test-Command "npm") {
$npmVersion = npm -v
Write-Success "npm is installed: $npmVersion"
}
else {
Write-Error "npm not found (should come with Node.js)"
}
}
# Python Setup
if ($setup_python -match "^[Yy]$") {
Write-Header "Setting up Python SDK"
if (Test-Command "python") {
$pythonVersion = python --version
Write-Success "Python is installed: $pythonVersion"
}
else {
Write-Warning "Python not found. Installing..."
winget install --id Python.Python.3.12
Write-Success "Python installed. You may need to restart your terminal."
}
if (Test-Command "pip") {
$pipVersion = pip --version
Write-Success "pip is installed: $pipVersion"
}
else {
Write-Error "pip not found (should come with Python)"
}
}
# Go Setup
if ($setup_go -match "^[Yy]$") {
Write-Header "Setting up Go SDK"
if (Test-Command "go") {
$goVersion = go version
Write-Success "Go is installed: $goVersion"
}
else {
Write-Warning "Go not found. Installing..."
winget install --id GoLang.Go
Write-Success "Go installed. You may need to restart your terminal."
}
}
# .NET Setup
if ($setup_dotnet -match "^[Yy]$") {
Write-Header "Setting up .NET SDK"
if (Test-Command "dotnet") {
$dotnetVersion = dotnet --version
Write-Success ".NET is installed: $dotnetVersion"
}
else {
Write-Warning ".NET not found. Installing..."
winget install --id Microsoft.DotNet.SDK.8
Write-Success ".NET installed. You may need to restart your terminal."
}
}
# Additional tools
Write-Header "Checking Additional Development Tools"
if (Test-Command "git") {
$gitVersion = git --version
Write-Success "Git is installed: $gitVersion"
}
else {
Write-Warning "Git not found. Installing..."
winget install --id Git.Git
}
if (Test-Command "code") {
Write-Success "VS Code is installed"
}
else {
Write-Warning "VS Code not found. Recommended for development."
$installVscode = Read-Host "Install VS Code? (y/n)"
if ($installVscode -match "^[Yy]$") {
winget install --id Microsoft.VisualStudioCode
}
}
# Summary
Write-Header "Setup Summary"
Write-Host "Your development environment has been checked and configured!"
Write-Host ""
Write-Host "Next steps:"
Write-Host "1. Restart your terminal to ensure all PATH changes take effect"
Write-Host "2. Create a new project directory"
Write-Host "3. Install the SDK for your chosen language"
Write-Host "4. Follow the Getting Started guide: docs\getting-started.md"
Write-Host ""
Write-Host "Quick start examples:"
if ($setup_nodejs -match "^[Yy]$") {
Write-Host ""
Write-Host "Node.js/TypeScript:"
Write-Host " mkdir my-app; cd my-app"
Write-Host " npm init -y"
Write-Host " npm install @github/copilot-sdk tsx"
}
if ($setup_python -match "^[Yy]$") {
Write-Host ""
Write-Host "Python:"
Write-Host " mkdir my-app; cd my-app"
Write-Host " python -m venv venv"
Write-Host " .\venv\Scripts\Activate.ps1"
Write-Host " pip install github-copilot-sdk"
}
if ($setup_go -match "^[Yy]$") {
Write-Host ""
Write-Host "Go:"
Write-Host " mkdir my-app; cd my-app"
Write-Host " go mod init my-app"
Write-Host " go get github.com/github/copilot-sdk/go"
}
if ($setup_dotnet -match "^[Yy]$") {
Write-Host ""
Write-Host ".NET:"
Write-Host " dotnet new console -n MyApp"
Write-Host " cd MyApp"
Write-Host " dotnet add package GitHub.Copilot.SDK"
}
Write-Host ""
Write-Success "Setup complete! Happy coding! 🚀"
Write-Host ""
Write-Host "Note: You may need to restart your terminal for PATH changes to take effect."