Skip to content

feat: add new function to list outdated packages #15

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

Merged
merged 3 commits into from
Sep 22, 2021

Conversation

danstis
Copy link
Owner

@danstis danstis commented Sep 22, 2021

Added a new function Get-Updates which check for outdated Chocolatey, WinGet and PowerShell packages/modules.
It also writes the outdated items to files in $env:Temp to be possibly queried in the PS profile to show outdated packages at the start of the terminal.

@danstis danstis requested a review from C-Roche September 22, 2021 01:36
@danstis danstis self-assigned this Sep 22, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@C-Roche
Copy link
Collaborator

C-Roche commented Sep 22, 2021

Perform a check to see if WinGet is installed and ignore it if it's not - or send a message back to say WinGet wasn't found..
Output a message for any system that is checked, but has no update, i.e. "Checked Chocolately and no updates are available".

@danstis
Copy link
Owner Author

danstis commented Sep 22, 2021

Perform a check to see if WinGet is installed and ignore it if it's not - or send a message back to say WinGet wasn't found..
Output a message for any system that is checked, but has no update, i.e. "Checked Chocolately and no updates are available".

Think the latest commit addresses these points.

@C-Roche
Copy link
Collaborator

C-Roche commented Sep 22, 2021

Takes a bit of time to run with no info coming back, so I'd put in some outputs like 'Checking Chocolatey...", etc.
Problem with your PS section as it creates the check file even if $ModuleUpdates is empty. You need to change:
$ModuleUpdates | ConvertTo-Json | Out-File -FilePath "$env:temp\powershell-outdated.json" -Encoding utf8 -Force
to
if ($ModuleUpdates) {
$ModuleUpdates | ConvertTo-Json | Out-File -FilePath "$env:temp\powershell-outdated.json" -Encoding utf8 -Force
}
You might also consider removing the output files after the script does its work to make sure subsequent runs don't pick them up.

@danstis
Copy link
Owner Author

danstis commented Sep 22, 2021

Takes a bit of time to run with no info coming back, so I'd put in some outputs like 'Checking Chocolatey...", etc.
Problem with your PS section as it creates the check file even if $ModuleUpdates is empty. You need to change:
$ModuleUpdates | ConvertTo-Json | Out-File -FilePath "$env:temp\powershell-outdated.json" -Encoding utf8 -Force
to
if ($ModuleUpdates) {
$ModuleUpdates | ConvertTo-Json | Out-File -FilePath "$env:temp\powershell-outdated.json" -Encoding utf8 -Force
}
You might also consider removing the output files after the script does its work to make sure subsequent runs don't pick them up.

Hmmm, that's intended, I primarily use this to write the files in the temp folder, so I can read them when starting a new console, This is done to give you instant results on launching a new terminal window.
The output from the function is really only there in case it is run manually, but for the most part, I see this running on a scheduled task automatically.

@C-Roche
Copy link
Collaborator

C-Roche commented Sep 22, 2021

That's fine, but you probably still don't want it creating empty files. Or if you do, there's no point in checking for the file and then outputting that there are no updates based on whether there's a file there or not.

@danstis
Copy link
Owner Author

danstis commented Sep 22, 2021

Yeah fair point, I'll update to remove the files before it starts, then check the non-existence as a sign of no updates.

@C-Roche
Copy link
Collaborator

C-Roche commented Sep 22, 2021

Looks good to me!

@danstis danstis merged commit b943c96 into master Sep 22, 2021
@danstis danstis deleted the Add-update-function branch September 22, 2021 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants