Skip to content
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

refactor(Get-Manifest): Select actual source for manifest #6142

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deprecated manifest
  • Loading branch information
HUMORCE committed Sep 20, 2024
commit e7155eacc06584b428dd474dbf13edfe3e2f0e25
4 changes: 3 additions & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ function app_status($app, $global) {
$status.failed = failed $app $global
$status.hold = ($install_info.hold -eq $true)

$deprecated_dir = (Find-BucketDirectory -Name $install_info.bucket -Root) + "\deprecated"
$status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName

$manifest = manifest $app $install_info.bucket $install_info.url
$status.removed = (!$manifest)
if ($manifest.version) {
Expand Down Expand Up @@ -581,7 +584,6 @@ function app_status($app, $global) {
if ($deps) {
$status.missing_deps += , $deps
}

return $status
}

Expand Down
6 changes: 5 additions & 1 deletion lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function url_manifest($url) {
}

function Get-Manifest($app) {
$bucket, $manifest, $url = $null
$bucket, $manifest, $url, $deprecated = $null
$app = $app.TrimStart('/')
# check if app is a URL or UNC path
if ($app -match '^(ht|f)tps?://|\\\\') {
Expand Down Expand Up @@ -63,6 +63,10 @@ function Get-Manifest($app) {
}
} else {
$manifest = manifest $app $bucket
if (!$manifest) {
$deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + "\deprecated"
$manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName
}
}
}
} else {
Expand Down
20 changes: 13 additions & 7 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,28 @@ if ($verbose) {
$original_dir = versiondir $app $manifest.version $global
$persist_dir = persistdir $app $global
} else {
$dir, $original_dir, $persist_dir = "<root>", "<root>", "<root>"
$dir, $original_dir, $persist_dir = '<root>', '<root>', '<root>'
}

if ($status.installed) {
$manifest_file = manifest_path $app $install.bucket
if ($install.url) {
$manifest_file = $install.url
}
if ($status.version -eq $manifest.version) {
if ($status.deprecated) {
$manifest_file = $status.deprecated
} elseif ($status.version -eq $manifest.version) {
$version_output = $status.version
} else {
$version_output = "$($status.version) (Update to $($manifest.version) available)"
}

}

$item = [ordered]@{ Name = $app }
if ($status.deprecated) {
$item.Name += ' (DEPRECATED)'
}
if ($manifest.description) {
$item.Description = $manifest.description
}
Expand All @@ -70,7 +76,7 @@ if ($manifest.license) {
$manifest.license
} elseif ($manifest.license -match '[|,]') {
if ($verbose) {
"$($manifest.license) ($(($manifest.license -Split "\||," | ForEach-Object { "https://spdx.org/licenses/$_.html" }) -join ', '))"
"$($manifest.license) ($(($manifest.license -Split '\||,' | ForEach-Object { "https://spdx.org/licenses/$_.html" }) -join ', '))"
} else {
$manifest.license
}
Expand Down Expand Up @@ -103,7 +109,7 @@ if ($status.installed) {
# Show installed versions
$installed_output = @()
Get-InstalledVersion -AppName $app -Global:$global | ForEach-Object {
$installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { " *global*" })" }
$installed_output += if ($verbose) { versiondir $app $_ $global } else { "$_$(if ($global) { ' *global*' })" }
}
$item.Installed = $installed_output -join "`n"

Expand Down Expand Up @@ -162,7 +168,7 @@ if ($status.installed) {
foreach ($url in @(url $manifest (Get-DefaultArchitecture))) {
try {
if (Test-Path (cache_path $app $manifest.version $url)) {
$cached = " (latest version is cached)"
$cached = ' (latest version is cached)'
} else {
$cached = $null
}
Expand Down Expand Up @@ -197,15 +203,15 @@ if ($binaries) {
$binary_output += $_
}
}
$item.Binaries = $binary_output -join " | "
$item.Binaries = $binary_output -join ' | '
}
$shortcuts = @(arch_specific 'shortcuts' $manifest $install.architecture)
if ($shortcuts) {
$shortcut_output = @()
$shortcuts | ForEach-Object {
$shortcut_output += $_[1]
}
$item.Shortcuts = $shortcut_output -join " | "
$item.Shortcuts = $shortcut_output -join ' | '
}
$env_set = arch_specific 'env_set' $manifest $install.architecture
if ($env_set) {
Expand Down
9 changes: 5 additions & 4 deletions libexec/scoop-status.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ $true, $false | ForEach-Object { # local and global apps
Get-ChildItem $dir | Where-Object name -NE 'scoop' | ForEach-Object {
$app = $_.name
$status = app_status $app $global
if (!$status.outdated -and !$status.failed -and !$status.removed -and !$status.missing_deps) { return }
if (!$status.outdated -and !$status.failed -and !$status.deprecated -and !$status.removed -and !$status.missing_deps) { return }

$item = [ordered]@{}
$item.Name = $app
$item.'Installed Version' = $status.version
$item.'Latest Version' = if ($status.outdated) { $status.latest_version } else { "" }
$item.'Missing Dependencies' = $status.missing_deps -Split ' ' -Join ' | '
$info = @()
if ($status.failed) { $info += 'Install failed' }
if ($status.hold) { $info += 'Held package' }
if ($status.removed) { $info += 'Manifest removed' }
if ($status.failed) { $info += 'Install failed' }
if ($status.hold) { $info += 'Held package' }
if ($status.deprecated) { $info += 'Deprecated' }
if ($status.removed) { $info += 'Manifest removed' }
$item.Info = $info -join ', '
$list += [PSCustomObject]$item
}
Expand Down