-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-dev-env.sh
More file actions
executable file
Β·462 lines (382 loc) Β· 12 KB
/
setup-dev-env.sh
File metadata and controls
executable file
Β·462 lines (382 loc) Β· 12 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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
#!/bin/bash
# Development environment setup for GitHub tools integration
set -e
echo "π οΈ Setting up development environment for GitHub tools integration..."
# Check for required tools
echo "π Checking for required tools..."
# Check GitHub CLI
if ! command -v gh &> /dev/null; then
echo "β GitHub CLI not found. Installing..."
# Detect OS and install GitHub CLI
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/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 gh -y
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install gh
else
echo "β Please install Homebrew first: https://brew.sh/"
exit 1
fi
else
echo "β Unsupported OS. Please install GitHub CLI manually: https://cli.github.com/"
exit 1
fi
else
echo "β
GitHub CLI found: $(gh --version | head -1)"
fi
# Check for uvx (Python package runner)
if ! command -v uvx &> /dev/null; then
echo "π¦ Installing uvx..."
pip install uvx
else
echo "β
uvx found: $(uvx --version)"
fi
# Check for Node.js (required for some tools)
if ! command -v node &> /dev/null; then
echo "β Node.js not found. Please install Node.js: https://nodejs.org/"
exit 1
else
echo "β
Node.js found: $(node --version)"
fi
# Check for VS Code (optional but recommended)
if command -v code &> /dev/null; then
echo "β
VS Code found: $(code --version | head -1)"
# Install recommended VS Code extensions
echo "π§ Installing recommended VS Code extensions..."
# GitHub extensions
code --install-extension GitHub.copilot || echo "β οΈ GitHub Copilot extension already installed or failed"
code --install-extension GitHub.copilot-chat || echo "β οΈ GitHub Copilot Chat extension already installed or failed"
code --install-extension GitHub.vscode-pull-request-github || echo "β οΈ GitHub Pull Requests extension already installed or failed"
# Python extensions
code --install-extension ms-python.python || echo "β οΈ Python extension already installed or failed"
code --install-extension ms-python.black-formatter || echo "β οΈ Black formatter extension already installed or failed"
code --install-extension ms-python.ruff || echo "β οΈ Ruff extension already installed or failed"
# Rust extensions
code --install-extension rust-lang.rust-analyzer || echo "β οΈ Rust Analyzer extension already installed or failed"
# Elixir extensions
code --install-extension PhoenixFramework.phoenix || echo "β οΈ Phoenix extension already installed or failed"
code --install-extension elixir-lsp.elixir-lsp || echo "β οΈ Elixir LSP extension already installed or failed"
# Docker extensions
code --install-extension ms-azuretools.vscode-docker || echo "β οΈ Docker extension already installed or failed"
else
echo "β οΈ VS Code not found. Recommended for optimal development experience."
echo "π‘ Install VS Code: https://code.visualstudio.com/"
fi
# Install GitHub CLI extensions
echo "π§ Installing GitHub CLI extensions..."
# Install Copilot CLI extension
echo "π€ Installing GitHub Copilot CLI extension..."
gh extension install github/gh-copilot || echo "β οΈ GitHub Copilot CLI extension already installed or failed"
# Install Spec Kit extension
echo "π Installing GitHub Spec Kit extension..."
gh extension install github/spec-kit || echo "β οΈ GitHub Spec Kit extension already installed or failed"
# Authenticate with GitHub CLI if not already authenticated
if ! gh auth status &> /dev/null; then
echo "π Please authenticate with GitHub CLI:"
gh auth login
else
echo "β
GitHub CLI authenticated"
fi
# Set up development workspace
echo "π Setting up development workspace..."
# Create development directories
mkdir -p workspace/{projects,specs,docs,scripts}
mkdir -p .github/{workflows,templates,ISSUE_TEMPLATE}
# Create development configuration files
echo "βοΈ Creating development configuration files..."
# VS Code workspace settings
cat > .vscode/settings.json << 'EOF'
{
"python.defaultInterpreterPath": "./.venv/bin/python",
"python.formatting.provider": "black",
"python.linting.enabled": true,
"python.linting.ruffEnabled": true,
"python.linting.mypyEnabled": true,
"rust-analyzer.checkOnSave.command": "clippy",
"elixirLS.path": "/path/to/elixir-ls/language_server.sh",
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/_build": true,
"**/deps": true,
"**/node_modules": true,
"**/target": true
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
EOF
# VS Code launch configurations
cat > .vscode/launch.json << 'EOF'
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: GitHub Tools API",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/api/python/github_api.py",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}/api/python"
}
},
{
"name": "Elixir: Phoenix Server",
"type": "mix_task",
"request": "launch",
"task": "phx.server",
"projectDir": "${workspaceFolder}/api/elixir"
}
]
}
EOF
# VS Code tasks
cat > .vscode/tasks.json << 'EOF'
{
"version": "2.0.0",
"tasks": [
{
"label": "Build All Components",
"type": "shell",
"command": "./build-all.sh",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
},
{
"label": "Start GitHub Tools API",
"type": "shell",
"command": "python",
"args": ["api/python/github_api.py"],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated"
}
},
{
"label": "Test GitHub Tools",
"type": "shell",
"command": "gh",
"args": ["copilot", "--help"],
"group": "test"
}
]
}
EOF
# Create development scripts
echo "π Creating development scripts..."
# Quick test script
cat > scripts/test-github-tools.sh << 'EOF'
#!/bin/bash
# Test GitHub tools integration
echo "π§ͺ Testing GitHub tools integration..."
# Test GitHub CLI
echo "π Testing GitHub CLI..."
gh --version
# Test Copilot CLI
echo "π€ Testing GitHub Copilot CLI..."
gh copilot --help || echo "β GitHub Copilot CLI not available"
# Test Spec Kit
echo "π Testing GitHub Spec Kit..."
gh spec --help || echo "β GitHub Spec Kit not available"
# Test Python environment
echo "π Testing Python environment..."
python --version
pip list | grep -E "(fastapi|uvicorn|pydantic)"
echo "β
Testing complete!"
EOF
chmod +x scripts/test-github-tools.sh
# Project creation script
cat > scripts/create-project.sh << 'EOF'
#!/bin/bash
# Create a new project with GitHub tools integration
set -e
if [ $# -eq 0 ]; then
echo "Usage: $0 <project-name> [project-type]"
echo "Example: $0 my-webapp webapp"
exit 1
fi
PROJECT_NAME=$1
PROJECT_TYPE=${2:-"webapp"}
echo "π Creating new project: $PROJECT_NAME (type: $PROJECT_TYPE)"
# Create project directory
mkdir -p "workspace/projects/$PROJECT_NAME"
cd "workspace/projects/$PROJECT_NAME"
# Generate specification using GitHub Spec Kit
echo "π Generating project specification..."
gh spec generate --type "$PROJECT_TYPE" "Create a $PROJECT_TYPE called $PROJECT_NAME" > spec.json
# Initialize git repository
echo "π§ Initializing git repository..."
git init
# Create basic project structure
echo "π Creating project structure..."
mkdir -p {src,tests,docs,scripts}
# Create README
cat > README.md << PROJECT_EOF
# $PROJECT_NAME
$PROJECT_TYPE project created with GitHub tools integration.
## Specification
Generated specification is available in \`spec.json\`.
## Development
This project is set up with GitHub tools integration:
- GitHub Copilot CLI for AI assistance
- GitHub Spec Kit for specification management
- Goose IDE for enhanced development experience
## Getting Started
1. Install dependencies
2. Run development server
3. Start building!
## Resources
- [GitHub Copilot CLI Documentation](https://cli.github.com/manual/gh_copilot)
- [GitHub Spec Kit Documentation](https://github.com/github/spec-kit)
- [Goose IDE Documentation](https://goose-ide.com)
PROJECT_EOF
echo "β
Project created successfully!"
echo "π Project location: $(pwd)"
echo "π― Next steps:"
echo " 1. Review the specification in spec.json"
echo " 2. Customize the project structure"
echo " 3. Start development with GitHub tools!"
EOF
chmod +x scripts/create-project.sh
# Create Git configuration
echo "π§ Creating Git configuration..."
cat > .gitignore << 'EOF'
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# Virtual environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Rust
target/
Cargo.lock
# Elixir
_build/
deps/
*.beam
*.dump
# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# API Keys and secrets
.env.local
.env.development.local
.env.test.local
.env.production.local
*.key
*.pem
EOF
# GitHub workflows
echo "π Creating GitHub workflows..."
cat > .github/workflows/github-tools.yml << 'EOF'
name: GitHub Tools Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test-github-tools:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install fastapi uvicorn pydantic
pip install PyGithub gitpython
- name: Set up GitHub CLI
uses: github/setup-gh-cli@v2
- name: Install GitHub CLI extensions
run: |
gh extension install github/gh-copilot
gh extension install github/spec-kit
- name: Test GitHub tools integration
run: |
./scripts/test-github-tools.sh
- name: Build project
run: |
./build-all.sh
deploy:
needs: test-github-tools
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
EOF
echo "β
Development environment setup complete!"
echo ""
echo "π― Next steps:"
echo " 1. Run './scripts/test-github-tools.sh' to verify installation"
echo " 2. Create a new project with './scripts/create-project.sh my-project'"
echo " 3. Start development with 'code .' to open VS Code"
echo " 4. Run 'vercel dev' to start local development server"
echo ""
echo "π Useful commands:"
echo " - gh copilot --help # GitHub Copilot CLI"
echo " - gh spec --help # GitHub Spec Kit"
echo " - ./build-all.sh # Build all components"
echo " - vercel dev # Start development server"