Skip to content

Commit be56faf

Browse files
authored
chore(release): Bump to version 0.5.1 (#6057)
2 parents 716b6db + 69edc6d commit be56faf

File tree

10 files changed

+180
-133
lines changed

10 files changed

+180
-133
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [v0.5.1](https://github.com/ScoopInstaller/Scoop/compare/v0.5.0...v0.5.1) - 2024-07-16
2+
3+
### Bug Fixes
4+
5+
- **scoop-alias:** Pass options correctly ([#6003](https://github.com/ScoopInstaller/Scoop/issues/6003))
6+
- **scoop-virustotal:** Adjust `json_path` parameters to retrieve correct analysis stats ([#6044](https://github.com/ScoopInstaller/Scoop/issues/6044))
7+
- **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051))
8+
- **database:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045))
9+
- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050))
10+
- **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/issues/6039))
11+
112
## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01
213

314
### Features

lib/buckets.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ function add_bucket($name, $repo) {
154154
}
155155
ensure $bucketsdir | Out-Null
156156
$dir = ensure $dir
157-
Invoke-Git -ArgumentList @('clone', $repo, $dir, '-q')
157+
$out = Invoke-Git -ArgumentList @('clone', $repo, $dir, '-q')
158+
if ($LASTEXITCODE -ne 0) {
159+
error "Failed to clone '$repo' to '$dir'.`n`nError given:`n$out`n`nPlease check the repository URL or network connection and try again."
160+
Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue
161+
return 1
162+
}
158163
Write-Host 'OK'
159164
if (get_config USE_SQLITE_CACHE) {
160165
info 'Updating cache...'

lib/commands.ps1

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Description: Functions for managing commands and aliases.
2+
3+
## Functions for commands
4+
15
function command_files {
26
(Get-ChildItem "$PSScriptRoot\..\libexec") + (Get-ChildItem "$scoopdir\shims") |
37
Where-Object 'scoop-.*?\.ps1$' -Property Name -Match
@@ -19,11 +23,10 @@ function command_path($cmd) {
1923
# get path from shim
2024
$shim_path = "$scoopdir\shims\scoop-$cmd.ps1"
2125
$line = ((Get-Content $shim_path) | Where-Object { $_.startswith('$path') })
22-
if($line) {
26+
if ($line) {
2327
Invoke-Command ([scriptblock]::Create($line)) -NoNewScope
2428
$cmd_path = $path
25-
}
26-
else { $cmd_path = $shim_path }
29+
} else { $cmd_path = $shim_path }
2730
}
2831

2932
$cmd_path
@@ -34,3 +37,82 @@ function exec($cmd, $arguments) {
3437

3538
& $cmd_path @arguments
3639
}
40+
41+
## Functions for aliases
42+
43+
function add_alias {
44+
param(
45+
[ValidateNotNullOrEmpty()]
46+
[string]$name,
47+
[ValidateNotNullOrEmpty()]
48+
[string]$command,
49+
[string]$description
50+
)
51+
52+
$aliases = get_config ALIAS ([PSCustomObject]@{})
53+
if ($aliases.$name) {
54+
abort "Alias '$name' already exists."
55+
}
56+
57+
$alias_script_name = "scoop-$name"
58+
$shimdir = shimdir $false
59+
if (Test-Path "$shimdir\$alias_script_name.ps1") {
60+
abort "File '$alias_script_name.ps1' already exists in shims directory."
61+
}
62+
$script = @(
63+
"# Summary: $description",
64+
"$command"
65+
) -join "`n"
66+
try {
67+
$script | Out-UTF8File "$shimdir\$alias_script_name.ps1"
68+
} catch {
69+
abort $_.Exception
70+
}
71+
72+
# Add the new alias to the config.
73+
$aliases | Add-Member -MemberType NoteProperty -Name $name -Value $alias_script_name
74+
set_config ALIAS $aliases | Out-Null
75+
}
76+
77+
function rm_alias {
78+
param(
79+
[ValidateNotNullOrEmpty()]
80+
[string]$name
81+
)
82+
83+
$aliases = get_config ALIAS ([PSCustomObject]@{})
84+
if (!$aliases.$name) {
85+
abort "Alias '$name' doesn't exist."
86+
}
87+
88+
info "Removing alias '$name'..."
89+
Remove-Item "$(shimdir $false)\scoop-$name.ps1"
90+
$aliases.PSObject.Properties.Remove($name)
91+
set_config ALIAS $aliases | Out-Null
92+
}
93+
94+
function list_aliases {
95+
param(
96+
[bool]$verbose
97+
)
98+
99+
$aliases = get_config ALIAS ([PSCustomObject]@{})
100+
$alias_info = $aliases.PSObject.Properties.Name | Where-Object { $_ } | ForEach-Object {
101+
$content = Get-Content (command_path $_)
102+
[PSCustomObject]@{
103+
Name = $_
104+
Summary = (summary $content).Trim()
105+
Command = ($content | Select-Object -Skip 1).Trim()
106+
}
107+
}
108+
if (!$alias_info) {
109+
info 'No alias found.'
110+
return
111+
}
112+
$alias_info = $alias_info | Sort-Object Name
113+
$properties = @('Name', 'Command')
114+
if ($verbose) {
115+
$properties += 'Summary'
116+
}
117+
$alias_info | Select-Object $properties
118+
}

lib/database.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ function Get-SQLite {
2121
# Install SQLite
2222
try {
2323
Write-Host "Downloading SQLite $Version..." -ForegroundColor DarkYellow
24-
$sqlitePkgPath = "$env:TEMP\sqlite.nupkg"
24+
$sqlitePkgPath = "$env:TEMP\sqlite.zip"
2525
$sqliteTempPath = "$env:TEMP\sqlite"
2626
$sqlitePath = "$PSScriptRoot\..\supporting\sqlite"
2727
Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/stub.system.data.sqlite.core.netframework/$version/stub.system.data.sqlite.core.netframework.$version.nupkg" -OutFile $sqlitePkgPath
2828
Write-Host "Extracting SQLite $Version..." -ForegroundColor DarkYellow -NoNewline
2929
Expand-Archive -Path $sqlitePkgPath -DestinationPath $sqliteTempPath -Force
3030
New-Item -Path $sqlitePath -ItemType Directory -Force | Out-Null
31-
Move-Item -Path "$sqliteTempPath\build\net45\*" -Destination $sqlitePath -Exclude '*.targets' -Force
32-
Move-Item -Path "$sqliteTempPath\lib\net45\System.Data.SQLite.dll" -Destination $sqlitePath -Force
31+
Move-Item -Path "$sqliteTempPath\build\net451\*", "$sqliteTempPath\lib\net451\System.Data.SQLite.dll" -Destination $sqlitePath -Force
3332
Remove-Item -Path $sqlitePkgPath, $sqliteTempPath -Recurse -Force
3433
Write-Host ' Done' -ForegroundColor DarkYellow
3534
return $true

lib/install.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
6060
create_startmenu_shortcuts $manifest $dir $global $architecture
6161
install_psmodule $manifest $dir $global
6262
env_add_path $manifest $dir $global $architecture
63-
env_set $manifest $dir $global $architecture
63+
env_set $manifest $global $architecture
6464

6565
# persist data
6666
persist_data $manifest $original_dir $persist_dir
@@ -898,12 +898,12 @@ function env_rm_path($manifest, $dir, $global, $arch) {
898898
}
899899
}
900900

901-
function env_set($manifest, $dir, $global, $arch) {
901+
function env_set($manifest, $global, $arch) {
902902
$env_set = arch_specific 'env_set' $manifest $arch
903903
if ($env_set) {
904-
$env_set | Get-Member -Member NoteProperty | ForEach-Object {
905-
$name = $_.name
906-
$val = substitute $env_set.$($_.name) @{ '$dir' = $dir }
904+
$env_set | Get-Member -MemberType NoteProperty | ForEach-Object {
905+
$name = $_.Name
906+
$val = $ExecutionContext.InvokeCommand.ExpandString($env_set.$($name))
907907
Set-EnvVar -Name $name -Value $val -Global:$global
908908
Set-Content env:\$name $val
909909
}
@@ -912,8 +912,8 @@ function env_set($manifest, $dir, $global, $arch) {
912912
function env_rm($manifest, $global, $arch) {
913913
$env_set = arch_specific 'env_set' $manifest $arch
914914
if ($env_set) {
915-
$env_set | Get-Member -Member NoteProperty | ForEach-Object {
916-
$name = $_.name
915+
$env_set | Get-Member -MemberType NoteProperty | ForEach-Object {
916+
$name = $_.Name
917917
Set-EnvVar -Name $name -Value $null -Global:$global
918918
if (Test-Path env:\$name) { Remove-Item env:\$name }
919919
}

libexec/scoop-alias.ps1

Lines changed: 47 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,68 @@
1-
# Usage: scoop alias add|list|rm [<args>]
1+
# Usage: scoop alias <subcommand> [options] [<args>]
22
# Summary: Manage scoop aliases
3-
# Help: Add, remove or list Scoop aliases
3+
# Help: Available subcommands: add, rm, list.
44
#
5-
# Aliases are custom Scoop subcommands that can be created to make common tasks
6-
# easier.
5+
# Aliases are custom Scoop subcommands that can be created to make common tasks easier.
76
#
8-
# To add an Alias:
9-
# scoop alias add <name> <command> <description>
7+
# To add an alias:
108
#
11-
# e.g.:
12-
# scoop alias add rm 'scoop uninstall $args[0]' 'Uninstalls an app'
13-
# scoop alias add upgrade 'scoop update *' 'Updates all apps, just like brew or apt'
9+
# scoop alias add <name> <command> [<description>]
10+
#
11+
# e.g.,
12+
#
13+
# scoop alias add rm 'scoop uninstall $args[0]' 'Uninstall an app'
14+
# scoop alias add upgrade 'scoop update *' 'Update all apps, just like "brew" or "apt"'
15+
#
16+
# To remove an alias:
17+
#
18+
# scoop alias rm <name>
19+
#
20+
# To list all aliases:
21+
#
22+
# scoop alias list [-v|--verbose]
1423
#
1524
# Options:
16-
# -v, --verbose Show alias description and table headers (works only for 'list')
25+
# -v, --verbose Show alias description and table headers (works only for "list")
1726

18-
param(
19-
[String]$opt,
20-
[String]$name,
21-
[String]$command,
22-
[String]$description,
23-
[Switch]$verbose = $false
24-
)
27+
param($SubCommand)
2528

26-
. "$PSScriptRoot\..\lib\install.ps1" # shim related
29+
. "$PSScriptRoot\..\lib\getopt.ps1"
2730

28-
$script:config_alias = 'alias'
29-
30-
function init_alias_config {
31-
$aliases = get_config $script:config_alias
32-
if ($aliases) {
33-
$aliases
31+
$SubCommands = @('add', 'rm', 'list')
32+
if ($SubCommand -notin $SubCommands) {
33+
if (!$SubCommand) {
34+
error '<subcommand> missing'
3435
} else {
35-
New-Object -TypeName PSObject
36+
error "'$SubCommand' is not one of available subcommands: $($SubCommands -join ', ')"
3637
}
38+
my_usage
39+
exit 1
3740
}
3841

39-
function add_alias($name, $command) {
40-
if (!$command) {
41-
abort "Can't create an empty alias."
42-
}
42+
$opt, $other, $err = getopt $Args 'v' , 'verbose'
43+
if ($err) { "scoop alias: $err"; exit 1 }
4344

44-
# get current aliases from config
45-
$aliases = init_alias_config
46-
if ($aliases.$name) {
47-
abort "Alias '$name' already exists."
48-
}
49-
50-
$alias_file = "scoop-$name"
45+
$name, $command, $description = $other
46+
$verbose = $opt.v -or $opt.verbose
5147

52-
# generate script
53-
$shimdir = shimdir $false
54-
if (Test-Path "$shimdir\$alias_file.ps1") {
55-
abort "File '$alias_file.ps1' already exists in shims directory."
48+
switch ($SubCommand) {
49+
'add' {
50+
if (!$name -or !$command) {
51+
error "<name> and <command> must be specified for subcommand 'add'"
52+
exit 1
53+
}
54+
add_alias $name $command $description
5655
}
57-
$script =
58-
@(
59-
"# Summary: $description",
60-
"$command"
61-
) -join "`r`n"
62-
$script | Out-UTF8File "$shimdir\$alias_file.ps1"
63-
64-
# add alias to config
65-
$aliases | Add-Member -MemberType NoteProperty -Name $name -Value $alias_file
66-
67-
set_config $script:config_alias $aliases | Out-Null
68-
}
69-
70-
function rm_alias($name) {
71-
$aliases = init_alias_config
72-
if (!$name) {
73-
abort 'Alias to be removed has not been specified!'
56+
'rm' {
57+
if (!$name) {
58+
error "<name> must be specified for subcommand 'rm'"
59+
exit 1
60+
}
61+
rm_alias $name
7462
}
75-
76-
if ($aliases.$name) {
77-
info "Removing alias '$name'..."
78-
79-
rm_shim $aliases.$name (shimdir $false)
80-
81-
$aliases.PSObject.Properties.Remove($name)
82-
set_config $script:config_alias $aliases | Out-Null
83-
} else {
84-
abort "Alias '$name' doesn't exist."
85-
}
86-
}
87-
88-
function list_aliases {
89-
$aliases = @()
90-
91-
(init_alias_config).PSObject.Properties.GetEnumerator() | ForEach-Object {
92-
$content = Get-Content (command_path $_.Name)
93-
$command = ($content | Select-Object -Skip 1).Trim()
94-
$summary = (summary $content).Trim()
95-
96-
$aliases += New-Object psobject -Property @{Name = $_.name; Summary = $summary; Command = $command }
97-
}
98-
99-
if (!$aliases.count) {
100-
info "No alias found."
63+
'list' {
64+
list_aliases $verbose
10165
}
102-
$aliases = $aliases.GetEnumerator() | Sort-Object Name
103-
if ($verbose) {
104-
return $aliases | Select-Object Name, Command, Summary
105-
} else {
106-
return $aliases | Select-Object Name, Command
107-
}
108-
}
109-
110-
switch ($opt) {
111-
'add' { add_alias $name $command }
112-
'rm' { rm_alias $name }
113-
'list' { list_aliases }
114-
default { my_usage; exit 1 }
11566
}
11667

11768
exit 0

libexec/scoop-install.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $specific_versions = $apps | Where-Object {
9191
}
9292

9393
# compare object does not like nulls
94-
if ($specific_versions.length -gt 0) {
94+
if ($specific_versions.Count -gt 0) {
9595
$difference = Compare-Object -ReferenceObject $apps -DifferenceObject $specific_versions -PassThru
9696
} else {
9797
$difference = $apps
@@ -100,13 +100,13 @@ if ($specific_versions.length -gt 0) {
100100
$specific_versions_paths = $specific_versions | ForEach-Object {
101101
$app, $bucket, $version = parse_app $_
102102
if (installed_manifest $app $version) {
103-
warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(if ($global) { " --global" })' to install a new version."
103+
warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(if ($global) { ' --global' })' to install a new version."
104104
continue
105105
}
106106

107107
generate_user_manifest $app $bucket $version
108108
}
109-
$apps = @(($specific_versions_paths + $difference) | Where-Object { $_ } | Sort-Object -Unique)
109+
$apps = @((@($specific_versions_paths) + $difference) | Where-Object { $_ } | Select-Object -Unique)
110110

111111
# remember which were explictly requested so that we can
112112
# differentiate after dependencies are added

libexec/scoop-reset.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $apps | ForEach-Object {
8484
env_rm_path $manifest $dir $global $architecture
8585
env_rm $manifest $global $architecture
8686
env_add_path $manifest $dir $global $architecture
87-
env_set $manifest $dir $global $architecture
87+
env_set $manifest $global $architecture
8888
# unlink all potential old link before re-persisting
8989
unlink_persist_data $manifest $original_dir
9090
persist_data $manifest $original_dir $persist_dir

0 commit comments

Comments
 (0)