@@ -415,8 +415,11 @@ function Install-ModuleFast {
415415 }
416416
417417 $httpClient = New-ModuleFastClient
418-
418+ Write-Progress - Id 1 - Activity ' Install-ModuleFast ' - Status ' Preparing Plan ' - PercentComplete 1
419419 $plan = Get-ModuleFastPlan $ModulesToInstall - HttpClient $httpClient
420+
421+ Write-Progress - Id 1 - Activity ' Install-ModuleFast' - Status " Installing: $ ( $plan.count ) Modules" - PercentComplete 50
422+
420423 $cancelSource = [CancellationTokenSource ]::new()
421424
422425 $installHelperParams = @ {
@@ -427,6 +430,7 @@ function Install-ModuleFast {
427430 HttpClient = $httpClient
428431 }
429432 Install-ModuleFastHelper @installHelperParams
433+ Write-Progress - Id 1 - Activity ' Install-ModuleFast' - Completed
430434}
431435
432436# endregion Main
@@ -478,6 +482,9 @@ function Install-ModuleFastHelper {
478482
479483 # Installation jobs are captured here, we will check them once all downloads have completed
480484 [List [Job2 ]]$installJobs = @ ()
485+
486+ $downloaded = 0
487+ $downloadedProgressId = Get-Random
481488 # TODO: Filestreams should be disposed in a try/catch in case of cancellation. In PS 7.3+, should be a clean() block
482489 while ($downloadTasks.count -gt 0 ) {
483490 # TODO: Check on in jobs and if there's a failure, cancel the rest of the jobs
@@ -509,15 +516,22 @@ function Install-ModuleFastHelper {
509516 Write-Debug " Starting Module Install Job for $ ( $context.Module ) "
510517 $installJob = Start-ThreadJob @installJobParams
511518 $installJobs.Add ($installJob )
519+ $downloaded ++
520+ Write-Progress - Id $downloadedProgressId - ParentId 1 - Activity ' Download' - Status " $downloaded /$ ( $ModuleToInstall.count ) Modules" - PercentComplete ($downloaded / $ModuleToInstall.count * 100 )
521+
512522 }
513523
514524 # TODO: Correlate the installjobs to a dictionary so we can return the original modulespec maybe?
515525 # Or is that even needed?
526+ $installed = 0
527+ $installProgressId = (Get-Random )
516528 while ($installJobs.count -gt 0 ) {
517529 $ErrorActionPreference = ' Stop'
518530 $completedJob = $installJobs | Wait-Job - Any
519531 $completedJob | Receive-Job - Wait - AutoRemoveJob
520532 if (-not $installJobs.Remove ($completedJob )) { throw ' Could not remove completed job from list. This is a bug, report it' }
533+ $installed ++
534+ Write-Progress - Id $installProgressId - ParentId 1 - Activity ' Install' - Status " $installed /$ ( $ModuleToInstall.count ) Modules" - PercentComplete ($installed / $ModuleToInstall.count * 100 )
521535 }
522536}
523537
@@ -536,9 +550,11 @@ function Install-ModuleFastOperation {
536550 )
537551 $ErrorActionPreference = ' Stop'
538552 $ModuleDestination = Join-Path $Destination $Name $Version
539- Write-Host " Installing $Name $Version from $DownloadPath to $ModuleDestination "
553+ Write-Verbose " Installing $Name $Version from $DownloadPath to $ModuleDestination "
554+ $progressPreference = ' SilentlyContinue'
540555 Expand-Archive - Path $DownloadPath - DestinationPath $ModuleDestination - Force
541- Write-Host " Installed $Name $Version from $DownloadPath to $ModuleDestination "
556+ $progressPreference = ' Continue'
557+ Write-Verbose " Installed $Name $Version from $DownloadPath to $ModuleDestination "
542558}
543559
544560# region Classes
@@ -1165,8 +1181,11 @@ function Limit-ModuleFastSpecs {
11651181 -not $Highest ? $Versions : @ ($Versions | Sort-Object - Descending | Select-Object - First 1 )
11661182}
11671183
1168-
1169-
1184+ try {
1185+ Update-TypeData - TypeName ' ModuleFastSpec' - DefaultDisplayPropertySet ' Name' , ' Required' , ' Min' , ' Max' - ErrorAction Stop
1186+ } catch [RuntimeException ] {
1187+ if ($PSItem -notmatch ' is already present' ) { throw }
1188+ }
11701189# endregion Helpers
11711190
11721191# Export-ModuleMember Get-ModuleFast
0 commit comments