-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
119 lines (95 loc) · 5.05 KB
/
install.ps1
File metadata and controls
119 lines (95 loc) · 5.05 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
# ─────────────────────────────────────────────────────────────
# smolerclaw installer for Windows
# Compiles the binary and installs to user PATH
# Usage: powershell -ExecutionPolicy Bypass -File install.ps1
# ─────────────────────────────────────────────────────────────
$ErrorActionPreference = "Stop"
$ProjectDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$BinName = "smolerclaw.exe"
$InstallDir = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps"
$InstallPath = Join-Path $InstallDir $BinName
Write-Host ""
Write-Host " smolerclaw installer" -ForegroundColor Cyan
Write-Host " ==================" -ForegroundColor Cyan
Write-Host ""
# ── Check bun ────────────────────────────────────────────────
Write-Host "[1/5] Checking bun..." -ForegroundColor Yellow
$bunPath = Get-Command bun -ErrorAction SilentlyContinue
if (-not $bunPath) {
Write-Host " ERROR: bun is not installed." -ForegroundColor Red
Write-Host " Install it: powershell -c 'irm bun.sh/install.ps1 | iex'"
exit 1
}
$bunVersion = & bun --version 2>&1
Write-Host " bun $bunVersion found." -ForegroundColor Green
# ── Install dependencies ─────────────────────────────────────
Write-Host "[2/5] Installing dependencies..." -ForegroundColor Yellow
Push-Location $ProjectDir
try {
& bun install --frozen-lockfile 2>&1 | Out-Null
Write-Host " Dependencies installed." -ForegroundColor Green
} catch {
Write-Host " WARNING: bun install had issues, trying without --frozen-lockfile..." -ForegroundColor Yellow
& bun install 2>&1 | Out-Null
}
# ── Typecheck + test ──────────────────────────────────────────
Write-Host "[3/5] Running checks..." -ForegroundColor Yellow
$typecheck = & bun run typecheck 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " ERROR: TypeScript errors found:" -ForegroundColor Red
Write-Host $typecheck
Pop-Location
exit 1
}
$testResult = & bun test 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " WARNING: Some tests failed:" -ForegroundColor Yellow
Write-Host ($testResult | Select-Object -Last 5)
} else {
$passLine = $testResult | Select-String "pass"
Write-Host " Checks passed. $passLine" -ForegroundColor Green
}
# ── Compile binary ────────────────────────────────────────────
Write-Host "[4/5] Compiling binary..." -ForegroundColor Yellow
# Read version from package.json
$pkg = Get-Content (Join-Path $ProjectDir "package.json") | ConvertFrom-Json
$version = $pkg.version
& bun build src/index.ts --compile --outfile "dist/$BinName" --target bun-windows-x64 --define "BUILD_VERSION='`"$version`"'" 2>&1 | Out-Null
if (-not (Test-Path "dist/$BinName")) {
Write-Host " ERROR: Compilation failed." -ForegroundColor Red
Pop-Location
exit 1
}
$size = [math]::Round((Get-Item "dist/$BinName").Length / 1MB, 1)
Write-Host " Compiled: dist/$BinName ($size MB)" -ForegroundColor Green
Pop-Location
# ── Install to PATH ───────────────────────────────────────────
Write-Host "[5/5] Installing to $InstallDir..." -ForegroundColor Yellow
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
Copy-Item (Join-Path $ProjectDir "dist\$BinName") $InstallPath -Force
Write-Host " Copied to: $InstallPath" -ForegroundColor Green
# Add to user PATH if not already there
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$InstallDir", "User")
Write-Host " Added $InstallDir to user PATH." -ForegroundColor Green
Write-Host " NOTE: Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow
} else {
Write-Host " $InstallDir already in PATH." -ForegroundColor Green
}
# ── Done ──────────────────────────────────────────────────────
Write-Host ""
Write-Host " Installation complete!" -ForegroundColor Cyan
Write-Host " smolerclaw v$version" -ForegroundColor Cyan
Write-Host ""
Write-Host " Usage:" -ForegroundColor White
Write-Host " smolerclaw # interactive mode"
Write-Host " smolerclaw 'explain this' # with prompt"
Write-Host " smolerclaw -p '2+2' # print mode"
Write-Host ""
Write-Host " First run:" -ForegroundColor White
Write-Host " Requires Claude Code with Pro/Max subscription."
Write-Host " smolerclaw"
Write-Host ""