@@ -37,9 +37,10 @@ Usage:
3737 install.ps1
3838
3939Environment:
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
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+ VIX_INSTALL_SHARE_DIR Runtime assets dir. Default: %LOCALAPPDATA%\Vix\share
4344
4445After install:
4546 vix upgrade
@@ -91,6 +92,13 @@ $BinDir = if ($env:VIX_INSTALL_DIR) {
9192 Join-Path $env: LOCALAPPDATA " Vix\bin"
9293}
9394
95+ $ShareDir = if ($env: VIX_INSTALL_SHARE_DIR ) {
96+ $env: VIX_INSTALL_SHARE_DIR
97+ } else {
98+ $installRoot = Split-Path - Parent $BinDir
99+ Join-Path $installRoot " share"
100+ }
101+
94102$BinName = " vix.exe"
95103
96104function Resolve-LatestTag ([string ]$repo ) {
@@ -304,12 +312,20 @@ function Install-Cli([string]$archivePath, [string]$tmpDir) {
304312
305313 New-Item - ItemType Directory - Force - Path $extractDir | Out-Null
306314 New-Item - ItemType Directory - Force - Path $BinDir | Out-Null
315+ New-Item - ItemType Directory - Force - Path $ShareDir | Out-Null
307316
308317 Step " Installing to $BinDir \$BinName "
309318
310- Expand-Archive - LiteralPath $archivePath - DestinationPath $extractDir - Force
319+ Expand-Archive `
320+ - LiteralPath $archivePath `
321+ - DestinationPath $extractDir `
322+ - Force
311323
312- $exeCandidate = Get-ChildItem - LiteralPath $extractDir - Recurse - File - Filter $BinName |
324+ $exeCandidate = Get-ChildItem `
325+ - LiteralPath $extractDir `
326+ - Recurse `
327+ - File `
328+ - Filter $BinName |
313329 Select-Object - First 1
314330
315331 if (-not $exeCandidate ) {
@@ -323,9 +339,71 @@ function Install-Cli([string]$archivePath, [string]$tmpDir) {
323339 $exe ,
324340 [System.StringComparison ]::OrdinalIgnoreCase
325341 )) {
326- Copy-Item - LiteralPath $exeCandidate.FullName - Destination $exe - Force
342+ Copy-Item `
343+ - LiteralPath $exeCandidate.FullName `
344+ - Destination $exe `
345+ - Force
346+ }
347+
348+ $noteSource = Join-Path $extractDir " share\vix\note"
349+ $noteDestination = Join-Path $ShareDir " vix\note"
350+ $noteParent = Split-Path - Parent $noteDestination
351+
352+ $noteIndex = Join-Path $noteSource " index.html"
353+ $noteCss = Join-Path $noteSource " assets\note.css"
354+ $noteJs = Join-Path $noteSource " assets\note.js"
355+
356+ if (-not (Test-Path - LiteralPath $noteIndex - PathType Leaf)) {
357+ Die " CLI archive does not contain Vix Note index.html"
358+ }
359+
360+ if (-not (Test-Path - LiteralPath $noteCss - PathType Leaf)) {
361+ Die " CLI archive does not contain Vix Note note.css"
362+ }
363+
364+ if (-not (Test-Path - LiteralPath $noteJs - PathType Leaf)) {
365+ Die " CLI archive does not contain Vix Note note.js"
366+ }
367+
368+ Step " Installing Vix Note assets to $noteDestination "
369+
370+ New-Item `
371+ - ItemType Directory `
372+ - Force `
373+ - Path $noteParent |
374+ Out-Null
375+
376+ if (Test-Path - LiteralPath $noteDestination ) {
377+ Remove-Item `
378+ - LiteralPath $noteDestination `
379+ - Recurse `
380+ - Force
381+ }
382+
383+ Copy-Item `
384+ - LiteralPath $noteSource `
385+ - Destination $noteDestination `
386+ - Recurse `
387+ - Force
388+
389+ $installedIndex = Join-Path $noteDestination " index.html"
390+ $installedCss = Join-Path $noteDestination " assets\note.css"
391+ $installedJs = Join-Path $noteDestination " assets\note.js"
392+
393+ if (-not (Test-Path - LiteralPath $installedIndex - PathType Leaf)) {
394+ Die " failed to install Vix Note index.html"
395+ }
396+
397+ if (-not (Test-Path - LiteralPath $installedCss - PathType Leaf)) {
398+ Die " failed to install Vix Note note.css"
327399 }
328400
401+ if (-not (Test-Path - LiteralPath $installedJs - PathType Leaf)) {
402+ Die " failed to install Vix Note note.js"
403+ }
404+
405+ Ok " Vix Note assets installed"
406+
329407 return $exe
330408}
331409
0 commit comments