forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoop-status.ps1
96 lines (82 loc) · 2.4 KB
/
scoop-status.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Usage: scoop status
# Summary: Show status and check for new app versions
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\versions.ps1"
. "$psscriptroot\..\lib\depends.ps1"
. "$psscriptroot\..\lib\config.ps1"
. "$psscriptroot\..\lib\git.ps1"
reset_aliases
# check if scoop needs updating
$currentdir = fullpath $(versiondir 'scoop' 'current')
$needs_update = $false
if(test-path "$currentdir\.git") {
Push-Location $currentdir
git_fetch -q origin
$commits = $(git log "HEAD..origin/$(scoop config SCOOP_BRANCH)" --oneline)
if($commits) { $needs_update = $true }
Pop-Location
}
else {
$needs_update = $true
}
if($needs_update) {
warn "Scoop is out of date. Run 'scoop update' to get the latest changes."
}
else { success "Scoop is up to date."}
$failed = @()
$outdated = @()
$removed = @()
$missing_deps = @()
$true, $false | ForEach-Object { # local and global apps
$global = $_
$dir = appsdir $global
if(!(test-path $dir)) { return }
Get-ChildItem $dir | Where-Object name -ne 'scoop' | ForEach-Object {
$app = $_.name
$status = app_status $app $global
if($status.failed) {
$failed += @{ $app = $status.version }
}
if($status.removed) {
$removed += @{ $app = $status.version }
}
if($status.outdated) {
$outdated += @{ $app = @($status.version, $status.latest_version) }
}
if($status.missing_deps) {
$missing_deps += ,(@($app) + @($status.missing_deps))
}
}
}
if($outdated) {
write-host -f DarkCyan 'Updates are available for:'
$outdated.keys | ForEach-Object {
$versions = $outdated.$_
" $_`: $($versions[0]) -> $($versions[1])"
}
}
if($removed) {
write-host -f DarkCyan 'These app manifests have been removed:'
$removed.keys | ForEach-Object {
" $_"
}
}
if($failed) {
write-host -f DarkCyan 'These apps failed to install:'
$failed.keys | ForEach-Object {
" $_"
}
}
if($missing_deps) {
write-host -f DarkCyan 'Missing runtime dependencies:'
$missing_deps | ForEach-Object {
$app, $deps = $_
" '$app' requires '$([string]::join("', '", $deps))'"
}
}
if(!$old -and !$removed -and !$failed -and !$missing_deps -and !$needs_update) {
success "Everything is ok!"
}
exit 0