-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
280 lines (246 loc) · 8.58 KB
/
install.ps1
File metadata and controls
280 lines (246 loc) · 8.58 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
# CodeFlow Engine - Windows Installation Script
# Usage: irm https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/install.ps1 | iex
# Or: .\engine\install.ps1 [-Full] [-Dev] [-Minimal] [-Docker]
[CmdletBinding()]
param(
[switch]$Full,
[switch]$Dev,
[switch]$Minimal,
[switch]$Docker,
[switch]$Action,
[switch]$Version,
[switch]$Help
)
$ErrorActionPreference = "Stop"
$ScriptVersion = "1.0.0"
# Colors
function Write-Status { param($Message) Write-Host "[*] $Message" -ForegroundColor Blue }
function Write-Success { param($Message) Write-Host "[+] $Message" -ForegroundColor Green }
function Write-Warning { param($Message) Write-Host "[!] $Message" -ForegroundColor Yellow }
function Write-Error { param($Message) Write-Host "[-] $Message" -ForegroundColor Red }
# Banner
function Show-Banner {
Write-Host ""
Write-Host " ___ _ ____ ____ _____ _ " -ForegroundColor Cyan
Write-Host " / _ \ | | | _ \| _ \ | ____|_ __ __ _(_)_ __ ___ " -ForegroundColor Cyan
Write-Host "| |_| |_ _| |_ ___ | |_) | |_) | | _| | '_ \ / _`` | | '_ \ / _ \" -ForegroundColor Cyan
Write-Host "| _ | | | | __/ _ \| __/| _ < | |___| | | | (_| | | | | | __/" -ForegroundColor Cyan
Write-Host "|_| |_|\__,_|\__\___/|_| |_| \_\ |_____|_| |_|\__, |_|_| |_|\___|" -ForegroundColor Cyan
Write-Host " |___/ " -ForegroundColor Cyan
Write-Host ""
Write-Host "AI-Powered GitHub PR Automation and Issue Management" -ForegroundColor White
Write-Host ""
}
# Help
function Show-Help {
Write-Host "Usage: .\install.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Minimal Install core package only (no extras)"
Write-Host " -Full Install with all features and integrations"
Write-Host " -Dev Install for development (includes dev tools)"
Write-Host " -Docker Set up Docker-based installation"
Write-Host " -Action Set up GitHub Action workflow in current repo"
Write-Host " -Version Show installer version"
Write-Host " -Help Show this help message"
Write-Host ""
}
# Check Python
function Test-Python {
Write-Status "Checking Python installation..."
try {
$pythonVersion = python --version 2>&1
if ($pythonVersion -match "Python (\d+)\.(\d+)") {
$major = [int]$Matches[1]
$minor = [int]$Matches[2]
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 12)) {
Write-Success "Python $major.$minor detected"
return $true
}
else {
Write-Error "Python 3.12+ required (found $major.$minor)"
Write-Host "Install Python from: https://www.python.org/downloads/" -ForegroundColor Yellow
return $false
}
}
}
catch {
Write-Error "Python not found. Please install Python 3.12+"
Write-Host "Install Python from: https://www.python.org/downloads/" -ForegroundColor Yellow
return $false
}
return $false
}
# Check pip
function Test-Pip {
try {
$null = pip --version
Write-Success "pip detected"
return $true
}
catch {
Write-Error "pip not found"
return $false
}
}
# Check Docker
function Test-Docker {
try {
$null = docker --version
Write-Success "Docker detected"
return $true
}
catch {
Write-Error "Docker not found. Please install Docker Desktop"
Write-Host "Install from: https://www.docker.com/products/docker-desktop/" -ForegroundColor Yellow
return $false
}
}
# Install via pip
function Install-CodeFlow {
param([string]$Type)
Write-Status "Installing CodeFlow Engine via pip..."
# Recommend virtual environment
if (-not $env:VIRTUAL_ENV -and $Type -ne "Minimal") {
Write-Warning "Consider using a virtual environment: python -m venv venv && .\venv\Scripts\Activate.ps1"
}
switch ($Type) {
"Minimal" {
Write-Status "Installing minimal package (core only)..."
pip install --no-deps codeflow-engine
}
"Full" {
Write-Status "Installing full package with all features..."
pip install "codeflow-engine[full]"
}
"Dev" {
Write-Status "Installing development package..."
if (Test-Path "pyproject.toml") {
pip install -e ".[dev]"
}
else {
Write-Status "Cloning repository..."
git clone https://github.com/JustAGhosT/codeflow-engine.git
Set-Location codeflow-engine\engine
pip install -e ".[dev]"
}
}
default {
Write-Status "Installing standard package..."
pip install codeflow-engine
}
}
if ($LASTEXITCODE -eq 0) {
Write-Success "CodeFlow Engine installed successfully!"
}
else {
Write-Error "Installation failed"
exit 1
}
}
# Install via Docker
function Install-Docker {
Write-Status "Setting up Docker installation..."
if (-not (Test-Path "docker-compose.yml")) {
Write-Status "Creating CodeFlow directory..."
New-Item -ItemType Directory -Force -Path "codeflow-engine" | Out-Null
Set-Location "codeflow-engine"
Write-Status "Downloading Docker Compose configuration..."
try {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/docker-compose.yml" -OutFile "docker-compose.yml"
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/configs/.env.example" -OutFile ".env.example"
}
catch {
Write-Error "Failed to download configuration files"
exit 1
}
}
if (-not (Test-Path ".env")) {
Write-Status "Creating .env file from template..."
Copy-Item ".env.example" ".env"
Write-Warning "Please edit .env file with your API keys before starting"
}
Write-Success "Docker setup complete!"
Write-Host ""
Write-Status "To start CodeFlow Engine:"
Write-Host " 1. Edit .env with your API keys"
Write-Host " 2. Run: docker compose up -d"
}
# Setup GitHub Action
function Install-GitHubAction {
Write-Status "Setting up GitHub Action workflow..."
$workflowDir = ".github\workflows"
$workflowFile = "$workflowDir\codeflow.yml"
if (-not (Test-Path $workflowDir)) {
New-Item -ItemType Directory -Force -Path $workflowDir | Out-Null
}
try {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/templates/quick-start/codeflow-workflow.yml" -OutFile $workflowFile
Write-Success "Created $workflowFile"
Write-Warning "Remember to add OPENAI_API_KEY to your repository secrets!"
}
catch {
Write-Error "Failed to download workflow file"
exit 1
}
}
# Show next steps
function Show-NextSteps {
Write-Host ""
Write-Host "==========================================" -ForegroundColor Green
Write-Success "Installation Complete!"
Write-Host "==========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:"
Write-Host ""
Write-Host " 1. Set up your API keys:"
Write-Host ' $env:GITHUB_TOKEN = "ghp_your_token"'
Write-Host ' $env:OPENAI_API_KEY = "sk-your_key"'
Write-Host ""
Write-Host " 2. Run CodeFlow CLI:"
Write-Host " CodeFlow --help"
Write-Host ""
Write-Host " 3. Add to your GitHub repo:"
Write-Host " .\install.ps1 -Action"
Write-Host ""
Write-Host "Documentation: https://github.com/JustAGhosT/codeflow-engine"
Write-Host ""
}
# Main
function Main {
Show-Banner
if ($Version) {
Write-Host "CodeFlow Engine Installer v$ScriptVersion"
exit 0
}
if ($Help) {
Show-Help
exit 0
}
if ($Action) {
Install-GitHubAction
exit 0
}
if ($Docker) {
if (-not (Test-Docker)) { exit 1 }
Install-Docker
exit 0
}
# Standard installation
if (-not (Test-Python)) { exit 1 }
if (-not (Test-Pip)) { exit 1 }
if ($Minimal) {
Install-CodeFlow -Type "Minimal"
}
elseif ($Full) {
Install-CodeFlow -Type "Full"
}
elseif ($Dev) {
Install-CodeFlow -Type "Dev"
}
else {
Install-CodeFlow -Type "Standard"
}
Show-NextSteps
}
Main