11#  PowerShell script to install docs-builder binary
22
33#  Use AppData\Local for user-specific installation instead of Program Files
4- $targetDir  =  Join-Path  - Path $env: LOCALAPPDATA  - ChildPath " docs-builder" 
4+ $targetDir    =  Join-Path  - Path $env: LOCALAPPDATA  - ChildPath " docs-builder" 
55$targetPath  =  Join-Path  - Path $targetDir  - ChildPath " docs-builder.exe" 
66
7+ $version  =  $env: DOCS_BUILDER_VERSION 
8+ if  (-not  $version ) { $version  =  ' latest'   }
9+ 
710#  Check if docs-builder already exists
811if  (Test-Path  - Path $targetPath ) {
912    Write-Host  " docs-builder is already installed." 
@@ -20,10 +23,15 @@ if (-not (Test-Path -Path $targetDir)) {
2023    New-Item  - ItemType Directory - Path $targetDir  - Force |  Out-Null 
2124}
2225
23- #  Download the latest Windows binary from releases
26+ if  ($version  -eq  ' latest'  ) {
27+     $downloadUrl  =  " https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip" 
28+ } else  {
29+     $downloadUrl  =  " https://github.com/elastic/docs-builder/releases/download/$version /docs-builder-win-x64.zip" 
30+ }
31+ 
2432$tempZipPath  =  " $env: TEMP \docs-builder-win-x64.zip" 
2533Write-Host  " Downloading docs-builder binary..." 
26- Invoke-WebRequest  - Uri " https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip "   - OutFile $tempZipPath 
34+ Invoke-WebRequest  - Uri $downloadUrl  - OutFile $tempZipPath 
2735
2836#  Create a temporary directory for extraction
2937$tempExtractPath  =  " $env: TEMP \docs-builder-extract" 
@@ -53,8 +61,8 @@ if ($currentPath -notlike "*$targetDir*") {
5361}
5462
5563#  Clean up temporary files
56- Remove-Item  - Path $tempZipPath  - Force
64+ Remove-Item  - Path $tempZipPath      - Force
5765Remove-Item  - Path $tempExtractPath  - Recurse - Force
5866
59- Write-Host  " docs-builder has been installed successfully and is available in your PATH." 
60- Write-Host  " You may need to restart your terminal or PowerShell session for the PATH changes to take effect." 
67+ Write-Host  " docs-builder ( $version )  has been installed successfully and is available in your PATH." 
68+ Write-Host  " You may need to restart your terminal or PowerShell session for the PATH changes to take effect." 
0 commit comments