@@ -20,6 +20,26 @@ param(
2020
2121$ErrorActionPreference = " Stop"
2222
23+ $interactiveOutput = -not [Console ]::IsOutputRedirected -and -not [Console ]::IsErrorRedirected -and
24+ $env: TERM -ne " dumb" -and -not $env: CI
25+
26+ function Write-InstallStatus {
27+ param ([string ]$Message , [switch ]$Progress )
28+
29+ if ($interactiveOutput -and -not $env: NO_COLOR ) {
30+ Write-Host $Message - ForegroundColor Cyan
31+ } else {
32+ Write-Host $Message
33+ }
34+ if ($interactiveOutput ) {
35+ if ($Progress ) {
36+ Write-Progress - Id 1 - Activity " Installing Jmix CLI" - Status $Message
37+ } else {
38+ Write-Progress - Id 1 - Activity " Installing Jmix CLI" - Completed
39+ }
40+ }
41+ }
42+
2343if ($env: OS -ne " Windows_NT" ) {
2444 throw " Jmix CLI installer: install.ps1 supports Windows only."
2545}
@@ -46,11 +66,13 @@ function Copy-ReleaseAsset {
4666 [Parameter (Mandatory = $true )][string ]$Destination
4767 )
4868
49- Write-Host " Downloading $Name ..."
69+ Write-InstallStatus " Downloading $Name ..." - Progress
5070 if (Test-Path - LiteralPath $ReleaseBaseUrl - PathType Container) {
5171 Copy-Item - LiteralPath (Join-Path $ReleaseBaseUrl $Name ) - Destination $Destination
5272 } else {
5373 $url = $ReleaseBaseUrl.TrimEnd (" /" ) + " /" + $Name
74+ # Keep Invoke-WebRequest's own byte progress quiet in logs as well.
75+ if (-not $interactiveOutput ) { $ProgressPreference = " SilentlyContinue" }
5476 Invoke-WebRequest - UseBasicParsing - Uri $url - OutFile $Destination
5577 }
5678}
6082 Copy-ReleaseAsset - Name $archiveName - Destination $archiveFile
6183 Copy-ReleaseAsset - Name $checksumName - Destination $checksumFile
6284
85+ Write-InstallStatus " Verifying $archiveName ..." - Progress
6386 $checksumContent = Get-Content - LiteralPath $checksumFile - Raw
6487 if ([string ]::IsNullOrWhiteSpace($checksumContent )) {
6588 throw " Jmix CLI installer: invalid checksum file for $archiveName ."
89112 $extractDir = Join-Path $tempDir " extracted"
90113 New-Item - ItemType Directory - Path $extractDir | Out-Null
91114 New-Item - ItemType Directory - Force - Path $versionsDir | Out-Null
115+ Write-InstallStatus " Extracting $archiveName ..." - Progress
92116 Expand-Archive - LiteralPath $archiveFile - DestinationPath $extractDir
93117 $imageDir = Join-Path $extractDir " jmix"
94118 if (-not (Test-Path - LiteralPath (Join-Path $imageDir " jmix.exe" ) - PathType Leaf)) {
@@ -124,7 +148,7 @@ try {
124148 Set-Content - LiteralPath (Join-Path $InstallRoot " bin-dir" ) - Value $BinDir - Encoding UTF8
125149
126150 if ($installed ) {
127- Write-Host " Installed Jmix CLI at $commandPath "
151+ Write-InstallStatus " Installed Jmix CLI at $commandPath "
128152 }
129153
130154 if (-not $SkipPathUpdate -and $env: JMIX_CLI_SKIP_PATH_UPDATE -ne " 1" ) {
@@ -140,6 +164,9 @@ try {
140164 $env: Path = " $BinDir ;$env: Path "
141165 }
142166} finally {
167+ if ($interactiveOutput ) {
168+ Write-Progress - Id 1 - Activity " Installing Jmix CLI" - Completed
169+ }
143170 if (Test-Path - LiteralPath $tempDir ) {
144171 Remove-Item - LiteralPath $tempDir - Recurse - Force
145172 }
@@ -149,5 +176,5 @@ if ($NoRun -or $env:JMIX_CLI_NO_RUN -eq "1") {
149176 return
150177}
151178
152- Write-Host " Starting the Jmix project wizard..."
179+ Write-InstallStatus " Starting the Jmix project wizard..."
153180& $launcher @CliArguments
0 commit comments