10
10
}
11
11
12
12
$ExitCode = 0
13
+ # TODO: Add some --remote parameter to not use installed manifest
14
+ # -g, --global Gather information from globally installed application if application is installed both locally and globally.
15
+ # Useful for pre-check of installed specific application in automatic deployments.
16
+ # -r, --remote > Remote manifest will be used to get all required information. Ignoring locally installed manifest (scoop-manifest.json).
17
+ # $Options, $Application, $_err = Resolve-GetOpt $args 'a:g' 'arch=', 'global'
13
18
$Options , $Application , $_err = Resolve-GetOpt $args ' a:' ' arch='
14
19
15
20
if ($_err ) { Stop-ScoopExecution - Message " scoop info: $_err " - ExitCode 2 }
16
21
if (! $Application ) { Stop-ScoopExecution - Message ' Parameter <APP> missing' - Usage (my_usage) }
22
+ if ($Application.Count -gt 1 ) { Write-UserMessage - Message ' Multiple <APP> parameters is not allowed. Ignoring all except the first.' - Warning }
17
23
18
24
$Application = $Application [0 ]
19
25
$Architecture = Resolve-ArchitectureParameter - Architecture $Options.a , $Options.arch
26
+ # $Global = $Options.'g' -or $Options.'global'
20
27
21
- # TODO: Adopt Resolve-ManifestInformation
22
- if ($Application -match ' ^(ht|f)tps?://|\\\\' ) {
23
- # check if $Application is a URL or UNC path
24
- $url = $Application
25
- $Application = appname_from_url $url
26
- $Global = installed $Application $true
27
- $Status = app_status $Application $Global
28
- $Manifest = url_manifest $url
29
- $manifest_file = $url
30
- } else {
31
- # else $Application is a normal app name
32
- $Global = installed $Application $true
33
- $Application , $bucket , $null = parse_app $Application
34
- $Status = app_status $Application $Global
35
- $Manifest , $bucket = find_manifest $Application $bucket
28
+ $Resolved = $null
29
+ try {
30
+ $Resolved = Resolve-ManifestInformation - ApplicationQuery $Application
31
+ } catch {
32
+ Stop-ScoopExecution - Message $_.Exception.Message
36
33
}
37
34
38
- if (! $Manifest ) { Stop-ScoopExecution - Message " Could not find manifest for '$ ( show_app $Application $bucket ) '" }
39
-
40
- $Name = $Application
35
+ # Variables
36
+ $Name = $Resolved.ApplicationName
37
+ $Message = @ ()
38
+ $Global = installed $Name $true
39
+ $Status = app_status $Name $Global
40
+ $Manifest = $Resolved.ManifestObject
41
+ $ManifestPath = @ ($Resolved.LocalPath )
41
42
42
- $install = install_info $Name $Status.version $Global
43
- $Status.installed = $install.bucket -eq $bucket
44
- $version_output = $Manifest.version
45
- if (! $manifest_file ) {
46
- $manifest_file = manifest_path $Name $bucket
47
- }
43
+ $ManifestPath = $ManifestPath , $Resolved.Url , (installed_manifest $Name $Manifest.version $Global - PathOnly), $Resolved.LocalPath |
44
+ Where-Object { ! [String ]::IsNullOrEmpty($_ ) } | Select-Object - Unique
48
45
49
- $currentVersion = Select-CurrentVersion - AppName $Name - Global:$Global
50
- $dir = versiondir $Name $currentVersion $Global
51
- $original_dir = versiondir $Name $Manifest.version $Global
52
- $persist_dir = persistdir $Name $Global
53
-
54
- if ($Status.installed ) {
55
- $manifest_file = manifest_path $Name $install.bucket
56
- if ($install.url ) {
57
- $manifest_file = $install.url
58
- }
59
- if ($Status.version -eq $Manifest.version ) {
60
- $version_output = $Status.version
61
- } else {
62
- $version_output = " $ ( $Status.version ) (Update to $ ( $Manifest.version ) available)"
63
- }
64
- $Architecture = $install.architecture
65
- }
46
+ $dir = (versiondir $Name $Manifest.version $Global ).TrimEnd(' \' )
47
+ $original_dir = (versiondir $Name $Resolved.Version $Global ).TrimEnd(' \' )
48
+ $persist_dir = (persistdir $Name $Global ).TrimEnd(' \' )
49
+ $up = if ($Status.outdated ) { ' Yes' } else { ' No' }
66
50
67
51
$Message = @ (" Name: $Name " )
68
- $Message += " Version: $version_output "
52
+ $Message += " Version: $ ( $Manifest .Version ) "
69
53
if ($Manifest.description ) { $Message += " Description: $ ( $Manifest.description ) " }
70
- if ($Manifest.homepage ) { $Message += " Website : $ ( $Manifest.homepage ) " }
54
+ if ($Manifest.homepage ) { $Message += " Homepage : $ ( $Manifest.homepage ) " }
71
55
72
56
# Show license
73
57
# TODO: Rework
@@ -85,6 +69,7 @@ if ($Manifest.license) {
85
69
}
86
70
$Message += " License: $license "
87
71
}
72
+
88
73
if ($Manifest.changelog ) {
89
74
$ch = $Manifest.changelog
90
75
if (! $ch.StartsWith (' http' )) {
@@ -98,25 +83,58 @@ if ($Manifest.changelog) {
98
83
}
99
84
100
85
# Manifest file
101
- $Message += @ (' Manifest:' , " $manifest_file " )
86
+ $Message += ' Manifest:'
87
+ foreach ($m in $ManifestPath ) { $Message += " $m " }
88
+
89
+ # Bucket info
90
+ if ($Resolved.Bucket ) {
91
+ $_m = " Bucket: $ ( $Resolved.Bucket ) "
92
+ $path = Find-BucketDirectory - Bucket $Resolved.Bucket
93
+
94
+ if ($path ) {
95
+ try {
96
+ # TODO: Quote
97
+ $_u = Invoke-GitCmd - Repository $path - Command ' config' - Argument @ (' --get' , ' remote.origin.url' )
98
+ if ($LASTEXITCODE -ne 0 ) { throw ' Ignore' }
99
+ if ($_u ) { $_m = " $_m ($_u )" }
100
+ } catch {
101
+ $_u = $null
102
+ }
103
+ }
104
+
105
+ $Message += $_m
106
+ }
102
107
103
108
# Show installed versions
104
109
if ($Status.installed ) {
105
- $Message += ' Installed:'
106
- $versions = Get-InstalledVersion - AppName $Name - Global:$Global
107
- $versions | ForEach-Object {
108
- $dir = versiondir $Name $_ $Global
109
- if ($Global ) { $dir += ' *global*' }
110
- $Message += " $dir "
110
+ $_m = ' Installed: Yes'
111
+ if ($Global ) { $_m = " $_m *global*" }
112
+ $Message += $_m
113
+
114
+ $Message += " Installation path: $dir "
115
+
116
+ $v = Get-InstalledVersion - AppName $Name - Global:$Global
117
+ if ($v.Count -gt 0 ) {
118
+ $Message += " Installed versions: $ ( $v -join ' , ' ) "
111
119
}
120
+ $Message += " Update available: $up "
121
+
122
+ $InstallInfo = install_info $Name $Manifest.version $Global
123
+ $Architecture = $InstallInfo.architecture
112
124
} else {
113
- $Message += ' Installed: No'
125
+ $inst = ' Installed: No'
126
+ # if ($reason) { $inst = "$inst ($reason)" }
127
+ $Message += $inst
114
128
}
115
129
130
+ $arm64Support = ' No'
131
+ if ($Manifest.architecture.arm64 ) { $arm64Support = ' Yes' }
132
+ $Message += " arm64 Support: $arm64Support "
133
+
116
134
$binaries = @ (arch_specific ' bin' $Manifest $Architecture )
117
135
if ($binaries ) {
118
136
$Message += ' Binaries:'
119
- $add = ' '
137
+ $add = ' '
120
138
foreach ($b in $binaries ) {
121
139
$addition = " $b "
122
140
if ($b -is [System.Array ]) {
@@ -167,10 +185,9 @@ if ($env_add_path) {
167
185
# endregion Environment
168
186
169
187
# Available versions:
170
- $vers = Find-BucketDirectory - Name $bucket | Join-Path - ChildPath " old\$Name " | Get-ChildItem - ErrorAction ' SilentlyContinue' - File |
188
+ $vers = Find-BucketDirectory - Name $Resolved .Bucket | Join-Path - ChildPath " old\$Name " | Get-ChildItem - ErrorAction ' SilentlyContinue' - File |
171
189
Where-Object - Property ' Name' -Match - Value " \.($ALLOWED_MANIFEST_EXTENSION_REGEX )$"
172
-
173
- if ($vers.Count -gt 0 ) { $Message += " Available Versions: $ ( $vers.BaseName -join ' , ' ) " }
190
+ if ($vers.Count -gt 0 ) { $Message += " Available archived versions: $ ( $vers.BaseName -join ' , ' ) " }
174
191
175
192
Write-UserMessage - Message $Message - Output
176
193
0 commit comments