forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoop-status.ps1
99 lines (80 loc) · 2.19 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
97
98
99
# 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"
function timeago($when) {
$diff = [datetime]::now - $last_update
if($diff.totaldays -gt 2) { return "$([int]$diff.totaldays) days ago" }
if($diff.totalhours -gt 2) { return "$([int]$diff.totalhours) hours ago" }
if($diff.totalminutes -gt 2) { return "$([int]$diff.totalminutes) minutes ago" }
return "$([int]$diff.totalseconds) seconds ago"
}
# check when scoop was last updated
git fetch origin
$commits = $(git log HEAD..origin/master --oneline)
if($commits) {
"scoop is out of date. run scoop update to get the latest changes."
}
else { "scoop is up-to-date."}
$failed = @()
$old = @()
$removed = @()
$missing_deps = @()
$true, $false | % { # local and global apps
$global = $_
$dir = appsdir $global
if(!(test-path $dir)) { return }
gci $dir | ? name -ne 'scoop' | % {
$app = $_.name
$version = current_version $app $global
if($version) {
$install_info = install_info $app $version $global
}
if(!$install_info) {
$failed += @{ $app = $version }; return
}
$manifest = manifest $app $install_info.bucket $install_info.url
if(!$manifest) { $removed += @{ $app = $version }; return }
if((compare_versions $manifest.version $version) -gt 0) {
$old += @{ $app = @($version, $manifest.version) }
}
$deps = @(runtime_deps $manifest) | ? { !(installed $_) }
if($deps) {
$missing_deps += ,(@($app) + @($deps))
}
}
}
if($old) {
"updates are available for:"
$old.keys | % {
$versions = $old.$_
" $_`: $($versions[0]) -> $($versions[1])"
}
}
if($removed) {
"these app manifests have been removed:"
$removed.keys | % {
" $_"
}
}
if($failed) {
"these apps failed to install:"
$failed.keys | % {
" $_"
}
}
if($missing_deps) {
"missing runtime dependencies:"
$missing_deps | % {
$app, $deps = $_
" $app requires $([string]::join(',', $deps))"
}
}
if(!$old -and !$removed -and !$failed -and !$missing_deps) {
success "everything is ok!"
}
exit 0