Skip to content

Commit abbfb87

Browse files
authored
Merge branch 'develop' into fix-encoding
2 parents 570ede1 + 3a1186e commit abbfb87

14 files changed

Lines changed: 98 additions & 105 deletions

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop)
1+
## [v0.2.1](https://github.com/ScoopInstaller/Scoop/compare/v0.2.0...v0.2.1) - 2022-06-10
22

33
### Features
44

55
- **core:** Add pre_uninstall and post_uninstall hooks ([#4957](https://github.com/ScoopInstaller/Scoop/issues/4957), [#4962](https://github.com/ScoopInstaller/Scoop/issues/4962))
66

77
### Bug Fixes
88

9-
- **chore:** Deprecate tls1 and tls1.1 ([#4950](https://github.com/ScoopInstaller/Scoop/pull/4950))
9+
- **chore:** Deprecate tls1 and tls1.1 ([#4950](https://github.com/ScoopInstaller/Scoop/issues/4950))
1010
- **chore:** Update Nonportable bucket URL ([#4955](https://github.com/ScoopInstaller/Scoop/issues/4955))
1111
- **core:** Using `Invoke-Command` instead of `Invoke-Expression` ([#4941](https://github.com/ScoopInstaller/Scoop/issues/4941))
1212
- **core:** Load config file before initialization ([#4932](https://github.com/ScoopInstaller/Scoop/issues/4932))
@@ -19,9 +19,13 @@
1919
- **shim:** Remove character replacement in .cmd -> .ps1 shims ([#4914](https://github.com/ScoopInstaller/Scoop/issues/4914))
2020
- **scoop:** Pass CLI arguments as string objects ([#4931](https://github.com/ScoopInstaller/Scoop/issues/4931))
2121
- **scoop-info:** Fix error message when manifest is not found ([#4935](https://github.com/ScoopInstaller/Scoop/issues/4935))
22-
- **scoop-search:** Require files in 'bucket' dir for remote known buckets ([#4943](https://github.com/ScoopInstaller/Scoop/issues/4943))
22+
- **scoop-search:** Require files in 'bucket' dir for remote known buckets ([#4944](https://github.com/ScoopInstaller/Scoop/issues/4944))
2323
- **update:** Prevent uninstall when update ([#4949](https://github.com/ScoopInstaller/Scoop/issues/4949))
2424

25+
### Code Refactoring
26+
27+
- **manifest:** Rename 'Find-Manifest()' to 'Get-Manifest() ([#4966](https://github.com/ScoopInstaller/Scoop/issues/4966))
28+
2529
### Documentation
2630

2731
- **readme:** Update license badge ([#4929](https://github.com/ScoopInstaller/Scoop/issues/4929))

lib/buckets.ps1

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,6 @@ function buckets {
7272
return Get-LocalBucket
7373
}
7474

75-
function Find-Manifest($app, $bucket) {
76-
$manifest, $url = $null, $null
77-
78-
# check if app is a URL or UNC path
79-
if ($app -match '^(ht|f)tps?://|\\\\') {
80-
$url = $app
81-
$app = appname_from_url $url
82-
$manifest = url_manifest $url
83-
} else {
84-
if ($bucket) {
85-
$manifest = manifest $app $bucket
86-
} else {
87-
foreach ($bucket in Get-LocalBucket) {
88-
$manifest = manifest $app $bucket
89-
if ($manifest) { break }
90-
}
91-
}
92-
93-
if (!$manifest) {
94-
# couldn't find app in buckets: check if it's a local path
95-
$path = $app
96-
if (!$path.endswith('.json')) { $path += '.json' }
97-
if (Test-Path $path) {
98-
$url = "$(Resolve-Path $path)"
99-
$app = appname_from_url $url
100-
$manifest, $bucket = url_manifest $url
101-
}
102-
}
103-
}
104-
105-
return $app, $manifest, $bucket, $url
106-
}
107-
10875
function Convert-RepositoryUri {
10976
[CmdletBinding()]
11077
param (
@@ -197,7 +164,7 @@ function rm_bucket($name) {
197164
}
198165

199166
function new_issue_msg($app, $bucket, $title, $body) {
200-
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket
167+
$app, $manifest, $bucket, $url = Get-Manifest "$bucket/$app"
201168
$url = known_bucket_repo $bucket
202169
$bucket_path = "$bucketsdir\$bucket"
203170

lib/core.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,12 @@ function applist($apps, $global) {
949949
return ,@($apps | ForEach-Object { ,@($_, $global) })
950950
}
951951

952-
function parse_app([string] $app) {
953-
if($app -match '(?:(?<bucket>[a-zA-Z0-9-_.]+)\/)?(?<app>.*\.json$|[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?') {
954-
return $matches['app'], $matches['bucket'], $matches['version']
952+
function parse_app([string]$app) {
953+
if ($app -match '^(?:(?<bucket>[a-zA-Z0-9-_.]+)/)?(?<app>.*\.json$|[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?$') {
954+
return $Matches['app'], $Matches['bucket'], $Matches['version']
955+
} else {
956+
return $app, $null, $null
955957
}
956-
return $app, $null, $null
957958
}
958959

959960
function show_app($app, $bucket, $version) {

lib/depends.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ function Get-Dependency {
3232
$Unresolved = @()
3333
)
3434
process {
35-
$AppName, $bucket, $null = parse_app $AppName
35+
$AppName, $manifest, $bucket, $null = Get-Manifest $AppName
3636
$Unresolved += $AppName
37-
$null, $manifest, $null, $null = Find-Manifest $AppName $bucket
3837

3938
if (!$manifest) {
4039
if (((Get-LocalBucket) -notcontains $bucket) -and $bucket) {

lib/install.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ function nightly_version($date, $quiet = $false) {
77
}
88

99
function install_app($app, $architecture, $global, $suggested, $use_cache = $true, $check_hash = $true) {
10-
$app, $bucket, $null = parse_app $app
11-
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket
10+
$app, $manifest, $bucket, $url = Get-Manifest $app
1211

1312
if(!$manifest) {
1413
abort "Couldn't find manifest for '$app'$(if($url) { " at the URL $url" })."

lib/manifest.ps1

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,47 @@ function url_manifest($url) {
2323
$str | convertfrom-json
2424
}
2525

26+
function Get-Manifest($app) {
27+
$bucket, $manifest, $url = $null
28+
# check if app is a URL or UNC path
29+
if ($app -match '^(ht|f)tps?://|\\\\') {
30+
$url = $app
31+
$app = appname_from_url $url
32+
$manifest = url_manifest $url
33+
} else {
34+
$app, $bucket, $version = parse_app $app
35+
if ($bucket) {
36+
$manifest = manifest $app $bucket
37+
} else {
38+
foreach ($bucket in Get-LocalBucket) {
39+
$manifest = manifest $app $bucket
40+
if ($manifest) {
41+
break
42+
}
43+
}
44+
}
45+
if (!$manifest) {
46+
# couldn't find app in buckets: check if it's a local path
47+
if (!$app.EndsWith('.json')) {
48+
$app += '.json'
49+
}
50+
if (Test-Path $app) {
51+
$url = Convert-Path $app
52+
$app = appname_from_url $url
53+
$manifest = url_manifest $url
54+
}
55+
}
56+
}
57+
return $app, $manifest, $bucket, $url
58+
}
59+
2660
function manifest($app, $bucket, $url) {
27-
if($url) { return url_manifest $url }
61+
if ($url) { return url_manifest $url }
2862
parse_json (manifest_path $app $bucket)
2963
}
3064

3165
function save_installed_manifest($app, $bucket, $dir, $url) {
32-
if($url) {
66+
if ($url) {
3367
$wc = New-Object Net.Webclient
3468
$wc.Headers.Add('User-Agent', (Get-UserAgent))
3569
$data = $wc.DownloadData($url)
@@ -53,7 +87,7 @@ function save_install_info($info, $dir) {
5387

5488
function install_info($app, $version, $global) {
5589
$path = "$(versiondir $app $version $global)\install.json"
56-
if(!(test-path $path)) { return $null }
90+
if (!(Test-Path $path)) { return $null }
5791
parse_json $path
5892
}
5993

@@ -75,20 +109,21 @@ function default_architecture {
75109
}
76110

77111
function arch_specific($prop, $manifest, $architecture) {
78-
if($manifest.architecture) {
112+
if ($manifest.architecture) {
79113
$val = $manifest.architecture.$architecture.$prop
80-
if($val) { return $val } # else fallback to generic prop
114+
if ($val) { return $val } # else fallback to generic prop
81115
}
82116

83-
if($manifest.$prop) { return $manifest.$prop }
117+
if ($manifest.$prop) { return $manifest.$prop }
84118
}
85119

86120
function supports_architecture($manifest, $architecture) {
87121
return -not [String]::IsNullOrEmpty((arch_specific 'url' $manifest $architecture))
88122
}
89123

90-
function generate_user_manifest($app, $bucket, $version) { # 'autoupdate.ps1' 'buckets.ps1' 'manifest.ps1'
91-
$null, $manifest, $bucket, $null = Find-Manifest $app $bucket
124+
function generate_user_manifest($app, $bucket, $version) {
125+
# 'autoupdate.ps1' 'buckets.ps1' 'manifest.ps1'
126+
$app, $manifest, $bucket, $null = Get-Manifest "$bucket/$app"
92127
if ("$($manifest.version)" -eq "$version") {
93128
return manifest_path $app $bucket
94129
}

libexec/scoop-cat.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
param($app)
55

66
. "$PSScriptRoot\..\lib\json.ps1" # 'ConvertToPrettyJson'
7-
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
7+
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
88

99
if (!$app) { error '<app> missing'; my_usage; exit 1 }
1010

11-
$app, $bucket, $null = parse_app $app
12-
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket
11+
$null, $manifest, $bucket, $url = Get-Manifest $app
1312

1413
if ($manifest) {
1514
$style = get_config cat_style

libexec/scoop-download.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
. "$PSScriptRoot\..\lib\getopt.ps1"
1919
. "$PSScriptRoot\..\lib\json.ps1" # 'autoupdate.ps1' (indirectly)
2020
. "$PSScriptRoot\..\lib\autoupdate.ps1" # 'generate_user_manifest' (indirectly)
21-
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture' 'generate_user_manifest' 'Find-Manifest' (indirectly)
21+
. "$PSScriptRoot\..\lib\manifest.ps1" # 'default_architecture' 'generate_user_manifest' 'Get-Manifest'
2222
. "$PSScriptRoot\..\lib\install.ps1"
2323

2424
$opt, $apps, $err = getopt $args 'fhua:' 'force', 'no-hash-check', 'no-update-scoop', 'arch='
@@ -51,7 +51,7 @@ foreach ($curr_app in $apps) {
5151
$bucket = $version = $app = $manifest = $url = $null
5252

5353
$app, $bucket, $version = parse_app $curr_app
54-
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket
54+
$app, $manifest, $bucket, $url = Get-Manifest "$bucket/$app"
5555

5656
info "Starting download for $app..."
5757

libexec/scoop-home.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Summary: Opens the app homepage
33
param($app)
44

5-
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
5+
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
66

77
if ($app) {
8-
$null, $manifest, $bucket, $null = Find-Manifest $app
8+
$null, $manifest, $bucket, $null = Get-Manifest $app
99
if ($manifest) {
1010
if ($manifest.homepage) {
1111
Start-Process $manifest.homepage

libexec/scoop-info.ps1

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# -v, --verbose Show full paths and URLs
55

66
. "$PSScriptRoot\..\lib\getopt.ps1"
7-
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Find-Manifest' (indirectly)
7+
. "$PSScriptRoot\..\lib\manifest.ps1" # 'Get-Manifest'
88
. "$PSScriptRoot\..\lib\versions.ps1" # 'Get-InstalledVersion'
99

1010
$opt, $app, $err = getopt $args 'v' 'verbose'
@@ -13,31 +13,21 @@ $verbose = $opt.v -or $opt.verbose
1313

1414
if (!$app) { my_usage; exit 1 }
1515

16-
if ($app -match '^(ht|f)tps?://|\\\\') {
17-
# check if $app is a URL or UNC path
18-
$url = $app
19-
$app = appname_from_url $url
20-
$global = installed $app $true
21-
$status = app_status $app $global
22-
$manifest = url_manifest $url
23-
$manifest_file = $url
24-
} else {
25-
# else $app is a normal app name
26-
$global = installed $app $true
27-
$app, $bucket, $null = parse_app $app
28-
$status = app_status $app $global
29-
$app, $manifest, $bucket, $url = Find-Manifest $app $bucket
30-
}
16+
$app, $manifest, $bucket, $url = Get-Manifest $app
3117

3218
if (!$manifest) {
3319
abort "Could not find manifest for '$(show_app $app)' in local buckets."
3420
}
3521

22+
$global = installed $app $true
23+
$status = app_status $app $global
3624
$install = install_info $app $status.version $global
3725
$status.installed = $bucket -and $install.bucket -eq $bucket
3826
$version_output = $manifest.version
39-
if (!$manifest_file) {
40-
$manifest_file = if ($bucket) { manifest_path $app $bucket } else { $url }
27+
$manifest_file = if ($bucket) {
28+
manifest_path $app $bucket
29+
} else {
30+
$url
4131
}
4232

4333
if ($verbose) {

0 commit comments

Comments
 (0)