Skip to content

Commit e94b5b7

Browse files
committed
Release v2.7.0
1 parent fee40bf commit e94b5b7

3 files changed

Lines changed: 165 additions & 205 deletions

File tree

vix-site/public/install.ps1

Lines changed: 86 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,53 @@
33
# irm https://vixcpp.com/install.ps1 | iex
44
#
55
# Optional:
6-
# $env:VIX_VERSION="v2.5.5"
6+
# $env:VIX_VERSION="v2.7.0"
77
# $env:VIX_REPO="vixcpp/vix"
8-
# $env:VIX_INSTALL_KIND="sdk" # sdk or cli
9-
# $env:VIX_INSTALL_PREFIX="$env:LOCALAPPDATA\Vix"
108
# $env:VIX_INSTALL_DIR="$env:LOCALAPPDATA\Vix\bin"
119

1210
$ErrorActionPreference = "Stop"
1311
$ProgressPreference = "SilentlyContinue"
1412

15-
function Info($msg) {
16-
Write-Host "› vix: $msg"
13+
$MinisignPubkey = "RWSIfpPSznK9A1gWUc8Eg2iXXQwU5d9BYuQNKGOcoujAF2stPu5rKFjQ"
14+
15+
function Step($msg) {
16+
Write-Host "$msg"
1717
}
1818

1919
function Ok($msg) {
20-
Write-Host "✔ vix: $msg" -ForegroundColor Green
20+
Write-Host " $msg" -ForegroundColor Green
2121
}
2222

23-
function Warn($msg) {
24-
Write-Host "! vix: $msg" -ForegroundColor Yellow
23+
function Hint($msg) {
24+
Write-Host " · $msg" -ForegroundColor DarkGray
2525
}
2626

2727
function Die($msg) {
28-
throw "✖ vix: $msg"
28+
Write-Host "$msg" -ForegroundColor Red
29+
exit 1
2930
}
3031

3132
function Show-Help {
3233
Write-Host @"
3334
Vix.cpp installer
3435
3536
Usage:
36-
install.ps1 Install Vix SDK
37-
install.ps1 --cli-only Install CLI only
38-
install.ps1 --sdk Install SDK
37+
install.ps1
3938
4039
Environment:
41-
VIX_VERSION Release version. Example: v2.5.5. Default: latest
42-
VIX_REPO GitHub repo. Default: vixcpp/vix
43-
VIX_INSTALL_KIND sdk or cli. Default: sdk
44-
VIX_INSTALL_PREFIX SDK install prefix. Default: %LOCALAPPDATA%\Vix
45-
VIX_INSTALL_DIR CLI bin dir. Default: %LOCALAPPDATA%\Vix\bin
40+
VIX_VERSION Release version. Example: v2.7.0. Default: latest
41+
VIX_REPO GitHub repo. Default: vixcpp/vix
42+
VIX_INSTALL_DIR CLI bin dir. Default: %LOCALAPPDATA%\Vix\bin
43+
44+
After install:
45+
vix upgrade
46+
vix upgrade --sdk list
47+
vix upgrade --sdk web
4648
"@
4749
}
4850

4951
foreach ($arg in $args) {
5052
switch ($arg) {
51-
"--cli-only" {
52-
$env:VIX_INSTALL_KIND = "cli"
53-
}
54-
"--sdk" {
55-
$env:VIX_INSTALL_KIND = "sdk"
56-
}
5753
"--help" {
5854
Show-Help
5955
exit 0
@@ -62,6 +58,15 @@ foreach ($arg in $args) {
6258
Show-Help
6359
exit 0
6460
}
61+
"--cli-only" {
62+
# Kept for compatibility. The installer is CLI-only now.
63+
}
64+
"--cli" {
65+
# Kept for compatibility. The installer is CLI-only now.
66+
}
67+
"--sdk" {
68+
Die "SDK install moved to: vix upgrade --sdk"
69+
}
6570
default {
6671
Die "unknown option: $arg"
6772
}
@@ -80,22 +85,10 @@ $Version = if ($env:VIX_VERSION) {
8085
"latest"
8186
}
8287

83-
$InstallKind = if ($env:VIX_INSTALL_KIND) {
84-
$env:VIX_INSTALL_KIND
85-
} else {
86-
"sdk"
87-
}
88-
89-
$PrefixDir = if ($env:VIX_INSTALL_PREFIX) {
90-
$env:VIX_INSTALL_PREFIX
91-
} else {
92-
Join-Path $env:LOCALAPPDATA "Vix"
93-
}
94-
9588
$BinDir = if ($env:VIX_INSTALL_DIR) {
9689
$env:VIX_INSTALL_DIR
9790
} else {
98-
Join-Path $PrefixDir "bin"
91+
Join-Path $env:LOCALAPPDATA "Vix\bin"
9992
}
10093

10194
$BinName = "vix.exe"
@@ -158,28 +151,54 @@ function Verify-Checksum([string]$archivePath, [string]$shaPath) {
158151
}
159152
}
160153

154+
function Verify-Signature([string]$archivePath, [string]$sigPath) {
155+
$minisign = Get-Command minisign -ErrorAction SilentlyContinue
156+
157+
if (-not $minisign) {
158+
return
159+
}
160+
161+
& minisign -Vm $archivePath -x $sigPath -P $MinisignPubkey *> $null
162+
163+
if ($LASTEXITCODE -ne 0) {
164+
Die "signature verification failed"
165+
}
166+
167+
Ok "minisign verified"
168+
}
169+
161170
function Download-And-Verify-Asset([string]$baseUrl, [string]$asset, [string]$tmpDir) {
162171
$archivePath = Join-Path $tmpDir $asset
163172
$shaPath = Join-Path $tmpDir ($asset + ".sha256")
173+
$sigPath = Join-Path $tmpDir ($asset + ".minisig")
164174

165175
$assetUrl = "$baseUrl/$asset"
166176
$shaUrl = "$baseUrl/$asset.sha256"
177+
$sigUrl = "$baseUrl/$asset.minisig"
167178

168-
Info "downloading $asset"
179+
Step "Downloading $asset"
169180

170181
try {
171182
Invoke-WebRequest -Uri $assetUrl -OutFile $archivePath
172183
} catch {
173-
Die "release asset not found: $asset. Check that the GitHub release contains this file: $assetUrl"
184+
Die "release asset not found: $asset"
174185
}
175186

176187
try {
177188
Invoke-WebRequest -Uri $shaUrl -OutFile $shaPath
178189
} catch {
179-
Die "checksum file not found: $asset.sha256. Check that the GitHub release contains this file: $shaUrl"
190+
Die "checksum file not found: $asset.sha256"
180191
}
181192

182193
Verify-Checksum $archivePath $shaPath
194+
Ok "sha256 verified"
195+
196+
try {
197+
Invoke-WebRequest -Uri $sigUrl -OutFile $sigPath
198+
Verify-Signature $archivePath $sigPath
199+
} catch {
200+
# minisign is optional for bootstrap install.
201+
}
183202

184203
return $archivePath
185204
}
@@ -188,7 +207,6 @@ function Install-SqliteDll([string]$installBin, [string]$tmpDir) {
188207
$sqliteDll = Join-Path $installBin "sqlite3.dll"
189208

190209
if (Test-Path -LiteralPath $sqliteDll) {
191-
Info "sqlite3.dll already exists"
192210
return
193211
}
194212

@@ -205,7 +223,7 @@ function Install-SqliteDll([string]$installBin, [string]$tmpDir) {
205223
$sqliteAsset = "sqlite-dll-win-x86-3530200.zip"
206224
}
207225
default {
208-
Warn "unsupported SQLite architecture: $archRaw"
226+
Hint "sqlite runtime skipped: unsupported architecture $archRaw"
209227
return
210228
}
211229
}
@@ -217,34 +235,35 @@ function Install-SqliteDll([string]$installBin, [string]$tmpDir) {
217235
New-Item -ItemType Directory -Force -Path $sqliteDir | Out-Null
218236
New-Item -ItemType Directory -Force -Path $installBin | Out-Null
219237

220-
Info "downloading SQLite runtime $sqliteAsset"
238+
Step "Installing SQLite runtime"
221239

222240
try {
223241
Invoke-WebRequest -Uri $sqliteUrl -OutFile $sqliteZip
224242
} catch {
225-
Die "could not download SQLite runtime: $sqliteUrl"
243+
Hint "sqlite runtime skipped"
244+
return
226245
}
227246

228247
try {
229248
Expand-Archive -LiteralPath $sqliteZip -DestinationPath $sqliteDir -Force
230249
} catch {
231-
Die "could not extract SQLite runtime"
250+
Hint "sqlite runtime skipped"
251+
return
232252
}
233253

234254
$dllCandidate = Get-ChildItem -LiteralPath $sqliteDir -Recurse -File -Filter "sqlite3.dll" |
235255
Select-Object -First 1
236256

237257
if (-not $dllCandidate) {
238-
Die "SQLite archive does not contain sqlite3.dll"
258+
Hint "sqlite runtime skipped"
259+
return
239260
}
240261

241262
Copy-Item -LiteralPath $dllCandidate.FullName -Destination $sqliteDll -Force
242263

243-
if (-not (Test-Path -LiteralPath $sqliteDll)) {
244-
Die "sqlite3.dll was not installed to $sqliteDll"
264+
if (Test-Path -LiteralPath $sqliteDll) {
265+
Ok "sqlite3.dll installed"
245266
}
246-
247-
Ok "installed sqlite3.dll"
248267
}
249268

250269
function Add-To-UserPath([string]$pathToAdd) {
@@ -286,52 +305,15 @@ function Install-Cli([string]$archivePath, [string]$tmpDir) {
286305
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
287306
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
288307

289-
Expand-Archive -LiteralPath $archivePath -DestinationPath $extractDir -Force
290-
291-
$exeCandidate = Get-ChildItem -LiteralPath $extractDir -Recurse -File -Filter $BinName |
292-
Select-Object -First 1
293-
294-
if (-not $exeCandidate) {
295-
Die "CLI archive does not contain $BinName"
296-
}
297-
298-
$exe = Join-Path $BinDir $BinName
299-
300-
if (-not [string]::Equals(
301-
$exeCandidate.FullName,
302-
$exe,
303-
[System.StringComparison]::OrdinalIgnoreCase
304-
)) {
305-
Copy-Item -LiteralPath $exeCandidate.FullName -Destination $exe -Force
306-
}
307-
308-
return $exe
309-
}
310-
311-
function Install-Sdk([string]$archivePath, [string]$tmpDir) {
312-
$extractDir = Join-Path $tmpDir "sdk"
313-
314-
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
315-
New-Item -ItemType Directory -Force -Path $PrefixDir | Out-Null
316-
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
308+
Step "Installing to $BinDir\$BinName"
317309

318310
Expand-Archive -LiteralPath $archivePath -DestinationPath $extractDir -Force
319311

320-
Get-ChildItem -Path $extractDir -Force | ForEach-Object {
321-
Copy-Item -Path $_.FullName -Destination $PrefixDir -Recurse -Force
322-
}
323-
324-
$exeCandidate = Get-ChildItem -Path $PrefixDir -Recurse -File -Filter $BinName |
325-
Where-Object { $_.FullName -match '[\\/](bin)[\\/].*vix\.exe$' } |
312+
$exeCandidate = Get-ChildItem -LiteralPath $extractDir -Recurse -File -Filter $BinName |
326313
Select-Object -First 1
327314

328315
if (-not $exeCandidate) {
329-
$exeCandidate = Get-ChildItem -Path $PrefixDir -Recurse -File -Filter $BinName |
330-
Select-Object -First 1
331-
}
332-
333-
if (-not $exeCandidate) {
334-
Die "SDK archive does not contain $BinName"
316+
Die "CLI archive does not contain $BinName"
335317
}
336318

337319
$exe = Join-Path $BinDir $BinName
@@ -348,57 +330,48 @@ function Install-Sdk([string]$archivePath, [string]$tmpDir) {
348330
}
349331

350332
$Arch = Detect-Architecture
333+
351334
$Tag = if ($Version -eq "latest") {
352335
Resolve-LatestTag $Repo
353336
} else {
354337
$Version
355338
}
356339

357-
switch ($InstallKind.ToLowerInvariant()) {
358-
"sdk" {
359-
$Asset = "vix-sdk-windows-$Arch.zip"
360-
}
361-
"cli" {
362-
$Asset = "vix-windows-$Arch.zip"
363-
}
364-
default {
365-
Die "unsupported VIX_INSTALL_KIND: $InstallKind"
366-
}
367-
}
368-
340+
$Asset = "vix-windows-$Arch.zip"
369341
$BaseUrl = "https://github.com/$Repo/releases/download/$Tag"
370342

371343
$TmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ("vix-" + [System.Guid]::NewGuid().ToString("N"))
372344
New-Item -ItemType Directory -Force -Path $TmpDir | Out-Null
373345

374346
try {
347+
Write-Host "" -NoNewline
348+
Write-Host "Vix.cpp" -NoNewline -ForegroundColor Green
349+
Write-Host " installer"
350+
Write-Host " ------------------------------------"
351+
Write-Host " version $Tag"
352+
Write-Host " platform windows/$Arch"
375353
Write-Host ""
376-
Write-Host "Vix.cpp" -ForegroundColor Green
377-
Info "installing $Tag ($InstallKind, windows-$Arch)"
378354

379355
$ArchivePath = Download-And-Verify-Asset $BaseUrl $Asset $TmpDir
380-
381-
if ($InstallKind.ToLowerInvariant() -eq "cli") {
382-
$Exe = Install-Cli $ArchivePath $TmpDir
383-
} else {
384-
$Exe = Install-Sdk $ArchivePath $TmpDir
385-
}
356+
$Exe = Install-Cli $ArchivePath $TmpDir
386357

387358
Install-SqliteDll $BinDir $TmpDir
388359

389360
$PathAlreadyReady = Add-To-UserPath $BinDir
390361

391362
try {
392363
& $Exe --version *> $null
393-
Ok "installed $Tag"
364+
Ok "Done — vix $Tag installed"
394365
} catch {
395-
Warn "installed, but 'vix --version' failed"
366+
Die "installed, but 'vix --version' failed"
396367
}
397368

398369
if ($PathAlreadyReady) {
399-
Ok "ready"
370+
Hint "run: vix upgrade --check"
371+
Hint "sdk: vix upgrade --sdk list"
400372
} else {
401-
Warn "installed, restart your terminal if 'vix' is not found"
373+
Hint "restart your terminal if 'vix' is not found"
374+
Hint "then run: vix upgrade --sdk list"
402375
}
403376
}
404377
finally {

0 commit comments

Comments
 (0)