From 42af27d16c655754639d5b8ad308835277e74426 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Mon, 8 Jul 2024 13:43:22 +0800 Subject: [PATCH 1/7] fix(sqlite): Fix compatibility with Windows PowerShell (#6045) --- CHANGELOG.md | 6 ++++++ lib/database.ps1 | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1af1cac61..f125069a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop) + +### Bug Fixes + +- **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) + ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 ### Features diff --git a/lib/database.ps1 b/lib/database.ps1 index ae45f46dc1..912db11c31 100644 --- a/lib/database.ps1 +++ b/lib/database.ps1 @@ -21,15 +21,14 @@ function Get-SQLite { # Install SQLite try { Write-Host "Downloading SQLite $Version..." -ForegroundColor DarkYellow - $sqlitePkgPath = "$env:TEMP\sqlite.nupkg" + $sqlitePkgPath = "$env:TEMP\sqlite.zip" $sqliteTempPath = "$env:TEMP\sqlite" $sqlitePath = "$PSScriptRoot\..\supporting\sqlite" 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 Write-Host "Extracting SQLite $Version..." -ForegroundColor DarkYellow -NoNewline Expand-Archive -Path $sqlitePkgPath -DestinationPath $sqliteTempPath -Force New-Item -Path $sqlitePath -ItemType Directory -Force | Out-Null - Move-Item -Path "$sqliteTempPath\build\net45\*" -Destination $sqlitePath -Exclude '*.targets' -Force - Move-Item -Path "$sqliteTempPath\lib\net45\System.Data.SQLite.dll" -Destination $sqlitePath -Force + Move-Item -Path "$sqliteTempPath\build\net451\*", "$sqliteTempPath\lib\net451\System.Data.SQLite.dll" -Destination $sqlitePath -Force Remove-Item -Path $sqlitePkgPath, $sqliteTempPath -Recurse -Force Write-Host ' Done' -ForegroundColor DarkYellow return $true From 83f25a4673c2619d6f6eae980fa8631a61736701 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Tue, 9 Jul 2024 00:24:42 +0800 Subject: [PATCH 2/7] fix(install): Expand env_set items (#6050) --- CHANGELOG.md | 1 + lib/install.ps1 | 14 +++++++------- libexec/scoop-reset.ps1 | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f125069a30..4b7d0fc483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes - **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) +- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/lib/install.ps1 b/lib/install.ps1 index cbe2b2f8b2..6c8c3ff11a 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -60,7 +60,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru create_startmenu_shortcuts $manifest $dir $global $architecture install_psmodule $manifest $dir $global env_add_path $manifest $dir $global $architecture - env_set $manifest $dir $global $architecture + env_set $manifest $global $architecture # persist data persist_data $manifest $original_dir $persist_dir @@ -898,12 +898,12 @@ function env_rm_path($manifest, $dir, $global, $arch) { } } -function env_set($manifest, $dir, $global, $arch) { +function env_set($manifest, $global, $arch) { $env_set = arch_specific 'env_set' $manifest $arch if ($env_set) { - $env_set | Get-Member -Member NoteProperty | ForEach-Object { - $name = $_.name - $val = substitute $env_set.$($_.name) @{ '$dir' = $dir } + $env_set | Get-Member -MemberType NoteProperty | ForEach-Object { + $name = $_.Name + $val = $ExecutionContext.InvokeCommand.ExpandString($env_set.$($name)) Set-EnvVar -Name $name -Value $val -Global:$global Set-Content env:\$name $val } @@ -912,8 +912,8 @@ function env_set($manifest, $dir, $global, $arch) { function env_rm($manifest, $global, $arch) { $env_set = arch_specific 'env_set' $manifest $arch if ($env_set) { - $env_set | Get-Member -Member NoteProperty | ForEach-Object { - $name = $_.name + $env_set | Get-Member -MemberType NoteProperty | ForEach-Object { + $name = $_.Name Set-EnvVar -Name $name -Value $null -Global:$global if (Test-Path env:\$name) { Remove-Item env:\$name } } diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index aeef05cc83..512540e8e6 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -84,7 +84,7 @@ $apps | ForEach-Object { env_rm_path $manifest $dir $global $architecture env_rm $manifest $global $architecture env_add_path $manifest $dir $global $architecture - env_set $manifest $dir $global $architecture + env_set $manifest $global $architecture # unlink all potential old link before re-persisting unlink_persist_data $manifest $original_dir persist_data $manifest $original_dir $persist_dir From 7cc4faea1d0f5dd7000ff42ac800f5c6eedb2f28 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Tue, 9 Jul 2024 01:16:23 +0800 Subject: [PATCH 3/7] fix(bucket): Implement error handling for failed bucket addition (#6051) --- CHANGELOG.md | 1 + lib/buckets.ps1 | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b7d0fc483..a6d00c0239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) - **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) +- **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 566cbd7119..87bc02d287 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -154,7 +154,12 @@ function add_bucket($name, $repo) { } ensure $bucketsdir | Out-Null $dir = ensure $dir - Invoke-Git -ArgumentList @('clone', $repo, $dir, '-q') + $out = Invoke-Git -ArgumentList @('clone', $repo, $dir, '-q') + if ($LASTEXITCODE -ne 0) { + error "Failed to clone '$repo' to '$dir'.`n`nError given:`n$out`n`nPlease check the repository URL or network connection and try again." + Remove-Item $dir -Recurse -Force -ErrorAction SilentlyContinue + return 1 + } Write-Host 'OK' if (get_config USE_SQLITE_CACHE) { info 'Updating cache...' From a76884af1904460f43c5cf2f493020ec55ac6b66 Mon Sep 17 00:00:00 2001 From: qiuyk <155824362+qwertyhjklxyz@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:22:06 +0800 Subject: [PATCH 4/7] fix(install): Fix parsing error when installing multiple apps w/ specific version (#6039) Co-authored-by: Hsiao-nan Cheung --- CHANGELOG.md | 1 + libexec/scoop-install.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6d00c0239..42df9d7711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) - **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) - **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) +- **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/pull/6039)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 173bcd868f..b7dda05d3c 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -91,7 +91,7 @@ $specific_versions = $apps | Where-Object { } # compare object does not like nulls -if ($specific_versions.length -gt 0) { +if ($specific_versions.Count -gt 0) { $difference = Compare-Object -ReferenceObject $apps -DifferenceObject $specific_versions -PassThru } else { $difference = $apps @@ -100,13 +100,13 @@ if ($specific_versions.length -gt 0) { $specific_versions_paths = $specific_versions | ForEach-Object { $app, $bucket, $version = parse_app $_ if (installed_manifest $app $version) { - warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(if ($global) { " --global" })' to install a new version." + warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(if ($global) { ' --global' })' to install a new version." continue } generate_user_manifest $app $bucket $version } -$apps = @(($specific_versions_paths + $difference) | Where-Object { $_ } | Sort-Object -Unique) +$apps = @((@($specific_versions_paths) + $difference) | Where-Object { $_ } | Select-Object -Unique) # remember which were explictly requested so that we can # differentiate after dependencies are added From 1c271f5b90f29185bf0052eb3e391a3200c78c92 Mon Sep 17 00:00:00 2001 From: Bill ZHANG <36790218+Lutra-Fs@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:45:09 +1000 Subject: [PATCH 5/7] fix(scoop-virustotal): Adjust `json_path` parameters to retrieve correct analysis stats (#6044) --- CHANGELOG.md | 3 ++- libexec/scoop-virustotal.ps1 | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42df9d7711..c9b232ef52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) - **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) - **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) -- **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/pull/6039)) +- **scoop-virustotal:** Adjust `json_path` parameters to retrieve correct analysis stats ([#6044](https://github.com/ScoopInstaller/Scoop/issues/6044)) +- **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/issues/6039)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index e1e7b9f75c..026712e9cc 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -102,14 +102,14 @@ Function Get-VirusTotalResultByHash ($hash, $url, $app) { $response = Invoke-WebRequest -Uri $api_url -Method GET -Headers $headers -UseBasicParsing $result = $response.Content $stats = json_path $result '$.data.attributes.last_analysis_stats' - [int]$malicious = json_path $stats '$.malicious' - [int]$suspicious = json_path $stats '$.suspicious' - [int]$timeout = json_path $stats '$.timeout' - [int]$undetected = json_path $stats '$.undetected' + [int]$malicious = json_path $stats '$[0].malicious' $null $false $true + [int]$suspicious = json_path $stats '$[0].suspicious' $null $false $true + [int]$timeout = json_path $stats '$[0].timeout' $null $false $true + [int]$undetected = json_path $stats '$[0].undetected' $null $false $true [int]$unsafe = $malicious + $suspicious [int]$total = $unsafe + $undetected - [int]$fileSize = json_path $result '$.data.attributes.size' - $report_hash = json_path $result '$.data.attributes.sha256' + [int]$fileSize = json_path $result '$.data.attributes.size' $null $false $true + $report_hash = json_path $result '$.data.attributes.sha256' $null $false $true $report_url = "https://www.virustotal.com/gui/file/$report_hash" if ($total -eq 0) { info "$app`: Analysis in progress." From 0138dc426657d6b6201a9c4aa86f3fc4aced9260 Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Mon, 15 Jul 2024 13:06:22 +0800 Subject: [PATCH 6/7] fix(scoop-alias): Pass options correctly (#6003) Co-authored-by: Hsiao-nan Cheung --- CHANGELOG.md | 1 + lib/commands.ps1 | 88 ++++++++++- libexec/scoop-alias.ps1 | 143 ++++++------------ ...ias.Tests.ps1 => Scoop-Commands.Tests.ps1} | 25 ++- 4 files changed, 145 insertions(+), 112 deletions(-) rename test/{Scoop-Alias.Tests.ps1 => Scoop-Commands.Tests.ps1} (56%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9b232ef52..b827198007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) - **scoop-virustotal:** Adjust `json_path` parameters to retrieve correct analysis stats ([#6044](https://github.com/ScoopInstaller/Scoop/issues/6044)) - **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/issues/6039)) +- **scoop-alias:** Pass options correctly ([#6003](https://github.com/ScoopInstaller/Scoop/issues/6003)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01 diff --git a/lib/commands.ps1 b/lib/commands.ps1 index 1aa6be1591..04775de357 100644 --- a/lib/commands.ps1 +++ b/lib/commands.ps1 @@ -1,3 +1,7 @@ +# Description: Functions for managing commands and aliases. + +## Functions for commands + function command_files { (Get-ChildItem "$PSScriptRoot\..\libexec") + (Get-ChildItem "$scoopdir\shims") | Where-Object 'scoop-.*?\.ps1$' -Property Name -Match @@ -19,11 +23,10 @@ function command_path($cmd) { # get path from shim $shim_path = "$scoopdir\shims\scoop-$cmd.ps1" $line = ((Get-Content $shim_path) | Where-Object { $_.startswith('$path') }) - if($line) { + if ($line) { Invoke-Command ([scriptblock]::Create($line)) -NoNewScope $cmd_path = $path - } - else { $cmd_path = $shim_path } + } else { $cmd_path = $shim_path } } $cmd_path @@ -34,3 +37,82 @@ function exec($cmd, $arguments) { & $cmd_path @arguments } + +## Functions for aliases + +function add_alias { + param( + [ValidateNotNullOrEmpty()] + [string]$name, + [ValidateNotNullOrEmpty()] + [string]$command, + [string]$description + ) + + $aliases = get_config ALIAS ([PSCustomObject]@{}) + if ($aliases.$name) { + abort "Alias '$name' already exists." + } + + $alias_script_name = "scoop-$name" + $shimdir = shimdir $false + if (Test-Path "$shimdir\$alias_script_name.ps1") { + abort "File '$alias_script_name.ps1' already exists in shims directory." + } + $script = @( + "# Summary: $description", + "$command" + ) -join "`n" + try { + $script | Out-UTF8File "$shimdir\$alias_script_name.ps1" + } catch { + abort $_.Exception + } + + # Add the new alias to the config. + $aliases | Add-Member -MemberType NoteProperty -Name $name -Value $alias_script_name + set_config ALIAS $aliases | Out-Null +} + +function rm_alias { + param( + [ValidateNotNullOrEmpty()] + [string]$name + ) + + $aliases = get_config ALIAS ([PSCustomObject]@{}) + if (!$aliases.$name) { + abort "Alias '$name' doesn't exist." + } + + info "Removing alias '$name'..." + Remove-Item "$(shimdir $false)\scoop-$name.ps1" + $aliases.PSObject.Properties.Remove($name) + set_config ALIAS $aliases | Out-Null +} + +function list_aliases { + param( + [bool]$verbose + ) + + $aliases = get_config ALIAS ([PSCustomObject]@{}) + $alias_info = $aliases.PSObject.Properties.Name | Where-Object { $_ } | ForEach-Object { + $content = Get-Content (command_path $_) + [PSCustomObject]@{ + Name = $_ + Summary = (summary $content).Trim() + Command = ($content | Select-Object -Skip 1).Trim() + } + } + if (!$alias_info) { + info 'No alias found.' + return + } + $alias_info = $alias_info | Sort-Object Name + $properties = @('Name', 'Command') + if ($verbose) { + $properties += 'Summary' + } + $alias_info | Select-Object $properties +} diff --git a/libexec/scoop-alias.ps1 b/libexec/scoop-alias.ps1 index 48a956fd64..4c07beeb1a 100644 --- a/libexec/scoop-alias.ps1 +++ b/libexec/scoop-alias.ps1 @@ -1,117 +1,68 @@ -# Usage: scoop alias add|list|rm [] +# Usage: scoop alias [options] [] # Summary: Manage scoop aliases -# Help: Add, remove or list Scoop aliases +# Help: Available subcommands: add, rm, list. # -# Aliases are custom Scoop subcommands that can be created to make common tasks -# easier. +# Aliases are custom Scoop subcommands that can be created to make common tasks easier. # -# To add an Alias: -# scoop alias add +# To add an alias: # -# e.g.: -# scoop alias add rm 'scoop uninstall $args[0]' 'Uninstalls an app' -# scoop alias add upgrade 'scoop update *' 'Updates all apps, just like brew or apt' +# scoop alias add [] +# +# e.g., +# +# scoop alias add rm 'scoop uninstall $args[0]' 'Uninstall an app' +# scoop alias add upgrade 'scoop update *' 'Update all apps, just like "brew" or "apt"' +# +# To remove an alias: +# +# scoop alias rm +# +# To list all aliases: +# +# scoop alias list [-v|--verbose] # # Options: -# -v, --verbose Show alias description and table headers (works only for 'list') +# -v, --verbose Show alias description and table headers (works only for "list") -param( - [String]$opt, - [String]$name, - [String]$command, - [String]$description, - [Switch]$verbose = $false -) +param($SubCommand) -. "$PSScriptRoot\..\lib\install.ps1" # shim related +. "$PSScriptRoot\..\lib\getopt.ps1" -$script:config_alias = 'alias' - -function init_alias_config { - $aliases = get_config $script:config_alias - if ($aliases) { - $aliases +$SubCommands = @('add', 'rm', 'list') +if ($SubCommand -notin $SubCommands) { + if (!$SubCommand) { + error ' missing' } else { - New-Object -TypeName PSObject + error "'$SubCommand' is not one of available subcommands: $($SubCommands -join ', ')" } + my_usage + exit 1 } -function add_alias($name, $command) { - if (!$command) { - abort "Can't create an empty alias." - } +$opt, $other, $err = getopt $Args 'v' , 'verbose' +if ($err) { "scoop alias: $err"; exit 1 } - # get current aliases from config - $aliases = init_alias_config - if ($aliases.$name) { - abort "Alias '$name' already exists." - } - - $alias_file = "scoop-$name" +$name, $command, $description = $other +$verbose = $opt.v -or $opt.verbose - # generate script - $shimdir = shimdir $false - if (Test-Path "$shimdir\$alias_file.ps1") { - abort "File '$alias_file.ps1' already exists in shims directory." +switch ($SubCommand) { + 'add' { + if (!$name -or !$command) { + error " and must be specified for subcommand 'add'" + exit 1 + } + add_alias $name $command $description } - $script = - @( - "# Summary: $description", - "$command" - ) -join "`r`n" - $script | Out-UTF8File "$shimdir\$alias_file.ps1" - - # add alias to config - $aliases | Add-Member -MemberType NoteProperty -Name $name -Value $alias_file - - set_config $script:config_alias $aliases | Out-Null -} - -function rm_alias($name) { - $aliases = init_alias_config - if (!$name) { - abort 'Alias to be removed has not been specified!' + 'rm' { + if (!$name) { + error " must be specified for subcommand 'rm'" + exit 1 + } + rm_alias $name } - - if ($aliases.$name) { - info "Removing alias '$name'..." - - rm_shim $aliases.$name (shimdir $false) - - $aliases.PSObject.Properties.Remove($name) - set_config $script:config_alias $aliases | Out-Null - } else { - abort "Alias '$name' doesn't exist." - } -} - -function list_aliases { - $aliases = @() - - (init_alias_config).PSObject.Properties.GetEnumerator() | ForEach-Object { - $content = Get-Content (command_path $_.Name) - $command = ($content | Select-Object -Skip 1).Trim() - $summary = (summary $content).Trim() - - $aliases += New-Object psobject -Property @{Name = $_.name; Summary = $summary; Command = $command } - } - - if (!$aliases.count) { - info "No alias found." + 'list' { + list_aliases $verbose } - $aliases = $aliases.GetEnumerator() | Sort-Object Name - if ($verbose) { - return $aliases | Select-Object Name, Command, Summary - } else { - return $aliases | Select-Object Name, Command - } -} - -switch ($opt) { - 'add' { add_alias $name $command } - 'rm' { rm_alias $name } - 'list' { list_aliases } - default { my_usage; exit 1 } } exit 0 diff --git a/test/Scoop-Alias.Tests.ps1 b/test/Scoop-Commands.Tests.ps1 similarity index 56% rename from test/Scoop-Alias.Tests.ps1 rename to test/Scoop-Commands.Tests.ps1 index e6fd33e7eb..05d5d1d153 100644 --- a/test/Scoop-Alias.Tests.ps1 +++ b/test/Scoop-Commands.Tests.ps1 @@ -1,8 +1,7 @@ BeforeAll { . "$PSScriptRoot\Scoop-TestLib.ps1" . "$PSScriptRoot\..\lib\core.ps1" - . "$PSScriptRoot\..\lib\help.ps1" - . "$PSScriptRoot\..\libexec\scoop-alias.ps1" | Out-Null + . "$PSScriptRoot\..\lib\commands.ps1" } Describe 'Manipulate Alias' -Tag 'Scoop' { @@ -15,32 +14,32 @@ Describe 'Manipulate Alias' -Tag 'Scoop' { ensure $shimdir } - It 'Creates a new alias if alias doesn''t exist' { - $alias_file = "$shimdir\scoop-rm.ps1" - $alias_file | Should -Not -Exist + It 'Creates a new alias if it does not exist' { + $alias_script = "$shimdir\scoop-rm.ps1" + $alias_script | Should -Not -Exist add_alias 'rm' '"hello, world!"' - & $alias_file | Should -Be 'hello, world!' + & $alias_script | Should -Be 'hello, world!' } - It 'Does not change existing file if its filename same as alias name' { - $alias_file = "$shimdir\scoop-rm.ps1" + It 'Skips an existing alias' { + $alias_script = "$shimdir\scoop-rm.ps1" Mock abort {} - New-Item $alias_file -Type File -Force - $alias_file | Should -Exist + New-Item $alias_script -Type File -Force + $alias_script | Should -Exist add_alias 'rm' '"test"' Should -Invoke -CommandName abort -Times 1 -ParameterFilter { $msg -eq "File 'scoop-rm.ps1' already exists in shims directory." } } It 'Removes an existing alias' { - $alias_file = "$shimdir\scoop-rm.ps1" - $alias_file | Should -Exist + $alias_script = "$shimdir\scoop-rm.ps1" + $alias_script | Should -Exist Mock get_config { @(@{'rm' = 'scoop-rm' }) } Mock info {} rm_alias 'rm' - $alias_file | Should -Not -Exist + $alias_script | Should -Not -Exist Should -Invoke -CommandName info -Times 1 -ParameterFilter { $msg -eq "Removing alias 'rm'..." } } } From 69edc6dc54ffbefd18dcb6f0a516b9f5897a8361 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Mon, 15 Jul 2024 13:17:19 +0800 Subject: [PATCH 7/7] chore(chglog): Update CHANGELOG for v0.5.1 (#6058) --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b827198007..08a15bda7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,13 @@ -## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop) +## [v0.5.1](https://github.com/ScoopInstaller/Scoop/compare/v0.5.0...v0.5.1) - 2024-07-16 ### Bug Fixes -- **sqlite:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) -- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) -- **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) +- **scoop-alias:** Pass options correctly ([#6003](https://github.com/ScoopInstaller/Scoop/issues/6003)) - **scoop-virustotal:** Adjust `json_path` parameters to retrieve correct analysis stats ([#6044](https://github.com/ScoopInstaller/Scoop/issues/6044)) +- **bucket:** Implement error handling for failed bucket addition ([#6051](https://github.com/ScoopInstaller/Scoop/issues/6051)) +- **database:** Fix compatibility with Windows PowerShell ([#6045](https://github.com/ScoopInstaller/Scoop/issues/6045)) +- **install:** Expand `env_set` items before setting Environment Variables ([#6050](https://github.com/ScoopInstaller/Scoop/issues/6050)) - **install:** Fix parsing error when installing multiple apps w/ specific version ([#6039](https://github.com/ScoopInstaller/Scoop/issues/6039)) -- **scoop-alias:** Pass options correctly ([#6003](https://github.com/ScoopInstaller/Scoop/issues/6003)) ## [v0.5.0](https://github.com/ScoopInstaller/Scoop/compare/v0.4.2...v0.5.0) - 2024-07-01