mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-10-01 01:36:52 +00:00
* Add show_app() function for displaying `app/bucket@version` * Add option to skip hash check on install/update Allows users to install an app when the manifest provides an outdated hash * Show filename instead of robocopy output when moving fails * Add new_issue_msg() for nicer error messages (with link bucket repo) - returns a message with a link to the buckets GitHub repository - clicking on the link opens a new issues with a predefined title * Use new_issue_msg() for errors while moving files - this removes the unreadable robocopy error dumps * Use new_issue_msg() error handling for check_hash() * Show robocopy exit code
67 lines
1.8 KiB
PowerShell
67 lines
1.8 KiB
PowerShell
$bucketsdir = "$scoopdir\buckets"
|
|
|
|
function bucketdir($name) {
|
|
if(!$name) { return relpath "..\bucket" } # main bucket
|
|
|
|
"$bucketsdir\$name"
|
|
}
|
|
|
|
function known_bucket_repos {
|
|
$dir = versiondir 'scoop' 'current'
|
|
$json = "$dir\buckets.json"
|
|
Get-Content $json -raw | convertfrom-json -ea stop
|
|
}
|
|
|
|
function known_bucket_repo($name) {
|
|
$buckets = known_bucket_repos
|
|
$buckets.$name
|
|
}
|
|
|
|
function apps_in_bucket($dir) {
|
|
Get-ChildItem $dir | Where-Object { $_.name.endswith('.json') } | ForEach-Object { $_ -replace '.json$', '' }
|
|
}
|
|
|
|
function buckets {
|
|
$buckets = @()
|
|
if(test-path $bucketsdir) {
|
|
Get-ChildItem $bucketsdir | ForEach-Object { $buckets += $_.name }
|
|
}
|
|
$buckets
|
|
}
|
|
|
|
function find_manifest($app, $bucket) {
|
|
if ($bucket) {
|
|
$manifest = manifest $app $bucket
|
|
if ($manifest) { return $manifest, $bucket }
|
|
return $null
|
|
}
|
|
|
|
$buckets = @($null) + @(buckets) # null for main bucket
|
|
foreach($bucket in $buckets) {
|
|
$manifest = manifest $app $bucket
|
|
if($manifest) { return $manifest, $bucket }
|
|
}
|
|
}
|
|
|
|
function new_issue_msg($app, $bucket, $title, $body) {
|
|
$app, $manifest, $bucket, $url = locate $app $bucket
|
|
$url = known_bucket_repo $bucket
|
|
if($manifest -and $null -eq $url -and $null -eq $bucket) {
|
|
$url = 'https://github.com/lukesampson/scoop'
|
|
}
|
|
if(!$url) {
|
|
return "Please contact the bucket maintainer!"
|
|
}
|
|
|
|
$title = [System.Web.HttpUtility]::UrlEncode("$app@$($manifest.version): $title")
|
|
$body = [System.Web.HttpUtility]::UrlEncode($body)
|
|
$url = $url -replace '^(.*).git$','$1'
|
|
$url = "$url/issues/new?title=$title"
|
|
if($body) {
|
|
$url += "&body=$body"
|
|
}
|
|
|
|
$msg = "`nPlease create a new issue by using the following link and paste your console output:"
|
|
return "$msg`n$url"
|
|
}
|