Skip to content

Commit

Permalink
chore(release): Bump to version 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Jun 21, 2022
2 parents d63b7d6 + 5987e49 commit 93db5f4
Show file tree
Hide file tree
Showing 13 changed files with 366 additions and 131 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
## [v0.2.2](https://github.com/ScoopInstaller/Scoop/compare/v0.2.1...v0.2.2) - 2022-06-21

### Features

- **core:** Add `Get-Encoding` function to fix missing webclient encoding ([#4956](https://github.com/ScoopInstaller/Scoop/issues/4956))
- **scoop-(un)hold:** Add `-g`/`--global` flag ([#4991](https://github.com/ScoopInstaller/Scoop/issues/4991))
- **scoop-update:** Support `scoop update scoop` ([#4992](https://github.com/ScoopInstaller/Scoop/issues/4992))
- **scoop-virustotal:** Migrate to VirusTotal API v3 ([#4983](https://github.com/ScoopInstaller/Scoop/issues/4983))

### Bug Fixes

- **manifest:** Fix bugs in 'Get-Manifest()' ([#4986](https://github.com/ScoopInstaller/Scoop/issues/4986))

## [v0.2.1](https://github.com/ScoopInstaller/Scoop/compare/v0.2.0...v0.2.1) - 2022-06-10

### Features
Expand Down
6 changes: 3 additions & 3 deletions bin/checkver.ps1
Expand Up @@ -113,7 +113,7 @@ $Queue | ForEach-Object {
} else {
$wc.Headers.Add('User-Agent', (Get-UserAgent))
}
Register-ObjectEvent $wc downloadstringcompleted -ErrorAction Stop | Out-Null
Register-ObjectEvent $wc downloadDataCompleted -ErrorAction Stop | Out-Null

$githubRegex = '\/releases\/tag\/(?:v|V)?([\d.]+)'

Expand Down Expand Up @@ -190,7 +190,7 @@ $Queue | ForEach-Object {
}

$wc.Headers.Add('Referer', (strip_filename $url))
$wc.DownloadStringAsync($url, $state)
$wc.DownloadDataAsync($url, $state)
}

function next($er) {
Expand Down Expand Up @@ -218,7 +218,7 @@ while ($in_progress -gt 0) {
$ver = $Version

if (!$ver) {
$page = $ev.SourceEventArgs.Result
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
$err = $ev.SourceEventArgs.Error
if ($json.checkver.script) {
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))
Expand Down
3 changes: 2 additions & 1 deletion bin/describe.ps1
Expand Up @@ -44,7 +44,8 @@ $Queue | ForEach-Object {
try {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$home_html = $wc.DownloadString($manifest.homepage)
$homepage = $wc.DownloadData($manifest.homepage)
$home_html = (Get-Encoding($wc)).GetString($homepage)
} catch {
Write-Host "`n$($_.Exception.Message)" -ForegroundColor Red
return
Expand Down
16 changes: 10 additions & 6 deletions lib/autoupdate.ps1
@@ -1,20 +1,21 @@
# Must included with 'json.ps1'
function find_hash_in_rdf([String] $url, [String] $basename) {
$data = $null
$xml = $null
try {
# Download and parse RDF XML file
$wc = New-Object Net.Webclient
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', (Get-UserAgent))
[xml]$data = $wc.downloadstring($url)
$data = $wc.DownloadData($url)
[xml]$xml = (Get-Encoding($wc)).GetString($data)
} catch [system.net.webexception] {
write-host -f darkred $_
write-host -f darkred "URL $url is not valid"
return $null
}

# Find file content
$digest = $data.RDF.Content | Where-Object { [String]$_.about -eq $basename }
$digest = $xml.RDF.Content | Where-Object { [String]$_.about -eq $basename }

return format_hash $digest.sha256
}
Expand All @@ -35,7 +36,8 @@ function find_hash_in_textfile([String] $url, [Hashtable] $substitutions, [Strin
$wc = New-Object Net.Webclient
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$hashfile = $wc.downloadstring($url)
$data = $wc.DownloadData($url)
$hashfile = (Get-Encoding($wc)).GetString($data)
} catch [system.net.webexception] {
write-host -f darkred $_
write-host -f darkred "URL $url is not valid"
Expand Down Expand Up @@ -88,7 +90,8 @@ function find_hash_in_json([String] $url, [Hashtable] $substitutions, [String] $
$wc = New-Object Net.Webclient
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$json = $wc.downloadstring($url)
$data = $wc.DownloadData($url)
$json = (Get-Encoding($wc)).GetString($data)
} catch [system.net.webexception] {
write-host -f darkred $_
write-host -f darkred "URL $url is not valid"
Expand All @@ -108,7 +111,8 @@ function find_hash_in_xml([String] $url, [Hashtable] $substitutions, [String] $x
$wc = New-Object Net.Webclient
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$xml = [xml]$wc.downloadstring($url)
$data = $wc.DownloadData($url)
$xml = [xml]((Get-Encoding($wc)).GetString($data))
} catch [system.net.webexception] {
write-host -f darkred $_
write-host -f darkred "URL $url is not valid"
Expand Down
10 changes: 9 additions & 1 deletion lib/core.ps1
Expand Up @@ -15,6 +15,14 @@ function Optimize-SecurityProtocol {
}
}

function Get-Encoding($wc) {
if ($null -ne $wc.ResponseHeaders -and $wc.ResponseHeaders['Content-Type'] -match 'charset=([^;]*)') {
return [System.Text.Encoding]::GetEncoding($Matches[1])
} else {
return [System.Text.Encoding]::GetEncoding('utf-8')
}
}

function Get-UserAgent() {
return "Scoop/1.0 (+http://scoop.sh/) PowerShell/$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor) (Windows NT $([System.Environment]::OSVersion.Version.Major).$([System.Environment]::OSVersion.Version.Minor); $(if($env:PROCESSOR_ARCHITECTURE -eq 'AMD64'){'Win64; x64; '})$(if($env:PROCESSOR_ARCHITEW6432 -eq 'AMD64'){'WOW64; '})$PSEdition)"
}
Expand Down Expand Up @@ -847,7 +855,7 @@ function Confirm-InstallationStatus {
$Global
)
$Installed = @()
$Apps | Select-Object -Unique | Where-Object { $_.Name -ne 'scoop' } | ForEach-Object {
$Apps | Select-Object -Unique | Where-Object { $_ -ne 'scoop' } | ForEach-Object {
$App, $null, $null = parse_app $_
if ($Global) {
if (Test-Path (appdir $App $true)) {
Expand Down
8 changes: 6 additions & 2 deletions lib/depends.ps1
Expand Up @@ -32,7 +32,7 @@ function Get-Dependency {
$Unresolved = @()
)
process {
$AppName, $manifest, $bucket, $null = Get-Manifest $AppName
$AppName, $manifest, $bucket, $url = Get-Manifest $AppName
$Unresolved += $AppName

if (!$manifest) {
Expand All @@ -57,7 +57,11 @@ function Get-Dependency {
if ($bucket) {
$Resolved += "$bucket/$AppName"
} else {
$Resolved += $AppName
if ($url) {
$Resolved += $url
} else {
$Resolved += $AppName
}
}
if ($Unresolved.Length -eq 0) {
return $Resolved
Expand Down
3 changes: 2 additions & 1 deletion lib/description.ps1
Expand Up @@ -18,7 +18,8 @@ function find_description($url, $html, $redir = $false) {
if($refresh -and !$redir) {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$html = $wc.downloadstring($refresh)
$data = $wc.DownloadData($refresh)
$html = (Get-Encoding($wc)).GetString($data)
return find_description $refresh $html $true
}

Expand Down
8 changes: 6 additions & 2 deletions lib/manifest.ps1
Expand Up @@ -12,7 +12,8 @@ function url_manifest($url) {
try {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$str = $wc.downloadstring($url)
$data = $wc.DownloadData($url)
$str = (Get-Encoding($wc)).GetString($data)
} catch [system.management.automation.methodinvocationexception] {
warn "error: $($_.exception.innerexception.message)"
} catch {
Expand All @@ -24,6 +25,7 @@ function url_manifest($url) {

function Get-Manifest($app) {
$bucket, $manifest, $url = $null
$app = $app.TrimStart('/')
# check if app is a URL or UNC path
if ($app -match '^(ht|f)tps?://|\\\\') {
$url = $app
Expand All @@ -44,6 +46,7 @@ function Get-Manifest($app) {
if (!$manifest) {
# couldn't find app in buckets: check if it's a local path
$appPath = $app
$bucket = $null
if (!$appPath.EndsWith('.json')) {
$appPath += '.json'
}
Expand All @@ -66,7 +69,8 @@ function save_installed_manifest($app, $bucket, $dir, $url) {
if ($url) {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$wc.downloadstring($url) > "$dir\manifest.json"
$data = $wc.DownloadData($url)
(Get-Encoding($wc)).GetString($data) | Out-UTF8File "$dir\manifest.json"
} else {
Copy-Item (manifest_path $app $bucket) "$dir\manifest.json"
}
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-download.ps1
Expand Up @@ -51,7 +51,7 @@ foreach ($curr_app in $apps) {
$bucket = $version = $app = $manifest = $url = $null

$app, $bucket, $version = parse_app $curr_app
$app, $manifest, $bucket, $url = Get-Manifest $curr_app
$app, $manifest, $bucket, $url = Get-Manifest "$bucket/$app"

info "Starting download for $app..."

Expand Down
32 changes: 26 additions & 6 deletions libexec/scoop-hold.ps1
@@ -1,23 +1,43 @@
# Usage: scoop hold <apps>
# Summary: Hold an app to disable updates
# Help: To hold a user-scoped app:
# scoop hold <app>
#
# To hold a global app:
# scoop hold -g <app>
#
# Options:
# -g, --global Hold globally installed apps

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'save_install_info' (indirectly)
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'

$apps = $args
$opt, $apps, $err = getopt $args 'g' 'global'
if ($err) { "scoop hold: $err"; exit 1 }

if(!$apps) {
$global = $opt.g -or $opt.global

if (!$apps) {
my_usage
exit 1
}

if ($global -and !(is_admin)) {
error 'You need admin rights to hold a global app.'
exit 1
}

$apps | ForEach-Object {
$app = $_
$global = installed $app $true

if (!(installed $app)) {
error "'$app' is not installed."
if (!(installed $app $global)) {
if ($global) {
error "'$app' is not installed globally."
} else {
error "'$app' is not installed."
}
return
}

Expand All @@ -29,7 +49,7 @@ $apps | ForEach-Object {
$dir = versiondir $app $version $global
$json = install_info $app $version $global
$install = @{}
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name))}
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name)) }
$install.hold = $true
save_install_info $install $dir
success "$app is now held and can not be updated anymore."
Expand Down
32 changes: 26 additions & 6 deletions libexec/scoop-unhold.ps1
@@ -1,23 +1,43 @@
# Usage: scoop unhold <app>
# Summary: Unhold an app to enable updates
# Help: To unhold a user-scoped app:
# scoop unhold <app>
#
# To unhold a global app:
# scoop unhold -g <app>
#
# Options:
# -g, --global Unhold globally installed apps

. "$PSScriptRoot\..\lib\getopt.ps1"
. "$PSScriptRoot\..\lib\json.ps1" # 'save_install_info' (indirectly)
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Select-CurrentVersion' (indirectly)
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'

$apps = $args
$opt, $apps, $err = getopt $args 'g' 'global'
if ($err) { "scoop unhold: $err"; exit 1 }

if(!$apps) {
$global = $opt.g -or $opt.global

if (!$apps) {
my_usage
exit 1
}

if ($global -and !(is_admin)) {
error 'You need admin rights to unhold a global app.'
exit 1
}

$apps | ForEach-Object {
$app = $_
$global = installed $app $true

if (!(installed $app)) {
error "'$app' is not installed."
if (!(installed $app $global)) {
if ($global) {
error "'$app' is not installed globally."
} else {
error "'$app' is not installed."
}
return
}

Expand All @@ -29,7 +49,7 @@ $apps | ForEach-Object {
$dir = versiondir $app $version $global
$json = install_info $app $version $global
$install = @{}
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name))}
$json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name)) }
$install.hold = $null
save_install_info $install $dir
success "$app is no longer held and can be updated again."
Expand Down
13 changes: 9 additions & 4 deletions libexec/scoop-update.ps1
Expand Up @@ -306,19 +306,24 @@ if (-not ($apps -or $all)) {
'ERROR: You need admin rights to update global apps.'; exit 1
}

if (is_scoop_outdated) {
update_scoop
}
$outdated = @()
$updateScoop = $null -ne ($apps | Where-Object { $_ -eq 'scoop' }) -or (is_scoop_outdated)
$apps = $apps | Where-Object { $_ -ne 'scoop' }
$apps_param = $apps

if ($updateScoop) {
update_scoop
}

if ($apps_param -eq '*' -or $all) {
$apps = applist (installed_apps $false) $false
if ($global) {
$apps += applist (installed_apps $true) $true
}
} else {
$apps = Confirm-InstallationStatus $apps_param -Global:$global
if ($apps_param) {
$apps = Confirm-InstallationStatus $apps_param -Global:$global
}
}
if ($apps) {
$apps | ForEach-Object {
Expand Down

0 comments on commit 93db5f4

Please sign in to comment.