mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-30 14:17:54 +00:00
* fix (decompress): `Expand-7zipArchive` only delete temp dir / `$extractDir` if it is empty (#6092) Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com> * refactor(download): Move download-related functions to 'download.ps1' (#6095) * fix(download): Fallback to default downloader when aria2 fails (#4292) * fix(commands): Handling broken aliases (#6141) * fix(shim): properly check `wslpath`/`cygpath` command first (#6114) Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com> * fix(scoop-bucket): Add missing import for `no_junction` envs (#6181) Signed-off-by: Chawye Hsu <su+git@chawyehsu.com> * docs(chglog): Update to 0.5.3 (#6258) * perf(shim): Update kiennq-shim to v3.1.2 (#6261) * fix(decompress): Replace deprecated 7ZIPEXTRACT_USE_EXTERNAL config (#6327) Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com> * fix(scoop-uninstall): Fix uninstaller does not gain Global state (#6430) * global arg * changelog * refactor(Get-Manifest): Select actual source for manifest (#6142) * first step * Revert "first step" This reverts commitc5907c3e25. * refactor(Get-Manifest): Select actual source for installed manifest * rework sub-commands, `scoop-depends` is NOT working at this stage * URI manifest * opt * deprecated manifest * source of manifests * source of manifest pt2 - Mark URI(path/URL/UNC/etc.) query as standalone manifest - Drop `installed` and `available update` items for [query] and [installed] are different sources. * remove variable preventing I forget it * scoop-info: fix source of manifest on bucket * fix `scoop-depends` * Fix Standalone and Source detection * fix global install * Fix scoop-cat, scoop-home - Query for remote manifest * scoop-list: info +deprecated * manifest: Fix first selected manifest * gramma.. * Fix61b3259* length * fix(scoop-depends-tests): Mocking `USE_EXTERNAL_7ZIP` as $false (#6431) * fix(scoop-depends-tests): Mocking `USE_EXTERNAL_7ZIP` as $false to avoding error when it is $true * CHANGELOG * feat(autoupdate): GitHub predefined hashes support (#6416) * feat(autoupdate): predefined hash case for GitHub - Remove `sha256:` prefix in `format_hash()` - Add GitHub support in `get_hash_for_app()` Close #6381 * doc(chglog): GitHub auto hash update * fix(autoupdate): remove prefix only * docs(CHANGELOG): Update to 0.5.3 (#6432) * docs(CHANGELOG): Update to 0.5.3 * 6416 --------- Signed-off-by: Chawye Hsu <su+git@chawyehsu.com> Co-authored-by: Olav Rønnestad Birkeland <6450056+o-l-a-v@users.noreply.github.com> Co-authored-by: kiennq <kien.n.quang@gmail.com> Co-authored-by: HUMORCE <humorce@outlook.com> Co-authored-by: Ryan <sitiom@proton.me> Co-authored-by: Chawye Hsu <su+git@chawyehsu.com> Co-authored-by: Bassel Rachid <101208715+basselworkforce@users.noreply.github.com> Co-authored-by: Wordless Echo <wordless@echo.moe>
142 lines
3.8 KiB
PowerShell
142 lines
3.8 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
List manifests which do not have valid URLs.
|
|
.PARAMETER App
|
|
Manifest name to search.
|
|
Placeholder is supported.
|
|
.PARAMETER Dir
|
|
Where to search for manifest(s).
|
|
.PARAMETER Timeout
|
|
How long (seconds) the request can be pending before it times out.
|
|
.PARAMETER SkipValid
|
|
Manifests will all valid URLs will not be shown.
|
|
#>
|
|
param(
|
|
[String] $App = '*',
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidateScript( {
|
|
if (!(Test-Path $_ -Type Container)) {
|
|
throw "$_ is not a directory!"
|
|
} else {
|
|
$true
|
|
}
|
|
})]
|
|
[String] $Dir,
|
|
[Int] $Timeout = 5,
|
|
[Switch] $SkipValid
|
|
)
|
|
|
|
. "$PSScriptRoot\..\lib\core.ps1"
|
|
. "$PSScriptRoot\..\lib\manifest.ps1"
|
|
. "$PSScriptRoot\..\lib\download.ps1"
|
|
|
|
$Dir = Convert-Path $Dir
|
|
$Queue = @()
|
|
|
|
Get-ChildItem $Dir -Filter "$App.json" -Recurse | ForEach-Object {
|
|
$manifest = parse_json $_.FullName
|
|
$Queue += , @($_.BaseName, $manifest)
|
|
}
|
|
|
|
Write-Host '[' -NoNewLine
|
|
Write-Host 'U' -NoNewLine -ForegroundColor Cyan
|
|
Write-Host ']RLs'
|
|
Write-Host ' | [' -NoNewLine
|
|
Write-Host 'O' -NoNewLine -ForegroundColor Green
|
|
Write-Host ']kay'
|
|
Write-Host ' | | [' -NoNewLine
|
|
Write-Host 'F' -NoNewLine -ForegroundColor Red
|
|
Write-Host ']ailed'
|
|
Write-Host ' | | |'
|
|
|
|
function test_dl([String] $url, $cookies) {
|
|
# Trim renaming suffix, prevent getting 40x response
|
|
$url = ($url -split '#/')[0]
|
|
|
|
$wreq = [Net.WebRequest]::Create($url)
|
|
$wreq.Timeout = $Timeout * 1000
|
|
if ($wreq -is [Net.HttpWebRequest]) {
|
|
$wreq.UserAgent = Get-UserAgent
|
|
$wreq.Referer = strip_filename $url
|
|
if ($cookies) {
|
|
$wreq.Headers.Add('Cookie', (cookie_header $cookies))
|
|
}
|
|
}
|
|
|
|
get_config PRIVATE_HOSTS | Where-Object { $_ -ne $null -and $url -match $_.match } | ForEach-Object {
|
|
(ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object {
|
|
$wreq.Headers[$_.Key] = $_.Value
|
|
}
|
|
}
|
|
|
|
$wres = $null
|
|
try {
|
|
$wres = $wreq.GetResponse()
|
|
|
|
return $url, $wres.StatusCode, $null
|
|
} catch {
|
|
$e = $_.Exception
|
|
if ($e.InnerException) { $e = $e.InnerException }
|
|
|
|
return $url, 'Error', $e.Message
|
|
} finally {
|
|
if ($null -ne $wres -and $wres -isnot [Net.FtpWebResponse]) {
|
|
$wres.Close()
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($man in $Queue) {
|
|
$name, $manifest = $man
|
|
$urls = @()
|
|
$ok = 0
|
|
$failed = 0
|
|
$errors = @()
|
|
|
|
if ($manifest.url) {
|
|
$manifest.url | ForEach-Object { $urls += $_ }
|
|
} else {
|
|
script:url $manifest '64bit' | ForEach-Object { $urls += $_ }
|
|
script:url $manifest '32bit' | ForEach-Object { $urls += $_ }
|
|
script:url $manifest 'arm64' | ForEach-Object { $urls += $_ }
|
|
}
|
|
|
|
$urls | ForEach-Object {
|
|
$url, $status, $msg = test_dl $_ $manifest.cookie
|
|
if ($msg) { $errors += "$msg ($url)" }
|
|
if ($status -eq 'OK' -or $status -eq 'OpeningData') { $ok += 1 } else { $failed += 1 }
|
|
}
|
|
|
|
if (($ok -eq $urls.Length) -and $SkipValid) { continue }
|
|
|
|
# URLS
|
|
Write-Host '[' -NoNewLine
|
|
Write-Host $urls.Length -NoNewLine -ForegroundColor Cyan
|
|
Write-Host ']' -NoNewLine
|
|
|
|
# Okay
|
|
Write-Host '[' -NoNewLine
|
|
if ($ok -eq $urls.Length) {
|
|
Write-Host $ok -NoNewLine -ForegroundColor Green
|
|
} elseif ($ok -eq 0) {
|
|
Write-Host $ok -NoNewLine -ForegroundColor Red
|
|
} else {
|
|
Write-Host $ok -NoNewLine -ForegroundColor Yellow
|
|
}
|
|
Write-Host ']' -NoNewLine
|
|
|
|
# Failed
|
|
Write-Host '[' -NoNewLine
|
|
if ($failed -eq 0) {
|
|
Write-Host $failed -NoNewLine -ForegroundColor Green
|
|
} else {
|
|
Write-Host $failed -NoNewLine -ForegroundColor Red
|
|
}
|
|
Write-Host '] ' -NoNewLine
|
|
Write-Host $name
|
|
|
|
$errors | ForEach-Object {
|
|
Write-Host " > $_" -ForegroundColor DarkRed
|
|
}
|
|
}
|