Skip to content

Commit 79902ac

Browse files
committed
feat(list,status,uninstall): Detect dependency
- ScoopInstaller#4515 Cleaner take 2 of #231 #2, #140, #61
1 parent b001941 commit 79902ac

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
🎉🎉 YAML typed manifest and archived manifest installation support 🎉🎉
66

7+
- **scoop-uninstall**: Warn user when he tries to uninstall dependency, which is still needed
8+
- **scoop-status**: Detect if applications, which were installed as dependency are still needed
9+
- **scoop-list**: Show if application was installed as dependency
10+
- If it was installed as dependency, the parent application will be shown as `{application}` in blue
711
- Adopt new resolve function for parameter passing
812
- **scoop-install**
913
- **scoop-depends**

lib/Applications.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ function app_status($app, $global) {
176176

177177
$install_info = install_info $app $status.version $global
178178

179+
$status.install_info = $install_info
179180
$status.failed = (!$install_info -or !$status.version)
180181
$status.hold = ($install_info.hold -eq $true)
181182

lib/Uninstall.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ function Uninstall-ScoopApplication {
7070
$install = install_info $App $version $Global
7171
$architecture = $install.architecture
7272

73+
if ($install.dependency_for -and (installed $install.dependency_for)) {
74+
Write-UserMessage -Message "Uninstalling dependency required for installed application '$($install.dependency_for)'. This operation could negatively influence the said application." -Warning
75+
}
76+
7377
Invoke-ManifestScript -Manifest $manifest -ScriptName 'pre_uninstall' -Architecture $architecture
7478
run_uninstaller $manifest $architecture $dir
7579
Invoke-ManifestScript -Manifest $manifest -ScriptName 'post_uninstall' -Architecture $architecture

libexec/scoop-list.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ $Applications | Sort-Object @SortSplat | Where-Object { !$Query -or ($_.name -ma
8989
if ($installInfo.architecture -and ($DefaultArchitecture -ne $installInfo.architecture)) {
9090
Write-Host " {$($installInfo.architecture)}" -ForegroundColor 'DarkRed' -NoNewline
9191
}
92+
93+
if ($installInfo.dependency_for) {
94+
Write-Host " {$($installInfo.dependency_for)}" -ForegroundColor 'DarkBlue' -NoNewline
95+
}
96+
9297
Write-Host ''
9398
}
9499
Write-Host ''

libexec/scoop-status.ps1

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Usage: scoop status [<OPTIONS>]
22
# Summary: Show status and check for available updates for all installed applications.
3-
# Help: Status command will check these factors and report if any of them is not satisfied:
3+
# Help: Status command will check various factors and report if any of them is not satisfied.
4+
# Following factors are checked:
45
# Scoop installation is up-to-date.
5-
# Installed applications use the latest version.
6-
# Remote manifests of installed applications are available.
6+
# Every installed application use the latest version.
7+
# Remote manifests of installed applications are accessible.
78
# All applications are successfully installed.
89
# All runtime dependencies are installed.
10+
# All installed dependencies are still needed.
911
#
1012
# Options:
1113
# -h, --help Show help for this command.
@@ -35,6 +37,7 @@ $Outdated = @()
3537
$Removed = @()
3638
$MissingDependencies = @()
3739
$Onhold = @()
40+
$CouldBeRemoved = @()
3841
$null, $null, $_err = Resolve-GetOpt $args
3942

4043
if ($_err) { Stop-ScoopExecution -Message "scoop status: $_err" -ExitCode 2 }
@@ -60,6 +63,8 @@ if ($UpdateRequired) {
6063
Write-UserMessage -Message 'Scoop is up to date' -Success
6164
}
6265

66+
$installedApps = @((installed_apps $true) + (installed_apps $false))
67+
6368
# Local and global applications
6469
foreach ($global in ($true, $false)) {
6570
$dir = appsdir $global
@@ -76,6 +81,9 @@ foreach ($global in ($true, $false)) {
7681
$Outdated += @{ $app = @($status.version, $status.latest_version) }
7782
if ($status.hold) { $Onhold += @{ $app = @($status.version, $status.latest_version) } }
7883
}
84+
if (($status.install_info.dependency_for) -and ($installedApps -notcontains $status.install_info.dependency_for)) {
85+
$CouldBeRemoved += $app
86+
}
7987
}
8088
}
8189

@@ -120,6 +128,13 @@ if ($MissingDependencies) {
120128
}
121129
}
122130

131+
if ($CouldBeRemoved) {
132+
Write-UserMessage -Message 'These dependencies could be removed:' -Color 'DarkCyan'
133+
$CouldBeRemoved | ForEach-Object {
134+
Write-UserMessage -Message " $_"
135+
}
136+
}
137+
123138
if (!$UpdateRequired -and !$Removed -and !$Failed -and !$MissingDependencies -and !$Outdated) { Write-UserMessage -Message 'Everything is ok!' -Success }
124139

125140
exit $ExitCode

0 commit comments

Comments
 (0)