Skip to content

Commit 4e8592f

Browse files
committed
feat: add powershell installer and simplify installation methods
1 parent 64551b5 commit 4e8592f

File tree

2 files changed

+178
-21
lines changed

2 files changed

+178
-21
lines changed

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,20 @@ The official command-line interface for [Vapi](https://vapi.ai) - Voice AI for d
2323

2424
## Installation
2525

26-
### Universal Install Script (Recommended)
26+
### Unix/Linux/macOS
2727

2828
```bash
2929
curl -sSL https://vapi.ai/install.sh | bash
3030
```
3131

32-
This script automatically detects your platform and installs the latest version.
33-
34-
### Package Managers
35-
36-
#### npm (Cross-platform)
37-
38-
```bash
39-
npm install -g @vapi-ai/cli
40-
```
41-
42-
#### Homebrew (macOS/Linux)
43-
44-
```bash
45-
brew tap VapiAI/homebrew-tap
46-
brew install vapi-cli
47-
```
48-
49-
#### Scoop (Windows)
32+
### Windows
5033

5134
```powershell
52-
scoop bucket add vapi https://github.com/VapiAI/scoop-bucket
53-
scoop install vapi-cli
35+
iex ((New-Object System.Net.WebClient).DownloadString('https://vapi.ai/install.ps1'))
5436
```
5537

38+
Both scripts automatically detect your platform and install the latest version.
39+
5640
### Docker
5741

5842
```bash

scripts/install.ps1

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Vapi CLI installation script for Windows
2+
# Usage: iex ((New-Object System.Net.WebClient).DownloadString('https://vapi.ai/install.ps1'))
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
# Configuration
7+
$Repo = "VapiAI/cli"
8+
$BinaryName = "vapi.exe"
9+
$InstallDir = "$env:LOCALAPPDATA\Programs\Vapi"
10+
11+
# Helper functions
12+
function Write-Info($Message) {
13+
Write-Host "[INFO] $Message" -ForegroundColor Green
14+
}
15+
16+
function Write-Error($Message) {
17+
Write-Host "[ERROR] $Message" -ForegroundColor Red
18+
exit 1
19+
}
20+
21+
function Write-Warning($Message) {
22+
Write-Host "[WARN] $Message" -ForegroundColor Yellow
23+
}
24+
25+
# Detect architecture
26+
function Get-Platform {
27+
$arch = $env:PROCESSOR_ARCHITECTURE
28+
29+
switch ($arch) {
30+
"AMD64" { return "Windows_x86_64" }
31+
"ARM64" { return "Windows_arm64" }
32+
default { Write-Error "Unsupported architecture: $arch" }
33+
}
34+
}
35+
36+
# Get latest release version
37+
function Get-LatestVersion {
38+
Write-Info "Fetching latest version..."
39+
40+
try {
41+
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
42+
$version = $response.tag_name
43+
44+
if (-not $version) {
45+
Write-Error "Failed to fetch latest version"
46+
}
47+
48+
Write-Info "Latest version: $version"
49+
return $version
50+
}
51+
catch {
52+
Write-Error "Failed to fetch latest version: $_"
53+
}
54+
}
55+
56+
# Download and install
57+
function Install-Vapi($Version, $Platform) {
58+
$url = "https://github.com/$Repo/releases/download/$Version/vapi_$Platform.tar.gz"
59+
$tempDir = [System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()
60+
$tarFile = "$tempDir\vapi.tar.gz"
61+
62+
Write-Info "Downloading Vapi CLI..."
63+
Write-Info "URL: $url"
64+
65+
# Create temp directory
66+
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
67+
68+
try {
69+
# Download the file
70+
Invoke-WebRequest -Uri $url -OutFile $tarFile
71+
72+
Write-Info "Extracting..."
73+
74+
# Extract tar.gz (requires tar.exe available in Windows 10+)
75+
if (Get-Command tar -ErrorAction SilentlyContinue) {
76+
tar -xzf $tarFile -C $tempDir
77+
} else {
78+
Write-Error "tar command not found. Please update to Windows 10 version 1803 or later."
79+
}
80+
81+
# Create install directory
82+
if (-not (Test-Path $InstallDir)) {
83+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
84+
}
85+
86+
# Move binary to install directory
87+
$binaryPath = "$tempDir\vapi.exe"
88+
if (-not (Test-Path $binaryPath)) {
89+
$binaryPath = "$tempDir\vapi" # Try without .exe extension
90+
}
91+
92+
if (Test-Path $binaryPath) {
93+
Move-Item $binaryPath "$InstallDir\$BinaryName" -Force
94+
} else {
95+
Write-Error "Binary not found after extraction"
96+
}
97+
98+
Write-Info "Vapi CLI installed successfully!"
99+
}
100+
catch {
101+
Write-Error "Installation failed: $_"
102+
}
103+
finally {
104+
# Cleanup
105+
if (Test-Path $tempDir) {
106+
Remove-Item $tempDir -Recurse -Force
107+
}
108+
}
109+
}
110+
111+
# Add to PATH
112+
function Add-ToPath {
113+
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
114+
115+
if ($currentPath -notlike "*$InstallDir*") {
116+
Write-Info "Adding Vapi CLI to PATH..."
117+
$newPath = "$currentPath;$InstallDir"
118+
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
119+
120+
# Update current session PATH
121+
$env:PATH = "$env:PATH;$InstallDir"
122+
123+
Write-Info "Added $InstallDir to your PATH"
124+
} else {
125+
Write-Info "Vapi CLI directory already in PATH"
126+
}
127+
}
128+
129+
# Verify installation
130+
function Test-Installation {
131+
$vapiPath = "$InstallDir\$BinaryName"
132+
133+
if (Test-Path $vapiPath) {
134+
# Test if vapi command works
135+
try {
136+
$version = & $vapiPath --version 2>$null
137+
Write-Info "Verification: $version"
138+
Write-Host ""
139+
Write-Info "Installation complete! 🎉"
140+
Write-Host ""
141+
Write-Host "Get started with:"
142+
Write-Host " vapi login"
143+
Write-Host " vapi --help"
144+
Write-Host ""
145+
Write-Warning "Please restart your terminal or PowerShell session to use 'vapi' command globally."
146+
}
147+
catch {
148+
Write-Warning "Vapi CLI was installed but verification failed"
149+
Write-Warning "You may need to restart your terminal"
150+
}
151+
} else {
152+
Write-Error "Installation verification failed - binary not found"
153+
}
154+
}
155+
156+
# Main installation flow
157+
function Main {
158+
Write-Host "===================================" -ForegroundColor Cyan
159+
Write-Host " Vapi CLI Installer" -ForegroundColor Cyan
160+
Write-Host "===================================" -ForegroundColor Cyan
161+
Write-Host ""
162+
163+
$platform = Get-Platform
164+
Write-Info "Detected platform: $platform"
165+
166+
$version = Get-LatestVersion
167+
Install-Vapi $version $platform
168+
Add-ToPath
169+
Test-Installation
170+
}
171+
172+
# Run main function
173+
Main

0 commit comments

Comments
 (0)