-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
executable file
·373 lines (328 loc) · 14.7 KB
/
Copy pathinstall.ps1
File metadata and controls
executable file
·373 lines (328 loc) · 14.7 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
# VibeCoding Installer for Windows
# Downloads and installs the latest release from GitHub
#
# Repository: https://github.com/startvibecoding/vibecoding
# Gitee: https://gitee.com/startvibecoding/vibecoding
# Author: zhenruyan
# Blog: https://pkold.com
#
# Usage:
# # Install (default)
# irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex
#
# # Install to custom directory
# $env:VIBECODING_INSTALL_DIR="C:\Tools\vibecoding"; irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex
#
# # Uninstall
# irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex; Uninstall-VibeCoding
$ErrorActionPreference = "Stop"
$REPO = "startvibecoding/vibecoding"
$BINARY_NAME = "vibecoding.exe"
$DEFAULT_INSTALL_DIR = "$env:LOCALAPPDATA\vibecoding"
# Colors
function Write-Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
function Write-Success { Write-Host "[SUCCESS] $args" -ForegroundColor Green }
function Write-Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
function Write-Error-Custom { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 }
# Show help
function Show-Help {
Write-Host ""
Write-Host "╔═══════════════════════════════════════════════════════════════╗" -ForegroundColor DarkCyan
Write-Host "║ VibeCoding Installer ║" -ForegroundColor DarkCyan
Write-Host "║ https://github.com/startvibecoding/vibecoding ║" -ForegroundColor DarkCyan
Write-Host "║ Author: zhenruyan | pkold.com ║" -ForegroundColor DarkCyan
Write-Host "╚═══════════════════════════════════════════════════════════════╝" -ForegroundColor DarkCyan
Write-Host ""
Write-Host "Usage: install.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Help Show this help message"
Write-Host " -Uninstall Uninstall VibeCoding"
Write-Host ""
Write-Host "Environment variables:"
Write-Host " VIBECODING_INSTALL_DIR Install directory (default: $env:LOCALAPPDATA\vibecoding)"
Write-Host ""
Write-Host "Examples:"
Write-Host " # Install"
Write-Host " irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex"
Write-Host ""
Write-Host " # Install to custom directory"
Write-Host " `$env:VIBECODING_INSTALL_DIR=`"C:\Tools\vibecoding`"; irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex"
Write-Host ""
Write-Host " # Uninstall"
Write-Host " irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex; Uninstall-VibeCoding"
Write-Host ""
}
# Uninstall VibeCoding
function Uninstall-VibeCoding {
Write-Host ""
Write-Host "╔═══════════════════════════════════════════════════════════════╗" -ForegroundColor DarkCyan
Write-Host "║ VibeCoding Uninstaller ║" -ForegroundColor DarkCyan
Write-Host "╚═══════════════════════════════════════════════════════════════╝" -ForegroundColor DarkCyan
Write-Host ""
$foundPaths = @()
# Check common install locations
$checkDirs = @(
"$env:LOCALAPPDATA\vibecoding",
"$env:USERPROFILE\.vibecoding\bin",
"$env:ProgramFiles\vibecoding"
)
foreach ($dir in $checkDirs) {
$binPath = Join-Path $dir $BINARY_NAME
if (Test-Path $binPath) {
$foundPaths += $binPath
}
}
# Also check PATH
$vibecodingInPath = Get-Command vibecoding -ErrorAction SilentlyContinue
if ($vibecodingInPath) {
$whichPath = $vibecodingInPath.Source
if ($foundPaths -notcontains $whichPath) {
$foundPaths += $whichPath
}
}
if ($foundPaths.Count -eq 0) {
Write-Warn "VibeCoding not found in common locations"
Write-Host ""
Write-Host "Checked locations:"
foreach ($dir in $checkDirs) {
Write-Host " - $dir\$BINARY_NAME"
}
Write-Host ""
Write-Host "If installed elsewhere, remove it manually"
Write-Host ""
return
}
# Show found installations
Write-Info "Found VibeCoding installations:"
Write-Host ""
foreach ($p in $foundPaths) {
Write-Host " - $p"
}
Write-Host ""
# Ask for confirmation
$answer = Read-Host "Remove all installations? [y/N]"
if ($answer -ne 'y' -and $answer -ne 'Y') {
Write-Info "Uninstall cancelled"
return
}
# Remove binaries
Write-Host ""
foreach ($p in $foundPaths) {
if (Test-Path $p) {
try {
Remove-Item -Path $p -Force
Write-Success "Removed: $p"
} catch {
Write-Warn "Failed to remove: $p - $_"
}
}
}
# Ask about config directory
Write-Host ""
$configDir = Join-Path $env:APPDATA "vibecoding"
if (Test-Path $configDir) {
Write-Info "Config directory: $configDir"
Write-Host ""
$answer = Read-Host "Remove config directory ($configDir)? [y/N]"
if ($answer -eq 'y' -or $answer -eq 'Y') {
try {
Remove-Item -Path $configDir -Recurse -Force
Write-Success "Removed: $configDir"
} catch {
Write-Warn "Failed to remove: $configDir - $_"
}
} else {
Write-Info "Kept: $configDir"
}
}
# Clean PATH entries
Write-Host ""
Write-Info "Checking PATH for VibeCoding entries..."
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$pathEntries = if ($currentPath) { $currentPath -split ';' | Where-Object { $_ -ne '' } } else { @() }
$vibecodingEntries = $pathEntries | Where-Object { $_ -like '*vibecoding*' }
if ($vibecodingEntries.Count -gt 0) {
Write-Info "Found VibeCoding PATH entries:"
foreach ($entry in $vibecodingEntries) {
Write-Host " - $entry"
}
Write-Host ""
$answer = Read-Host "Remove VibeCoding from PATH? [y/N]"
if ($answer -eq 'y' -or $answer -eq 'Y') {
$newEntries = $pathEntries | Where-Object { $_ -notlike '*vibecoding*' }
$newPath = $newEntries -join ';'
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
$env:Path = [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + $newPath
Write-Success "Removed VibeCoding from PATH"
}
} else {
Write-Info "No VibeCoding PATH entries found"
}
# Uninstall npm package if installed via npm
Write-Host ""
$npmCommand = Get-Command npm -ErrorAction SilentlyContinue
if ($npmCommand) {
$npmGlobalRoot = & npm root -g 2>$null
$npmInstallerPath = Join-Path $npmGlobalRoot "vibecoding-installer"
if (Test-Path $npmInstallerPath) {
Write-Info "Found npm global installation"
$answer = Read-Host "Uninstall npm package (vibecoding-installer)? [y/N]"
if ($answer -eq 'y' -or $answer -eq 'Y') {
try {
& npm uninstall -g vibecoding-installer
Write-Success "Uninstalled npm package"
} catch {
Write-Warn "Failed to uninstall npm package: $_"
}
}
}
}
Write-Host ""
Write-Success "Uninstall complete!"
Write-Host ""
Write-Host " Thank you for using VibeCoding! 🙏" -ForegroundColor White
Write-Host ""
Write-Host " If you have any feedback, please visit:" -ForegroundColor White
Write-Host " - GitHub: https://github.com/startvibecoding/vibecoding" -ForegroundColor Cyan
Write-Host " - Gitee: https://gitee.com/startvibecoding/vibecoding" -ForegroundColor Cyan
Write-Host ""
}
# Parse arguments
param(
[switch]$Help,
[switch]$Uninstall
)
if ($Help) {
Show-Help
exit 0
}
if ($Uninstall) {
Uninstall-VibeCoding
exit 0
}
# Banner
Write-Host ""
Write-Host "╔═══════════════════════════════════════════════════════════════╗" -ForegroundColor DarkCyan
Write-Host "║ VibeCoding Installer ║" -ForegroundColor DarkCyan
Write-Host "║ https://github.com/startvibecoding/vibecoding ║" -ForegroundColor DarkCyan
Write-Host "║ Author: zhenruyan | pkold.com ║" -ForegroundColor DarkCyan
Write-Host "╚═══════════════════════════════════════════════════════════════╝" -ForegroundColor DarkCyan
Write-Host ""
# Detect architecture
$arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { Write-Error-Custom "32-bit systems are not supported" }
Write-Info "Detected architecture: windows/$arch"
# Get install directory
$installDir = if ($env:VIBECODING_INSTALL_DIR) { $env:VIBECODING_INSTALL_DIR } else { $DEFAULT_INSTALL_DIR }
Write-Info "Install directory: $installDir"
# Get latest version from GitHub
Write-Info "Fetching latest version..."
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$REPO/releases/latest" -Headers @{
"Accept" = "application/vnd.github.v3+json"
}
$version = $release.tag_name
Write-Info "Latest version: $version"
} catch {
Write-Error-Custom "Failed to fetch latest version: $_"
}
# Find download URL
$versionNum = $release.tag_name -replace '^v', ''
$archiveName = "vibecoding-${versionNum}-windows-$arch.zip"
$asset = $release.assets | Where-Object { $_.name -eq $archiveName }
if (-not $asset) {
Write-Error-Custom "Release asset not found: $archiveName"
}
$downloadUrl = $asset.browser_download_url
Write-Info "Download URL: $downloadUrl"
# Create temp directory
$tempDir = Join-Path $env:TEMP "vibecoding-install-$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try {
# Download archive
$archivePath = Join-Path $tempDir $archiveName
Write-Info "Downloading $archiveName..."
$progressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath -UseBasicParsing
$progressPreference = 'Continue'
Write-Success "Download complete"
# Extract archive
Write-Info "Extracting archive..."
$extractPath = Join-Path $tempDir "extract"
Expand-Archive -Path $archivePath -DestinationPath $extractPath -Force
# Find binary
$binaryPath = Get-ChildItem -Path $extractPath -Filter $BINARY_NAME -Recurse | Select-Object -First 1
if (-not $binaryPath) {
Write-Error-Custom "Binary not found in archive"
}
# Create install directory
if (-not (Test-Path $installDir)) {
Write-Info "Creating install directory: $installDir"
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
}
# Install binary
$destPath = Join-Path $installDir $BINARY_NAME
Write-Info "Installing to $destPath..."
Copy-Item -Path $binaryPath.FullName -Destination $destPath -Force
Write-Success "Installed $BINARY_NAME to $installDir"
# Add to PATH if not already present
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
# Use exact matching by splitting PATH into entries
$pathEntries = if ($currentPath) { $currentPath -split ';' | Where-Object { $_ -ne '' } } else { @() }
if ($pathEntries -notcontains $installDir) {
Write-Info "Adding $installDir to PATH..."
# Safely join without leading/trailing semicolons
$newPath = if ($currentPath) { "$currentPath;$installDir" } else { $installDir }
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
# Update current session PATH so user can use it immediately
$env:Path = [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [Environment]::GetEnvironmentVariable("Path", "User")
Write-Success "Added to PATH (restart other terminals to take effect)"
} else {
Write-Info "$installDir is already in PATH"
}
# Show config directory info
$configDir = Join-Path $env:APPDATA "vibecoding"
$settingsPath = Join-Path $configDir "settings.json"
Write-Host ""
Write-Success "Installation complete!"
Write-Host ""
Write-Host " Install directory: $destPath" -ForegroundColor White
Write-Host " Config directory : $configDir" -ForegroundColor White
Write-Host " - Settings file: $settingsPath" -ForegroundColor Gray
Write-Host ""
Write-Host " Version: $version" -ForegroundColor White
Write-Host ""
# Check if vibecoding is available
$vibecodingPath = Get-Command vibecoding -ErrorAction SilentlyContinue
if ($vibecodingPath) {
Write-Host " Get started:" -ForegroundColor White
Write-Host " vibecoding --help" -ForegroundColor Gray
Write-Host ""
Write-Host " Uninstall:" -ForegroundColor White
Write-Host " irm https://gitee.com/startvibecoding/vibecoding/raw/main/install.ps1 | iex; Uninstall-VibeCoding" -ForegroundColor Gray
Write-Host ""
} else {
Write-Warn "'vibecoding' is not found in your current PATH."
Write-Host ""
Write-Host " To add it to your PATH manually:" -ForegroundColor White
Write-Host ""
Write-Host " # PowerShell (current session):" -ForegroundColor Cyan
Write-Host " `$env:Path += `";$installDir`"" -ForegroundColor Cyan
Write-Host ""
Write-Host " # PowerShell (permanent, current user):" -ForegroundColor Cyan
Write-Host " [Environment]::SetEnvironmentVariable('Path', `$env:Path + ';$installDir', 'User')" -ForegroundColor Cyan
Write-Host ""
Write-Host " # CMD (permanent, current user):" -ForegroundColor Cyan
Write-Host " setx Path `"%Path%;$installDir`"" -ForegroundColor Cyan
Write-Host ""
Write-Host " # Or add via System Settings > Environment Variables > User PATH" -ForegroundColor Cyan
Write-Host ""
}
} catch {
Write-Error-Custom "Installation failed: $_"
} finally {
# Cleanup
if (Test-Path $tempDir) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}
}