Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #43

Merged
merged 5 commits into from
Aug 17, 2024
Merged

Dev #43

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# WinGet-Essentials PowerShell Module

![PSGallery](https://img.shields.io/powershellgallery/p/WinGet-Essentials)
[![pwsh version](https://img.shields.io/powershellgallery/v/WinGet-Essentials)](https://www.powershellgallery.com/packages/WinGet-Essentials)
[![pwsh platform](https://img.shields.io/powershellgallery/p/WinGet-Essentials)](https://www.powershellgallery.com/packages/WinGet-Essentials)
[![pwsh downloads](https://img.shields.io/powershellgallery/dt/WinGet-Essentials)](https://www.powershellgallery.com/packages/WinGet-Essentials)
[![CI](https://github.com/jjcarrier/WinGet-Essentials/actions/workflows/ci.yml/badge.svg)](https://github.com/jjcarrier/WinGet-Essentials/actions/workflows/ci.yml)

## [Table of Contents](#table-of-contents)
Expand Down Expand Up @@ -98,6 +100,10 @@ module, in an Administrator instance of PowerShell, run:
Update-WinGetEssentials
```

> [!NOTE]\
> Module versions >= 1.11.0 do not require this command to run in an Admin
> instance, so long as the user has permissions to create SymLinks.

### Alternative update method (for module versions < 1.6.1)

If desired, it is also possible to perform a more manual upgrade process using
Expand Down
2 changes: 1 addition & 1 deletion WinGet-Essentials/WinGet-Essentials.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'WinGet-Essentials.psm1'
ModuleVersion = '1.11.2'
ModuleVersion = '1.12.0'
GUID = '2a2b6c24-d6cc-4d59-a456-e7ccd90afd03'
Author = 'Jon Carrier'
CompanyName = 'Unknown'
Expand Down
21 changes: 15 additions & 6 deletions WinGet-Essentials/modules/WinGet-Update.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function Update-WinGetEssentials
$newest = @(Get-Module WinGet-Essentials -ListAvailable)[0]
Write-Output "- Updated Version: $($newest.Version)"
Import-Module WinGet-Essentials -RequiredVersion $newest.Version
Import-Module "$PSScriptRoot/WinGet-Utils.psm1"
Import-Module (Join-Path -Path (Split-Path $newest.Path -Parent) -ChildPath "modules/WinGet-Utils.psm1")

if (-not($Force) -and ($current.Version -eq $newest.Version)) {
Write-Output "No new version detected."
Expand Down Expand Up @@ -274,7 +274,10 @@ function Update-WinGetSoftware
# Bypasses prompts. If a prior upgrade fails, the process will continue
# to the next. NOTE: This overrides -WhatIf and -Confirm; however, it
# does not disable the -Interactive switch.
[switch]$Force
[switch]$Force,

# Skips syncing latest upgrade info. Ignored if -Sync is specified.
[switch]$NoSync
)

<#
Expand Down Expand Up @@ -585,6 +588,8 @@ function Update-WinGetSoftware
Write-Output "Getting winget upgrades ..."

$upgradeTable = @()
$cacheFile = $CacheFilePath.Replace('{HOSTNAME}', $(hostname).ToLower())

if ($Sync) {
$jobName = Start-Job -ScriptBlock {
$commandArgs = @('source', 'update')
Expand All @@ -596,22 +601,26 @@ function Update-WinGetSoftware
}

Show-JobProgress $jobName
$cacheFile = $CacheFilePath.Replace('{HOSTNAME}', $(hostname).ToLower())
$upgradeTable = (Get-Content $cacheFile | ConvertFrom-Json).upgrades

if ($upgradeTable.Count -gt 0) {
Write-Output "`nAvailable Upgrades:"
Write-Output "Available Upgrades:"
$upgradeTable | Format-Table
}
return
}
else {

if ($NoSync) {
Write-Output "Sync Skipped."
} else {
$jobName = Start-Job -ScriptBlock {
Get-WinGetSoftwareUpgrade -UseIgnores -Detruncate
}

Show-JobProgress $jobName
$cacheFile = $CacheFilePath.Replace('{HOSTNAME}', $(hostname).ToLower())
}

if (Test-Path $cacheFile) {
$upgradeTable = (Get-Content $cacheFile | ConvertFrom-Json).upgrades
}

Expand Down
19 changes: 12 additions & 7 deletions WinGet-Essentials/modules/WinGet-Utils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,19 @@ function Show-JobProgress
$progressIndicator = @('|', '/', '-', '\')
$progressIter = 0

Start-TerminalBusy
Hide-TerminalCursor
while ($Job.JobStateInfo.State -eq "Running") {
$progressIter = ($progressIter + 1) % $progressIndicator.Count
Write-Host "$($progressIndicator[$progressIter])`b" -NoNewline
Start-Sleep -Milliseconds 125
try {
Start-TerminalBusy
Hide-TerminalCursor
while ($Job.JobStateInfo.State -eq "Running") {
$progressIter = ($progressIter + 1) % $progressIndicator.Count
Write-Host "$($progressIndicator[$progressIter])`b" -NoNewline
Start-Sleep -Milliseconds 125
}
}
finally {
Write-Host " `b" -NoNewline
Stop-TerminalBusy
}
Stop-TerminalBusy
}

<#
Expand Down
Loading